From e8d22f02df9882e673e3cd72f1ef4218a6fb22ef Mon Sep 17 00:00:00 2001 From: Roy Shea Date: Wed, 20 Aug 2008 17:46:43 -0700 Subject: [PATCH] mstask/tests: Basic conformance test for (Set|Get)AccountInformation. --- dlls/mstask/tests/task.c | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/dlls/mstask/tests/task.c b/dlls/mstask/tests/task.c index b1f194c4ef4..7e9e831e1f7 100644 --- a/dlls/mstask/tests/task.c +++ b/dlls/mstask/tests/task.c @@ -427,6 +427,77 @@ static void test_SetMaxRunTime_GetMaxRunTime(void) return; } +static void test_SetAccountInformation_GetAccountInformation(void) +{ + BOOL setup; + HRESULT hres; + LPWSTR account_name; + const WCHAR dummy_account_name[] = {'N', 'o', 'S', 'u', 'c', 'h', + 'A', 'c', 'c', 'o', 'u', 'n', 't', 0}; + + setup = setup_task(); + ok(setup, "Failed to setup test_task\n"); + if (!setup) + { + skip("Failed to create task. Skipping tests.\n"); + return; + } + + /* Get account information before it is set */ + hres = ITask_GetAccountInformation(test_task, &account_name); + /* WinXP returns HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND): 0x80070002 but + * Win2K returns SCHED_E_CANNOT_OPEN_TASK: 0x8004130d */ + todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || + hres == SCHED_E_CANNOT_OPEN_TASK, + "Unset account name generated: 0x%08x\n", hres); + + /* Attempt to set to a dummy account without a password */ + /* This test passes on WinXP but fails on Win2K */ + hres = ITask_SetAccountInformation(test_task, dummy_account_name, NULL); + todo_wine ok(hres == S_OK, + "Failed setting dummy account with no password: %08x\n", hres); + hres = ITask_GetAccountInformation(test_task, &account_name); + todo_wine ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres); + if (hres == S_OK) + { + todo_wine ok(!lstrcmpW(account_name, dummy_account_name), + "Got %s, expected %s\n", dbgstr_w(account_name), + dbgstr_w(dummy_account_name)); + CoTaskMemFree(account_name); + } + + /* Attempt to set to a dummy account with a (invalid) password */ + /* This test passes on WinXP but fails on Win2K */ + hres = ITask_SetAccountInformation(test_task, dummy_account_name, + dummy_account_name); + todo_wine ok(hres == S_OK, + "Failed setting dummy account with password: %08x\n", hres); + hres = ITask_GetAccountInformation(test_task, &account_name); + todo_wine ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres); + if (hres == S_OK) + { + todo_wine ok(!lstrcmpW(account_name, dummy_account_name), + "Got %s, expected %s\n", dbgstr_w(account_name), + dbgstr_w(dummy_account_name)); + CoTaskMemFree(account_name); + } + + /* Attempt to set to the local system account */ + hres = ITask_SetAccountInformation(test_task, empty, NULL); + todo_wine ok(hres == S_OK, "Failed setting system account: %08x\n", hres); + hres = ITask_GetAccountInformation(test_task, &account_name); + todo_wine ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres); + if (hres == S_OK) + { + todo_wine ok(!lstrcmpW(account_name, empty), + "Got %s, expected empty string\n", dbgstr_w(account_name)); + CoTaskMemFree(account_name); + } + + cleanup_task(); + return; +} + START_TEST(task) { CoInitialize(NULL); @@ -435,5 +506,6 @@ START_TEST(task) test_SetParameters_GetParameters(); test_SetComment_GetComment(); test_SetMaxRunTime_GetMaxRunTime(); + test_SetAccountInformation_GetAccountInformation(); CoUninitialize(); }