ReactOS 0.4.16-dev-401-g45b008d
datetime.c
Go to the documentation of this file.
1/* Unit test suite for datetime control.
2*
3* Copyright 2007 Kanit Therdsteerasukdi
4*
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.
9*
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.
14*
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
18*/
19
20#include <windows.h>
21#include <commctrl.h>
22
23#include "wine/test.h"
24#include "msg.h"
25#include "v6util.h"
26
27#define expect(EXPECTED, GOT) ok((GOT)==(EXPECTED), "Expected %d, got %ld\n", (EXPECTED), (GOT))
28
29#define expect_unsuccess(EXPECTED, GOT) ok((GOT)==(EXPECTED), "Expected %d(unsuccessful), got %ld(successful)\n", (EXPECTED), (GOT))
30
31#define NUM_MSG_SEQUENCES 1
32#define DATETIME_SEQ_INDEX 0
33
34static BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
35
37
38static const struct message test_dtm_set_format_seq[] = {
41 { 0 }
42};
43
46 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, RGB(255, 255, 255) },
47 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, RGB(100, 180, 220) },
50 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_MONTHBK, RGB(255, 255, 255) },
51 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_MONTHBK, RGB(100, 180, 220) },
54 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TEXT, RGB(255, 255, 255) },
55 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TEXT, RGB(100, 180, 220) },
58 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLEBK, RGB(255, 255, 255) },
59 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLEBK, RGB(100, 180, 220) },
62 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, RGB(255, 255, 255) },
63 { DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, RGB(100, 180, 220) },
69 { 0 }
70};
71
73 { DTM_SETMCFONT, sent|lparam, 0, 1 },
75 { 0 }
76};
77
78static const struct message test_dtm_get_monthcal_seq[] = {
80 { 0 }
81};
82
83static const struct message test_dtm_set_and_get_range_seq[] = {
85 { DTM_GETRANGE, sent|wparam, 0 },
88 { DTM_GETRANGE, sent|wparam, 0 },
92 { DTM_GETRANGE, sent|wparam, 0 },
94 { DTM_GETRANGE, sent|wparam, 0 },
96 { DTM_GETRANGE, sent|wparam, 0 },
97 { 0 }
98};
99
104 { DTM_GETRANGE, sent|wparam, 0 },
108 { DTM_GETRANGE, sent|wparam, 0 },
110 { DTM_GETRANGE, sent|wparam, 0 },
112 { DTM_GETRANGE, sent|wparam, 0 },
113 { 0 }
114};
115
124 { 0 }
125};
126
129 { DTM_GETRANGE, sent|wparam, 0 },
136 { 0 }
137};
138
140{
142 static LONG defwndproc_counter = 0;
143 struct message msg = { 0 };
144 LRESULT ret;
145
146 msg.message = message;
147 msg.flags = sent|wparam|lparam;
148 if (defwndproc_counter) msg.flags |= defwinproc;
149 msg.wParam = wParam;
150 msg.lParam = lParam;
152
153 defwndproc_counter++;
155 defwndproc_counter--;
156
157 return ret;
158}
159
161{
162 WNDPROC oldproc;
163 HWND hWndDateTime = NULL;
164
165 hWndDateTime = CreateWindowExA(0,
167 NULL,
168 style,
169 0,50,300,120,
170 NULL,
171 NULL,
172 NULL,
173 NULL);
174
175 if (!hWndDateTime) return NULL;
176
177 oldproc = (WNDPROC)SetWindowLongPtrA(hWndDateTime, GWLP_WNDPROC,
179 SetWindowLongPtrA(hWndDateTime, GWLP_USERDATA, (LONG_PTR)oldproc);
180
181 return hWndDateTime;
182}
183
184static void test_dtm_set_format(void)
185{
186 HWND hWnd;
187 CHAR txt[256];
188 SYSTEMTIME systime;
189 LRESULT r;
190
192
194
196 expect(1, r);
197
199 (LPARAM)"'Today is: 'hh':'m':'s dddd MMM dd', 'yyyy");
200 expect(1, r);
201
203
204 r = SendMessageA(hWnd, DTM_SETFORMATA, 0, (LPARAM)"'hh' hh");
205 expect(1, r);
206 ZeroMemory(&systime, sizeof(systime));
207 systime.wYear = 2000;
208 systime.wMonth = systime.wDay = 1;
209 r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, 0, (LPARAM)&systime);
210 expect(1, r);
211 GetWindowTextA(hWnd, txt, 256);
212 ok(strcmp(txt, "hh 12") == 0, "String mismatch (\"%s\" vs \"hh 12\")\n", txt);
213
215}
216
217static void test_mccolor_types(HWND hWndDateTime, int mccolor_type, const char* mccolor_name)
218{
219 COLORREF theColor, prevColor, crColor;
220
221 theColor=RGB(0,0,0);
222 crColor = SendMessageA(hWndDateTime, DTM_SETMCCOLOR, mccolor_type, theColor);
223 ok(crColor != ~0u, "%s: Set RGB(0,0,0): Expected COLORREF of previous value, got %d\n", mccolor_name, crColor);
224 prevColor=theColor;
225 theColor=RGB(255,255,255);
226 crColor = SendMessageA(hWndDateTime, DTM_SETMCCOLOR, mccolor_type, theColor);
227 ok(crColor==prevColor, "%s: Set RGB(255,255,255): Expected COLORREF of previous value, got %d\n", mccolor_name, crColor);
228 prevColor=theColor;
229 theColor=RGB(100,180,220);
230 crColor = SendMessageA(hWndDateTime, DTM_SETMCCOLOR, mccolor_type, theColor);
231 ok(crColor==prevColor, "%s: Set RGB(100,180,220): Expected COLORREF of previous value, got %d\n", mccolor_name, crColor);
232 crColor = SendMessageA(hWndDateTime, DTM_GETMCCOLOR, mccolor_type, 0);
233 ok(crColor==theColor, "%s: GETMCCOLOR: Expected %d, got %d\n", mccolor_name, theColor, crColor);
234}
235
237{
238 HWND hWnd;
239
241
243
244 test_mccolor_types(hWnd, MCSC_BACKGROUND, "MCSC_BACKGROUND");
245 test_mccolor_types(hWnd, MCSC_MONTHBK, "MCSC_MONTHBK");
246 test_mccolor_types(hWnd, MCSC_TEXT, "MCSC_TEXT");
247 test_mccolor_types(hWnd, MCSC_TITLEBK, "MCSC_TITLEBK");
248 test_mccolor_types(hWnd, MCSC_TITLETEXT, "MCSC_TITLETEXT");
249 test_mccolor_types(hWnd, MCSC_TRAILINGTEXT, "MCSC_TRAILINGTEXT");
250
252
254}
255
257{
258 HFONT hFontOrig, hFontNew;
259 HWND hWnd;
260
262
264
265 hFontOrig = GetStockObject(DEFAULT_GUI_FONT);
267 hFontNew = (HFONT)SendMessageA(hWnd, DTM_GETMCFONT, 0, 0);
268 ok(hFontOrig == hFontNew, "Expected hFontOrig==hFontNew, hFontOrig=%p, hFontNew=%p\n", hFontOrig, hFontNew);
269
272}
273
274static void test_dtm_get_monthcal(void)
275{
276 LRESULT r;
277 HWND hWnd;
278
280
282
283 todo_wine {
285 ok(r == 0, "Expected NULL(no child month calendar control), got %ld\n", r);
286 }
287
290}
291
292static void fill_systime_struct(SYSTEMTIME *st, int year, int month, int dayofweek, int day, int hour, int minute, int second, int milliseconds)
293{
294 st->wYear = year;
295 st->wMonth = month;
296 st->wDayOfWeek = dayofweek;
297 st->wDay = day;
298 st->wHour = hour;
299 st->wMinute = minute;
300 st->wSecond = second;
301 st->wMilliseconds = milliseconds;
302}
303
305{
306 return (st1->wYear == st2->wYear)
307 && (st1->wMonth == st2->wMonth)
308 && (st1->wDayOfWeek == st2->wDayOfWeek)
309 && (st1->wDay == st2->wDay);
310}
311
313{
314 return (st1->wHour == st2->wHour)
315 && (st1->wMinute == st2->wMinute)
316 && (st1->wSecond == st2->wSecond)
317 && (st1->wMilliseconds == st2->wMilliseconds);
318}
319
321{
322 if(!compare_systime_date(st1, st2))
323 return 0;
324
325 return compare_systime_time(st1, st2);
326}
327
328#define expect_systime(ST1, ST2) ok(compare_systime((ST1), (ST2))==1, "ST1 != ST2\n")
329#define expect_systime_date(ST1, ST2) ok(compare_systime_date((ST1), (ST2))==1, "ST1.date != ST2.date\n")
330#define expect_systime_time(ST1, ST2) ok(compare_systime_time((ST1), (ST2))==1, "ST1.time != ST2.time\n")
331
333{
334 LRESULT r;
335 SYSTEMTIME st[2];
336 SYSTEMTIME getSt[2];
337 HWND hWnd;
338
340
342
343 /* initialize st[0] to lowest possible value */
344 fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
345 /* initialize st[1] to all invalid numbers */
346 fill_systime_struct(&st[1], 0, 0, 7, 0, 24, 60, 60, 1000);
347
349 expect(1, r);
350 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
351 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);
352 expect_systime(&st[0], &getSt[0]);
353
356
357 /* set st[0] to all invalid numbers */
358 fill_systime_struct(&st[0], 0, 0, 7, 0, 24, 60, 60, 1000);
359 /* set st[1] to highest possible value */
360 fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);
361
363 expect(1, r);
364 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
365 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);
366 expect_systime(&st[1], &getSt[1]);
367
372
373 /* set st[0] to highest possible value */
374 fill_systime_struct(&st[0], 30827, 12, 6, 31, 23, 59, 59, 999);
375
377 expect(1, r);
378 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
379 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);
380 expect_systime(&st[0], &getSt[0]);
381 expect_systime(&st[1], &getSt[1]);
382
383 /* initialize st[0] to lowest possible value */
384 fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
385 /* set st[1] to highest possible value */
386 fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);
387
389 expect(1, r);
390 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
391 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);
392 expect_systime(&st[0], &getSt[0]);
393 expect_systime(&st[1], &getSt[1]);
394
395 /* set st[0] to value higher than minimum */
396 fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
397 /* set st[1] to value lower than maximum */
398 fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);
399
401 expect(1, r);
402 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
403 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);
404 expect_systime(&st[0], &getSt[0]);
405 expect_systime(&st[1], &getSt[1]);
406
408
409 /* DTM_SETRANGE with 0 flags */
411 ok(r, "got %lu\n", r);
412 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
413 ok(r == 0, "got %lu\n", r);
414 ok(getSt[0].wYear == 0 && getSt[1].wYear == 0, "got %u, %u\n", getSt[0].wYear, getSt[1].wYear);
415
417}
418
419/* when max<min for DTM_SETRANGE, Windows seems to swap the min and max values,
420although that's undocumented. However, it doesn't seem to be implemented
421correctly, causing some strange side effects */
423{
424 LRESULT r;
425 SYSTEMTIME st[2];
426 SYSTEMTIME getSt[2];
427 SYSTEMTIME origSt;
428 HWND hWnd;
429
432
433 fill_systime_struct(&st[0], 2007, 2, 4, 15, 2, 2, 2, 2);
434
436 expect(1, r);
437 r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&origSt);
438 ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
439 expect_systime(&st[0], &origSt);
440
441 /* set st[0] to value higher than st[1] */
442 fill_systime_struct(&st[0], 2007, 3, 2, 31, 23, 59, 59, 999);
443 fill_systime_struct(&st[1], 1980, 1, 3, 23, 14, 34, 37, 465);
444
445 /* since min>max, min and max values should be swapped by DTM_SETRANGE
446 automatically */
448 expect(1, r);
449 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
450 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);
451 todo_wine {
452 ok(compare_systime(&st[0], &getSt[0]) == 1 ||
453 broken(compare_systime(&st[0], &getSt[1]) == 1), /* comctl32 version <= 5.80 */
454 "ST1 != ST2\n");
455
456 ok(compare_systime(&st[1], &getSt[1]) == 1 ||
457 broken(compare_systime(&st[1], &getSt[0]) == 1), /* comctl32 version <= 5.80 */
458 "ST1 != ST2\n");
459 }
460
461 fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
462
464 expect(1, r);
465 r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
466 ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
467 /* the time part seems to not change after swapping the min and max values
468 and doing DTM_SETSYSTEMTIME */
469 expect_systime_date(&st[0], &getSt[0]);
470 todo_wine {
471 ok(compare_systime_time(&origSt, &getSt[0]) == 1 ||
472 broken(compare_systime_time(&st[0], &getSt[0]) == 1), /* comctl32 version <= 5.80 */
473 "ST1.time != ST2.time\n");
474 }
475
476 /* set st[0] to value higher than minimum */
477 fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
478 /* set st[1] to value lower than maximum */
479 fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);
480
482 expect(1, r);
483 /* for some reason after we swapped the min and max values before,
484 whenever we do a DTM_SETRANGE, the DTM_GETRANGE will return the values
485 swapped*/
486 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
487 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);
488 todo_wine {
489 ok(compare_systime(&st[0], &getSt[1]) == 1 ||
490 broken(compare_systime(&st[0], &getSt[0]) == 1), /* comctl32 version <= 5.80 */
491 "ST1 != ST2\n");
492
493 ok(compare_systime(&st[1], &getSt[0]) == 1 ||
494 broken(compare_systime(&st[1], &getSt[1]) == 1), /* comctl32 version <= 5.80 */
495 "ST1 != ST2\n");
496 }
497
498 /* set st[0] to value higher than st[1] */
499 fill_systime_struct(&st[0], 2007, 3, 2, 31, 23, 59, 59, 999);
500 fill_systime_struct(&st[1], 1980, 1, 3, 23, 14, 34, 37, 465);
501
502 /* set min>max again, so that the return values of DTM_GETRANGE are no
503 longer swapped the next time we do a DTM SETRANGE and DTM_GETRANGE*/
505 expect(1, r);
506 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
507 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);
508 expect_systime(&st[0], &getSt[1]);
509 expect_systime(&st[1], &getSt[0]);
510
511 /* initialize st[0] to lowest possible value */
512 fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
513 /* set st[1] to highest possible value */
514 fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);
515
517 expect(1, r);
518 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
519 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);
520 expect_systime(&st[0], &getSt[0]);
521 expect_systime(&st[1], &getSt[1]);
522
524
526}
527
529{
530 LRESULT r;
531 SYSTEMTIME st, getSt, ref;
532 HWND hWnd;
533
535 ok(hWnd !=NULL, "Expected non NULL, got %p\n", hWnd);
537 expect(0, r);
538
540
543
545 expect(1, r);
547 ok(r == GDT_NONE, "Expected %d, not %d(GDT_VALID) or %d(GDT_ERROR), got %ld\n", GDT_NONE, GDT_VALID, GDT_ERROR, r);
548
549 /* set st to lowest possible value */
550 fill_systime_struct(&st, 1601, 1, 0, 1, 0, 0, 0, 0);
551
553 expect(1, r);
554
555 /* set st to highest possible value */
556 fill_systime_struct(&st, 30827, 12, 6, 31, 23, 59, 59, 999);
557
559 expect(1, r);
560
561 /* set st to value between min and max */
562 fill_systime_struct(&st, 1980, 1, 3, 23, 14, 34, 37, 465);
563
565 expect(1, r);
567 ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
568 expect_systime(&st, &getSt);
569
570 /* set st to invalid value */
571 fill_systime_struct(&st, 0, 0, 7, 0, 24, 60, 60, 1000);
572
575
577
578 /* set to some valid value */
581 expect(1, r);
584 expect_systime(&ref, &getSt);
585
586 /* year invalid */
587 st = ref;
588 st.wYear = 0;
590 todo_wine expect(1, r);
593 expect_systime(&ref, &getSt);
594 /* month invalid */
595 st = ref;
596 st.wMonth = 13;
598 expect(0, r);
601 expect_systime(&ref, &getSt);
602 /* day invalid */
603 st = ref;
604 st.wDay = 32;
606 expect(0, r);
609 expect_systime(&ref, &getSt);
610 /* day invalid for current month */
611 st = ref;
612 st.wDay = 30;
613 st.wMonth = 2;
615 expect(0, r);
618 expect_systime(&ref, &getSt);
619 /* day of week isn't validated */
620 st = ref;
621 st.wDayOfWeek = 10;
623 expect(1, r);
626 expect_systime(&ref, &getSt);
627 /* hour invalid */
628 st = ref;
629 st.wHour = 25;
631 expect(0, r);
634 expect_systime(&ref, &getSt);
635 /* minute invalid */
636 st = ref;
637 st.wMinute = 60;
639 expect(0, r);
642 expect_systime(&ref, &getSt);
643 /* sec invalid */
644 st = ref;
645 st.wSecond = 60;
647 expect(0, r);
650 expect_systime(&ref, &getSt);
651 /* msec invalid */
652 st = ref;
653 st.wMilliseconds = 1000;
655 expect(0, r);
658 expect_systime(&ref, &getSt);
659
660 /* day of week should be calculated automatically,
661 actual day of week for this date is 4 */
662 fill_systime_struct(&st, 2009, 10, 1, 1, 0, 0, 10, 200);
664 expect(1, r);
667 /* 01.10.2009 is Thursday */
668 expect(4, (LRESULT)getSt.wDayOfWeek);
669 st.wDayOfWeek = 4;
670 expect_systime(&st, &getSt);
671}
672
674{
675 LRESULT r;
676 SYSTEMTIME st[2], getSt[2], refSt;
677 HWND hWnd;
678
680
682
683 /* set range */
684 fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
685 fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);
686
688 expect(1, r);
689 r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
690 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);
691 expect_systime(&st[0], &getSt[0]);
692 expect_systime(&st[1], &getSt[1]);
693
694 /* Initially set a valid time */
695 fill_systime_struct(&refSt, 1999, 9, 4, 9, 19, 9, 9, 999);
697 expect(1, r);
698 r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
699 ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
700 expect_systime(&refSt, &getSt[0]);
701
702 /* Now set an out-of-bounds time */
703 fill_systime_struct(&st[0], 2010, 1, 0, 1, 0, 0, 0, 0);
704
706 expect(1, r);
707 r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
708 ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
709 expect_systime(&refSt, &getSt[0]);
710
711 fill_systime_struct(&st[0], 1977, 1, 0, 1, 0, 0, 0, 0);
712
714 expect(1, r);
715 r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
716 ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
717 expect_systime(&refSt, &getSt[0]);
718
719 ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_systime_with_limits, "test_dtm_set_and_get_systime_with_limits", FALSE);
720
722}
723
724static void test_dtm_get_ideal_size(void)
725{
726 HWND hwnd;
727 HDC hdc;
728 HFONT hfont;
729 LOGFONTA lf;
731 SIZE size;
732 BOOL r;
733
736 if (!r)
737 {
738 win_skip("DTM_GETIDEALSIZE is not available\n");
740 return;
741 }
742
743 /* Set font so that the test is consistent on Wine and Windows */
744 ZeroMemory(&lf, sizeof(lf));
745 lf.lfWeight = FW_NORMAL;
746 lf.lfHeight = 20;
747 lstrcpyA(lf.lfFaceName, "Tahoma");
750
751 hdc = GetDC(hwnd);
754
756 ok(r, "Expect DTM_GETIDEALSIZE message to return true\n");
757 ok(size.cx > 0 && size.cy >= tm.tmHeight,
758 "Expect size.cx > 0 and size.cy >= %d, got cx:%d cy:%d\n", tm.tmHeight, size.cx, size.cy);
759
762}
763
764static void test_wm_set_get_text(void)
765{
766 static const CHAR a_str[] = "a";
767 CHAR buff[16], time[16], caltype[3];
768 HWND hWnd;
769 LRESULT ret;
770
772
773 ret = SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)a_str);
774 ok(CB_ERR == ret ||
775 broken(0 == ret) || /* comctl32 <= 4.72 */
776 broken(1 == ret), /* comctl32 <= 4.70 */
777 "Expected CB_ERR, got %ld\n", ret);
778
779 buff[0] = 0;
781 ok(strcmp(buff, a_str) != 0, "Expected text to change, got %s\n", buff);
782 ok(ret != 0, "Expected non-zero return value\n");
783
784 SetLastError(0xdeadbeef);
786 if (ret == 0)
787 skip("Must know local calendar type (%x)\n", GetLastError());
788 else if (atoi(caltype) != CAL_GREGORIAN)
789 skip("DateTimePicker Control only supports Gregorian calendar (type: %s)\n", caltype);
790 else {
791 SetLastError(0xdeadbeef);
793 if (ret == 0)
794 skip("GetDateFormat failed, returned %ld, error %d\n", ret, GetLastError());
795 else
796 ok(!strcmp(buff, time), "Expected %s, got %s\n", time, buff);
797 }
798
800}
801
802static void test_dts_shownone(void)
803{
804 HWND hwnd;
805 DWORD style;
806
807 /* it isn't allowed to change DTS_SHOWNONE after creation */
812 ok(!(style & DTS_SHOWNONE), "Expected DTS_SHOWNONE not to be set\n");
814
819 ok(style & DTS_SHOWNONE, "Expected DTS_SHOWNONE to be set\n");
821}
822
823static void init_functions(void)
824{
825 HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
826
827#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
829#undef X
830}
831
832START_TEST(datetime)
833{
836 HANDLE ctxt;
837
839
840 iccex.dwSize = sizeof(iccex);
841 iccex.dwICC = ICC_DATE_CLASSES;
842 pInitCommonControlsEx(&iccex);
843
845
856
857 if (!load_v6_module(&cookie, &ctxt))
858 return;
859
867
869}
static HFONT hfont
@ sent
Definition: SystemMenu.c:27
@ defwinproc
Definition: SystemMenu.c:32
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define add_message(msg)
Definition: SystemMenu.c:98
#define ok_sequence(exp, contx, todo)
Definition: SystemMenu.c:275
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
Arabic default style
Definition: afstyles.h:94
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static void init_msg_sequences(struct msg_sequence **seq, int n)
Definition: msg.h:393
static void flush_sequences(struct msg_sequence **seq, int n)
Definition: msg.h:99
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:900
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
static DOUBLE day(DOUBLE time)
Definition: date.c:117
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
INT WINAPI GetLocaleInfoA(LCID lcid, LCTYPE lctype, LPSTR buffer, INT len)
Definition: locale.c:1600
static const WCHAR month[12][4]
Definition: session.c:2150
#define RGB(r, g, b)
Definition: precomp.h:71
static unsigned char buff[32768]
Definition: fatten.c:17
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizeiptr size
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
INT WINAPI GetDateFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpDateStr, INT cchOut)
Definition: lcformat.c:936
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
__u16 time
Definition: mkdosfs.c:8
HDC hdc
Definition: main.c:9
static const struct message test_dtm_get_monthcal_seq[]
Definition: datetime.c:78
#define expect_unsuccess(EXPECTED, GOT)
Definition: datetime.c:29
static void test_dtm_set_and_get_range(void)
Definition: datetime.c:332
static const struct message test_dtm_set_range_swap_min_max_seq[]
Definition: datetime.c:100
static LPARAM compare_systime_time(SYSTEMTIME *st1, SYSTEMTIME *st2)
Definition: datetime.c:312
static const struct message test_dtm_set_and_get_systime_with_limits[]
Definition: datetime.c:127
static void test_dtm_set_format(void)
Definition: datetime.c:184
#define NUM_MSG_SEQUENCES
Definition: datetime.c:31
#define X(f)
static const struct message test_dtm_set_and_get_range_seq[]
Definition: datetime.c:83
static void fill_systime_struct(SYSTEMTIME *st, int year, int month, int dayofweek, int day, int hour, int minute, int second, int milliseconds)
Definition: datetime.c:292
#define expect_systime(ST1, ST2)
Definition: datetime.c:328
static const struct message test_dtm_set_format_seq[]
Definition: datetime.c:38
static void test_wm_set_get_text(void)
Definition: datetime.c:764
static LPARAM compare_systime(SYSTEMTIME *st1, SYSTEMTIME *st2)
Definition: datetime.c:320
static struct msg_sequence * sequences[NUM_MSG_SEQUENCES]
Definition: datetime.c:36
static void test_dtm_set_range_swap_min_max(void)
Definition: datetime.c:422
static const struct message test_dtm_set_and_get_system_time_seq[]
Definition: datetime.c:116
static const struct message test_dtm_set_and_get_mcfont_seq[]
Definition: datetime.c:72
static void test_dtm_get_ideal_size(void)
Definition: datetime.c:724
#define expect(EXPECTED, GOT)
Definition: datetime.c:27
static void test_dtm_set_and_get_mccolor(void)
Definition: datetime.c:236
#define expect_systime_date(ST1, ST2)
Definition: datetime.c:329
static const struct message test_dtm_set_and_get_mccolor_seq[]
Definition: datetime.c:44
#define DATETIME_SEQ_INDEX
Definition: datetime.c:32
static HWND create_datetime_control(DWORD style)
Definition: datetime.c:160
static void test_dtm_set_and_get_systemtime_with_limits(void)
Definition: datetime.c:673
static void test_mccolor_types(HWND hWndDateTime, int mccolor_type, const char *mccolor_name)
Definition: datetime.c:217
static LRESULT WINAPI datetime_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: datetime.c:139
static void init_functions(void)
Definition: datetime.c:823
static void test_dts_shownone(void)
Definition: datetime.c:802
static void test_dtm_set_and_get_mcfont(void)
Definition: datetime.c:256
static void test_dtm_get_monthcal(void)
Definition: datetime.c:274
static void test_dtm_set_and_get_system_time(void)
Definition: datetime.c:528
static LPARAM compare_systime_date(SYSTEMTIME *st1, SYSTEMTIME *st2)
Definition: datetime.c:304
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define todo_wine
Definition: custom.c:89
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define LOCALE_USER_DEFAULT
long LONG
Definition: pedump.c:60
#define MCSC_MONTHBK
Definition: commctrl.h:4216
#define DTM_GETIDEALSIZE
Definition: commctrl.h:4360
#define DTM_GETMONTHCAL
Definition: commctrl.h:4353
#define GDTR_MAX
Definition: commctrl.h:4462
#define DTM_SETMCCOLOR
Definition: commctrl.h:4349
#define GDTR_MIN
Definition: commctrl.h:4461
#define MCSC_TITLEBK
Definition: commctrl.h:4214
#define MCSC_TITLETEXT
Definition: commctrl.h:4215
#define DTM_SETMCFONT
Definition: commctrl.h:4355
#define GDT_ERROR
Definition: commctrl.h:4464
#define GDT_NONE
Definition: commctrl.h:4466
#define ICC_DATE_CLASSES
Definition: commctrl.h:67
#define DTM_GETMCFONT
Definition: commctrl.h:4357
#define DTM_SETRANGE
Definition: commctrl.h:4340
#define DTM_SETSYSTEMTIME
Definition: commctrl.h:4336
#define MCSC_TEXT
Definition: commctrl.h:4213
#define DTM_GETMCCOLOR
Definition: commctrl.h:4351
#define DTM_GETRANGE
Definition: commctrl.h:4338
#define DTS_SHOWNONE
Definition: commctrl.h:4363
#define GDT_VALID
Definition: commctrl.h:4465
#define DATETIMEPICK_CLASSA
Definition: commctrl.h:4328
#define MCSC_TRAILINGTEXT
Definition: commctrl.h:4217
#define DTM_SETFORMATA
Definition: commctrl.h:4342
#define DTM_GETSYSTEMTIME
Definition: commctrl.h:4334
#define MCSC_BACKGROUND
Definition: commctrl.h:4212
#define win_skip
Definition: test.h:163
LONG lfHeight
Definition: dimm.idl:42
LONG lfWeight
Definition: dimm.idl:46
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
WORD wYear
Definition: winbase.h:930
WORD wMilliseconds
Definition: winbase.h:937
WORD wMonth
Definition: winbase.h:931
WORD wHour
Definition: winbase.h:934
WORD wSecond
Definition: winbase.h:936
WORD wMinute
Definition: winbase.h:935
WORD wDay
Definition: winbase.h:933
WORD wDayOfWeek
Definition: winbase.h:932
Definition: cookie.c:34
Definition: tftpd.h:60
UINT message
Definition: SystemMenu.c:42
Definition: send.c:48
Definition: time.h:68
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
uint32_t ULONG_PTR
Definition: typedefs.h:65
static BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
Definition: v6util.h:73
static void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
Definition: v6util.h:65
int ret
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1302
#define ZeroMemory
Definition: winbase.h:1737
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
DWORD COLORREF
Definition: windef.h:300
#define WINAPI
Definition: msvc.h:6
HGDIOBJ WINAPI GetStockObject(_In_ int)
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
#define FW_NORMAL
Definition: wingdi.h:373
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
#define CAL_GREGORIAN
Definition: winnls.h:445
#define LOCALE_ICALENDARTYPE
Definition: winnls.h:75
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define SetWindowLongPtrA
Definition: winuser.h:5357
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
LONG WINAPI SetWindowLongA(_In_ HWND, _In_ int, _In_ LONG)
#define CB_ERR
Definition: winuser.h:2438
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_GETTEXT
Definition: winuser.h:1621
#define GetWindowLongPtrA
Definition: winuser.h:4831
#define WM_SETTEXT
Definition: winuser.h:1620
#define WM_SETFONT
Definition: winuser.h:1653
HDC WINAPI GetDC(_In_opt_ HWND)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909
#define GWL_STYLE
Definition: winuser.h:855
BOOL WINAPI DestroyWindow(_In_ HWND)
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char CHAR
Definition: xmlstorage.h:175