Added a few more Unicode digits from Unicode version 4.1.
[wine] / dlls / user / tests / monitor.c
1 /*
2  * Unit tests for monitor APIs
3  *
4  * Copyright 2005 Huw Davies
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "wine/test.h"
22 #include "winbase.h"
23 #include "wingdi.h"
24 #include "winuser.h"
25
26 static HMODULE hdll;
27 static BOOL (WINAPI *pEnumDisplayDevicesA)(LPCSTR,DWORD,LPDISPLAY_DEVICEA,DWORD);
28 static BOOL (WINAPI *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
29 static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
30
31 static void init_function_pointers(void)
32 {
33     hdll = GetModuleHandleA("user32.dll");
34
35     if(hdll)
36     {
37        pEnumDisplayDevicesA = (void*)GetProcAddress(hdll, "EnumDisplayDevicesA");
38        pEnumDisplayMonitors = (void*)GetProcAddress(hdll, "EnumDisplayMonitors");
39        pGetMonitorInfoA = (void*)GetProcAddress(hdll, "GetMonitorInfoA");
40     }
41 }
42
43 static BOOL CALLBACK monitor_enum_proc(HMONITOR hmon, HDC hdc, LPRECT lprc,
44                                        LPARAM lparam)
45 {
46     MONITORINFOEXA mi;
47     char *primary = (char *)lparam;
48
49     mi.cbSize = sizeof(mi);
50
51     ok(pGetMonitorInfoA(hmon, (MONITORINFO*)&mi), "GetMonitorInfo failed\n");
52     if(mi.dwFlags == MONITORINFOF_PRIMARY)
53         strcpy(primary, mi.szDevice);
54
55     return TRUE;
56 }
57
58 static void test_enumdisplaydevices(void)
59 {
60     DISPLAY_DEVICEA dd;
61     char primary_device_name[32];
62     char primary_monitor_device_name[32];
63     DWORD primary_num = -1, num = 0;
64
65     dd.cb = sizeof(dd);
66     if(pEnumDisplayDevicesA == NULL) return;
67     while(1)
68     {
69         BOOL ret;
70         ret = pEnumDisplayDevicesA(NULL, num, &dd, 0);
71         ok(ret || num != 0, "EnumDisplayDevices fails with num == 0\n");
72         if(!ret) break;
73         if(dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
74         {
75             strcpy(primary_device_name, dd.DeviceName);
76             primary_num = num;
77         }
78         num++;
79     }
80     ok(primary_num != -1, "Didn't get the primary device\n");
81
82     if(pEnumDisplayMonitors && pGetMonitorInfoA) {
83         ok(pEnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name),
84            "EnumDisplayMonitors failed\n");
85
86         ok(!strcmp(primary_monitor_device_name, primary_device_name),
87            "monitor device name %s, device name %s\n", primary_monitor_device_name,
88            primary_device_name);
89     }
90 }
91
92
93 START_TEST(monitor)
94 {
95     init_function_pointers();
96     test_enumdisplaydevices();
97 }