2008-08-21 03:29:03 +02:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
2008-08-22 21:52:46 +02:00
|
|
|
ok(found_state.cbTriggerSize == expected_state.cbTriggerSize,
|
2008-08-21 03:29:03 +02:00
|
|
|
"cbTriggerSize: Found %d but expected %d\n",
|
|
|
|
found_state.cbTriggerSize, expected_state.cbTriggerSize);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.Reserved1 == expected_state.Reserved1,
|
2008-08-21 03:29:03 +02:00
|
|
|
"Reserved1: Found %d but expected %d\n",
|
|
|
|
found_state.Reserved1, expected_state.Reserved1);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.wBeginYear == expected_state.wBeginYear,
|
2008-08-21 03:29:03 +02:00
|
|
|
"wBeginYear: Found %d but expected %d\n",
|
|
|
|
found_state.wBeginYear, expected_state.wBeginYear);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.wBeginMonth == expected_state.wBeginMonth,
|
2008-08-21 03:29:03 +02:00
|
|
|
"wBeginMonth: Found %d but expected %d\n",
|
|
|
|
found_state.wBeginMonth, expected_state.wBeginMonth);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.wBeginDay == expected_state.wBeginDay,
|
2008-08-21 03:29:03 +02:00
|
|
|
"wBeginDay: Found %d but expected %d\n",
|
|
|
|
found_state.wBeginDay, expected_state.wBeginDay);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.wEndYear == expected_state.wEndYear,
|
2008-08-21 03:29:03 +02:00
|
|
|
"wEndYear: Found %d but expected %d\n",
|
|
|
|
found_state.wEndYear, expected_state.wEndYear);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.wEndMonth == expected_state.wEndMonth,
|
2008-08-21 03:29:03 +02:00
|
|
|
"wEndMonth: Found %d but expected %d\n",
|
|
|
|
found_state.wEndMonth, expected_state.wEndMonth);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.wEndDay == expected_state.wEndDay,
|
2008-08-21 03:29:03 +02:00
|
|
|
"wEndDay: Found %d but expected %d\n",
|
|
|
|
found_state.wEndDay, expected_state.wEndDay);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.wStartHour == expected_state.wStartHour,
|
2008-08-21 03:29:03 +02:00
|
|
|
"wStartHour: Found %d but expected %d\n",
|
|
|
|
found_state.wStartHour, expected_state.wStartHour);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.wStartMinute == expected_state.wStartMinute,
|
2008-08-21 03:29:03 +02:00
|
|
|
"wStartMinute: Found %d but expected %d\n",
|
|
|
|
found_state.wStartMinute, expected_state.wStartMinute);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.MinutesDuration == expected_state.MinutesDuration,
|
2008-08-21 03:29:03 +02:00
|
|
|
"MinutesDuration: Found %d but expected %d\n",
|
|
|
|
found_state.MinutesDuration, expected_state.MinutesDuration);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.MinutesInterval == expected_state.MinutesInterval,
|
2008-08-21 03:29:03 +02:00
|
|
|
"MinutesInterval: Found %d but expected %d\n",
|
|
|
|
found_state.MinutesInterval, expected_state.MinutesInterval);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.rgFlags == expected_state.rgFlags,
|
2008-08-21 03:29:03 +02:00
|
|
|
"rgFlags: Found %d but expected %d\n",
|
|
|
|
found_state.rgFlags, expected_state.rgFlags);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.TriggerType == expected_state.TriggerType,
|
2008-08-21 03:29:03 +02:00
|
|
|
"TriggerType: Found %d but expected %d\n",
|
|
|
|
found_state.TriggerType, expected_state.TriggerType);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.Type.Daily.DaysInterval == expected_state.Type.Daily.DaysInterval,
|
2008-08-21 03:29:03 +02:00
|
|
|
"Type.Daily.DaysInterval: Found %d but expected %d\n",
|
|
|
|
found_state.Type.Daily.DaysInterval, expected_state.Type.Daily.DaysInterval);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.Reserved2 == expected_state.Reserved2,
|
2008-08-21 03:29:03 +02:00
|
|
|
"Reserved2: Found %d but expected %d\n",
|
|
|
|
found_state.Reserved2, expected_state.Reserved2);
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(found_state.wRandomMinutesInterval == expected_state.wRandomMinutesInterval,
|
2008-08-21 03:29:03 +02:00
|
|
|
"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();
|
2008-08-22 21:52:46 +02:00
|
|
|
ok(setup, "Failed to setup test_task\n");
|
2008-08-21 03:29:03 +02:00
|
|
|
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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
2008-08-22 21:52:46 +02:00
|
|
|
compare_trigger_state(trigger_state, empty_trigger_state);
|
2008-08-21 03:29:03 +02:00
|
|
|
|
|
|
|
/* Test setting basic empty trigger */
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &empty_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
|
|
|
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
|
|
|
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to GetTrigger\n");
|
2008-08-22 21:52:46 +02:00
|
|
|
compare_trigger_state(trigger_state, empty_trigger_state);
|
2008-08-21 03:29:03 +02:00
|
|
|
|
|
|
|
/* Test setting basic non-empty trigger */
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
|
|
|
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
|
|
|
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to GetTrigger\n");
|
2008-08-22 21:52:46 +02:00
|
|
|
compare_trigger_state(trigger_state, normal_trigger_state);
|
2008-08-21 03:29:03 +02:00
|
|
|
|
|
|
|
/* 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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
normal_trigger_state.cbTriggerSize = sizeof(trigger_state) + 1;
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
|
|
|
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
|
|
|
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
2011-02-07 23:58:06 +01:00
|
|
|
ok(hres == S_OK, "Expected S_OK: 0x%08x\n", hres);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(trigger_state.Reserved1 == 0 && trigger_state.Reserved2 == 0,
|
2008-08-21 03:29:03 +02:00
|
|
|
"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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
normal_trigger_state.wBeginMonth = 13;
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
normal_trigger_state.wBeginDay = 32;
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
normal_trigger_state.wBeginMonth = 2;
|
|
|
|
normal_trigger_state.wBeginDay = 30;
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
|
|
|
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
|
|
|
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
2011-02-07 23:58:06 +01:00
|
|
|
ok(hres == S_OK, "Expected S_OK: 0x%08x\n", hres);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(trigger_state.wEndYear == 0, "End year should be 0: %d\n",
|
2008-08-21 03:29:03 +02:00
|
|
|
trigger_state.wEndYear);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(trigger_state.wEndMonth == 200, "End month should be 200: %d\n",
|
2008-08-21 03:29:03 +02:00
|
|
|
trigger_state.wEndMonth);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(trigger_state.wEndDay == 200, "End day should be 200: %d\n",
|
2008-08-21 03:29:03 +02:00
|
|
|
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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
normal_trigger_state.wStartHour = 3;
|
|
|
|
normal_trigger_state.wStartHour = 60;
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
normal_trigger_state.MinutesDuration = 5;
|
|
|
|
normal_trigger_state.MinutesInterval = 6;
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
normal_trigger_state.MinutesDuration = 0;
|
|
|
|
normal_trigger_state.MinutesInterval = 6;
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
normal_trigger_state.MinutesDuration = 5;
|
|
|
|
normal_trigger_state.MinutesInterval = 0;
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == E_INVALIDARG, "Expected E_INVALIDARG: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
normal_trigger_state.rgFlags =
|
|
|
|
TASK_TRIGGER_FLAG_DISABLED | TASK_TRIGGER_FLAG_HAS_END_DATE;
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
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);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
|
|
|
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
|
|
|
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
2011-02-07 23:58:06 +01:00
|
|
|
ok(hres == S_OK, "Expected S_OK: 0x%08x\n", hres);
|
2008-08-22 21:52:46 +02:00
|
|
|
ok(trigger_state.Type.Weekly.WeeksInterval == 0xcfcf,
|
2008-08-21 03:29:03 +02:00
|
|
|
"Expected WeeksInterval set remain untouched: %d\n",
|
|
|
|
trigger_state.Type.Weekly.WeeksInterval);
|
2008-08-22 21:52:46 +02:00
|
|
|
ok(trigger_state.Type.Weekly.rgfDaysOfTheWeek == 0xcfcf,
|
2008-08-21 03:29:03 +02:00
|
|
|
"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);
|
2011-02-07 23:58:06 +01:00
|
|
|
ok(hres == S_OK, "Expected S_OK: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
|
|
|
|
/* Test setting trigger with set wRandomMinutesInterval */
|
|
|
|
normal_trigger_state.wRandomMinutesInterval = 5;
|
|
|
|
hres = ITaskTrigger_SetTrigger(test_trigger, &normal_trigger_state);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(hres == S_OK, "Failed to set trigger: 0x%08x\n", hres);
|
2008-08-21 03:29:03 +02:00
|
|
|
memset(&trigger_state, 0xcf, sizeof(trigger_state));
|
|
|
|
trigger_state.cbTriggerSize = sizeof(trigger_state);
|
|
|
|
hres = ITaskTrigger_GetTrigger(test_trigger, &trigger_state);
|
2011-02-07 23:58:06 +01:00
|
|
|
ok(hres == S_OK, "Expected S_OK: 0x%08x\n", hres);
|
2008-08-22 21:53:59 +02:00
|
|
|
ok(trigger_state.wRandomMinutesInterval == 0,
|
2008-08-21 03:29:03 +02:00
|
|
|
"wRandomMinutesInterval should be set to zero\n");
|
|
|
|
normal_trigger_state.wRandomMinutesInterval = 0;
|
|
|
|
|
2008-08-22 21:53:59 +02:00
|
|
|
/* 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");
|
|
|
|
|
|
|
|
|
2008-08-21 03:29:03 +02:00
|
|
|
cleanup_trigger();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
START_TEST(task_trigger)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
test_SetTrigger_GetTrigger();
|
|
|
|
CoUninitialize();
|
|
|
|
}
|