Add a test for some edit control behaviours, make it pass under Wine.
[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 *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
28 static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
29
30 static void init_function_pointers(void)
31 {
32     hdll = GetModuleHandleA("user32.dll");
33
34     if(hdll)
35     {
36        pEnumDisplayMonitors = (void*)GetProcAddress(hdll, "EnumDisplayMonitors");
37        pGetMonitorInfoA = (void*)GetProcAddress(hdll, "GetMonitorInfoA");
38     }
39 }
40
41 static BOOL CALLBACK monitor_enum_proc(HMONITOR hmon, HDC hdc, LPRECT lprc,
42                                        LPARAM lparam)
43 {
44     MONITORINFOEXA mi;
45     char *primary = (char *)lparam;
46
47     mi.cbSize = sizeof(mi);
48
49     ok(pGetMonitorInfoA(hmon, (MONITORINFO*)&mi), "GetMonitorInfo failed\n");
50     if(mi.dwFlags == MONITORINFOF_PRIMARY)
51         strcpy(primary, mi.szDevice);
52
53     return TRUE;
54 }
55
56 static void test_enumdisplaydevices(void)
57 {
58     DISPLAY_DEVICEA dd;
59     char primary_device_name[32];
60     char primary_monitor_device_name[32];
61     DWORD primary_num = -1, num = 0;
62
63     dd.cb = sizeof(dd);
64     while(1)
65     {
66         BOOL ret;
67         ret = EnumDisplayDevicesA(NULL, num, &dd, 0), "EnumDisplayDevices fails\n";
68         ok(ret || num != 0, "EnumDisplayDevices fails with num == 0\n");
69         if(!ret) break;
70         if(dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
71         {
72             strcpy(primary_device_name, dd.DeviceName);
73             primary_num = num;
74         }
75         num++;
76     }
77     ok(primary_num != -1, "Didn't get the primary device\n");
78
79     if(pEnumDisplayMonitors && pGetMonitorInfoA) {
80         ok(pEnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name),
81            "EnumDisplayMonitors failed\n");
82
83         ok(!strcmp(primary_monitor_device_name, primary_device_name),
84            "monitor device name %s, device name %s\n", primary_monitor_device_name,
85            primary_device_name);
86     }
87 }
88
89
90 START_TEST(monitor)
91 {
92     init_function_pointers();
93     test_enumdisplaydevices();
94 }