2007-12-01 18:29:29 +00:00
|
|
|
/* Unit test suite for datetime control.
|
|
|
|
*
|
|
|
|
* Copyright 2007 Kanit Therdsteerasukdi
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2013-03-16 17:07:05 +00:00
|
|
|
//#include <windows.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
|
|
|
#include <winnls.h>
|
2007-12-01 18:29:29 +00:00
|
|
|
#include <commctrl.h>
|
2013-03-16 17:07:05 +00:00
|
|
|
//#include "wine/test.h"
|
2007-12-01 18:29:29 +00:00
|
|
|
#include "msg.h"
|
|
|
|
|
|
|
|
#define expect(EXPECTED, GOT) ok((GOT)==(EXPECTED), "Expected %d, got %ld\n", (EXPECTED), (GOT))
|
|
|
|
|
|
|
|
#define expect_unsuccess(EXPECTED, GOT) ok((GOT)==(EXPECTED), "Expected %d(unsuccessful), got %ld(successful)\n", (EXPECTED), (GOT))
|
|
|
|
|
|
|
|
#define NUM_MSG_SEQUENCES 1
|
|
|
|
#define DATETIME_SEQ_INDEX 0
|
|
|
|
|
|
|
|
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
|
|
|
|
|
|
|
|
static const struct message test_dtm_set_format_seq[] = {
|
2010-05-30 15:19:09 +00:00
|
|
|
{ DTM_SETFORMATA, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ DTM_SETFORMATA, sent|wparam, 0 },
|
2007-12-01 18:29:29 +00:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_dtm_set_and_get_mccolor_seq[] = {
|
2010-05-30 15:19:09 +00:00
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, RGB(255, 255, 255) },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, RGB(100, 180, 220) },
|
|
|
|
{ DTM_GETMCCOLOR, sent|wparam|lparam, MCSC_BACKGROUND, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_MONTHBK, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_MONTHBK, RGB(255, 255, 255) },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_MONTHBK, RGB(100, 180, 220) },
|
|
|
|
{ DTM_GETMCCOLOR, sent|wparam|lparam, MCSC_MONTHBK, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TEXT, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TEXT, RGB(255, 255, 255) },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TEXT, RGB(100, 180, 220) },
|
|
|
|
{ DTM_GETMCCOLOR, sent|wparam|lparam, MCSC_TEXT, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLEBK, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLEBK, RGB(255, 255, 255) },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLEBK, RGB(100, 180, 220) },
|
|
|
|
{ DTM_GETMCCOLOR, sent|wparam|lparam, MCSC_TITLEBK, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, RGB(255, 255, 255) },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, RGB(100, 180, 220) },
|
|
|
|
{ DTM_GETMCCOLOR, sent|wparam|lparam, MCSC_TITLETEXT, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TRAILINGTEXT, 0 },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TRAILINGTEXT, RGB(255, 255, 255) },
|
|
|
|
{ DTM_SETMCCOLOR, sent|wparam|lparam, MCSC_TRAILINGTEXT, RGB(100, 180, 220) },
|
|
|
|
{ DTM_GETMCCOLOR, sent|wparam|lparam, MCSC_TRAILINGTEXT, 0 },
|
2007-12-01 18:29:29 +00:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_dtm_set_and_get_mcfont_seq[] = {
|
2010-05-30 15:19:09 +00:00
|
|
|
{ DTM_SETMCFONT, sent|lparam, 0, 1 },
|
|
|
|
{ DTM_GETMCFONT, sent|wparam|lparam, 0, 0 },
|
2007-12-01 18:29:29 +00:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_dtm_get_monthcal_seq[] = {
|
2010-05-30 15:19:09 +00:00
|
|
|
{ DTM_GETMONTHCAL, sent|wparam|lparam, 0, 0 },
|
2007-12-01 18:29:29 +00:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_dtm_set_and_get_range_seq[] = {
|
2010-05-30 15:19:09 +00:00
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MAX },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MAX },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN | GDTR_MAX },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN | GDTR_MAX },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN | GDTR_MAX },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN | GDTR_MAX },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
2007-12-01 18:29:29 +00:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_dtm_set_range_swap_min_max_seq[] = {
|
2010-05-30 15:19:09 +00:00
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_GETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN | GDTR_MAX },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_GETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN | GDTR_MAX },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN | GDTR_MAX },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN | GDTR_MAX },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
2007-12-01 18:29:29 +00:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_dtm_set_and_get_system_time_seq[] = {
|
2010-05-30 15:19:09 +00:00
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, GDT_NONE },
|
|
|
|
{ DTM_GETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_GETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, 0 },
|
2007-12-01 18:29:29 +00:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2012-12-14 23:24:10 +00:00
|
|
|
static const struct message test_dtm_set_and_get_systime_with_limits[] = {
|
|
|
|
{ DTM_SETRANGE, sent|wparam, GDTR_MIN | GDTR_MAX },
|
|
|
|
{ DTM_GETRANGE, sent|wparam, 0 },
|
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_GETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_GETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_SETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ DTM_GETSYSTEMTIME, sent|wparam, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2007-12-01 18:29:29 +00:00
|
|
|
static LRESULT WINAPI datetime_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2010-05-30 15:19:09 +00:00
|
|
|
WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
|
2009-05-17 07:05:22 +00:00
|
|
|
static LONG defwndproc_counter = 0;
|
2007-12-01 18:29:29 +00:00
|
|
|
LRESULT ret;
|
|
|
|
struct message msg;
|
|
|
|
|
|
|
|
msg.message = message;
|
|
|
|
msg.flags = sent|wparam|lparam;
|
|
|
|
if (defwndproc_counter) msg.flags |= defwinproc;
|
|
|
|
msg.wParam = wParam;
|
|
|
|
msg.lParam = lParam;
|
2013-03-16 17:07:05 +00:00
|
|
|
msg.id = 0;
|
2007-12-01 18:29:29 +00:00
|
|
|
add_message(sequences, DATETIME_SEQ_INDEX, &msg);
|
|
|
|
|
|
|
|
defwndproc_counter++;
|
2010-05-30 15:19:09 +00:00
|
|
|
ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
|
2007-12-01 18:29:29 +00:00
|
|
|
defwndproc_counter--;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
static HWND create_datetime_control(DWORD style)
|
2007-12-01 18:29:29 +00:00
|
|
|
{
|
2010-05-30 15:19:09 +00:00
|
|
|
WNDPROC oldproc;
|
2007-12-01 18:29:29 +00:00
|
|
|
HWND hWndDateTime = NULL;
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
hWndDateTime = CreateWindowExA(0,
|
|
|
|
DATETIMEPICK_CLASSA,
|
2007-12-01 18:29:29 +00:00
|
|
|
NULL,
|
|
|
|
style,
|
|
|
|
0,50,300,120,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
if (!hWndDateTime) return NULL;
|
2007-12-01 18:29:29 +00:00
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
oldproc = (WNDPROC)SetWindowLongPtrA(hWndDateTime, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)datetime_subclass_proc);
|
|
|
|
SetWindowLongPtrA(hWndDateTime, GWLP_USERDATA, (LONG_PTR)oldproc);
|
2007-12-01 18:29:29 +00:00
|
|
|
|
|
|
|
return hWndDateTime;
|
|
|
|
}
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
static void test_dtm_set_format(void)
|
2007-12-01 18:29:29 +00:00
|
|
|
{
|
2010-05-30 15:19:09 +00:00
|
|
|
HWND hWnd;
|
2008-04-04 16:43:16 +00:00
|
|
|
CHAR txt[256];
|
|
|
|
SYSTEMTIME systime;
|
2007-12-01 18:29:29 +00:00
|
|
|
LRESULT r;
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
hWnd = create_datetime_control(DTS_SHOWNONE);
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETFORMATA, 0, 0);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETFORMATA, 0,
|
2007-12-01 18:29:29 +00:00
|
|
|
(LPARAM)"'Today is: 'hh':'m':'s dddd MMM dd', 'yyyy");
|
|
|
|
expect(1, r);
|
|
|
|
|
|
|
|
ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_format_seq, "test_dtm_set_format", FALSE);
|
2008-04-04 16:43:16 +00:00
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETFORMATA, 0, (LPARAM)"'hh' hh");
|
2008-04-04 16:43:16 +00:00
|
|
|
expect(1, r);
|
|
|
|
ZeroMemory(&systime, sizeof(systime));
|
|
|
|
systime.wYear = 2000;
|
|
|
|
systime.wMonth = systime.wDay = 1;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, 0, (LPARAM)&systime);
|
2008-04-04 16:43:16 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
GetWindowTextA(hWnd, txt, 256);
|
2010-05-30 15:19:09 +00:00
|
|
|
ok(strcmp(txt, "hh 12") == 0, "String mismatch (\"%s\" vs \"hh 12\")\n", txt);
|
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_mccolor_types(HWND hWndDateTime, int mccolor_type, const char* mccolor_name)
|
|
|
|
{
|
2012-01-26 15:19:24 +00:00
|
|
|
COLORREF theColor, prevColor, crColor;
|
2007-12-01 18:29:29 +00:00
|
|
|
|
|
|
|
theColor=RGB(0,0,0);
|
2014-04-22 14:05:48 +00:00
|
|
|
crColor = SendMessageA(hWndDateTime, DTM_SETMCCOLOR, mccolor_type, theColor);
|
2012-01-26 15:19:24 +00:00
|
|
|
ok(crColor != ~0u, "%s: Set RGB(0,0,0): Expected COLORREF of previous value, got %d\n", mccolor_name, crColor);
|
2007-12-01 18:29:29 +00:00
|
|
|
prevColor=theColor;
|
|
|
|
theColor=RGB(255,255,255);
|
2014-04-22 14:05:48 +00:00
|
|
|
crColor = SendMessageA(hWndDateTime, DTM_SETMCCOLOR, mccolor_type, theColor);
|
2012-01-26 15:19:24 +00:00
|
|
|
ok(crColor==prevColor, "%s: Set RGB(255,255,255): Expected COLORREF of previous value, got %d\n", mccolor_name, crColor);
|
2007-12-01 18:29:29 +00:00
|
|
|
prevColor=theColor;
|
|
|
|
theColor=RGB(100,180,220);
|
2014-04-22 14:05:48 +00:00
|
|
|
crColor = SendMessageA(hWndDateTime, DTM_SETMCCOLOR, mccolor_type, theColor);
|
2012-01-26 15:19:24 +00:00
|
|
|
ok(crColor==prevColor, "%s: Set RGB(100,180,220): Expected COLORREF of previous value, got %d\n", mccolor_name, crColor);
|
2014-04-22 14:05:48 +00:00
|
|
|
crColor = SendMessageA(hWndDateTime, DTM_GETMCCOLOR, mccolor_type, 0);
|
2012-01-26 15:19:24 +00:00
|
|
|
ok(crColor==theColor, "%s: GETMCCOLOR: Expected %d, got %d\n", mccolor_name, theColor, crColor);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
static void test_dtm_set_and_get_mccolor(void)
|
2007-12-01 18:29:29 +00:00
|
|
|
{
|
2010-05-30 15:19:09 +00:00
|
|
|
HWND hWnd;
|
|
|
|
|
|
|
|
hWnd = create_datetime_control(DTS_SHOWNONE);
|
2007-12-01 18:29:29 +00:00
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
2010-05-30 15:19:09 +00:00
|
|
|
|
|
|
|
test_mccolor_types(hWnd, MCSC_BACKGROUND, "MCSC_BACKGROUND");
|
|
|
|
test_mccolor_types(hWnd, MCSC_MONTHBK, "MCSC_MONTHBK");
|
|
|
|
test_mccolor_types(hWnd, MCSC_TEXT, "MCSC_TEXT");
|
|
|
|
test_mccolor_types(hWnd, MCSC_TITLEBK, "MCSC_TITLEBK");
|
|
|
|
test_mccolor_types(hWnd, MCSC_TITLETEXT, "MCSC_TITLETEXT");
|
|
|
|
test_mccolor_types(hWnd, MCSC_TRAILINGTEXT, "MCSC_TRAILINGTEXT");
|
|
|
|
|
|
|
|
ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_mccolor_seq, "test_dtm_set_and_get_mccolor", FALSE);
|
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
static void test_dtm_set_and_get_mcfont(void)
|
2007-12-01 18:29:29 +00:00
|
|
|
{
|
|
|
|
HFONT hFontOrig, hFontNew;
|
2010-05-30 15:19:09 +00:00
|
|
|
HWND hWnd;
|
|
|
|
|
|
|
|
hWnd = create_datetime_control(DTS_SHOWNONE);
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
2007-12-01 18:29:29 +00:00
|
|
|
|
2009-01-17 17:42:01 +00:00
|
|
|
hFontOrig = GetStockObject(DEFAULT_GUI_FONT);
|
2014-04-22 14:05:48 +00:00
|
|
|
SendMessageA(hWnd, DTM_SETMCFONT, (WPARAM)hFontOrig, TRUE);
|
|
|
|
hFontNew = (HFONT)SendMessageA(hWnd, DTM_GETMCFONT, 0, 0);
|
2007-12-01 18:29:29 +00:00
|
|
|
ok(hFontOrig == hFontNew, "Expected hFontOrig==hFontNew, hFontOrig=%p, hFontNew=%p\n", hFontOrig, hFontNew);
|
|
|
|
|
|
|
|
ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_mcfont_seq, "test_dtm_set_and_get_mcfont", FALSE);
|
2010-05-30 15:19:09 +00:00
|
|
|
DestroyWindow(hWnd);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
static void test_dtm_get_monthcal(void)
|
2007-12-01 18:29:29 +00:00
|
|
|
{
|
|
|
|
LRESULT r;
|
2010-05-30 15:19:09 +00:00
|
|
|
HWND hWnd;
|
|
|
|
|
|
|
|
hWnd = create_datetime_control(DTS_SHOWNONE);
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
2007-12-01 18:29:29 +00:00
|
|
|
|
|
|
|
todo_wine {
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETMONTHCAL, 0, 0);
|
2009-01-17 17:42:01 +00:00
|
|
|
ok(r == 0, "Expected NULL(no child month calendar control), got %ld\n", r);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_get_monthcal_seq, "test_dtm_get_monthcal", FALSE);
|
2010-05-30 15:19:09 +00:00
|
|
|
DestroyWindow(hWnd);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void fill_systime_struct(SYSTEMTIME *st, int year, int month, int dayofweek, int day, int hour, int minute, int second, int milliseconds)
|
|
|
|
{
|
|
|
|
st->wYear = year;
|
|
|
|
st->wMonth = month;
|
|
|
|
st->wDayOfWeek = dayofweek;
|
|
|
|
st->wDay = day;
|
|
|
|
st->wHour = hour;
|
|
|
|
st->wMinute = minute;
|
|
|
|
st->wSecond = second;
|
|
|
|
st->wMilliseconds = milliseconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LPARAM compare_systime_date(SYSTEMTIME *st1, SYSTEMTIME *st2)
|
|
|
|
{
|
|
|
|
return (st1->wYear == st2->wYear)
|
|
|
|
&& (st1->wMonth == st2->wMonth)
|
|
|
|
&& (st1->wDayOfWeek == st2->wDayOfWeek)
|
|
|
|
&& (st1->wDay == st2->wDay);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LPARAM compare_systime_time(SYSTEMTIME *st1, SYSTEMTIME *st2)
|
|
|
|
{
|
|
|
|
return (st1->wHour == st2->wHour)
|
|
|
|
&& (st1->wMinute == st2->wMinute)
|
|
|
|
&& (st1->wSecond == st2->wSecond)
|
|
|
|
&& (st1->wMilliseconds == st2->wMilliseconds);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LPARAM compare_systime(SYSTEMTIME *st1, SYSTEMTIME *st2)
|
|
|
|
{
|
|
|
|
if(!compare_systime_date(st1, st2))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return compare_systime_time(st1, st2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define expect_systime(ST1, ST2) ok(compare_systime((ST1), (ST2))==1, "ST1 != ST2\n")
|
|
|
|
#define expect_systime_date(ST1, ST2) ok(compare_systime_date((ST1), (ST2))==1, "ST1.date != ST2.date\n")
|
|
|
|
#define expect_systime_time(ST1, ST2) ok(compare_systime_time((ST1), (ST2))==1, "ST1.time != ST2.time\n")
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
static void test_dtm_set_and_get_range(void)
|
2007-12-01 18:29:29 +00:00
|
|
|
{
|
|
|
|
LRESULT r;
|
|
|
|
SYSTEMTIME st[2];
|
|
|
|
SYSTEMTIME getSt[2];
|
2010-05-30 15:19:09 +00:00
|
|
|
HWND hWnd;
|
|
|
|
|
|
|
|
hWnd = create_datetime_control(DTS_SHOWNONE);
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
2007-12-01 18:29:29 +00:00
|
|
|
|
|
|
|
/* initialize st[0] to lowest possible value */
|
|
|
|
fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
|
2008-04-04 16:43:16 +00:00
|
|
|
/* initialize st[1] to all invalid numbers */
|
2007-12-01 18:29:29 +00:00
|
|
|
fill_systime_struct(&st[1], 0, 0, 7, 0, 24, 60, 60, 1000);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
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);
|
|
|
|
expect_systime(&st[0], &getSt[0]);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect_unsuccess(0, r);
|
|
|
|
|
|
|
|
/* set st[0] to all invalid numbers */
|
|
|
|
fill_systime_struct(&st[0], 0, 0, 7, 0, 24, 60, 60, 1000);
|
|
|
|
/* set st[1] to highest possible value */
|
|
|
|
fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2016-06-05 18:56:37 +00:00
|
|
|
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);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect_systime(&st[1], &getSt[1]);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect_unsuccess(0, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect_unsuccess(0, r);
|
|
|
|
|
|
|
|
/* set st[0] to highest possible value */
|
|
|
|
fill_systime_struct(&st[0], 30827, 12, 6, 31, 23, 59, 59, 999);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
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);
|
|
|
|
expect_systime(&st[0], &getSt[0]);
|
|
|
|
expect_systime(&st[1], &getSt[1]);
|
|
|
|
|
|
|
|
/* initialize st[0] to lowest possible value */
|
|
|
|
fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
|
|
|
|
/* set st[1] to highest possible value */
|
|
|
|
fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
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);
|
|
|
|
expect_systime(&st[0], &getSt[0]);
|
|
|
|
expect_systime(&st[1], &getSt[1]);
|
|
|
|
|
|
|
|
/* set st[0] to value higher than minimum */
|
|
|
|
fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
|
|
|
|
/* set st[1] to value lower than maximum */
|
|
|
|
fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
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);
|
|
|
|
expect_systime(&st[0], &getSt[0]);
|
|
|
|
expect_systime(&st[1], &getSt[1]);
|
|
|
|
|
|
|
|
ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_range_seq, "test_dtm_set_and_get_range", FALSE);
|
2010-05-30 15:19:09 +00:00
|
|
|
|
2016-06-05 18:56:37 +00:00
|
|
|
/* DTM_SETRANGE with 0 flags */
|
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, 0, (LPARAM)st);
|
|
|
|
ok(r, "got %lu\n", r);
|
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
|
|
|
ok(r == 0, "got %lu\n", r);
|
|
|
|
ok(getSt[0].wYear == 0 && getSt[1].wYear == 0, "got %u, %u\n", getSt[0].wYear, getSt[1].wYear);
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
DestroyWindow(hWnd);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* when max<min for DTM_SETRANGE, Windows seems to swap the min and max values,
|
|
|
|
although that's undocumented. However, it doesn't seem to be implemented
|
|
|
|
correctly, causing some strange side effects */
|
2010-05-30 15:19:09 +00:00
|
|
|
static void test_dtm_set_range_swap_min_max(void)
|
2007-12-01 18:29:29 +00:00
|
|
|
{
|
|
|
|
LRESULT r;
|
|
|
|
SYSTEMTIME st[2];
|
|
|
|
SYSTEMTIME getSt[2];
|
|
|
|
SYSTEMTIME origSt;
|
2010-05-30 15:19:09 +00:00
|
|
|
HWND hWnd;
|
|
|
|
|
|
|
|
hWnd = create_datetime_control(DTS_SHOWNONE);
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
2007-12-01 18:29:29 +00:00
|
|
|
|
|
|
|
fill_systime_struct(&st[0], 2007, 2, 4, 15, 2, 2, 2, 2);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st[0]);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&origSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
|
|
|
|
expect_systime(&st[0], &origSt);
|
|
|
|
|
|
|
|
/* set st[0] to value higher than st[1] */
|
|
|
|
fill_systime_struct(&st[0], 2007, 3, 2, 31, 23, 59, 59, 999);
|
|
|
|
fill_systime_struct(&st[1], 1980, 1, 3, 23, 14, 34, 37, 465);
|
|
|
|
|
|
|
|
/* since min>max, min and max values should be swapped by DTM_SETRANGE
|
|
|
|
automatically */
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
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);
|
|
|
|
todo_wine {
|
2010-05-30 15:19:09 +00:00
|
|
|
ok(compare_systime(&st[0], &getSt[0]) == 1 ||
|
|
|
|
broken(compare_systime(&st[0], &getSt[1]) == 1), /* comctl32 version <= 5.80 */
|
|
|
|
"ST1 != ST2\n");
|
|
|
|
|
|
|
|
ok(compare_systime(&st[1], &getSt[1]) == 1 ||
|
|
|
|
broken(compare_systime(&st[1], &getSt[0]) == 1), /* comctl32 version <= 5.80 */
|
|
|
|
"ST1 != ST2\n");
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st[0]);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
|
2007-12-01 18:29:29 +00:00
|
|
|
ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
|
|
|
|
/* the time part seems to not change after swapping the min and max values
|
|
|
|
and doing DTM_SETSYSTEMTIME */
|
|
|
|
expect_systime_date(&st[0], &getSt[0]);
|
|
|
|
todo_wine {
|
2010-05-30 15:19:09 +00:00
|
|
|
ok(compare_systime_time(&origSt, &getSt[0]) == 1 ||
|
|
|
|
broken(compare_systime_time(&st[0], &getSt[0]) == 1), /* comctl32 version <= 5.80 */
|
|
|
|
"ST1.time != ST2.time\n");
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set st[0] to value higher than minimum */
|
|
|
|
fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
|
|
|
|
/* set st[1] to value lower than maximum */
|
|
|
|
fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
|
|
|
/* for some reason after we swapped the min and max values before,
|
|
|
|
whenever we do a DTM_SETRANGE, the DTM_GETRANGE will return the values
|
|
|
|
swapped*/
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
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);
|
|
|
|
todo_wine {
|
2010-05-30 15:19:09 +00:00
|
|
|
ok(compare_systime(&st[0], &getSt[1]) == 1 ||
|
|
|
|
broken(compare_systime(&st[0], &getSt[0]) == 1), /* comctl32 version <= 5.80 */
|
|
|
|
"ST1 != ST2\n");
|
|
|
|
|
|
|
|
ok(compare_systime(&st[1], &getSt[0]) == 1 ||
|
|
|
|
broken(compare_systime(&st[1], &getSt[1]) == 1), /* comctl32 version <= 5.80 */
|
|
|
|
"ST1 != ST2\n");
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set st[0] to value higher than st[1] */
|
|
|
|
fill_systime_struct(&st[0], 2007, 3, 2, 31, 23, 59, 59, 999);
|
|
|
|
fill_systime_struct(&st[1], 1980, 1, 3, 23, 14, 34, 37, 465);
|
|
|
|
|
|
|
|
/* set min>max again, so that the return values of DTM_GETRANGE are no
|
|
|
|
longer swapped the next time we do a DTM SETRANGE and DTM_GETRANGE*/
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
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);
|
|
|
|
expect_systime(&st[0], &getSt[1]);
|
|
|
|
expect_systime(&st[1], &getSt[0]);
|
|
|
|
|
|
|
|
/* initialize st[0] to lowest possible value */
|
|
|
|
fill_systime_struct(&st[0], 1601, 1, 0, 1, 0, 0, 0, 0);
|
|
|
|
/* set st[1] to highest possible value */
|
|
|
|
fill_systime_struct(&st[1], 30827, 12, 6, 31, 23, 59, 59, 999);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
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);
|
|
|
|
expect_systime(&st[0], &getSt[0]);
|
|
|
|
expect_systime(&st[1], &getSt[1]);
|
|
|
|
|
|
|
|
ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_range_swap_min_max_seq, "test_dtm_set_range_swap_min_max", FALSE);
|
2010-05-30 15:19:09 +00:00
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
static void test_dtm_set_and_get_system_time(void)
|
2007-12-01 18:29:29 +00:00
|
|
|
{
|
|
|
|
LRESULT r;
|
2010-05-30 15:19:09 +00:00
|
|
|
SYSTEMTIME st, getSt, ref;
|
|
|
|
HWND hWnd, hWndDateTime_test_gdt_none;
|
2007-12-01 18:29:29 +00:00
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
hWndDateTime_test_gdt_none = create_datetime_control(0);
|
2007-12-01 18:29:29 +00:00
|
|
|
|
|
|
|
ok(hWndDateTime_test_gdt_none!=NULL, "Expected non NULL, got %p\n", hWndDateTime_test_gdt_none);
|
|
|
|
if(hWndDateTime_test_gdt_none) {
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWndDateTime_test_gdt_none, DTM_SETSYSTEMTIME, GDT_NONE, (LPARAM)&st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(0, r);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
skip("hWndDateTime_test_gdt_none is NULL\n");
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow(hWndDateTime_test_gdt_none);
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
hWnd = create_datetime_control(DTS_SHOWNONE);
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_NONE, (LPARAM)&st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
ok(r == GDT_NONE, "Expected %d, not %d(GDT_VALID) or %d(GDT_ERROR), got %ld\n", GDT_NONE, GDT_VALID, GDT_ERROR, r);
|
|
|
|
|
|
|
|
/* set st to lowest possible value */
|
|
|
|
fill_systime_struct(&st, 1601, 1, 0, 1, 0, 0, 0, 0);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
|
|
|
|
|
|
|
/* set st to highest possible value */
|
|
|
|
fill_systime_struct(&st, 30827, 12, 6, 31, 23, 59, 59, 999);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
|
|
|
|
|
|
|
/* set st to value between min and max */
|
|
|
|
fill_systime_struct(&st, 1980, 1, 3, 23, 14, 34, 37, 465);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2007-12-01 18:29:29 +00:00
|
|
|
ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
|
|
|
|
expect_systime(&st, &getSt);
|
|
|
|
|
|
|
|
/* set st to invalid value */
|
|
|
|
fill_systime_struct(&st, 0, 0, 7, 0, 24, 60, 60, 1000);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2007-12-01 18:29:29 +00:00
|
|
|
expect_unsuccess(0, r);
|
|
|
|
|
|
|
|
ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_system_time_seq, "test_dtm_set_and_get_system_time", FALSE);
|
2010-05-30 15:19:09 +00:00
|
|
|
|
|
|
|
/* set to some valid value */
|
|
|
|
GetSystemTime(&ref);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&ref);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
|
|
|
|
|
|
|
/* year invalid */
|
|
|
|
st = ref;
|
|
|
|
st.wYear = 0;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2010-05-30 15:19:09 +00:00
|
|
|
todo_wine expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
|
|
|
/* month invalid */
|
|
|
|
st = ref;
|
|
|
|
st.wMonth = 13;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(0, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
|
|
|
/* day invalid */
|
|
|
|
st = ref;
|
|
|
|
st.wDay = 32;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(0, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
2012-01-26 15:19:24 +00:00
|
|
|
/* day invalid for current month */
|
|
|
|
st = ref;
|
|
|
|
st.wDay = 30;
|
|
|
|
st.wMonth = 2;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2012-01-26 15:19:24 +00:00
|
|
|
expect(0, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2012-01-26 15:19:24 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
/* day of week isn't validated */
|
|
|
|
st = ref;
|
|
|
|
st.wDayOfWeek = 10;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
|
|
|
/* hour invalid */
|
|
|
|
st = ref;
|
|
|
|
st.wHour = 25;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(0, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
|
|
|
/* minute invalid */
|
|
|
|
st = ref;
|
|
|
|
st.wMinute = 60;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(0, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
|
|
|
/* sec invalid */
|
|
|
|
st = ref;
|
|
|
|
st.wSecond = 60;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(0, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
|
|
|
/* msec invalid */
|
|
|
|
st = ref;
|
|
|
|
st.wMilliseconds = 1000;
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(0, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
expect_systime(&ref, &getSt);
|
|
|
|
|
|
|
|
/* day of week should be calculated automatically,
|
|
|
|
actual day of week for this date is 4 */
|
|
|
|
fill_systime_struct(&st, 2009, 10, 1, 1, 0, 0, 10, 200);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt);
|
2010-05-30 15:19:09 +00:00
|
|
|
expect(GDT_VALID, r);
|
|
|
|
/* 01.10.2009 is Thursday */
|
|
|
|
expect(4, (LRESULT)getSt.wDayOfWeek);
|
|
|
|
st.wDayOfWeek = 4;
|
|
|
|
expect_systime(&st, &getSt);
|
2012-12-14 23:24:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_dtm_set_and_get_systemtime_with_limits(void)
|
|
|
|
{
|
|
|
|
LRESULT r;
|
|
|
|
SYSTEMTIME st[2], getSt[2], refSt;
|
|
|
|
HWND hWnd;
|
|
|
|
|
|
|
|
hWnd = create_datetime_control(DTS_SHOWNONE);
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
/* set range */
|
|
|
|
fill_systime_struct(&st[0], 1980, 1, 3, 23, 14, 34, 37, 465);
|
|
|
|
fill_systime_struct(&st[1], 2007, 3, 2, 31, 23, 59, 59, 999);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st);
|
2012-12-14 23:24:10 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETRANGE, 0, (LPARAM)getSt);
|
2012-12-14 23:24:10 +00:00
|
|
|
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);
|
|
|
|
expect_systime(&st[0], &getSt[0]);
|
|
|
|
expect_systime(&st[1], &getSt[1]);
|
|
|
|
|
|
|
|
/* Initially set a valid time */
|
|
|
|
fill_systime_struct(&refSt, 1999, 9, 4, 9, 19, 9, 9, 999);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&refSt);
|
2012-12-14 23:24:10 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
|
2012-12-14 23:24:10 +00:00
|
|
|
ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
|
|
|
|
expect_systime(&refSt, &getSt[0]);
|
|
|
|
|
|
|
|
/* Now set an out-of-bounds time */
|
|
|
|
fill_systime_struct(&st[0], 2010, 1, 0, 1, 0, 0, 0, 0);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st[0]);
|
2012-12-14 23:24:10 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
|
2012-12-14 23:24:10 +00:00
|
|
|
ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
|
|
|
|
expect_systime(&refSt, &getSt[0]);
|
|
|
|
|
|
|
|
fill_systime_struct(&st[0], 1977, 1, 0, 1, 0, 0, 0, 0);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st[0]);
|
2012-12-14 23:24:10 +00:00
|
|
|
expect(1, r);
|
2014-04-22 14:05:48 +00:00
|
|
|
r = SendMessageA(hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&getSt[0]);
|
2012-12-14 23:24:10 +00:00
|
|
|
ok(r == GDT_VALID, "Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld\n", GDT_VALID, GDT_NONE, GDT_ERROR, r);
|
|
|
|
expect_systime(&refSt, &getSt[0]);
|
|
|
|
|
|
|
|
ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_systime_with_limits, "test_dtm_set_and_get_systime_with_limits", FALSE);
|
2010-05-30 15:19:09 +00:00
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
static void test_wm_set_get_text(void)
|
2007-12-01 18:29:29 +00:00
|
|
|
{
|
2010-05-30 15:19:09 +00:00
|
|
|
static const CHAR a_str[] = "a";
|
2012-01-26 15:19:24 +00:00
|
|
|
CHAR buff[16], time[16], caltype[3];
|
2010-05-30 15:19:09 +00:00
|
|
|
HWND hWnd;
|
|
|
|
LRESULT ret;
|
|
|
|
|
|
|
|
hWnd = create_datetime_control(0);
|
|
|
|
|
2014-04-22 14:05:48 +00:00
|
|
|
ret = SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)a_str);
|
2010-05-30 15:19:09 +00:00
|
|
|
ok(CB_ERR == ret ||
|
|
|
|
broken(0 == ret) || /* comctl32 <= 4.72 */
|
|
|
|
broken(1 == ret), /* comctl32 <= 4.70 */
|
|
|
|
"Expected CB_ERR, got %ld\n", ret);
|
|
|
|
|
|
|
|
buff[0] = 0;
|
2014-04-22 14:05:48 +00:00
|
|
|
ret = SendMessageA(hWnd, WM_GETTEXT, sizeof(buff), (LPARAM)buff);
|
2012-01-26 15:19:24 +00:00
|
|
|
ok(strcmp(buff, a_str) != 0, "Expected text to change, got %s\n", buff);
|
|
|
|
ok(ret != 0, "Expected non-zero return value\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, caltype, 3);
|
|
|
|
if (ret == 0)
|
|
|
|
skip("Must know local calendar type (%x)\n", GetLastError());
|
|
|
|
else if (atoi(caltype) != CAL_GREGORIAN)
|
|
|
|
skip("DateTimePicker Control only supports Gregorian calendar (type: %s)\n", caltype);
|
|
|
|
else {
|
|
|
|
SetLastError(0xdeadbeef);
|
2014-04-22 14:05:48 +00:00
|
|
|
ret = GetDateFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, time, sizeof(time));
|
2012-01-26 15:19:24 +00:00
|
|
|
if (ret == 0)
|
|
|
|
skip("GetDateFormat failed, returned %ld, error %d\n", ret, GetLastError());
|
|
|
|
else
|
|
|
|
ok(!strcmp(buff, time), "Expected %s, got %s\n", time, buff);
|
|
|
|
}
|
2010-05-30 15:19:09 +00:00
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_dts_shownone(void)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
DWORD style;
|
|
|
|
|
|
|
|
/* it isn't allowed to change DTS_SHOWNONE after creation */
|
|
|
|
hwnd = create_datetime_control(0);
|
2014-04-22 14:05:48 +00:00
|
|
|
style = GetWindowLongA(hwnd, GWL_STYLE);
|
|
|
|
SetWindowLongA(hwnd, GWL_STYLE, style | DTS_SHOWNONE);
|
|
|
|
style = GetWindowLongA(hwnd, GWL_STYLE);
|
2010-05-30 15:19:09 +00:00
|
|
|
ok(!(style & DTS_SHOWNONE), "Expected DTS_SHOWNONE not to be set\n");
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
hwnd = create_datetime_control(DTS_SHOWNONE);
|
2014-04-22 14:05:48 +00:00
|
|
|
style = GetWindowLongA(hwnd, GWL_STYLE);
|
|
|
|
SetWindowLongA(hwnd, GWL_STYLE, style & ~DTS_SHOWNONE);
|
|
|
|
style = GetWindowLongA(hwnd, GWL_STYLE);
|
2010-05-30 15:19:09 +00:00
|
|
|
ok(style & DTS_SHOWNONE, "Expected DTS_SHOWNONE to be set\n");
|
|
|
|
DestroyWindow(hwnd);
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(datetime)
|
|
|
|
{
|
2008-04-04 16:43:16 +00:00
|
|
|
HMODULE hComctl32;
|
|
|
|
BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
|
|
|
|
INITCOMMONCONTROLSEX iccex;
|
|
|
|
|
|
|
|
hComctl32 = GetModuleHandleA("comctl32.dll");
|
|
|
|
pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
|
|
|
|
if (!pInitCommonControlsEx)
|
|
|
|
{
|
|
|
|
skip("InitCommonControlsEx() is missing. Skipping the tests\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
iccex.dwSize = sizeof(iccex);
|
|
|
|
iccex.dwICC = ICC_DATE_CLASSES;
|
|
|
|
pInitCommonControlsEx(&iccex);
|
|
|
|
|
2007-12-01 18:29:29 +00:00
|
|
|
init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2010-05-30 15:19:09 +00:00
|
|
|
test_dtm_set_format();
|
|
|
|
test_dtm_set_and_get_mccolor();
|
|
|
|
test_dtm_set_and_get_mcfont();
|
|
|
|
test_dtm_get_monthcal();
|
|
|
|
test_dtm_set_and_get_range();
|
|
|
|
test_dtm_set_range_swap_min_max();
|
|
|
|
test_dtm_set_and_get_system_time();
|
2012-12-14 23:24:10 +00:00
|
|
|
test_dtm_set_and_get_systemtime_with_limits();
|
2010-05-30 15:19:09 +00:00
|
|
|
test_wm_set_get_text();
|
|
|
|
test_dts_shownone();
|
2007-12-01 18:29:29 +00:00
|
|
|
}
|