2008-08-19 23:58:53 +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 const WCHAR empty[] = {0};
|
|
|
|
|
|
|
|
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);
|
2008-08-21 10:09:18 +02:00
|
|
|
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-09-11 11:49:27 +02:00
|
|
|
ok(!lstrcmpiW(stored_name, empty),
|
2009-08-19 13:36:50 +02:00
|
|
|
"Got %s, expected empty string\n", wine_dbgstr_w(stored_name));
|
2008-08-19 23:58:53 +02:00
|
|
|
CoTaskMemFree(stored_name);
|
|
|
|
}
|
|
|
|
|
2008-09-01 17:01:17 +02:00
|
|
|
/* Set application name to a nonexistent application and then get
|
2008-08-19 23:58:53 +02:00
|
|
|
* the application name that is actually stored */
|
|
|
|
hres = ITask_SetApplicationName(test_task, non_application_name);
|
2008-08-21 10:09:18 +02:00
|
|
|
ok(hres == S_OK, "Failed setting name %s: %08x\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(non_application_name), hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
hres = ITask_GetApplicationName(test_task, &stored_name);
|
2008-08-21 10:09:18 +02:00
|
|
|
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
|
|
|
full_name = path_resolve_name(non_application_name);
|
2008-09-11 11:49:27 +02:00
|
|
|
ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(stored_name), wine_dbgstr_w(full_name));
|
2008-08-19 23:58:53 +02:00
|
|
|
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);
|
2008-08-21 10:09:18 +02:00
|
|
|
ok(hres == S_OK, "Failed setting name %s: %08x\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(notepad_exe), hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
hres = ITask_GetApplicationName(test_task, &stored_name);
|
2008-08-21 10:09:18 +02:00
|
|
|
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
|
|
|
full_name = path_resolve_name(notepad_exe);
|
2008-09-11 11:49:27 +02:00
|
|
|
ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(stored_name), wine_dbgstr_w(full_name));
|
2008-08-19 23:58:53 +02:00
|
|
|
CoTaskMemFree(stored_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set a valid application name without program type extension and
|
|
|
|
* then get the stored name */
|
|
|
|
hres = ITask_SetApplicationName(test_task, notepad);
|
2009-08-19 13:36:50 +02:00
|
|
|
ok(hres == S_OK, "Failed setting name %s: %08x\n", wine_dbgstr_w(notepad), hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
hres = ITask_GetApplicationName(test_task, &stored_name);
|
2008-08-21 10:09:18 +02:00
|
|
|
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-09-17 16:23:08 +02:00
|
|
|
full_name = path_resolve_name(notepad_exe); /* XP SP1 appends .exe */
|
|
|
|
if (lstrcmpiW(stored_name, full_name) != 0)
|
|
|
|
{
|
|
|
|
full_name = path_resolve_name(notepad);
|
|
|
|
ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(stored_name), wine_dbgstr_w(full_name));
|
2008-09-17 16:23:08 +02:00
|
|
|
}
|
2008-08-19 23:58:53 +02:00
|
|
|
CoTaskMemFree(stored_name);
|
|
|
|
}
|
|
|
|
|
2008-09-01 17:01:17 +02:00
|
|
|
/* After having a valid application name set, set application the name
|
|
|
|
* to a nonexistent application and then get the name that is
|
2008-08-19 23:58:53 +02:00
|
|
|
* actually stored */
|
|
|
|
hres = ITask_SetApplicationName(test_task, non_application_name);
|
2008-08-21 10:09:18 +02:00
|
|
|
ok(hres == S_OK, "Failed setting name %s: %08x\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(non_application_name), hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
hres = ITask_GetApplicationName(test_task, &stored_name);
|
2008-08-21 10:09:18 +02:00
|
|
|
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
|
|
|
full_name = path_resolve_name(non_application_name);
|
2008-09-11 11:49:27 +02:00
|
|
|
ok(!lstrcmpiW(stored_name, full_name), "Got %s, expected %s\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(stored_name), wine_dbgstr_w(full_name));
|
2008-08-19 23:58:53 +02:00
|
|
|
CoTaskMemFree(stored_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear application name */
|
|
|
|
hres = ITask_SetApplicationName(test_task, empty);
|
2009-08-19 13:36:50 +02:00
|
|
|
ok(hres == S_OK, "Failed setting name %s: %08x\n", wine_dbgstr_w(empty), hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
hres = ITask_GetApplicationName(test_task, &stored_name);
|
2008-08-21 10:09:18 +02:00
|
|
|
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
|
2008-08-19 23:58:53 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-09-11 11:49:27 +02:00
|
|
|
ok(!lstrcmpiW(stored_name, empty),
|
2009-08-19 13:36:50 +02:00
|
|
|
"Got %s, expected empty string\n", wine_dbgstr_w(stored_name));
|
2008-08-19 23:58:53 +02:00
|
|
|
CoTaskMemFree(stored_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_task();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-20 00:01:07 +02:00
|
|
|
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);
|
2008-08-22 21:52:46 +02:00
|
|
|
ok(hres == S_OK, "Failed to create trigger: 0x%08x\n", hres);
|
2008-08-20 00:01:07 +02:00
|
|
|
if (hres != S_OK)
|
|
|
|
{
|
|
|
|
cleanup_task();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ITaskTrigger_Release(test_trigger);
|
|
|
|
cleanup_task();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-21 02:44:30 +02:00
|
|
|
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);
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
2008-08-21 02:44:30 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(!lstrcmpW(parameters, empty),
|
2009-08-19 13:36:50 +02:00
|
|
|
"Got %s, expected empty string\n", wine_dbgstr_w(parameters));
|
2008-08-21 02:44:30 +02:00
|
|
|
CoTaskMemFree(parameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set parameters to a simple string */
|
|
|
|
hres = ITask_SetParameters(test_task, parameters_a);
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(parameters_a), hres);
|
2008-08-21 02:44:30 +02:00
|
|
|
hres = ITask_GetParameters(test_task, ¶meters);
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
2008-08-21 02:44:30 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(!lstrcmpW(parameters, parameters_a), "Got %s, expected %s\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(parameters), wine_dbgstr_w(parameters_a));
|
2008-08-21 02:44:30 +02:00
|
|
|
CoTaskMemFree(parameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update parameters to a different simple string */
|
|
|
|
hres = ITask_SetParameters(test_task, parameters_b);
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(parameters_b), hres);
|
2008-08-21 02:44:30 +02:00
|
|
|
hres = ITask_GetParameters(test_task, ¶meters);
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
2008-08-21 02:44:30 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(!lstrcmpW(parameters, parameters_b), "Got %s, expected %s\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(parameters), wine_dbgstr_w(parameters_b));
|
2008-08-21 02:44:30 +02:00
|
|
|
CoTaskMemFree(parameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear parameters */
|
|
|
|
hres = ITask_SetParameters(test_task, empty);
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(empty), hres);
|
2008-08-21 02:44:30 +02:00
|
|
|
hres = ITask_GetParameters(test_task, ¶meters);
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
2008-08-21 02:44:30 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:05:07 +02:00
|
|
|
ok(!lstrcmpW(parameters, empty),
|
2009-08-19 13:36:50 +02:00
|
|
|
"Got %s, expected empty string\n", wine_dbgstr_w(parameters));
|
2008-08-21 02:44:30 +02:00
|
|
|
CoTaskMemFree(parameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_task();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-21 02:45:03 +02:00
|
|
|
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);
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
|
2008-08-21 02:45:03 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(!lstrcmpW(comment, empty),
|
2009-08-19 13:36:50 +02:00
|
|
|
"Got %s, expected empty string\n", wine_dbgstr_w(comment));
|
2008-08-21 02:45:03 +02:00
|
|
|
CoTaskMemFree(comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set comment to a simple string */
|
|
|
|
hres = ITask_SetComment(test_task, comment_a);
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(hres == S_OK, "Failed setting comment %s: %08x\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(comment_a), hres);
|
2008-08-21 02:45:03 +02:00
|
|
|
hres = ITask_GetComment(test_task, &comment);
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
|
2008-08-21 02:45:03 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(!lstrcmpW(comment, comment_a), "Got %s, expected %s\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(comment), wine_dbgstr_w(comment_a));
|
2008-08-21 02:45:03 +02:00
|
|
|
CoTaskMemFree(comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update comment to a different simple string */
|
|
|
|
hres = ITask_SetComment(test_task, comment_b);
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(hres == S_OK, "Failed setting comment %s: %08x\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(comment_b), hres);
|
2008-08-21 02:45:03 +02:00
|
|
|
hres = ITask_GetComment(test_task, &comment);
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
|
2008-08-21 02:45:03 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(!lstrcmpW(comment, comment_b), "Got %s, expected %s\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(comment), wine_dbgstr_w(comment_b));
|
2008-08-21 02:45:03 +02:00
|
|
|
CoTaskMemFree(comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear comment */
|
|
|
|
hres = ITask_SetComment(test_task, empty);
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(hres == S_OK, "Failed setting comment %s: %08x\n",
|
2009-08-19 13:36:50 +02:00
|
|
|
wine_dbgstr_w(empty), hres);
|
2008-08-21 02:45:03 +02:00
|
|
|
hres = ITask_GetComment(test_task, &comment);
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
|
2008-08-21 02:45:03 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:05:43 +02:00
|
|
|
ok(!lstrcmpW(comment, empty),
|
2009-08-19 13:36:50 +02:00
|
|
|
"Got %s, expected empty string\n", wine_dbgstr_w(comment));
|
2008-08-21 02:45:03 +02:00
|
|
|
CoTaskMemFree(comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_task();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-21 02:46:05 +02:00
|
|
|
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);
|
2008-08-21 22:06:19 +02:00
|
|
|
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);
|
2008-08-21 02:46:05 +02:00
|
|
|
|
|
|
|
/* Basic set test */
|
|
|
|
max_run_time = 0;
|
|
|
|
hres = ITask_SetMaxRunTime(test_task, 1234);
|
2008-08-21 22:06:19 +02:00
|
|
|
ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
|
2008-08-21 02:46:05 +02:00
|
|
|
hres = ITask_GetMaxRunTime(test_task, &max_run_time);
|
2008-08-21 22:06:19 +02:00
|
|
|
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);
|
2008-08-21 02:46:05 +02:00
|
|
|
|
|
|
|
/* Verify that time can be set to zero */
|
|
|
|
max_run_time = 1;
|
|
|
|
hres = ITask_SetMaxRunTime(test_task, 0);
|
2008-08-21 22:06:19 +02:00
|
|
|
ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
|
2008-08-21 02:46:05 +02:00
|
|
|
hres = ITask_GetMaxRunTime(test_task, &max_run_time);
|
2008-08-21 22:06:19 +02:00
|
|
|
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);
|
2008-08-21 02:46:05 +02:00
|
|
|
|
|
|
|
/* Check resolution by setting time to one */
|
|
|
|
max_run_time = 0;
|
|
|
|
hres = ITask_SetMaxRunTime(test_task, 1);
|
2008-08-21 22:06:19 +02:00
|
|
|
ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
|
2008-08-21 02:46:05 +02:00
|
|
|
hres = ITask_GetMaxRunTime(test_task, &max_run_time);
|
2008-08-21 22:06:19 +02:00
|
|
|
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);
|
2008-08-21 02:46:05 +02:00
|
|
|
|
|
|
|
/* Verify that time can be set to INFINITE */
|
|
|
|
max_run_time = 0;
|
|
|
|
hres = ITask_SetMaxRunTime(test_task, INFINITE);
|
2008-08-21 22:06:19 +02:00
|
|
|
ok(hres == S_OK, "Failed to set max runtime: 0x%08x\n", hres);
|
2008-08-21 02:46:05 +02:00
|
|
|
hres = ITask_GetMaxRunTime(test_task, &max_run_time);
|
2008-08-21 22:06:19 +02:00
|
|
|
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);
|
2008-08-21 02:46:05 +02:00
|
|
|
|
|
|
|
cleanup_task();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-21 02:46:43 +02:00
|
|
|
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};
|
2008-08-21 22:07:00 +02:00
|
|
|
const WCHAR dummy_account_name_b[] = {'N', 'o', 'S', 'u', 'c', 'h',
|
|
|
|
'A', 'c', 'c', 'o', 'u', 'n', 't', 'B', 0};
|
2008-08-21 02:46:43 +02:00
|
|
|
|
|
|
|
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
|
2008-08-27 10:59:56 +02:00
|
|
|
* Win2K returns SCHED_E_CANNOT_OPEN_TASK: 0x8004130d
|
|
|
|
* Win9x doesn't support security services */
|
2009-12-22 14:01:22 +01:00
|
|
|
if (hres == SCHED_E_NO_SECURITY_SERVICES || hres == SCHED_E_SERVICE_NOT_RUNNING)
|
2008-08-27 10:59:56 +02:00
|
|
|
{
|
|
|
|
win_skip("Security services are not supported\n");
|
|
|
|
cleanup_task();
|
|
|
|
return;
|
|
|
|
}
|
2008-08-21 22:07:00 +02:00
|
|
|
ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
|
2008-08-21 02:46:43 +02:00
|
|
|
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);
|
2008-08-21 22:07:00 +02:00
|
|
|
ok(hres == S_OK,
|
2008-08-21 02:46:43 +02:00
|
|
|
"Failed setting dummy account with no password: %08x\n", hres);
|
|
|
|
hres = ITask_GetAccountInformation(test_task, &account_name);
|
2008-09-11 09:42:30 +02:00
|
|
|
ok(hres == S_OK ||
|
2008-09-17 16:23:08 +02:00
|
|
|
broken(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
|
2010-02-05 11:35:38 +01:00
|
|
|
hres == SCHED_E_CANNOT_OPEN_TASK ||
|
|
|
|
hres == 0x200), /* win2k */
|
2008-09-11 09:42:30 +02:00
|
|
|
"GetAccountInformation failed: %08x\n", hres);
|
2008-08-21 02:46:43 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:07:00 +02:00
|
|
|
ok(!lstrcmpW(account_name, dummy_account_name),
|
2009-08-19 13:36:50 +02:00
|
|
|
"Got %s, expected %s\n", wine_dbgstr_w(account_name),
|
|
|
|
wine_dbgstr_w(dummy_account_name));
|
2008-08-21 02:46:43 +02:00
|
|
|
CoTaskMemFree(account_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attempt to set to a dummy account with a (invalid) password */
|
|
|
|
/* This test passes on WinXP but fails on Win2K */
|
2008-08-21 22:07:00 +02:00
|
|
|
hres = ITask_SetAccountInformation(test_task, dummy_account_name_b,
|
|
|
|
dummy_account_name_b);
|
|
|
|
ok(hres == S_OK,
|
2008-08-21 02:46:43 +02:00
|
|
|
"Failed setting dummy account with password: %08x\n", hres);
|
|
|
|
hres = ITask_GetAccountInformation(test_task, &account_name);
|
2008-09-11 09:42:30 +02:00
|
|
|
ok(hres == S_OK ||
|
2008-09-17 16:23:08 +02:00
|
|
|
broken(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
|
2010-02-05 11:35:38 +01:00
|
|
|
hres == SCHED_E_CANNOT_OPEN_TASK ||
|
|
|
|
hres == 0x200), /* win2k */
|
2008-09-11 09:42:30 +02:00
|
|
|
"GetAccountInformation failed: %08x\n", hres);
|
2008-08-21 02:46:43 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:07:00 +02:00
|
|
|
ok(!lstrcmpW(account_name, dummy_account_name_b),
|
2009-08-19 13:36:50 +02:00
|
|
|
"Got %s, expected %s\n", wine_dbgstr_w(account_name),
|
|
|
|
wine_dbgstr_w(dummy_account_name_b));
|
2008-08-21 02:46:43 +02:00
|
|
|
CoTaskMemFree(account_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attempt to set to the local system account */
|
|
|
|
hres = ITask_SetAccountInformation(test_task, empty, NULL);
|
2008-08-21 22:07:00 +02:00
|
|
|
ok(hres == S_OK, "Failed setting system account: %08x\n", hres);
|
2008-08-21 02:46:43 +02:00
|
|
|
hres = ITask_GetAccountInformation(test_task, &account_name);
|
2008-09-11 09:42:30 +02:00
|
|
|
ok(hres == S_OK ||
|
2008-09-17 16:23:08 +02:00
|
|
|
broken(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
|
2010-02-05 11:35:38 +01:00
|
|
|
hres == SCHED_E_CANNOT_OPEN_TASK ||
|
|
|
|
hres == 0x200), /* win2k */
|
2008-09-11 09:42:30 +02:00
|
|
|
"GetAccountInformation failed: %08x\n", hres);
|
2008-08-21 02:46:43 +02:00
|
|
|
if (hres == S_OK)
|
|
|
|
{
|
2008-08-21 22:07:00 +02:00
|
|
|
ok(!lstrcmpW(account_name, empty),
|
2009-08-19 13:36:50 +02:00
|
|
|
"Got %s, expected empty string\n", wine_dbgstr_w(account_name));
|
2008-08-21 02:46:43 +02:00
|
|
|
CoTaskMemFree(account_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_task();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-30 10:58:39 +02:00
|
|
|
static void test_GetFlags(void)
|
|
|
|
{
|
|
|
|
BOOL setup;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD flags;
|
|
|
|
|
|
|
|
setup = setup_task();
|
|
|
|
ok(setup, "Failed to setup test_task\n");
|
|
|
|
if (!setup)
|
|
|
|
{
|
|
|
|
skip("Failed to create task. Skipping tests.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0) /* crashes under Windows */
|
|
|
|
hr = ITask_GetFlags(test_task, NULL);
|
|
|
|
|
|
|
|
flags = 0xdeadbeef;
|
|
|
|
hr = ITask_GetFlags(test_task, &flags);
|
|
|
|
ok(hr == S_OK, "GetFlags error %#x\n", hr);
|
|
|
|
ok(flags == 0, "got %#x\n", flags);
|
|
|
|
|
|
|
|
if (0) /* crashes under Windows */
|
|
|
|
hr = ITask_GetTaskFlags(test_task, NULL);
|
|
|
|
|
|
|
|
flags = 0xdeadbeef;
|
|
|
|
hr = ITask_GetTaskFlags(test_task, &flags);
|
|
|
|
ok(hr == S_OK, "GetTaskFlags error %#x\n", hr);
|
|
|
|
ok(flags == 0, "got %#x\n", flags);
|
|
|
|
|
|
|
|
cleanup_task();
|
|
|
|
}
|
|
|
|
|
2008-08-19 23:58:53 +02:00
|
|
|
START_TEST(task)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
test_SetApplicationName_GetApplicationName();
|
2008-08-20 00:01:07 +02:00
|
|
|
test_CreateTrigger();
|
2008-08-21 02:44:30 +02:00
|
|
|
test_SetParameters_GetParameters();
|
2008-08-21 02:45:03 +02:00
|
|
|
test_SetComment_GetComment();
|
2008-08-21 02:46:05 +02:00
|
|
|
test_SetMaxRunTime_GetMaxRunTime();
|
2008-08-21 02:46:43 +02:00
|
|
|
test_SetAccountInformation_GetAccountInformation();
|
2018-03-30 10:58:39 +02:00
|
|
|
test_GetFlags();
|
2008-08-19 23:58:53 +02:00
|
|
|
CoUninitialize();
|
|
|
|
}
|