Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/taskschd/task.c | 15 ++++++++++++++- dlls/taskschd/tests/scheduler.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/dlls/taskschd/task.c b/dlls/taskschd/task.c index 9959f042a2..ee5a7dd4b6 100644 --- a/dlls/taskschd/task.c +++ b/dlls/taskschd/task.c @@ -39,6 +39,7 @@ typedef struct { IDailyTrigger IDailyTrigger_iface; LONG ref; short interval; + WCHAR *start_boundary; } DailyTrigger;
static inline DailyTrigger *impl_from_IDailyTrigger(IDailyTrigger *iface) @@ -88,7 +89,11 @@ static ULONG WINAPI DailyTrigger_Release(IDailyTrigger *iface) TRACE("(%p) ref=%d\n", This, ref);
if(!ref) + { + TRACE("destroying %p\n", iface); + heap_free(This->start_boundary); heap_free(This); + }
return ref; } @@ -183,7 +188,14 @@ static HRESULT WINAPI DailyTrigger_get_StartBoundary(IDailyTrigger *iface, BSTR static HRESULT WINAPI DailyTrigger_put_StartBoundary(IDailyTrigger *iface, BSTR start) { DailyTrigger *This = impl_from_IDailyTrigger(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(start)); + WCHAR *str = NULL; + + TRACE("(%p)->(%s)\n", This, debugstr_w(start)); + + if (start && !(str = heap_strdupW(start))) return E_OUTOFMEMORY; + heap_free(This->start_boundary); + This->start_boundary = str; + return S_OK; }
@@ -290,6 +302,7 @@ static HRESULT DailyTrigger_create(ITrigger **trigger) daily_trigger->IDailyTrigger_iface.lpVtbl = &DailyTrigger_vtbl; daily_trigger->ref = 1; daily_trigger->interval = 1; + daily_trigger->start_boundary = NULL;
*trigger = (ITrigger*)&daily_trigger->IDailyTrigger_iface; return S_OK; diff --git a/dlls/taskschd/tests/scheduler.c b/dlls/taskschd/tests/scheduler.c index c7de7c7041..fb6d626e14 100644 --- a/dlls/taskschd/tests/scheduler.c +++ b/dlls/taskschd/tests/scheduler.c @@ -1195,9 +1195,37 @@ static void change_settings(ITaskDefinition *taskdef, struct settings *test)
static void test_daily_trigger(ITrigger *trigger) { + static const WCHAR startW[] = + {'2','0','0','4','-','0','1','-','0','1','T','0','0',':','0','0',':','0','0',0}; + static const WCHAR start2W[] = + {'2','0','0','4','-','0','1','-','0','1','T','0','0',':','0','0',':','0','0','Z',0}; + static const WCHAR start3W[] = + {'2','0','0','4','-','0','1','-','0','1','T','0','0',':','0','0',':','0','0','+','0','1',':','0','0',0}; + static const WCHAR start4W[] = + {'2','0','0','4','.','0','1','.','0','1','T','0','0','.','0','0','.','0','0',0}; + static const WCHAR start5W[] = + {'9','9','9','9','-','9','9','-','9','9','T','9','9',':','9','9',':','9','9',0}; + static const WCHAR start6W[] = + {'i','n','v','a','l','i','d',0}; + static const struct + { + const WCHAR *str; + HRESULT hr; + } + start_test[] = + { + {startW, S_OK}, + {start2W, S_OK}, + {start3W, S_OK}, + {start4W, S_OK}, + {start5W, S_OK}, + {start6W, S_OK}, + }; IDailyTrigger *daily_trigger; + BSTR start_boundary; short interval; HRESULT hr; + ULONG i;
hr = ITrigger_QueryInterface(trigger, &IID_IDailyTrigger, (void**)&daily_trigger); ok(hr == S_OK, "Could not get IDailyTrigger iface: %08x\n", hr); @@ -1225,6 +1253,17 @@ static void test_daily_trigger(ITrigger *trigger) ok(hr == S_OK, "get_DaysInterval failed: %08x\n", hr); ok(interval == 2, "interval = %d\n", interval);
+ for (i = 0; i < sizeof(start_test)/sizeof(start_test[0]); i++) + { + start_boundary = SysAllocString(start_test[i].str); + hr = IDailyTrigger_put_StartBoundary(daily_trigger, start_boundary); + ok(hr == start_test[i].hr, "%u: got %08x expected %08x\n", i, hr, start_test[i].hr); + SysFreeString(start_boundary); + } + + hr = IDailyTrigger_put_StartBoundary(daily_trigger, NULL); + ok(hr == S_OK, "put_StartBoundary failed: %08x\n", hr); + IDailyTrigger_Release(daily_trigger); }