1 /* Unit test suite for datetime control.
3 * Copyright 2007 Kanit Therdsteerasukdi
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
26 #define expect(EXPECTED, GOT) ok((GOT)==(EXPECTED), "Expected %d, got %ld\n", (EXPECTED), (GOT))
28 #define expect_unsuccess(EXPECTED, GOT) ok((GOT)==(EXPECTED), "Expected %d(unsuccessful), got %ld(successful)\n", (EXPECTED), (GOT))
30 #define NUM_MSG_SEQUENCES 1
31 #define DATETIME_SEQ_INDEX 0
33 static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
35 static const struct message test_dtm_set_format_seq[] = {
36 { DTM_SETFORMATA, sent|wparam|lparam, 0x00000000, 0x00000000 },
37 { DTM_SETFORMATA, sent|wparam, 0x00000000 },
41 static const struct message test_dtm_set_and_get_mccolor_seq[] = {
42 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
43 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000000, 0x00ffffff },
44 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000000, 0x00dcb464 },
45 { DTM_GETMCCOLOR, sent|wparam|lparam, 0x00000000, 0x00000000 },
46 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000004, 0x00000000 },
47 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000004, 0x00ffffff },
48 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000004, 0x00dcb464 },
49 { DTM_GETMCCOLOR, sent|wparam|lparam, 0x00000004, 0x00000000 },
50 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000001, 0x00000000 },
51 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000001, 0x00ffffff },
52 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000001, 0x00dcb464 },
53 { DTM_GETMCCOLOR, sent|wparam|lparam, 0x00000001, 0x00000000 },
54 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000002, 0x00000000 },
55 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000002, 0x00ffffff },
56 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000002, 0x00dcb464 },
57 { DTM_GETMCCOLOR, sent|wparam|lparam, 0x00000002, 0x00000000 },
58 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000003, 0x00000000 },
59 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000003, 0x00ffffff },
60 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000003, 0x00dcb464 },
61 { DTM_GETMCCOLOR, sent|wparam|lparam, 0x00000003, 0x00000000 },
62 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000005, 0x00000000 },
63 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000005, 0x00ffffff },
64 { DTM_SETMCCOLOR, sent|wparam|lparam, 0x00000005, 0x00dcb464 },
65 { DTM_GETMCCOLOR, sent|wparam|lparam, 0x00000005, 0x00000000 },
69 static const struct message test_dtm_set_and_get_mcfont_seq[] = {
70 { DTM_SETMCFONT, sent|lparam, 0, 0x00000001 },
71 { DTM_GETMCFONT, sent|wparam|lparam, 0x00000000, 0x00000000 },
75 static const struct message test_dtm_get_monthcal_seq[] = {
76 { DTM_GETMONTHCAL, sent|wparam|lparam, 0x00000000, 0x00000000 },
80 static const struct message test_dtm_set_and_get_range_seq[] = {
81 { DTM_SETRANGE, sent|wparam, 0x00000001 },
82 { DTM_GETRANGE, sent|wparam, 0x00000000 },
83 { DTM_SETRANGE, sent|wparam, 0x00000002 },
84 { DTM_SETRANGE, sent|wparam, 0x00000002 },
85 { DTM_GETRANGE, sent|wparam, 0x00000000},
86 { DTM_SETRANGE, sent|wparam, 0x00000001 },
87 { DTM_SETRANGE, sent|wparam, 0x00000003 },
88 { DTM_SETRANGE, sent|wparam, 0x00000003 },
89 { DTM_GETRANGE, sent|wparam, 0x00000000 },
90 { DTM_SETRANGE, sent|wparam, 0x00000003 },
91 { DTM_GETRANGE, sent|wparam, 0x00000000 },
92 { DTM_SETRANGE, sent|wparam, 0x00000003 },
93 { DTM_GETRANGE, sent|wparam, 0x00000000 },
97 static const struct message test_dtm_set_range_swap_min_max_seq[] = {
98 { DTM_SETSYSTEMTIME, sent|wparam, 0x00000000 },
99 { DTM_GETSYSTEMTIME, sent|wparam, 0x00000000 },
100 { DTM_SETRANGE, sent|wparam, 0x00000003 },
101 { DTM_GETRANGE, sent|wparam, 0x00000000 },
102 { DTM_SETSYSTEMTIME, sent|wparam, 0x00000000 },
103 { DTM_GETSYSTEMTIME, sent|wparam, 0x00000000 },
104 { DTM_SETRANGE, sent|wparam, 0x00000003 },
105 { DTM_GETRANGE, sent|wparam, 0x00000000 },
106 { DTM_SETRANGE, sent|wparam, 0x00000003 },
107 { DTM_GETRANGE, sent|wparam, 0x00000000 },
108 { DTM_SETRANGE, sent|wparam, 0x00000003 },
109 { DTM_GETRANGE, sent|wparam, 0x00000000 },
113 static const struct message test_dtm_set_and_get_system_time_seq[] = {
114 { DTM_SETSYSTEMTIME, sent|wparam, 0x00000001 },
115 { DTM_GETSYSTEMTIME, sent|wparam, 0x00000000 },
116 { DTM_SETSYSTEMTIME, sent|wparam, 0x00000000 },
117 { DTM_SETSYSTEMTIME, sent|wparam, 0x00000000 },
118 { DTM_SETSYSTEMTIME, sent|wparam, 0x00000000 },
119 { DTM_GETSYSTEMTIME, sent|wparam, 0x00000000 },
120 { DTM_SETSYSTEMTIME, sent|wparam, 0x00000000 },
124 static const struct message destroy_window_seq[] = {
125 { WM_DESTROY, sent|wparam|lparam, 0x00000000, 0x00000000 },
126 { WM_NCDESTROY, sent|wparam|lparam, 0x00000000, 0x00000000 },
135 static LRESULT WINAPI datetime_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
137 struct subclass_info *info = (struct subclass_info *)GetWindowLongA(hwnd, GWL_USERDATA);
138 static long defwndproc_counter = 0;
142 trace("datetime: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
144 msg.message = message;
145 msg.flags = sent|wparam|lparam;
146 if (defwndproc_counter) msg.flags |= defwinproc;
149 add_message(sequences, DATETIME_SEQ_INDEX, &msg);
151 defwndproc_counter++;
152 ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam);
153 defwndproc_counter--;
158 static HWND create_datetime_control(DWORD style, DWORD exstyle)
160 struct subclass_info *info;
161 HWND hWndDateTime = NULL;
163 info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info));
167 hWndDateTime = CreateWindowEx(0,
178 HeapFree(GetProcessHeap(), 0, info);
182 info->oldproc = (WNDPROC)SetWindowLongA(hWndDateTime, GWL_WNDPROC,
183 (LONG)datetime_subclass_proc);
184 SetWindowLongA(hWndDateTime, GWL_USERDATA, (LONG)info);
189 static void test_dtm_set_format(HWND hWndDateTime)
194 r = SendMessage(hWndDateTime, DTM_SETFORMAT, 0, (LPARAM)NULL);
197 r = SendMessage(hWndDateTime, DTM_SETFORMAT, 0,
198 (LPARAM)"'Today is: 'hh':'m':'s dddd MMM dd', 'yyyy");
202 ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_format_seq, "test_dtm_set_format", FALSE);
203 flush_sequences(sequences, NUM_MSG_SEQUENCES);
206 void test_mccolor_types(HWND hWndDateTime, int mccolor_type, const char* mccolor_name)
209 COLORREF theColor, prevColor;
212 r = SendMessage(hWndDateTime, DTM_SETMCCOLOR, mccolor_type, theColor);
213 ok(r != -1, "%s: Set RGB(0,0,0): Expected COLORREF of previous value, got %ld\n", mccolor_name, r);
215 theColor=RGB(255,255,255);
216 r = SendMessage(hWndDateTime, DTM_SETMCCOLOR, mccolor_type, theColor);
217 ok(r==prevColor, "%s: Set RGB(255,255,255): Expected COLORREF of previous value, got %ld\n", mccolor_name, r);
219 theColor=RGB(100,180,220);
220 r = SendMessage(hWndDateTime, DTM_SETMCCOLOR, mccolor_type, theColor);
221 ok(r==prevColor, "%s: Set RGB(100,180,220): Expected COLORREF of previous value, got %ld\n", mccolor_name, r);
222 r = SendMessage(hWndDateTime, DTM_GETMCCOLOR, mccolor_type, 0);
223 ok(r==theColor, "%s: GETMCCOLOR: Expected %d, got %ld\n", mccolor_name, theColor, r);
226 static void test_dtm_set_and_get_mccolor(HWND hWndDateTime)
228 test_mccolor_types(hWndDateTime, MCSC_BACKGROUND, "MCSC_BACKGROUND");
229 test_mccolor_types(hWndDateTime, MCSC_MONTHBK, "MCSC_MONTHBK");
230 test_mccolor_types(hWndDateTime, MCSC_TEXT, "MCSC_TEXT");
231 test_mccolor_types(hWndDateTime, MCSC_TITLEBK, "MCSC_TITLEBK");
232 test_mccolor_types(hWndDateTime, MCSC_TITLETEXT, "MCSC_TITLETEXT");
233 test_mccolor_types(hWndDateTime, MCSC_TRAILINGTEXT, "MCSC_TRAILINGTEXT");
235 ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_mccolor_seq, "test_dtm_set_and_get_mccolor", FALSE);
236 flush_sequences(sequences, NUM_MSG_SEQUENCES);
239 static void test_dtm_set_and_get_mcfont(HWND hWndDateTime)
241 HFONT hFontOrig, hFontNew;
243 hFontOrig = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
244 SendMessage(hWndDateTime, DTM_SETMCFONT, (WPARAM)hFontOrig, TRUE);
245 hFontNew = (HFONT)SendMessage(hWndDateTime, DTM_GETMCFONT, 0, 0);
246 ok(hFontOrig == hFontNew, "Expected hFontOrig==hFontNew, hFontOrig=%p, hFontNew=%p\n", hFontOrig, hFontNew);
248 ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_mcfont_seq, "test_dtm_set_and_get_mcfont", FALSE);
249 flush_sequences(sequences, NUM_MSG_SEQUENCES);
252 static void test_dtm_get_monthcal(HWND hWndDateTime)
257 r = SendMessage(hWndDateTime, DTM_GETMONTHCAL, 0, 0);
258 ok(r == (LPARAM)NULL, "Expected NULL(no child month calendar control), got %ld\n", r);
261 ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_get_monthcal_seq, "test_dtm_get_monthcal", FALSE);
262 flush_sequences(sequences, NUM_MSG_SEQUENCES);
265 void fill_systime_struct(SYSTEMTIME *st, int year, int month, int dayofweek, int day, int hour, int minute, int second, int milliseconds)
269 st->wDayOfWeek = dayofweek;
272 st->wMinute = minute;
273 st->wSecond = second;
274 st->wMilliseconds = milliseconds;
277 LPARAM compare_systime_date(SYSTEMTIME *st1, SYSTEMTIME *st2)
279 return (st1->wYear == st2->wYear)
280 && (st1->wMonth == st2->wMonth)
281 && (st1->wDayOfWeek == st2->wDayOfWeek)
282 && (st1->wDay == st2->wDay);
285 LPARAM compare_systime_time(SYSTEMTIME *st1, SYSTEMTIME *st2)
287 return (st1->wHour == st2->wHour)
288 && (st1->wMinute == st2->wMinute)
289 && (st1->wSecond == st2->wSecond)
290 && (st1->wMilliseconds == st2->wMilliseconds);
293 LPARAM compare_systime(SYSTEMTIME *st1, SYSTEMTIME *st2)
295 if(!compare_systime_date(st1, st2))
298 return compare_systime_time(st1, st2);
301 #define expect_systime(ST1, ST2) ok(compare_systime((ST1), (ST2))==1, "ST1 != ST2\n")
302 #define expect_systime_date(ST1, ST2) ok(compare_systime_date((ST1), (ST2))==1, "ST1.date != ST2.date\n")
303 #define expect_systime_time(ST1, ST2) ok(compare_systime_time((ST1), (ST2))==1, "ST1.time != ST2.time\n")
305 static void test_dtm_set_and_get_range(HWND hWndDateTime)
311 /* initialize st[0] to lowest possible value */
312 fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
313 /* intialize st[1] to all invalid numbers */
314 fill_systime_struct(&st[1], 0, 0, 7, 0, 24, 60, 60, 1000);
316 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN, (LPARAM)st);
318 r = SendMessage(hWndDateTime, DTM_GETRANGE, 0, (LPARAM)getSt);
319 ok(r == GDTR_MIN, "Expected %x, not %x(GDTR_MAX) or %x(GDTR_MIN | GDTR_MAX), got %lx\n", GDTR_MIN, GDTR_MAX, GDTR_MIN | GDTR_MAX, r);
320 expect_systime(&st[0], &getSt[0]);
322 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MAX, (LPARAM)st);
323 expect_unsuccess(0, r);
325 /* set st[0] to all invalid numbers */
326 fill_systime_struct(&st[0], 0, 0, 7, 0, 24, 60, 60, 1000);
327 /* set st[1] to highest possible value */
328 fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);
330 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MAX, (LPARAM)st);
332 r = SendMessage(hWndDateTime, DTM_GETRANGE, 0, (LPARAM)getSt);
334 ok(r == GDTR_MAX, "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MIN | GDTR_MAX), got %lx\n", GDTR_MAX, GDTR_MIN, GDTR_MIN | GDTR_MAX, r);
336 expect_systime(&st[1], &getSt[1]);
338 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN, (LPARAM)st);
339 expect_unsuccess(0, r);
340 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
341 expect_unsuccess(0, r);
343 /* set st[0] to highest possible value */
344 fill_systime_struct(&st[0], 30827, 12, 6, 31, 23, 59, 59, 999);
346 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
348 r = SendMessage(hWndDateTime, DTM_GETRANGE, 0, (LPARAM)getSt);
349 ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
350 expect_systime(&st[0], &getSt[0]);
351 expect_systime(&st[1], &getSt[1]);
353 /* initialize st[0] to lowest possible value */
354 fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
355 /* set st[1] to highest possible value */
356 fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);
358 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
360 r = SendMessage(hWndDateTime, DTM_GETRANGE, 0, (LPARAM)getSt);
361 ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
362 expect_systime(&st[0], &getSt[0]);
363 expect_systime(&st[1], &getSt[1]);
365 /* set st[0] to value higher than minimum */
366 fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
367 /* set st[1] to value lower than maximum */
368 fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);
370 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
372 r = SendMessage(hWndDateTime, DTM_GETRANGE, 0, (LPARAM)getSt);
373 ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
374 expect_systime(&st[0], &getSt[0]);
375 expect_systime(&st[1], &getSt[1]);
377 ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_range_seq, "test_dtm_set_and_get_range", FALSE);
378 flush_sequences(sequences, NUM_MSG_SEQUENCES);
381 /* when max<min for DTM_SETRANGE, Windows seems to swap the min and max values,
382 although that's undocumented. However, it doesn't seem to be implemented
383 correctly, causing some strange side effects */
384 static void test_dtm_set_range_swap_min_max(HWND hWndDateTime)
391 fill_systime_struct(&st[0], 2007, 2, 4, 15, 2, 2, 2, 2);
393 r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st[0]);
395 r = SendMessage(hWndDateTime, DTM_GETSYSTEMTIME, 0, (LPARAM)&origSt);
396 ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
397 expect_systime(&st[0], &origSt);
399 /* set st[0] to value higher than st[1] */
400 fill_systime_struct(&st[0], 2007, 3, 2, 31, 23, 59, 59, 999);
401 fill_systime_struct(&st[1], 1980, 1, 3, 23, 14, 34, 37, 465);
403 /* since min>max, min and max values should be swapped by DTM_SETRANGE
405 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
407 r = SendMessage(hWndDateTime, DTM_GETRANGE, 0, (LPARAM)getSt);
408 ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
410 expect_systime(&st[0], &getSt[0]);
413 expect_systime(&st[1], &getSt[1]);
416 fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
418 r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st[0]);
420 r = SendMessage(hWndDateTime, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
421 ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
422 /* the time part seems to not change after swapping the min and max values
423 and doing DTM_SETSYSTEMTIME */
424 expect_systime_date(&st[0], &getSt[0]);
426 expect_systime_time(&origSt, &getSt[0]);
429 /* set st[0] to value higher than minimum */
430 fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
431 /* set st[1] to value lower than maximum */
432 fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);
434 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
436 /* for some reason after we swapped the min and max values before,
437 whenever we do a DTM_SETRANGE, the DTM_GETRANGE will return the values
439 r = SendMessage(hWndDateTime, DTM_GETRANGE, 0, (LPARAM)getSt);
440 ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
442 expect_systime(&st[0], &getSt[1]);
445 expect_systime(&st[1], &getSt[0]);
448 /* set st[0] to value higher than st[1] */
449 fill_systime_struct(&st[0], 2007, 3, 2, 31, 23, 59, 59, 999);
450 fill_systime_struct(&st[1], 1980, 1, 3, 23, 14, 34, 37, 465);
452 /* set min>max again, so that the return values of DTM_GETRANGE are no
453 longer swapped the next time we do a DTM SETRANGE and DTM_GETRANGE*/
454 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
456 r = SendMessage(hWndDateTime, DTM_GETRANGE, 0, (LPARAM)getSt);
457 ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
458 expect_systime(&st[0], &getSt[1]);
459 expect_systime(&st[1], &getSt[0]);
461 /* initialize st[0] to lowest possible value */
462 fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
463 /* set st[1] to highest possible value */
464 fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);
466 r = SendMessage(hWndDateTime, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
468 r = SendMessage(hWndDateTime, DTM_GETRANGE, 0, (LPARAM)getSt);
469 ok(r == (GDTR_MIN | GDTR_MAX), "Expected %x, not %x(GDTR_MIN) or %x(GDTR_MAX), got %lx\n", (GDTR_MIN | GDTR_MAX), GDTR_MIN, GDTR_MAX, r);
470 expect_systime(&st[0], &getSt[0]);
471 expect_systime(&st[1], &getSt[1]);
473 ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_range_swap_min_max_seq, "test_dtm_set_range_swap_min_max", FALSE);
474 flush_sequences(sequences, NUM_MSG_SEQUENCES);
477 static void test_dtm_set_and_get_system_time(HWND hWndDateTime)
483 r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_NONE, (LPARAM)&st);
485 r = SendMessage(hWndDateTime, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
486 ok(r == GDT_NONE, "Expected %d, not %d(GDT_VALID) or %d(GDT_ERROR), got %ld\n", GDT_NONE, GDT_VALID, GDT_ERROR, r);
488 /* set st to lowest possible value */
489 fill_systime_struct(&st, 1601, 1, 0, 1, 0, 0, 0, 0);
491 r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
494 /* set st to highest possible value */
495 fill_systime_struct(&st, 30827, 12, 6, 31, 23, 59, 59, 999);
497 r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
500 /* set st to value between min and max */
501 fill_systime_struct(&st, 1980, 1, 3, 23, 14, 34, 37, 465);
503 r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
505 r = SendMessage(hWndDateTime, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
506 ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
507 expect_systime(&st, &getSt);
509 /* set st to invalid value */
510 fill_systime_struct(&st, 0, 0, 7, 0, 24, 60, 60, 1000);
513 r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
514 expect_unsuccess(0, r);
517 ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_system_time_seq, "test_dtm_set_and_get_system_time", FALSE);
518 flush_sequences(sequences, NUM_MSG_SEQUENCES);
521 static void test_datetime_control(void)
525 hWndDateTime = create_datetime_control(DTS_SHOWNONE, 0);
527 ok(hWndDateTime != NULL, "Expected non NULL, got %p\n", hWndDateTime);
528 if(hWndDateTime!=NULL) {
529 test_dtm_set_format(hWndDateTime);
530 test_dtm_set_and_get_mccolor(hWndDateTime);
531 test_dtm_set_and_get_mcfont(hWndDateTime);
532 test_dtm_get_monthcal(hWndDateTime);
533 test_dtm_set_and_get_range(hWndDateTime);
534 test_dtm_set_range_swap_min_max(hWndDateTime);
535 test_dtm_set_and_get_system_time(hWndDateTime);
538 skip("hWndDateTime is NULL\n");
541 DestroyWindow(hWndDateTime);
542 ok_sequence(sequences, DATETIME_SEQ_INDEX, destroy_window_seq, "test_dtm_set_and_get_system_time", TRUE);
547 INITCOMMONCONTROLSEX icex;
549 icex.dwSize = sizeof(icex);
550 icex.dwICC = ICC_DATE_CLASSES;
551 InitCommonControlsEx(&icex);
552 init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
554 test_datetime_control();