mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 13:13:00 +00:00
Commit 2/2
Imported mstask_winetest.exe, winhttp_winetest.exe from Wine HEAD svn path=/trunk/; revision=36031
This commit is contained in:
parent
b7a82e6a51
commit
d2b37f54df
10 changed files with 2019 additions and 0 deletions
17
rostests/winetests/mstask/mstask.rbuild
Normal file
17
rostests/winetests/mstask/mstask.rbuild
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<group>
|
||||
<module name="mstask_winetest" type="win32cui" installbase="bin" installname="mstask_winetest.exe" allowwarnings="true">
|
||||
<include base="mstask_winetest">.</include>
|
||||
<define name="WINVER">0x600</define>
|
||||
<define name="_WIN32_WINNT">0x600</define>
|
||||
<file>task.c</file>
|
||||
<file>task_scheduler.c</file>
|
||||
<file>task_trigger.c</file>
|
||||
<file>testlist.c</file>
|
||||
<library>wine</library>
|
||||
<library>ole32</library>
|
||||
<library>kernel32</library>
|
||||
<library>ntdll</library>
|
||||
</module>
|
||||
</group>
|
520
rostests/winetests/mstask/task.c
Normal file
520
rostests/winetests/mstask/task.c
Normal file
|
@ -0,0 +1,520 @@
|
|||
/*
|
||||
* Test suite for Task interface
|
||||
*
|
||||
* Copyright (C) 2008 Google (Roy Shea)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "corerror.h"
|
||||
#include "mstask.h"
|
||||
#include "wine/test.h"
|
||||
|
||||
static ITaskScheduler *test_task_scheduler;
|
||||
static ITask *test_task;
|
||||
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 ((ret = realloc(list[idx], size)))
|
||||
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)
|
||||
{
|
||||
HRESULT hres;
|
||||
const WCHAR task_name[] = {'T','e','s','t','i','n','g', 0};
|
||||
|
||||
hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_ITaskScheduler, (void **) &test_task_scheduler);
|
||||
if(hres != S_OK)
|
||||
return FALSE;
|
||||
hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name, &CLSID_CTask,
|
||||
&IID_ITask, (IUnknown**)&test_task);
|
||||
if(hres != S_OK)
|
||||
{
|
||||
ITaskScheduler_Release(test_task_scheduler);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void cleanup_task(void)
|
||||
{
|
||||
ITask_Release(test_task);
|
||||
ITaskScheduler_Release(test_task_scheduler);
|
||||
}
|
||||
|
||||
static LPCWSTR path_resolve_name(LPCWSTR base_name)
|
||||
{
|
||||
static WCHAR buffer[MAX_PATH];
|
||||
int len;
|
||||
|
||||
len = SearchPathW(NULL, base_name, NULL, 0, NULL, NULL);
|
||||
if (len == 0)
|
||||
return base_name;
|
||||
else if (len < MAX_PATH)
|
||||
{
|
||||
SearchPathW(NULL, base_name, NULL, MAX_PATH, buffer, NULL);
|
||||
return buffer;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void test_SetApplicationName_GetApplicationName(void)
|
||||
{
|
||||
BOOL setup;
|
||||
HRESULT hres;
|
||||
LPWSTR stored_name;
|
||||
LPCWSTR full_name;
|
||||
const WCHAR non_application_name[] = {'N','o','S','u','c','h',
|
||||
'A','p','p','l','i','c','a','t','i','o','n', 0};
|
||||
const WCHAR notepad_exe[] = {
|
||||
'n','o','t','e','p','a','d','.','e','x','e', 0};
|
||||
const WCHAR notepad[] = {'n','o','t','e','p','a','d', 0};
|
||||
|
||||
setup = setup_task();
|
||||
ok(setup, "Failed to setup test_task\n");
|
||||
if (!setup)
|
||||
{
|
||||
skip("Failed to create task. Skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Attempt getting before setting application name */
|
||||
hres = ITask_GetApplicationName(test_task, &stored_name);
|
||||
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(stored_name, empty),
|
||||
"Got %s, expected empty string\n", dbgstr_w(stored_name));
|
||||
CoTaskMemFree(stored_name);
|
||||
}
|
||||
|
||||
/* Set application name to a nonexistent application and then get
|
||||
* the application name that is actually stored */
|
||||
hres = ITask_SetApplicationName(test_task, non_application_name);
|
||||
ok(hres == S_OK, "Failed setting name %s: %08x\n",
|
||||
dbgstr_w(non_application_name), hres);
|
||||
hres = ITask_GetApplicationName(test_task, &stored_name);
|
||||
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
full_name = path_resolve_name(non_application_name);
|
||||
ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
|
||||
dbgstr_w(stored_name), dbgstr_w(full_name));
|
||||
CoTaskMemFree(stored_name);
|
||||
}
|
||||
|
||||
/* Set a valid application name with program type extension and then
|
||||
* get the stored name */
|
||||
hres = ITask_SetApplicationName(test_task, notepad_exe);
|
||||
ok(hres == S_OK, "Failed setting name %s: %08x\n",
|
||||
dbgstr_w(notepad_exe), hres);
|
||||
hres = ITask_GetApplicationName(test_task, &stored_name);
|
||||
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
full_name = path_resolve_name(notepad_exe);
|
||||
ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
|
||||
dbgstr_w(stored_name), dbgstr_w(full_name));
|
||||
CoTaskMemFree(stored_name);
|
||||
}
|
||||
|
||||
/* Set a valid application name without program type extension and
|
||||
* then get the stored name */
|
||||
hres = ITask_SetApplicationName(test_task, notepad);
|
||||
ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(notepad), hres);
|
||||
hres = ITask_GetApplicationName(test_task, &stored_name);
|
||||
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
full_name = path_resolve_name(notepad);
|
||||
ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
|
||||
dbgstr_w(stored_name), dbgstr_w(full_name));
|
||||
CoTaskMemFree(stored_name);
|
||||
}
|
||||
|
||||
/* After having a valid application name set, set application the name
|
||||
* to a nonexistent application and then get the name that is
|
||||
* actually stored */
|
||||
hres = ITask_SetApplicationName(test_task, non_application_name);
|
||||
ok(hres == S_OK, "Failed setting name %s: %08x\n",
|
||||
dbgstr_w(non_application_name), hres);
|
||||
hres = ITask_GetApplicationName(test_task, &stored_name);
|
||||
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
full_name = path_resolve_name(non_application_name);
|
||||
ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
|
||||
dbgstr_w(stored_name), dbgstr_w(full_name));
|
||||
CoTaskMemFree(stored_name);
|
||||
}
|
||||
|
||||
/* Clear application name */
|
||||
hres = ITask_SetApplicationName(test_task, empty);
|
||||
ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(empty), hres);
|
||||
hres = ITask_GetApplicationName(test_task, &stored_name);
|
||||
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(stored_name, empty),
|
||||
"Got %s, expected empty string\n", dbgstr_w(stored_name));
|
||||
CoTaskMemFree(stored_name);
|
||||
}
|
||||
|
||||
cleanup_task();
|
||||
return;
|
||||
}
|
||||
|
||||
static void test_CreateTrigger(void)
|
||||
{
|
||||
BOOL setup;
|
||||
HRESULT hres;
|
||||
WORD trigger_index;
|
||||
ITaskTrigger *test_trigger;
|
||||
|
||||
setup = setup_task();
|
||||
ok(setup, "Failed to setup test_task\n");
|
||||
if (!setup)
|
||||
{
|
||||
skip("Failed to create task. Skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
hres = ITask_CreateTrigger(test_task, &trigger_index, &test_trigger);
|
||||
ok(hres == S_OK, "Failed to create trigger: 0x%08x\n", hres);
|
||||
if (hres != S_OK)
|
||||
{
|
||||
cleanup_task();
|
||||
return;
|
||||
}
|
||||
|
||||
ITaskTrigger_Release(test_trigger);
|
||||
cleanup_task();
|
||||
return;
|
||||
}
|
||||
|
||||
static void test_SetParameters_GetParameters(void)
|
||||
{
|
||||
BOOL setup;
|
||||
HRESULT hres;
|
||||
LPWSTR parameters;
|
||||
const WCHAR parameters_a[] = {'f','o','o','.','t','x','t', 0};
|
||||
const WCHAR parameters_b[] = {'f','o','o','.','t','x','t',' ',
|
||||
'b','a','r','.','t','x','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 parameters before setting them */
|
||||
hres = ITask_GetParameters(test_task, ¶meters);
|
||||
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(parameters, empty),
|
||||
"Got %s, expected empty string\n", dbgstr_w(parameters));
|
||||
CoTaskMemFree(parameters);
|
||||
}
|
||||
|
||||
/* Set parameters to a simple string */
|
||||
hres = ITask_SetParameters(test_task, parameters_a);
|
||||
ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
||||
dbgstr_w(parameters_a), hres);
|
||||
hres = ITask_GetParameters(test_task, ¶meters);
|
||||
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(parameters, parameters_a), "Got %s, expected %s\n",
|
||||
dbgstr_w(parameters), dbgstr_w(parameters_a));
|
||||
CoTaskMemFree(parameters);
|
||||
}
|
||||
|
||||
/* Update parameters to a different simple string */
|
||||
hres = ITask_SetParameters(test_task, parameters_b);
|
||||
ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
||||
dbgstr_w(parameters_b), hres);
|
||||
hres = ITask_GetParameters(test_task, ¶meters);
|
||||
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(parameters, parameters_b), "Got %s, expected %s\n",
|
||||
dbgstr_w(parameters), dbgstr_w(parameters_b));
|
||||
CoTaskMemFree(parameters);
|
||||
}
|
||||
|
||||
/* Clear parameters */
|
||||
hres = ITask_SetParameters(test_task, empty);
|
||||
ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
||||
dbgstr_w(empty), hres);
|
||||
hres = ITask_GetParameters(test_task, ¶meters);
|
||||
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(parameters, empty),
|
||||
"Got %s, expected empty string\n", dbgstr_w(parameters));
|
||||
CoTaskMemFree(parameters);
|
||||
}
|
||||
|
||||
cleanup_task();
|
||||
return;
|
||||
}
|
||||
|
||||
static void test_SetComment_GetComment(void)
|
||||
{
|
||||
BOOL setup;
|
||||
HRESULT hres;
|
||||
LPWSTR comment;
|
||||
const WCHAR comment_a[] = {'C','o','m','m','e','n','t','.', 0};
|
||||
const WCHAR comment_b[] = {'L','o','n','g','e','r',' ',
|
||||
'c','o','m','m','e','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 comment before setting it*/
|
||||
hres = ITask_GetComment(test_task, &comment);
|
||||
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(comment, empty),
|
||||
"Got %s, expected empty string\n", dbgstr_w(comment));
|
||||
CoTaskMemFree(comment);
|
||||
}
|
||||
|
||||
/* Set comment to a simple string */
|
||||
hres = ITask_SetComment(test_task, comment_a);
|
||||
ok(hres == S_OK, "Failed setting comment %s: %08x\n",
|
||||
dbgstr_w(comment_a), hres);
|
||||
hres = ITask_GetComment(test_task, &comment);
|
||||
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(comment, comment_a), "Got %s, expected %s\n",
|
||||
dbgstr_w(comment), dbgstr_w(comment_a));
|
||||
CoTaskMemFree(comment);
|
||||
}
|
||||
|
||||
/* Update comment to a different simple string */
|
||||
hres = ITask_SetComment(test_task, comment_b);
|
||||
ok(hres == S_OK, "Failed setting comment %s: %08x\n",
|
||||
dbgstr_w(comment_b), hres);
|
||||
hres = ITask_GetComment(test_task, &comment);
|
||||
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(comment, comment_b), "Got %s, expected %s\n",
|
||||
dbgstr_w(comment), dbgstr_w(comment_b));
|
||||
CoTaskMemFree(comment);
|
||||
}
|
||||
|
||||
/* Clear comment */
|
||||
hres = ITask_SetComment(test_task, empty);
|
||||
ok(hres == S_OK, "Failed setting comment %s: %08x\n",
|
||||
dbgstr_w(empty), hres);
|
||||
hres = ITask_GetComment(test_task, &comment);
|
||||
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(comment, empty),
|
||||
"Got %s, expected empty string\n", dbgstr_w(comment));
|
||||
CoTaskMemFree(comment);
|
||||
}
|
||||
|
||||
cleanup_task();
|
||||
return;
|
||||
}
|
||||
|
||||
static void test_SetMaxRunTime_GetMaxRunTime(void)
|
||||
{
|
||||
BOOL setup;
|
||||
HRESULT hres;
|
||||
DWORD max_run_time;
|
||||
|
||||
setup = setup_task();
|
||||
ok(setup, "Failed to setup test_task\n");
|
||||
if (!setup)
|
||||
{
|
||||
skip("Failed to create task. Skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Default time is 3 days:
|
||||
* 3 days * 24 hours * 60 minutes * 60 seconds * 1000 ms = 259200000 */
|
||||
max_run_time = 0;
|
||||
hres = ITask_GetMaxRunTime(test_task, &max_run_time);
|
||||
ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
|
||||
ok(max_run_time == 259200000, "Expected 259200000: %d\n", max_run_time);
|
||||
|
||||
/* Basic set test */
|
||||
max_run_time = 0;
|
||||
hres = ITask_SetMaxRunTime(test_task, 1234);
|
||||
ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
|
||||
hres = ITask_GetMaxRunTime(test_task, &max_run_time);
|
||||
ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
|
||||
ok(max_run_time == 1234, "Expected 1234: %d\n", max_run_time);
|
||||
|
||||
/* Verify that time can be set to zero */
|
||||
max_run_time = 1;
|
||||
hres = ITask_SetMaxRunTime(test_task, 0);
|
||||
ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
|
||||
hres = ITask_GetMaxRunTime(test_task, &max_run_time);
|
||||
ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
|
||||
ok(max_run_time == 0, "Expected 0: %d\n", max_run_time);
|
||||
|
||||
/* Check resolution by setting time to one */
|
||||
max_run_time = 0;
|
||||
hres = ITask_SetMaxRunTime(test_task, 1);
|
||||
ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
|
||||
hres = ITask_GetMaxRunTime(test_task, &max_run_time);
|
||||
ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
|
||||
ok(max_run_time == 1, "Expected 1: %d\n", max_run_time);
|
||||
|
||||
/* Verify that time can be set to INFINITE */
|
||||
max_run_time = 0;
|
||||
hres = ITask_SetMaxRunTime(test_task, INFINITE);
|
||||
ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
|
||||
hres = ITask_GetMaxRunTime(test_task, &max_run_time);
|
||||
ok(hres == S_OK, "Failed to get max runtime: 0x%08x\n", hres);
|
||||
ok(max_run_time == INFINITE, "Expected INFINITE: %d\n", max_run_time);
|
||||
|
||||
cleanup_task();
|
||||
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};
|
||||
const WCHAR dummy_account_name_b[] = {'N', 'o', 'S', 'u', 'c', 'h',
|
||||
'A', 'c', 'c', 'o', 'u', 'n', 't', 'B', 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
|
||||
* Win9x doesn't support security services */
|
||||
if (hres == SCHED_E_NO_SECURITY_SERVICES)
|
||||
{
|
||||
win_skip("Security services are not supported\n");
|
||||
cleanup_task();
|
||||
return;
|
||||
}
|
||||
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);
|
||||
ok(hres == S_OK,
|
||||
"Failed setting dummy account with no password: %08x\n", hres);
|
||||
hres = ITask_GetAccountInformation(test_task, &account_name);
|
||||
ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
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_b,
|
||||
dummy_account_name_b);
|
||||
ok(hres == S_OK,
|
||||
"Failed setting dummy account with password: %08x\n", hres);
|
||||
hres = ITask_GetAccountInformation(test_task, &account_name);
|
||||
ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
ok(!lstrcmpW(account_name, dummy_account_name_b),
|
||||
"Got %s, expected %s\n", dbgstr_w(account_name),
|
||||
dbgstr_w(dummy_account_name_b));
|
||||
CoTaskMemFree(account_name);
|
||||
}
|
||||
|
||||
/* Attempt to set to the local system account */
|
||||
hres = ITask_SetAccountInformation(test_task, empty, NULL);
|
||||
ok(hres == S_OK, "Failed setting system account: %08x\n", hres);
|
||||
hres = ITask_GetAccountInformation(test_task, &account_name);
|
||||
ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
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);
|
||||
test_SetApplicationName_GetApplicationName();
|
||||
test_CreateTrigger();
|
||||
test_SetParameters_GetParameters();
|
||||
test_SetComment_GetComment();
|
||||
test_SetMaxRunTime_GetMaxRunTime();
|
||||
test_SetAccountInformation_GetAccountInformation();
|
||||
CoUninitialize();
|
||||
}
|
111
rostests/winetests/mstask/task_scheduler.c
Normal file
111
rostests/winetests/mstask/task_scheduler.c
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Test suite for TaskScheduler interface
|
||||
*
|
||||
* Copyright (C) 2008 Google (Roy Shea)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "corerror.h"
|
||||
|
||||
#include "initguid.h"
|
||||
#include "mstask.h"
|
||||
#include "wine/test.h"
|
||||
|
||||
static ITaskScheduler *test_task_scheduler;
|
||||
|
||||
static void test_NewWorkItem(void)
|
||||
{
|
||||
HRESULT hres;
|
||||
ITask *task;
|
||||
const WCHAR task_name[] = {'T', 'e', 's', 't', 'i', 'n', 'g', 0};
|
||||
GUID GUID_BAD;
|
||||
|
||||
/* Initialize a GUID that will not be a recognized CLSID or a IID */
|
||||
CoCreateGuid(&GUID_BAD);
|
||||
|
||||
/* Create TaskScheduler */
|
||||
hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_ITaskScheduler, (void **) &test_task_scheduler);
|
||||
ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres);
|
||||
if (hres != S_OK)
|
||||
{
|
||||
skip("Failed to create task scheduler. Skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Test basic task creation */
|
||||
hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
|
||||
&CLSID_CTask, &IID_ITask, (IUnknown**)&task);
|
||||
ok(hres == S_OK, "NewNetworkItem failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
ITask_Release(task);
|
||||
|
||||
/* Task creation attempt using invalid work item class ID */
|
||||
hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
|
||||
&GUID_BAD, &IID_ITask, (IUnknown**)&task);
|
||||
ok(hres == CLASS_E_CLASSNOTAVAILABLE,
|
||||
"Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
|
||||
|
||||
/* Task creation attempt using invalid interface ID */
|
||||
hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
|
||||
&CLSID_CTask, &GUID_BAD, (IUnknown**)&task);
|
||||
ok(hres == E_NOINTERFACE, "Expected E_NOINTERFACE: %08x\n", hres);
|
||||
|
||||
/* Task creation attempt using invalid work item class and interface ID */
|
||||
hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
|
||||
&GUID_BAD, &GUID_BAD, (IUnknown**)&task);
|
||||
ok(hres == CLASS_E_CLASSNOTAVAILABLE,
|
||||
"Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
|
||||
|
||||
ITaskScheduler_Release(test_task_scheduler);
|
||||
return;
|
||||
}
|
||||
|
||||
static void test_Activate(void)
|
||||
{
|
||||
HRESULT hres;
|
||||
ITask *task = NULL;
|
||||
const WCHAR not_task_name[] =
|
||||
{'N', 'o', 'S', 'u', 'c', 'h', 'T', 'a', 's', 'k', 0};
|
||||
|
||||
/* Create TaskScheduler */
|
||||
hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_ITaskScheduler, (void **) &test_task_scheduler);
|
||||
ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres);
|
||||
if (hres != S_OK)
|
||||
{
|
||||
skip("Failed to create task scheduler. Skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Attempt to activate a nonexistent task */
|
||||
hres = ITaskScheduler_Activate(test_task_scheduler, not_task_name,
|
||||
&IID_ITask, (IUnknown**)&task);
|
||||
ok(hres == COR_E_FILENOTFOUND, "Expected COR_E_FILENOTFOUND: %08x\n", hres);
|
||||
|
||||
ITaskScheduler_Release(test_task_scheduler);
|
||||
return;
|
||||
}
|
||||
|
||||
START_TEST(task_scheduler)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
test_NewWorkItem();
|
||||
test_Activate();
|
||||
CoUninitialize();
|
||||
}
|
380
rostests/winetests/mstask/task_trigger.c
Normal file
380
rostests/winetests/mstask/task_trigger.c
Normal file
|
@ -0,0 +1,380 @@
|
|||
/*
|
||||
* Test suite for Task interface
|
||||
*
|
||||
* Copyright (C) 2008 Google (Roy Shea)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include <corerror.h>
|
||||
|
||||
#include "mstask.h"
|
||||
#include "wine/test.h"
|
||||
|
||||
static ITaskScheduler *test_task_scheduler;
|
||||
static ITask *test_task;
|
||||
static ITaskTrigger *test_trigger;
|
||||
static WORD trigger_index;
|
||||
|
||||
static BOOL setup_trigger(void)
|
||||
{
|
||||
HRESULT hres;
|
||||
const WCHAR task_name[] = {'T','e','s','t','i','n','g', 0};
|
||||
|
||||
hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_ITaskScheduler, (void **) &test_task_scheduler);
|
||||
if(hres != S_OK)
|
||||
return FALSE;
|
||||
hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
|
||||
&CLSID_CTask, &IID_ITask, (IUnknown**)&test_task);
|
||||
if(hres != S_OK)
|
||||
{
|
||||
ITaskScheduler_Release(test_task_scheduler);
|
||||
return FALSE;
|
||||
}
|
||||
hres = ITask_CreateTrigger(test_task, &trigger_index, &test_trigger);
|
||||
if(hres != S_OK)
|
||||
{
|
||||
ITask_Release(test_task);
|
||||
ITaskScheduler_Release(test_task_scheduler);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void cleanup_trigger(void)
|
||||
{
|
||||
ITaskTrigger_Release(test_trigger);
|
||||
ITask_Release(test_task);
|
||||
ITaskScheduler_Release(test_task_scheduler);
|
||||
}
|
||||
|
||||
static BOOL compare_trigger_state(TASK_TRIGGER found_state,
|
||||
TASK_TRIGGER expected_state)
|
||||
{
|
||||
ok(found_state.cbTriggerSize == expected_state.cbTriggerSize,
|
||||
"cbTriggerSize: Found %d but expected %d\n",
|
||||
found_state.cbTriggerSize, expected_state.cbTriggerSize);
|
||||
|
||||
ok(found_state.Reserved1 == expected_state.Reserved1,
|
||||
"Reserved1: Found %d but expected %d\n",
|
||||
found_state.Reserved1, expected_state.Reserved1);
|
||||
|
||||
ok(found_state.wBeginYear == expected_state.wBeginYear,
|
||||
"wBeginYear: Found %d but expected %d\n",
|
||||
found_state.wBeginYear, expected_state.wBeginYear);
|
||||
|
||||
ok(found_state.wBeginMonth == expected_state.wBeginMonth,
|
||||
"wBeginMonth: Found %d but expected %d\n",
|
||||
found_state.wBeginMonth, expected_state.wBeginMonth);
|
||||
|
||||
ok(found_state.wBeginDay == expected_state.wBeginDay,
|
||||
"wBeginDay: Found %d but expected %d\n",
|
||||
found_state.wBeginDay, expected_state.wBeginDay);
|
||||
|
||||
ok(found_state.wEndYear == expected_state.wEndYear,
|
||||
"wEndYear: Found %d but expected %d\n",
|
||||
found_state.wEndYear, expected_state.wEndYear);
|
||||
|
||||
ok(found_state.wEndMonth == expected_state.wEndMonth,
|
||||
"wEndMonth: Found %d but expected %d\n",
|
||||
found_state.wEndMonth, expected_state.wEndMonth);
|
||||
|
||||
ok(found_state.wEndDay == expected_state.wEndDay,
|
||||
"wEndDay: Found %d but expected %d\n",
|
||||
found_state.wEndDay, expected_state.wEndDay);
|
||||
|
||||
ok(found_state.wStartHour == expected_state.wStartHour,
|
||||
"wStartHour: Found %d but expected %d\n",
|
||||
found_state.wStartHour, expected_state.wStartHour);
|
||||
|
||||
ok(found_state.wStartMinute == expected_state.wStartMinute,
|
||||
"wStartMinute: Found %d but expected %d\n",
|
||||
found_state.wStartMinute, expected_state.wStartMinute);
|
||||
|
||||
ok(found_state.MinutesDuration == expected_state.MinutesDuration,
|
||||
"MinutesDuration: Found %d but expected %d\n",
|
||||
found_state.MinutesDuration, expected_state.MinutesDuration);
|
||||
|
||||
ok(found_state.MinutesInterval == expected_state.MinutesInterval,
|
||||
"MinutesInterval: Found %d but expected %d\n",
|
||||
found_state.MinutesInterval, expected_state.MinutesInterval);
|
||||
|
||||
ok(found_state.rgFlags == expected_state.rgFlags,
|
||||
"rgFlags: Found %d but expected %d\n",
|
||||
found_state.rgFlags, expected_state.rgFlags);
|
||||
|
||||
ok(found_state.TriggerType == expected_state.TriggerType,
|
||||
"TriggerType: Found %d but expected %d\n",
|
||||
found_state.TriggerType, expected_state.TriggerType);
|
||||
|
||||
ok(found_state.Type.Daily.DaysInterval == expected_state.Type.Daily.DaysInterval,
|
||||
"Type.Daily.DaysInterval: Found %d but expected %d\n",
|
||||
found_state.Type.Daily.DaysInterval, expected_state.Type.Daily.DaysInterval);
|
||||
|
||||
ok(found_state.Reserved2 == expected_state.Reserved2,
|
||||
"Reserved2: Found %d but expected %d\n",
|
||||
found_state.Reserved2, expected_state.Reserved2);
|
||||
|
||||
ok(found_state.wRandomMinutesInterval == expected_state.wRandomMinutesInterval,
|
||||
"wRandomMinutesInterval: Found %d but expected %d\n",
|
||||
found_state.wRandomMinutesInterval, expected_state.wRandomMinutesInterval);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void test_SetTrigger_GetTrigger(void)
|
||||
{
|
||||
BOOL setup;
|
||||
HRESULT hres;
|
||||
TASK_TRIGGER trigger_state;
|
||||
TASK_TRIGGER empty_trigger_state = {
|
||||
sizeof(trigger_state), 0,
|
||||
0, 0, 0,
|
||||
0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
TASK_TRIGGER_FLAG_DISABLED, TASK_TIME_TRIGGER_DAILY, {{1}},
|
||||
0, 0
|
||||
};
|
||||
TASK_TRIGGER normal_trigger_state = {
|
||||
sizeof(trigger_state), 0,
|
||||
1980, 1, 1,
|
||||
2980, 2, 2,
|
||||
3, 3,
|
||||
0, 0,
|
||||
TASK_TRIGGER_FLAG_DISABLED, TASK_TIME_TRIGGER_DAILY, {{1}},
|
||||
0, 0
|
||||
};
|
||||
SYSTEMTIME time;
|
||||
|
||||
setup = setup_trigger();
|
||||
ok(setup, "Failed to setup test_task\n");
|
||||
if (!setup)
|
||||
{
|
||||
skip("Failed to create task. Skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Setup a trigger with base values for this test run */
|
||||
GetLocalTime(&time);
|
||||
empty_trigger_state.wStartHour = time.wHour;
|
||||
empty_trigger_state.wStartMinute = time.wMinute;
|
||||
empty_trigger_state.wBeginYear = time.wYear;
|
||||
empty_trigger_state.wBeginMonth = time.wMonth;
|
||||
empty_trigger_state.wBeginDay = time.wDay;
|
||||
|
||||
/* Test trigger state after trigger creation but before setting * state */
|
||||
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
||||
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
||||
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
compare_trigger_state(trigger_state, empty_trigger_state);
|
||||
|
||||
/* Test setting basic empty trigger */
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &empty_trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
||||
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
||||
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
||||
ok(hres == S_OK, "Failed to GetTrigger\n");
|
||||
compare_trigger_state(trigger_state, empty_trigger_state);
|
||||
|
||||
/* Test setting basic non-empty trigger */
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
||||
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
||||
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
||||
ok(hres == S_OK, "Failed to GetTrigger\n");
|
||||
compare_trigger_state(trigger_state, normal_trigger_state);
|
||||
|
||||
/* The following tests modify the normal_trigger_state structure
|
||||
* before each test, and return the normal_trigger_state structure
|
||||
* back to its original valid state after each test. This keeps
|
||||
* each test run independent. */
|
||||
|
||||
/* Test setting trigger with invalid cbTriggerSize */
|
||||
normal_trigger_state.cbTriggerSize = sizeof(trigger_state) - 1;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.cbTriggerSize = sizeof(trigger_state) + 1;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.cbTriggerSize = sizeof(trigger_state);
|
||||
|
||||
/* Test setting trigger with invalid Reserved fields */
|
||||
normal_trigger_state.Reserved1 = 80;
|
||||
normal_trigger_state.Reserved2 = 80;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
||||
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
||||
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
||||
ok(trigger_state.Reserved1 == 0 && trigger_state.Reserved2 == 0,
|
||||
"Reserved fields should be set to zero\n");
|
||||
normal_trigger_state.Reserved1 = 0;
|
||||
normal_trigger_state.Reserved2 = 0;
|
||||
|
||||
/* Test setting trigger with invalid month */
|
||||
normal_trigger_state.wBeginMonth = 0;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.wBeginMonth = 13;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.wBeginMonth = 1;
|
||||
|
||||
/* Test setting trigger with invalid begin date */
|
||||
normal_trigger_state.wBeginDay = 0;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.wBeginDay = 32;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.wBeginMonth = 2;
|
||||
normal_trigger_state.wBeginDay = 30;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.wBeginMonth = 1;
|
||||
normal_trigger_state.wBeginDay = 1;
|
||||
|
||||
/* Test setting trigger invalid end date */
|
||||
normal_trigger_state.wEndYear = 0;
|
||||
normal_trigger_state.wEndMonth = 200;
|
||||
normal_trigger_state.wEndDay = 200;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
||||
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
||||
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
||||
ok(trigger_state.wEndYear == 0, "End year should be 0: %d\n",
|
||||
trigger_state.wEndYear);
|
||||
ok(trigger_state.wEndMonth == 200, "End month should be 200: %d\n",
|
||||
trigger_state.wEndMonth);
|
||||
ok(trigger_state.wEndDay == 200, "End day should be 200: %d\n",
|
||||
trigger_state.wEndDay);
|
||||
normal_trigger_state.rgFlags =
|
||||
TASK_TRIGGER_FLAG_DISABLED | TASK_TRIGGER_FLAG_HAS_END_DATE;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.rgFlags = TASK_TRIGGER_FLAG_DISABLED;
|
||||
normal_trigger_state.wEndYear = 2980;
|
||||
normal_trigger_state.wEndMonth = 1;
|
||||
normal_trigger_state.wEndDay = 1;
|
||||
|
||||
/* Test setting trigger with invalid hour or minute*/
|
||||
normal_trigger_state.wStartHour = 24;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.wStartHour = 3;
|
||||
normal_trigger_state.wStartHour = 60;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.wStartHour = 3;
|
||||
|
||||
/* Test setting trigger with invalid duration / interval pairs */
|
||||
normal_trigger_state.MinutesDuration = 5;
|
||||
normal_trigger_state.MinutesInterval = 5;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.MinutesDuration = 5;
|
||||
normal_trigger_state.MinutesInterval = 6;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.MinutesDuration = 0;
|
||||
normal_trigger_state.MinutesInterval = 6;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.MinutesDuration = 5;
|
||||
normal_trigger_state.MinutesInterval = 0;
|
||||
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
||||
normal_trigger_state.MinutesDuration = 0;
|
||||
normal_trigger_state.MinutesInterval = 0;
|
||||
|
||||
/* Test setting trigger with end date before start date */
|
||||
normal_trigger_state.wEndYear = 1979;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
normal_trigger_state.rgFlags =
|
||||
TASK_TRIGGER_FLAG_DISABLED | TASK_TRIGGER_FLAG_HAS_END_DATE;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
normal_trigger_state.rgFlags = TASK_TRIGGER_FLAG_DISABLED;
|
||||
normal_trigger_state.wEndYear = 2980;
|
||||
normal_trigger_state.wEndMonth = 1;
|
||||
normal_trigger_state.wEndDay = 1;
|
||||
|
||||
|
||||
/* Test setting trigger with invalid TriggerType and Type */
|
||||
normal_trigger_state.TriggerType = TASK_TIME_TRIGGER_ONCE;
|
||||
normal_trigger_state.Type.Weekly.WeeksInterval = 2;
|
||||
normal_trigger_state.Type.Weekly.rgfDaysOfTheWeek = (TASK_MONDAY | TASK_TUESDAY);
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
||||
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
||||
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
||||
ok(trigger_state.Type.Weekly.WeeksInterval == 0xcfcf,
|
||||
"Expected WeeksInterval set remain untouched: %d\n",
|
||||
trigger_state.Type.Weekly.WeeksInterval);
|
||||
ok(trigger_state.Type.Weekly.rgfDaysOfTheWeek == 0xcfcf,
|
||||
"Expected WeeksInterval set remain untouched: %d\n",
|
||||
trigger_state.Type.Weekly.rgfDaysOfTheWeek);
|
||||
normal_trigger_state.TriggerType = TASK_TIME_TRIGGER_DAILY;
|
||||
normal_trigger_state.Type.Daily.DaysInterval = 1;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
|
||||
/* Test setting trigger with set wRandomMinutesInterval */
|
||||
normal_trigger_state.wRandomMinutesInterval = 5;
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
||||
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
||||
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
||||
ok(trigger_state.wRandomMinutesInterval == 0,
|
||||
"wRandomMinutesInterval should be set to zero\n");
|
||||
normal_trigger_state.wRandomMinutesInterval = 0;
|
||||
|
||||
/* Test GetTrigger using invalid cbTriggerSiz in pTrigger. In
|
||||
* contrast to available documentation, this succeeds in practice. */
|
||||
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
||||
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
||||
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
||||
trigger_state.cbTriggerSize = sizeof(trigger_state) - 1;
|
||||
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
||||
ok(hres == S_OK, "Failed to GetTrigger\n");
|
||||
ok(compare_trigger_state(trigger_state, normal_trigger_state),
|
||||
"Invalid state\n");
|
||||
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
||||
trigger_state.cbTriggerSize = 0;
|
||||
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
||||
ok(hres == S_OK, "Failed to GetTrigger\n");
|
||||
ok(compare_trigger_state(trigger_state, normal_trigger_state),
|
||||
"Invalid state\n");
|
||||
|
||||
|
||||
cleanup_trigger();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
START_TEST(task_trigger)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
test_SetTrigger_GetTrigger();
|
||||
CoUninitialize();
|
||||
}
|
19
rostests/winetests/mstask/testlist.c
Normal file
19
rostests/winetests/mstask/testlist.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* Automatically generated file; DO NOT EDIT!! */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#define STANDALONE
|
||||
#include "wine/test.h"
|
||||
|
||||
extern void func_task(void);
|
||||
extern void func_task_scheduler(void);
|
||||
extern void func_task_trigger(void);
|
||||
|
||||
const struct test winetest_testlist[] =
|
||||
{
|
||||
{ "task", func_task },
|
||||
{ "task_scheduler", func_task_scheduler },
|
||||
{ "task_trigger", func_task_trigger },
|
||||
{ 0, 0 }
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue