USER: unit test functions for timer functions
Mike McCormack
mike at codeweavers.com
Sat Nov 13 04:14:27 CST 2004
The previous patch should be applied to make this test pass.
Mike
ChangeLog:
* unit test functions for timer functions
-------------- next part --------------
Index: dlls/user/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/Makefile.in,v
retrieving revision 1.12
diff -u -r1.12 Makefile.in
--- dlls/user/tests/Makefile.in 8 Nov 2004 22:10:05 -0000 1.12
+++ dlls/user/tests/Makefile.in 13 Nov 2004 09:57:36 -0000
@@ -18,6 +18,7 @@
resource.c \
sysparams.c \
text.c \
+ timer.c \
win.c \
wsprintf.c
--- /dev/null 1994-07-18 08:46:18.000000000 +0900
+++ dlls/user/tests/timer.c 2004-11-13 19:10:45.000000000 +0900
@@ -0,0 +1,102 @@
+/* Unit test for Timer functions
+ *
+ * Copyright 2004 Mike McCormack
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "wine/test.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "wingdi.h"
+#include "winuser.h"
+
+typedef struct _thread_info
+{
+ HWND hWnd;
+ HANDLE handles[2];
+ DWORD id;
+} thread_info;
+
+VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT id, DWORD dwTime)
+{
+}
+
+#define TIMER_ID 0x19
+
+DWORD WINAPI thread_proc(LPVOID x)
+{
+ thread_info *info = x;
+ DWORD r;
+
+ r = KillTimer(info->hWnd, 0x19);
+ ok(r,"KillTimer failed in thread\n");
+ r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
+ ok(r,"SetTimer failed in thread\n");
+ ok(r==TIMER_ID,"SetTimer id different\n");
+ r = SetEvent(info->handles[0]);
+ ok(r,"SetEvent failed in thread\n");
+ return 0;
+}
+
+int test_timer_thread(void)
+{
+ WNDCLASS cls;
+ char className[] = "timertestclass";
+ char winName[] = "timer window";
+ thread_info info;
+ DWORD id;
+
+ cls.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
+ cls.lpfnWndProc = DefWindowProc;
+ cls.cbClsExtra = 0;
+ cls.cbWndExtra = 4;
+ cls.hInstance = 0;
+ cls.hIcon = LoadIcon (0, IDI_APPLICATION);
+ cls.hCursor = LoadCursor (0, IDC_ARROW);
+ cls.hbrBackground = GetStockObject (WHITE_BRUSH);
+ cls.lpszMenuName = 0;
+ cls.lpszClassName = className;
+
+ ok(RegisterClass (&cls), "register class failed\n");
+
+ /* Setup windows */
+ info.hWnd = CreateWindow (className, winName,
+ WS_OVERLAPPEDWINDOW ,
+ CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
+ NULL, NULL, 0);
+
+ info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
+ ok(info.id, "SetTimer failed");
+ ok(info.id==TIMER_ID, "SetTimer timer ID different");
+ info.handles[0] = CreateEvent(NULL,0,0,NULL);
+ info.handles[1] = CreateThread(NULL,0,thread_proc,&info,0,&id);
+
+ WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
+
+ WaitForSingleObject(info.handles[1], INFINITE);
+
+ ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
+
+ ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
+ ok(UnregisterClass(className,NULL), "failed to unregister class\n");
+ return 0;
+}
+
+
+START_TEST(timer)
+{
+ test_timer_thread();
+}
More information about the wine-patches
mailing list