https://git.reactos.org/?p=reactos.git;a=commitdiff;h=249d55f4a05cd6ffd87641...
commit 249d55f4a05cd6ffd87641ddb6dc52b948834285 Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Wed Jan 16 15:37:14 2019 +0200 Commit: Giannis Adamopoulos gadamopoulos@reactos.org CommitDate: Wed Jan 16 22:59:35 2019 +0200
[USER32_APITEST] Add tests for GetMessageTime --- modules/rostests/apitests/user32/CMakeLists.txt | 1 + modules/rostests/apitests/user32/MessageTime.c | 97 +++++++++++++++++++++++++ modules/rostests/apitests/user32/testlist.c | 2 + 3 files changed, 100 insertions(+)
diff --git a/modules/rostests/apitests/user32/CMakeLists.txt b/modules/rostests/apitests/user32/CMakeLists.txt index 87a257ec81..6ff84272f5 100644 --- a/modules/rostests/apitests/user32/CMakeLists.txt +++ b/modules/rostests/apitests/user32/CMakeLists.txt @@ -22,6 +22,7 @@ list(APPEND SOURCE InitializeLpkHooks.c LoadImage.c LookupIconIdFromDirectoryEx.c + MessageTime.c NextDlgItem.c PrivateExtractIcons.c RealGetWindowClass.c diff --git a/modules/rostests/apitests/user32/MessageTime.c b/modules/rostests/apitests/user32/MessageTime.c new file mode 100644 index 0000000000..ba3a600db1 --- /dev/null +++ b/modules/rostests/apitests/user32/MessageTime.c @@ -0,0 +1,97 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for message times + * PROGRAMMERS: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com + */ + +#include "precomp.h" + +#define TIMER_ID 999 +#define TIMER_INTERVAL 500 /* 500 milliseconds */ + +static INT s_nCount = 0; +static LONG s_nMsgTime = 0; + +static LRESULT CALLBACK +WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_CREATE: + s_nCount = 0; + s_nMsgTime = GetMessageTime(); + SetTimer(hwnd, TIMER_ID, TIMER_INTERVAL, NULL); + break; + case WM_TIMER: + if (s_nCount != 0) + { + ok(GetMessageTime() - s_nMsgTime >= TIMER_INTERVAL / 2, + "message time is wrong\n"); + } + s_nMsgTime = GetMessageTime(); + ok(s_nMsgTime != 0, "message time was zero.\n"); + s_nCount++; + if (s_nCount >= 5) + { + KillTimer(hwnd, TIMER_ID); + DestroyWindow(hwnd); + } + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProcW(hwnd, uMsg, wParam, lParam); + } + return 0; +} + +START_TEST(MessageTime) +{ + static const WCHAR s_szName[] = L"MessageTimeTestWindow"; + WNDCLASSW wc; + ATOM atom; + HWND hwnd; + MSG msg; + BOOL bRet; + + ZeroMemory(&wc, sizeof(wc)); + wc.lpfnWndProc = WindowProc; + wc.hInstance = GetModuleHandleW(NULL); + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); + wc.lpszClassName = s_szName; + atom = RegisterClassW(&wc); + ok(atom != 0, "RegisterClassW\n"); + + hwnd = CreateWindowW(s_szName, s_szName, + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, + CW_USEDEFAULT, 0, + NULL, NULL, GetModuleHandleW(NULL), NULL); + ok(hwnd != NULL, "CreateWindowW\n"); + + if (hwnd) + { + ShowWindow(hwnd, SW_SHOWNORMAL); + UpdateWindow(hwnd); + + while (GetMessageW(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + } + else + { + skip("hwnd was NULL.\n"); + } + + bRet = UnregisterClassW(s_szName, GetModuleHandleW(NULL)); + ok_int(bRet, 1); + + ok_int(s_nCount, 5); + ok(s_nMsgTime != 0, "message time was zero.\n"); +} diff --git a/modules/rostests/apitests/user32/testlist.c b/modules/rostests/apitests/user32/testlist.c index c72a48ff81..d7f06b134c 100644 --- a/modules/rostests/apitests/user32/testlist.c +++ b/modules/rostests/apitests/user32/testlist.c @@ -24,6 +24,7 @@ extern void func_GetWindowPlacement(void); extern void func_InitializeLpkHooks(void); extern void func_LoadImage(void); extern void func_LookupIconIdFromDirectoryEx(void); +extern void func_MessageTime(void); extern void func_NextDlgItem(void); extern void func_PrivateExtractIcons(void); extern void func_RealGetWindowClass(void); @@ -68,6 +69,7 @@ const struct test winetest_testlist[] = { "InitializeLpkHooks", func_InitializeLpkHooks }, { "LoadImage", func_LoadImage }, { "LookupIconIdFromDirectoryEx", func_LookupIconIdFromDirectoryEx }, + { "MessageTime", func_MessageTime }, { "NextDlgItem", func_NextDlgItem }, { "PrivateExtractIcons", func_PrivateExtractIcons }, { "RealGetWindowClass", func_RealGetWindowClass },