mstask/tests: Use the global wine_dbgstr_w instead of a local variant.

This commit is contained in:
Alexandre Julliard 2009-08-19 13:36:50 +02:00
parent 86f9fce74c
commit ef5864fcc0
1 changed files with 30 additions and 61 deletions

View File

@ -28,37 +28,6 @@ static ITaskScheduler *test_task_scheduler;
static ITask *test_task; static ITask *test_task;
static const WCHAR empty[] = {0}; static const WCHAR empty[] = {0};
/* allocate some tmp string space */
/* FIXME: this is not 100% thread-safe */
static char *get_tmp_space(int size)
{
static char *list[16];
static long pos;
char *ret;
int idx;
idx = ++pos % (sizeof(list)/sizeof(list[0]));
if (list[idx])
ret = HeapReAlloc( GetProcessHeap(), 0, list[idx], size );
else
ret = HeapAlloc( GetProcessHeap(), 0, size );
if (ret)
list[idx] = ret;
return ret;
}
static const char *dbgstr_w(LPCWSTR str)
{
char *buf;
int len;
if(!str)
return "(null)";
len = lstrlenW(str) + 1;
buf = get_tmp_space(len);
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, len, NULL, NULL);
return buf;
}
static BOOL setup_task(void) static BOOL setup_task(void)
{ {
HRESULT hres; HRESULT hres;
@ -126,7 +95,7 @@ static void test_SetApplicationName_GetApplicationName(void)
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpiW(stored_name, empty), ok(!lstrcmpiW(stored_name, empty),
"Got %s, expected empty string\n", dbgstr_w(stored_name)); "Got %s, expected empty string\n", wine_dbgstr_w(stored_name));
CoTaskMemFree(stored_name); CoTaskMemFree(stored_name);
} }
@ -134,14 +103,14 @@ static void test_SetApplicationName_GetApplicationName(void)
* the application name that is actually stored */ * the application name that is actually stored */
hres = ITask_SetApplicationName(test_task, non_application_name); hres = ITask_SetApplicationName(test_task, non_application_name);
ok(hres == S_OK, "Failed setting name %s: %08x\n", ok(hres == S_OK, "Failed setting name %s: %08x\n",
dbgstr_w(non_application_name), hres); wine_dbgstr_w(non_application_name), hres);
hres = ITask_GetApplicationName(test_task, &stored_name); hres = ITask_GetApplicationName(test_task, &stored_name);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres); ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
full_name = path_resolve_name(non_application_name); full_name = path_resolve_name(non_application_name);
ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n", ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name)); wine_dbgstr_w(stored_name), wine_dbgstr_w(full_name));
CoTaskMemFree(stored_name); CoTaskMemFree(stored_name);
} }
@ -149,21 +118,21 @@ static void test_SetApplicationName_GetApplicationName(void)
* get the stored name */ * get the stored name */
hres = ITask_SetApplicationName(test_task, notepad_exe); hres = ITask_SetApplicationName(test_task, notepad_exe);
ok(hres == S_OK, "Failed setting name %s: %08x\n", ok(hres == S_OK, "Failed setting name %s: %08x\n",
dbgstr_w(notepad_exe), hres); wine_dbgstr_w(notepad_exe), hres);
hres = ITask_GetApplicationName(test_task, &stored_name); hres = ITask_GetApplicationName(test_task, &stored_name);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres); ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
full_name = path_resolve_name(notepad_exe); full_name = path_resolve_name(notepad_exe);
ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n", ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name)); wine_dbgstr_w(stored_name), wine_dbgstr_w(full_name));
CoTaskMemFree(stored_name); CoTaskMemFree(stored_name);
} }
/* Set a valid application name without program type extension and /* Set a valid application name without program type extension and
* then get the stored name */ * then get the stored name */
hres = ITask_SetApplicationName(test_task, notepad); hres = ITask_SetApplicationName(test_task, notepad);
ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(notepad), hres); ok(hres == S_OK, "Failed setting name %s: %08x\n", wine_dbgstr_w(notepad), hres);
hres = ITask_GetApplicationName(test_task, &stored_name); hres = ITask_GetApplicationName(test_task, &stored_name);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres); ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
@ -173,7 +142,7 @@ static void test_SetApplicationName_GetApplicationName(void)
{ {
full_name = path_resolve_name(notepad); full_name = path_resolve_name(notepad);
ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n", ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name)); wine_dbgstr_w(stored_name), wine_dbgstr_w(full_name));
} }
CoTaskMemFree(stored_name); CoTaskMemFree(stored_name);
} }
@ -183,26 +152,26 @@ static void test_SetApplicationName_GetApplicationName(void)
* actually stored */ * actually stored */
hres = ITask_SetApplicationName(test_task, non_application_name); hres = ITask_SetApplicationName(test_task, non_application_name);
ok(hres == S_OK, "Failed setting name %s: %08x\n", ok(hres == S_OK, "Failed setting name %s: %08x\n",
dbgstr_w(non_application_name), hres); wine_dbgstr_w(non_application_name), hres);
hres = ITask_GetApplicationName(test_task, &stored_name); hres = ITask_GetApplicationName(test_task, &stored_name);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres); ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
full_name = path_resolve_name(non_application_name); full_name = path_resolve_name(non_application_name);
ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n", ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name)); wine_dbgstr_w(stored_name), wine_dbgstr_w(full_name));
CoTaskMemFree(stored_name); CoTaskMemFree(stored_name);
} }
/* Clear application name */ /* Clear application name */
hres = ITask_SetApplicationName(test_task, empty); hres = ITask_SetApplicationName(test_task, empty);
ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(empty), hres); ok(hres == S_OK, "Failed setting name %s: %08x\n", wine_dbgstr_w(empty), hres);
hres = ITask_GetApplicationName(test_task, &stored_name); hres = ITask_GetApplicationName(test_task, &stored_name);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres); ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpiW(stored_name, empty), ok(!lstrcmpiW(stored_name, empty),
"Got %s, expected empty string\n", dbgstr_w(stored_name)); "Got %s, expected empty string\n", wine_dbgstr_w(stored_name));
CoTaskMemFree(stored_name); CoTaskMemFree(stored_name);
} }
@ -261,46 +230,46 @@ static void test_SetParameters_GetParameters(void)
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(parameters, empty), ok(!lstrcmpW(parameters, empty),
"Got %s, expected empty string\n", dbgstr_w(parameters)); "Got %s, expected empty string\n", wine_dbgstr_w(parameters));
CoTaskMemFree(parameters); CoTaskMemFree(parameters);
} }
/* Set parameters to a simple string */ /* Set parameters to a simple string */
hres = ITask_SetParameters(test_task, parameters_a); hres = ITask_SetParameters(test_task, parameters_a);
ok(hres == S_OK, "Failed setting parameters %s: %08x\n", ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
dbgstr_w(parameters_a), hres); wine_dbgstr_w(parameters_a), hres);
hres = ITask_GetParameters(test_task, &parameters); hres = ITask_GetParameters(test_task, &parameters);
ok(hres == S_OK, "GetParameters failed: %08x\n", hres); ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(parameters, parameters_a), "Got %s, expected %s\n", ok(!lstrcmpW(parameters, parameters_a), "Got %s, expected %s\n",
dbgstr_w(parameters), dbgstr_w(parameters_a)); wine_dbgstr_w(parameters), wine_dbgstr_w(parameters_a));
CoTaskMemFree(parameters); CoTaskMemFree(parameters);
} }
/* Update parameters to a different simple string */ /* Update parameters to a different simple string */
hres = ITask_SetParameters(test_task, parameters_b); hres = ITask_SetParameters(test_task, parameters_b);
ok(hres == S_OK, "Failed setting parameters %s: %08x\n", ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
dbgstr_w(parameters_b), hres); wine_dbgstr_w(parameters_b), hres);
hres = ITask_GetParameters(test_task, &parameters); hres = ITask_GetParameters(test_task, &parameters);
ok(hres == S_OK, "GetParameters failed: %08x\n", hres); ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(parameters, parameters_b), "Got %s, expected %s\n", ok(!lstrcmpW(parameters, parameters_b), "Got %s, expected %s\n",
dbgstr_w(parameters), dbgstr_w(parameters_b)); wine_dbgstr_w(parameters), wine_dbgstr_w(parameters_b));
CoTaskMemFree(parameters); CoTaskMemFree(parameters);
} }
/* Clear parameters */ /* Clear parameters */
hres = ITask_SetParameters(test_task, empty); hres = ITask_SetParameters(test_task, empty);
ok(hres == S_OK, "Failed setting parameters %s: %08x\n", ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
dbgstr_w(empty), hres); wine_dbgstr_w(empty), hres);
hres = ITask_GetParameters(test_task, &parameters); hres = ITask_GetParameters(test_task, &parameters);
ok(hres == S_OK, "GetParameters failed: %08x\n", hres); ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(parameters, empty), ok(!lstrcmpW(parameters, empty),
"Got %s, expected empty string\n", dbgstr_w(parameters)); "Got %s, expected empty string\n", wine_dbgstr_w(parameters));
CoTaskMemFree(parameters); CoTaskMemFree(parameters);
} }
@ -331,46 +300,46 @@ static void test_SetComment_GetComment(void)
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(comment, empty), ok(!lstrcmpW(comment, empty),
"Got %s, expected empty string\n", dbgstr_w(comment)); "Got %s, expected empty string\n", wine_dbgstr_w(comment));
CoTaskMemFree(comment); CoTaskMemFree(comment);
} }
/* Set comment to a simple string */ /* Set comment to a simple string */
hres = ITask_SetComment(test_task, comment_a); hres = ITask_SetComment(test_task, comment_a);
ok(hres == S_OK, "Failed setting comment %s: %08x\n", ok(hres == S_OK, "Failed setting comment %s: %08x\n",
dbgstr_w(comment_a), hres); wine_dbgstr_w(comment_a), hres);
hres = ITask_GetComment(test_task, &comment); hres = ITask_GetComment(test_task, &comment);
ok(hres == S_OK, "GetComment failed: %08x\n", hres); ok(hres == S_OK, "GetComment failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(comment, comment_a), "Got %s, expected %s\n", ok(!lstrcmpW(comment, comment_a), "Got %s, expected %s\n",
dbgstr_w(comment), dbgstr_w(comment_a)); wine_dbgstr_w(comment), wine_dbgstr_w(comment_a));
CoTaskMemFree(comment); CoTaskMemFree(comment);
} }
/* Update comment to a different simple string */ /* Update comment to a different simple string */
hres = ITask_SetComment(test_task, comment_b); hres = ITask_SetComment(test_task, comment_b);
ok(hres == S_OK, "Failed setting comment %s: %08x\n", ok(hres == S_OK, "Failed setting comment %s: %08x\n",
dbgstr_w(comment_b), hres); wine_dbgstr_w(comment_b), hres);
hres = ITask_GetComment(test_task, &comment); hres = ITask_GetComment(test_task, &comment);
ok(hres == S_OK, "GetComment failed: %08x\n", hres); ok(hres == S_OK, "GetComment failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(comment, comment_b), "Got %s, expected %s\n", ok(!lstrcmpW(comment, comment_b), "Got %s, expected %s\n",
dbgstr_w(comment), dbgstr_w(comment_b)); wine_dbgstr_w(comment), wine_dbgstr_w(comment_b));
CoTaskMemFree(comment); CoTaskMemFree(comment);
} }
/* Clear comment */ /* Clear comment */
hres = ITask_SetComment(test_task, empty); hres = ITask_SetComment(test_task, empty);
ok(hres == S_OK, "Failed setting comment %s: %08x\n", ok(hres == S_OK, "Failed setting comment %s: %08x\n",
dbgstr_w(empty), hres); wine_dbgstr_w(empty), hres);
hres = ITask_GetComment(test_task, &comment); hres = ITask_GetComment(test_task, &comment);
ok(hres == S_OK, "GetComment failed: %08x\n", hres); ok(hres == S_OK, "GetComment failed: %08x\n", hres);
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(comment, empty), ok(!lstrcmpW(comment, empty),
"Got %s, expected empty string\n", dbgstr_w(comment)); "Got %s, expected empty string\n", wine_dbgstr_w(comment));
CoTaskMemFree(comment); CoTaskMemFree(comment);
} }
@ -481,8 +450,8 @@ static void test_SetAccountInformation_GetAccountInformation(void)
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(account_name, dummy_account_name), ok(!lstrcmpW(account_name, dummy_account_name),
"Got %s, expected %s\n", dbgstr_w(account_name), "Got %s, expected %s\n", wine_dbgstr_w(account_name),
dbgstr_w(dummy_account_name)); wine_dbgstr_w(dummy_account_name));
CoTaskMemFree(account_name); CoTaskMemFree(account_name);
} }
@ -500,8 +469,8 @@ static void test_SetAccountInformation_GetAccountInformation(void)
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(account_name, dummy_account_name_b), ok(!lstrcmpW(account_name, dummy_account_name_b),
"Got %s, expected %s\n", dbgstr_w(account_name), "Got %s, expected %s\n", wine_dbgstr_w(account_name),
dbgstr_w(dummy_account_name_b)); wine_dbgstr_w(dummy_account_name_b));
CoTaskMemFree(account_name); CoTaskMemFree(account_name);
} }
@ -516,7 +485,7 @@ static void test_SetAccountInformation_GetAccountInformation(void)
if (hres == S_OK) if (hres == S_OK)
{ {
ok(!lstrcmpW(account_name, empty), ok(!lstrcmpW(account_name, empty),
"Got %s, expected empty string\n", dbgstr_w(account_name)); "Got %s, expected empty string\n", wine_dbgstr_w(account_name));
CoTaskMemFree(account_name); CoTaskMemFree(account_name);
} }