Release 20050930.
[wine/gsoc-2012-control.git] / dlls / user / tests / monitor.c
blob5765ee2aae9f0fa4a2b228014d68446875ad063a
1 /*
2 * Unit tests for monitor APIs
4 * Copyright 2005 Huw Davies
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.
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.
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
21 #include "wine/test.h"
22 #include "winbase.h"
23 #include "wingdi.h"
24 #include "winuser.h"
26 static BOOL CALLBACK monitor_enum_proc(HMONITOR hmon, HDC hdc, LPRECT lprc,
27 LPARAM lparam)
29 MONITORINFOEXA mi;
30 char *primary = (char *)lparam;
32 mi.cbSize = sizeof(mi);
34 ok(GetMonitorInfoA(hmon, (MONITORINFO*)&mi), "GetMonitorInfo failed\n");
35 if(mi.dwFlags == MONITORINFOF_PRIMARY)
36 strcpy(primary, mi.szDevice);
38 return TRUE;
41 static void test_enumdisplaydevices(void)
43 DISPLAY_DEVICEA dd;
44 char primary_device_name[32];
45 char primary_monitor_device_name[32];
46 DWORD primary_num = -1, num = 0;
48 dd.cb = sizeof(dd);
49 while(1)
51 BOOL ret;
52 ret = EnumDisplayDevicesA(NULL, num, &dd, 0), "EnumDisplayDevices fails\n";
53 ok(ret || num != 0, "EnumDisplayDevices fails with num == 0\n");
54 if(!ret) break;
55 if(dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
57 strcpy(primary_device_name, dd.DeviceName);
58 primary_num = num;
60 num++;
62 ok(primary_num != -1, "Didn't get the primary device\n");
64 ok(EnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name),
65 "EnumDisplayMonitors failed\n");
67 ok(!strcmp(primary_monitor_device_name, primary_device_name),
68 "monitor device name %s, device name %s\n", primary_monitor_device_name,
69 primary_device_name);
74 START_TEST(monitor)
76 test_enumdisplaydevices();