mstask: Implement ITaskScheduler::Delete().

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2018-05-11 12:36:23 +08:00 committed by Alexandre Julliard
parent 9ec4b572f8
commit 4bd663629d
2 changed files with 31 additions and 9 deletions

View File

@ -302,12 +302,25 @@ static HRESULT WINAPI MSTASK_ITaskScheduler_Activate(ITaskScheduler *iface,
return hr; return hr;
} }
static HRESULT WINAPI MSTASK_ITaskScheduler_Delete( static HRESULT WINAPI MSTASK_ITaskScheduler_Delete(ITaskScheduler *iface, LPCWSTR name)
ITaskScheduler* iface,
LPCWSTR pwszName)
{ {
FIXME("%p, %s: stub\n", iface, debugstr_w(pwszName)); static const WCHAR tasksW[] = { '\\','T','a','s','k','s','\\',0 };
return E_NOTIMPL; static const WCHAR jobW[] = { '.','j','o','b',0 };
WCHAR task_name[MAX_PATH];
TRACE("%p, %s\n", iface, debugstr_w(name));
if (strchrW(name, '.')) return E_INVALIDARG;
GetWindowsDirectoryW(task_name, MAX_PATH);
lstrcatW(task_name, tasksW);
lstrcatW(task_name, name);
lstrcatW(task_name, jobW);
if (!DeleteFileW(task_name))
return HRESULT_FROM_WIN32(GetLastError());
return S_OK;
} }
static HRESULT WINAPI MSTASK_ITaskScheduler_NewWorkItem( static HRESULT WINAPI MSTASK_ITaskScheduler_NewWorkItem(

View File

@ -249,7 +249,7 @@ static void test_save_task_curfile(ITask *task)
curfile = NULL; curfile = NULL;
hr = IPersistFile_GetCurFile(pfile, &curfile); hr = IPersistFile_GetCurFile(pfile, &curfile);
ok(hr == S_OK, "GetCurFile error %#x\n", hr); ok(hr == S_OK, "GetCurFile error %#x\n", hr);
ok(curfile && curfile[0] , "curfile should not be NULL\n"); ok(curfile && curfile[0], "curfile should not be NULL\n");
ok(file_exists(curfile), "curfile should exist\n"); ok(file_exists(curfile), "curfile should exist\n");
@ -343,6 +343,12 @@ static void test_task_storage(void)
return; return;
} }
hr = ITaskScheduler_Delete(scheduler, Task1_ext);
ok(hr == E_INVALIDARG, "wrong error %#x\n", hr);
hr = ITaskScheduler_Delete(scheduler, Task1);
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "wrong error %#x\n", hr);
hr = ITaskScheduler_NewWorkItem(scheduler, Task1_ext, &CLSID_CTask, &IID_ITask, (IUnknown **)&task); hr = ITaskScheduler_NewWorkItem(scheduler, Task1_ext, &CLSID_CTask, &IID_ITask, (IUnknown **)&task);
ok(hr == E_INVALIDARG, "wrong error %#x\n", hr); ok(hr == E_INVALIDARG, "wrong error %#x\n", hr);
@ -418,9 +424,12 @@ static void test_task_storage(void)
test_save_task_curfile(task); test_save_task_curfile(task);
DeleteFileW(task1_full_name); hr = ITaskScheduler_Delete(scheduler, Task1);
DeleteFileW(task2_full_name); ok(hr == S_OK, "got %#x\n", hr);
DeleteFileW(task3_full_name); hr = ITaskScheduler_Delete(scheduler, Task2);
ok(hr == S_OK, "got %#x\n", hr);
hr = ITaskScheduler_Delete(scheduler, Task3);
ok(hr == S_OK, "got %#x\n", hr);
ITask_Release(task); ITask_Release(task);
ITaskScheduler_Release(scheduler); ITaskScheduler_Release(scheduler);