2 * comctl32 month calendar unit tests
4 * Copyright (C) 2006 Vitaliy Margolen
5 * Copyright (C) 2007 Farshad Agah
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/test.h"
35 #define expect(expected, got) ok(expected == got, "Expected %d, got %d\n", expected, got);
37 #define NUM_MSG_SEQUENCES 2
38 #define PARENT_SEQ_INDEX 0
39 #define MONTHCAL_SEQ_INDEX 1
46 static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
48 static const struct message create_parent_window_seq[] = {
49 { WM_GETMINMAXINFO, sent },
50 { WM_NCCREATE, sent },
51 { WM_NCCALCSIZE, sent|wparam, 0 },
53 { WM_SHOWWINDOW, sent|wparam, 1 },
54 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
55 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
56 { WM_ACTIVATEAPP, sent|wparam, 1 },
57 { WM_NCACTIVATE, sent|wparam, 1 },
58 { WM_ACTIVATE, sent|wparam, 1 },
59 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
60 { WM_IME_NOTIFY, sent|defwinproc|optional },
61 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
62 /* Win9x adds SWP_NOZORDER below */
63 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
64 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
70 static const struct message create_monthcal_control_seq[] = {
71 { WM_NOTIFYFORMAT, sent|lparam, 0, NF_QUERY },
72 { WM_QUERYUISTATE, sent },
74 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE},
78 static const struct message create_monthcal_multi_sel_style_seq[] = {
79 { WM_NOTIFYFORMAT, sent|lparam, 0, NF_QUERY },
80 { WM_QUERYUISTATE, sent },
85 static const struct message monthcal_color_seq[] = {
86 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, 0},
87 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, RGB(0,0,0)},
88 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, 0},
89 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, RGB(255,255,255)},
90 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, 0},
92 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_MONTHBK, 0},
93 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_MONTHBK, RGB(0,0,0)},
94 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_MONTHBK, 0},
95 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_MONTHBK, RGB(255,255,255)},
96 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_MONTHBK, 0},
98 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TEXT, 0},
99 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_TEXT, RGB(0,0,0)},
100 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TEXT, 0},
101 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_TEXT, RGB(255,255,255)},
102 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TEXT, 0},
104 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TITLEBK, 0},
105 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_TITLEBK, RGB(0,0,0)},
106 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TITLEBK, 0},
107 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_TITLEBK, RGB(255,255,255)},
108 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TITLEBK, 0},
110 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, 0},
111 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, RGB(0,0,0)},
112 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, 0},
113 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, RGB(255,255,255)},
114 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, 0},
116 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TRAILINGTEXT, 0},
117 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_TRAILINGTEXT, RGB(0,0,0)},
118 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TRAILINGTEXT, 0},
119 { MCM_SETCOLOR, sent|wparam|lparam, MCSC_TRAILINGTEXT, RGB(255,255,255)},
120 { MCM_GETCOLOR, sent|wparam|lparam, MCSC_TRAILINGTEXT, 0},
124 static const struct message monthcal_curr_date_seq[] = {
125 { MCM_SETCURSEL, sent|wparam, 0},
126 { WM_PAINT, sent|wparam|lparam|defwinproc, 0, 0},
127 { WM_NCPAINT, sent|wparam|lparam|defwinproc, 1, 0},
128 { WM_ERASEBKGND, sent|lparam|defwinproc, 0},
129 { MCM_SETCURSEL, sent|wparam, 0},
130 { MCM_SETCURSEL, sent|wparam, 0},
131 { MCM_GETCURSEL, sent|wparam, 0},
132 { MCM_GETCURSEL, sent|wparam|lparam, 0, 0},
136 static const struct message monthcal_first_day_seq[] = {
137 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
139 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -5},
140 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
142 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -4},
143 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
145 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -3},
146 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
148 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -2},
149 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
151 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -1},
152 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
154 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
155 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
157 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 1},
158 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
160 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 2},
161 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
163 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 3},
164 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
166 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 4},
167 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
169 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 5},
170 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
172 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 6},
173 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
175 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 7},
176 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
178 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 8},
179 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
181 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 9},
182 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
184 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 10},
185 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
187 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 11},
188 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
192 static const struct message monthcal_unicode_seq[] = {
193 { MCM_GETUNICODEFORMAT, sent|wparam|lparam, 0, 0},
194 { MCM_SETUNICODEFORMAT, sent|wparam|lparam, 1, 0},
195 { MCM_GETUNICODEFORMAT, sent|wparam|lparam, 0, 0},
196 { MCM_SETUNICODEFORMAT, sent|wparam|lparam, 0, 0},
197 { MCM_GETUNICODEFORMAT, sent|wparam|lparam, 0, 0},
198 { MCM_SETUNICODEFORMAT, sent|wparam|lparam, 1, 0},
202 static const struct message monthcal_hit_test_seq[] = {
203 { MCM_HITTEST, sent|wparam, 0},
204 { MCM_HITTEST, sent|wparam, 0},
205 { MCM_HITTEST, sent|wparam, 0},
206 { MCM_HITTEST, sent|wparam, 0},
210 static const struct message monthcal_today_seq[] = {
211 { MCM_SETTODAY, sent|wparam, 0},
212 { WM_PAINT, sent|wparam|lparam|defwinproc, 0, 0},
213 { MCM_GETTODAY, sent|wparam, 0},
214 { MCM_SETTODAY, sent|wparam, 0},
215 { WM_PAINT, sent|wparam|lparam|defwinproc, 0, 0},
216 { MCM_GETTODAY, sent|wparam, 0},
220 static const struct message monthcal_scroll_seq[] = {
221 { MCM_SETMONTHDELTA, sent|wparam|lparam, 2, 0},
222 { MCM_SETMONTHDELTA, sent|wparam|lparam, 3, 0},
223 { MCM_GETMONTHDELTA, sent|wparam|lparam, 0, 0},
224 { MCM_SETMONTHDELTA, sent|wparam|lparam, 12, 0},
225 { MCM_GETMONTHDELTA, sent|wparam|lparam, 0, 0},
226 { MCM_SETMONTHDELTA, sent|wparam|lparam, 15, 0},
227 { MCM_GETMONTHDELTA, sent|wparam|lparam, 0, 0},
228 { MCM_SETMONTHDELTA, sent|wparam|lparam, -5, 0},
229 { MCM_GETMONTHDELTA, sent|wparam|lparam, 0, 0},
233 static const struct message monthcal_max_sel_day_seq[] = {
234 { MCM_SETMAXSELCOUNT, sent|wparam|lparam, 5, 0},
235 { MCM_GETMAXSELCOUNT, sent|wparam|lparam, 0, 0},
236 { MCM_SETMAXSELCOUNT, sent|wparam|lparam, 15, 0},
237 { MCM_GETMAXSELCOUNT, sent|wparam|lparam, 0, 0},
238 { MCM_SETMAXSELCOUNT, sent|wparam|lparam, -1, 0},
239 { MCM_GETMAXSELCOUNT, sent|wparam|lparam, 0, 0},
243 /* expected message sequence for parent*/
244 static const struct message destroy_monthcal_parent_msgs_seq[] = {
245 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY},
249 /* expected message sequence for child*/
250 static const struct message destroy_monthcal_child_msgs_seq[] = {
251 { WM_SHOWWINDOW, sent|wparam|lparam, 0, 0},
252 { WM_WINDOWPOSCHANGING, sent|wparam, 0},
253 { WM_WINDOWPOSCHANGED, sent|wparam, 0},
254 { WM_DESTROY, sent|wparam|lparam, 0, 0},
255 { WM_NCDESTROY, sent|wparam|lparam, 0, 0},
259 static const struct message destroy_monthcal_multi_sel_style_seq[] = {
260 { WM_DESTROY, sent|wparam|lparam, 0, 0},
261 { WM_NCDESTROY, sent|wparam|lparam, 0, 0},
265 /* expected message sequence for parent window*/
266 static const struct message destroy_parent_seq[] = {
267 { WM_WINDOWPOSCHANGING, sent|wparam, 0},
268 { WM_WINDOWPOSCHANGED, sent|wparam, 0},
269 { WM_NCACTIVATE, sent|wparam|lparam, 0, 0},
270 { WM_ACTIVATE, sent|wparam|lparam, 0, 0},
271 { WM_ACTIVATEAPP, sent|wparam, 0},
272 { WM_KILLFOCUS, sent|wparam|lparam, 0, 0},
273 { WM_IME_SETCONTEXT, sent|wparam|optional, 0},
274 { WM_IME_NOTIFY, sent|wparam|lparam|defwinproc|optional, 1, 0},
275 { WM_DESTROY, sent|wparam|lparam, 0, 0},
276 { WM_NCDESTROY, sent|wparam|lparam, 0, 0},
280 static void test_monthcal(void)
283 SYSTEMTIME st[2], st1[2];
284 INITCOMMONCONTROLSEX ic = {sizeof(INITCOMMONCONTROLSEX), ICC_DATE_CLASSES};
285 int res, month_range;
287 InitCommonControlsEx(&ic);
288 hwnd = CreateWindowA(MONTHCAL_CLASSA, "MonthCal", WS_POPUP | WS_VISIBLE, CW_USEDEFAULT,
289 0, 300, 300, 0, 0, NULL, NULL);
290 ok(hwnd != NULL, "Failed to create MonthCal\n");
291 GetSystemTime(&st[0]);
294 /* Invalid date/time */
296 /* Time should not matter */
297 st[1].wHour = st[1].wMinute = st[1].wSecond = 70;
298 ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set MAX limit\n");
299 ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "No limits should be set\n");
300 ok(st1[0].wYear != 2000, "Lover limit changed\n");
303 ok(!SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Should have failed to set limits\n");
304 ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "No limits should be set\n");
305 ok(st1[0].wYear != 2000, "Lover limit changed\n");
306 ok(!SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Should have failed to set MAX limit\n");
307 ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "No limits should be set\n");
308 ok(st1[0].wYear != 2000, "Lover limit changed\n");
310 GetSystemTime(&st[0]);
315 month_range = SendMessage(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st1);
317 ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Failed to set both min and max limits\n");
318 res = SendMessage(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st1);
319 ok(res == month_range, "Invalid month range (%d)\n", res);
320 ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == (GDTR_MIN|GDTR_MAX), "Limits should be set\n");
323 ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Failed to set both min and max limits\n");
324 res = SendMessage(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st1);
325 ok(res == month_range, "Invalid month range (%d)\n", res);
328 ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Failed to set both min and max limits\n");
330 ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), "Failed to set both min and max limits\n");
333 ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n");
334 ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "Only MAX limit should be set\n");
336 ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n");
338 ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n");
340 ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n");
341 ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "Only MAX limit should be set\n");
346 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
348 static long defwndproc_counter = 0;
352 /* do not log painting messages */
353 if (message != WM_PAINT &&
354 message != WM_ERASEBKGND &&
355 message != WM_NCPAINT &&
356 message != WM_NCHITTEST &&
357 message != WM_GETTEXT &&
358 message != WM_GETICON &&
359 message != WM_DEVICECHANGE)
361 trace("parent: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
363 msg.message = message;
364 msg.flags = sent|wparam|lparam;
365 if (defwndproc_counter) msg.flags |= defwinproc;
368 add_message(sequences, PARENT_SEQ_INDEX, &msg);
371 defwndproc_counter++;
372 ret = DefWindowProcA(hwnd, message, wParam, lParam);
373 defwndproc_counter--;
378 static BOOL register_parent_wnd_class()
383 cls.lpfnWndProc = parent_wnd_proc;
386 cls.hInstance = GetModuleHandleA(NULL);
388 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
389 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
390 cls.lpszMenuName = NULL;
391 cls.lpszClassName = "Month-Cal test parent class";
392 return RegisterClassA(&cls);
395 static HWND create_parent_window(void)
399 InitCommonControls();
401 /* flush message sequences, so we can check the new sequence by the end of function */
402 flush_sequences(sequences, NUM_MSG_SEQUENCES);
404 if (!register_parent_wnd_class())
407 hwnd = CreateWindowEx(0, "Month-Cal test parent class",
408 "Month-Cal test parent window",
409 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
410 WS_MAXIMIZEBOX | WS_VISIBLE,
412 GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
416 /* check for message sequences */
417 ok_sequence(sequences, PARENT_SEQ_INDEX, create_parent_window_seq, "create parent window", TRUE);
422 static LRESULT WINAPI monthcal_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
424 struct subclass_info *info = (struct subclass_info *)GetWindowLongA(hwnd, GWL_USERDATA);
425 static long defwndproc_counter = 0;
429 trace("monthcal: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
431 msg.message = message;
432 msg.flags = sent|wparam|lparam;
433 if (defwndproc_counter) msg.flags |= defwinproc;
436 add_message(sequences, MONTHCAL_SEQ_INDEX, &msg);
438 defwndproc_counter++;
439 ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam);
440 defwndproc_counter--;
445 static HWND create_monthcal_control(DWORD style, HWND parent_window)
447 struct subclass_info *info;
449 static const INITCOMMONCONTROLSEX ic = {sizeof(INITCOMMONCONTROLSEX), ICC_DATE_CLASSES};
451 InitCommonControlsEx(&ic);
453 info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info));
457 hwnd = CreateWindowEx(0,
462 parent_window, NULL, GetModuleHandleA(NULL), NULL);
466 HeapFree(GetProcessHeap(), 0, info);
470 info->oldproc = (WNDPROC)SetWindowLongA(hwnd, GWL_WNDPROC,
471 (LONG)monthcal_subclass_proc);
472 SetWindowLongA(hwnd, GWL_USERDATA, (LONG)info);
478 /* Setter and Getters Tests */
480 static void test_monthcal_color(HWND hwnd)
484 flush_sequences(sequences, NUM_MSG_SEQUENCES);
486 /* Setter and Getters for color*/
487 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_BACKGROUND, 0);
488 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_BACKGROUND, RGB(0,0,0));
490 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_BACKGROUND, 0);
491 expect(RGB(0,0,0), temp);
492 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_BACKGROUND, RGB(255,255,255));
494 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_BACKGROUND, 0);
495 expect(RGB(255,255,255), temp);
497 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_MONTHBK, 0);
498 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_MONTHBK, RGB(0,0,0));
500 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_MONTHBK, 0);
501 expect(RGB(0,0,0), temp);
502 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_MONTHBK, RGB(255,255,255));
504 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_MONTHBK, 0);
505 expect(RGB(255,255,255), temp);
507 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TEXT, 0);
508 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_TEXT, RGB(0,0,0));
510 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TEXT, 0);
511 expect(RGB(0,0,0), temp);
512 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_TEXT, RGB(255,255,255));
514 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TEXT, 0);
515 expect(RGB(255,255,255), temp);
517 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TITLEBK, 0);
518 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_TITLEBK, RGB(0,0,0));
520 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TITLEBK, 0);
521 expect(RGB(0,0,0), temp);
522 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_TITLEBK, RGB(255,255,255));
524 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TITLEBK, 0);
525 expect(RGB(255,255,255), temp);
527 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TITLETEXT, 0);
528 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_TITLETEXT, RGB(0,0,0));
530 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TITLETEXT, 0);
531 expect(RGB(0,0,0), temp);
532 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_TITLETEXT, RGB(255,255,255));
534 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TITLETEXT, 0);
535 expect(RGB(255,255,255), temp);
537 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TRAILINGTEXT, 0);
538 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_TRAILINGTEXT, RGB(0,0,0));
540 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TRAILINGTEXT, 0);
541 expect(RGB(0,0,0), temp);
542 res = SendMessage(hwnd, MCM_SETCOLOR, MCSC_TRAILINGTEXT, RGB(255,255,255));
544 temp = SendMessage(hwnd, MCM_GETCOLOR, MCSC_TRAILINGTEXT, 0);
545 expect(RGB(255,255,255), temp);
547 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_color_seq, "monthcal color", FALSE);
550 static void test_monthcal_currDate(HWND hwnd)
552 SYSTEMTIME st_original, st_new, st_test;
555 flush_sequences(sequences, NUM_MSG_SEQUENCES);
557 /* Setter and Getters for current date selected */
558 st_original.wYear = 2000;
559 st_original.wMonth = 11;
560 st_original.wDay = 28;
561 st_original.wHour = 11;
562 st_original.wMinute = 59;
563 st_original.wSecond = 30;
564 st_original.wMilliseconds = 0;
565 st_original.wDayOfWeek = 0;
567 st_new = st_test = st_original;
569 /* Should not validate the time */
570 res = SendMessage(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_test);
573 /* Overflow matters, check for wDay */
575 res = SendMessage(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_test);
578 /* correct wDay before checking for wMonth */
580 expect(st_original.wDay, st_test.wDay);
582 /* Overflow matters, check for wMonth */
584 res = SendMessage(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_test);
587 /* checking if gets the information right, modify st_new */
595 res = SendMessage(hwnd, MCM_GETCURSEL, 0, (LPARAM)&st_new);
598 /* st_new change to st_origin, above settings with overflow */
599 /* should not change the current settings */
600 expect(st_original.wYear, st_new.wYear);
601 expect(st_original.wMonth, st_new.wMonth);
602 expect(st_original.wDay, st_new.wDay);
603 expect(st_original.wHour, st_new.wHour);
604 expect(st_original.wMinute, st_new.wMinute);
605 expect(st_original.wSecond, st_new.wSecond);
607 /* lparam cannot be NULL */
608 res = SendMessage(hwnd, MCM_GETCURSEL, 0, (LPARAM) NULL);
611 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_curr_date_seq, "monthcal currDate", TRUE);
614 static void test_monthcal_firstDay(HWND hwnd)
616 int res, fday, i, prev;
618 LCID lcid = LOCALE_USER_DEFAULT;
620 flush_sequences(sequences, NUM_MSG_SEQUENCES);
622 /* Setter and Getters for first day of week */
623 /* check for locale first day */
624 if(GetLocaleInfo(lcid, LOCALE_IFIRSTDAYOFWEEK, b, 128)){
626 res = SendMessage(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0);
630 /* checking for the values that actually will be stored as */
631 /* current first day when we set a new value */
632 for (i = -5; i < 12; i++){
633 res = SendMessage(hwnd, MCM_SETFIRSTDAYOFWEEK, 0, (LPARAM) i);
635 res = SendMessage(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0);
639 expect(MAKELONG(fday, FALSE), res);
641 expect(MAKELONG(fday, TRUE), res);
643 expect(MAKELONG(i, TRUE), res);
647 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_first_day_seq, "monthcal firstDay", FALSE);
650 skip("Cannot retrieve first day of the week\n");
655 static void test_monthcal_unicode(HWND hwnd)
659 flush_sequences(sequences, NUM_MSG_SEQUENCES);
661 /* Setter and Getters for Unicode format */
663 /* getting the current settings */
664 temp = SendMessage(hwnd, MCM_GETUNICODEFORMAT, 0, 0);
666 /* setting to 1, should return previous settings */
667 res = SendMessage(hwnd, MCM_SETUNICODEFORMAT, 1, 0);
670 /* current setting is 1, so, should return 1 */
671 res = SendMessage(hwnd, MCM_GETUNICODEFORMAT, 0, 0);
672 todo_wine {expect(1, res);}
674 /* setting to 0, should return previous settings */
675 res = SendMessage(hwnd, MCM_SETUNICODEFORMAT, 0, 0);
676 todo_wine {expect(1, res);}
678 /* current setting is 0, so, it should return 0 */
679 res = SendMessage(hwnd, MCM_GETUNICODEFORMAT, 0, 0);
682 /* should return previous settings */
683 res = SendMessage(hwnd, MCM_SETUNICODEFORMAT, 1, 0);
686 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_unicode_seq, "monthcal unicode", FALSE);
689 static void test_monthcal_HitTest(HWND hwnd)
694 memset(&mchit, 0, sizeof(MCHITTESTINFO));
696 flush_sequences(sequences, NUM_MSG_SEQUENCES);
698 /* Setters for HITTEST */
700 /* (0, 0) is the top left of the control and should not be active */
701 mchit.cbSize = sizeof(MCHITTESTINFO);
704 res = SendMessage(hwnd, MCM_HITTEST, 0, (LPARAM) & mchit);
705 expect(0, mchit.pt.x);
706 expect(0, mchit.pt.y);
707 expect(mchit.uHit, res);
708 todo_wine {expect(MCHT_NOWHERE, res);}
710 /* (300, 300) is the bottom right of the control and should not be active */
713 res = SendMessage(hwnd, MCM_HITTEST, 0, (LPARAM) & mchit);
714 expect(300, mchit.pt.x);
715 expect(300, mchit.pt.y);
716 expect(mchit.uHit, res);
717 todo_wine {expect(MCHT_NOWHERE, res);}
719 /* (500, 500) is completely out of the control and should not be active */
722 res = SendMessage(hwnd, MCM_HITTEST, 0, (LPARAM) & mchit);
723 expect(500, mchit.pt.x);
724 expect(500, mchit.pt.y);
725 expect(mchit.uHit, res);
726 todo_wine {expect(MCHT_NOWHERE, res);}
728 /* (150, 200) is in active area */
731 res = SendMessage(hwnd, MCM_HITTEST, 0, (LPARAM) & mchit);
732 expect(150, mchit.pt.x);
733 expect(200, mchit.pt.y);
734 expect(mchit.uHit, res);
736 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_hit_test_seq, "monthcal hit test", FALSE);
739 static void test_monthcal_today(HWND hwnd)
741 SYSTEMTIME st_test, st_new;
744 flush_sequences(sequences, NUM_MSG_SEQUENCES);
746 /* Setter and Getters for "today" information */
748 /* check for overflow, should be ok */
755 SendMessage(hwnd, MCM_SETTODAY, 0, (LPARAM)&st_test);
757 res = SendMessage(hwnd, MCM_GETTODAY, 0, (LPARAM)&st_new);
760 /* st_test should not change */
761 expect(38, st_test.wDay);
762 expect(38, st_test.wMonth);
764 /* st_new should change, overflow does not matter */
765 expect(38, st_new.wDay);
766 expect(38, st_new.wMonth);
768 /* check for zero, should be ok*/
772 SendMessage(hwnd, MCM_SETTODAY, 0, (LPARAM)&st_test);
774 res = SendMessage(hwnd, MCM_GETTODAY, 0, (LPARAM)&st_new);
777 /* st_test should not change */
778 expect(0, st_test.wDay);
779 expect(0, st_test.wMonth);
781 /* st_new should change to zero*/
782 expect(0, st_new.wDay);
783 expect(0, st_new.wMonth);
785 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_today_seq, "monthcal today", TRUE);
788 static void test_monthcal_scroll(HWND hwnd)
792 flush_sequences(sequences, NUM_MSG_SEQUENCES);
794 /* Setter and Getters for scroll rate */
795 res = SendMessage(hwnd, MCM_SETMONTHDELTA, 2, 0);
798 res = SendMessage(hwnd, MCM_SETMONTHDELTA, 3, 0);
800 res = SendMessage(hwnd, MCM_GETMONTHDELTA, 0, 0);
803 res = SendMessage(hwnd, MCM_SETMONTHDELTA, 12, 0);
805 res = SendMessage(hwnd, MCM_GETMONTHDELTA, 0, 0);
808 res = SendMessage(hwnd, MCM_SETMONTHDELTA, 15, 0);
810 res = SendMessage(hwnd, MCM_GETMONTHDELTA, 0, 0);
813 res = SendMessage(hwnd, MCM_SETMONTHDELTA, -5, 0);
815 res = SendMessage(hwnd, MCM_GETMONTHDELTA, 0, 0);
818 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_scroll_seq, "monthcal scroll", FALSE);
821 static void test_monthcal_MaxSelDay(HWND hwnd)
825 flush_sequences(sequences, NUM_MSG_SEQUENCES);
827 /* Setter and Getters for max selected days */
828 res = SendMessage(hwnd, MCM_SETMAXSELCOUNT, 5, 0);
830 res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
833 res = SendMessage(hwnd, MCM_SETMAXSELCOUNT, 15, 0);
835 res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
838 res = SendMessage(hwnd, MCM_SETMAXSELCOUNT, -1, 0);
839 todo_wine {expect(0, res);}
840 res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
841 todo_wine {expect(15, res);}
843 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_max_sel_day_seq, "monthcal MaxSelDay", FALSE);
849 HWND hwnd, parent_wnd;
852 init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
854 parent_wnd = create_parent_window();
856 flush_sequences(sequences, NUM_MSG_SEQUENCES);
857 hwnd = create_monthcal_control(WS_CHILD | WS_BORDER | WS_VISIBLE, parent_wnd);
859 ok_sequence(sequences, PARENT_SEQ_INDEX, create_monthcal_control_seq, "create monthcal control", TRUE);
861 test_monthcal_color(hwnd);
862 test_monthcal_currDate(hwnd);
863 test_monthcal_firstDay(hwnd);
864 test_monthcal_unicode(hwnd);
865 test_monthcal_HitTest(hwnd);
866 test_monthcal_today(hwnd);
867 test_monthcal_scroll(hwnd);
869 flush_sequences(sequences, NUM_MSG_SEQUENCES);
871 ok_sequence(sequences, PARENT_SEQ_INDEX, destroy_monthcal_parent_msgs_seq, "Destroy monthcal (parent msg)", FALSE);
872 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, destroy_monthcal_child_msgs_seq, "Destroy monthcal (child msg)", FALSE);
874 flush_sequences(sequences, NUM_MSG_SEQUENCES);
875 hwnd = create_monthcal_control(MCS_MULTISELECT, parent_wnd);
877 ok_sequence(sequences, PARENT_SEQ_INDEX, create_monthcal_multi_sel_style_seq, "create monthcal (multi sel style)", TRUE);
879 test_monthcal_MaxSelDay(hwnd);
881 flush_sequences(sequences, NUM_MSG_SEQUENCES);
883 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, destroy_monthcal_multi_sel_style_seq, "Destroy monthcal (multi sel style)", FALSE);
885 flush_sequences(sequences, NUM_MSG_SEQUENCES);
886 DestroyWindow(parent_wnd);
887 ok_sequence(sequences, PARENT_SEQ_INDEX, destroy_parent_seq, "Destroy parent window", FALSE);