[USER32_APITEST] Add tests for EnumDisplaySettingsA
[reactos.git] / rostests / apitests / user32 / EnumDisplaySettings.c
1 #include <apitest.h>
2
3 #include <wingdi.h>
4 #include <winuser.h>
5
6 #define SIZEOF_DEVMODEW_300_W 188
7 #define SIZEOF_DEVMODEW_400_W 212
8 #define SIZEOF_DEVMODEW_500_W 220
9
10 #define SIZEOF_DEVMODEW_300_A 124
11 #define SIZEOF_DEVMODEW_400_A 148
12 #define SIZEOF_DEVMODEW_500_A 156
13
14 START_TEST(EnumDisplaySettings)
15 {
16 DEVMODEW dmW;
17 DEVMODEA dmA;
18 HDC icDisplay;
19
20 /* TODO: test with a printer driver */
21
22 icDisplay = CreateICW(L"DISPLAY", NULL, NULL, NULL);
23 ok(icDisplay != NULL, "\n");
24
25 dmW.dmDriverExtra = 0x7777;
26
27 /* Try ridiculous size */
28 dmW.dmSize = 0x8888;
29 ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dmW), "\n");
30 ok(dmW.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmW.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
31 ok(dmW.dmSize == SIZEOF_DEVMODEW_300_W, "%d\n", dmW.dmSize);
32 ok(dmW.dmDriverExtra == 0, "%d\n", dmW.dmDriverExtra);
33
34 /* Try a tiny size */
35 dmW.dmSize = 4;
36 ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dmW), "\n");
37 ok(dmW.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmW.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
38 ok(dmW.dmSize == SIZEOF_DEVMODEW_300_W, "%d\n", dmW.dmSize);
39
40 /* Something in between */
41 dmW.dmSize = (SIZEOF_DEVMODEW_300_W + SIZEOF_DEVMODEW_400_W) / 2 ;
42 ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dmW), "\n");
43 ok(dmW.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmW.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
44 ok(dmW.dmSize == SIZEOF_DEVMODEW_300_W, "%d\n", dmW.dmSize);
45
46 /* WINVER < 0x0400 */
47 dmW.dmSize = SIZEOF_DEVMODEW_300_W;
48 ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dmW), "\n");
49 ok(dmW.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmW.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
50 ok(dmW.dmSize == SIZEOF_DEVMODEW_300_W, "%d\n", dmW.dmSize);
51
52 /* WINVER < 0x0500 */
53 dmW.dmSize = SIZEOF_DEVMODEW_400_W;
54 ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dmW), "\n");
55 ok(dmW.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmW.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
56 ok(dmW.dmSize == SIZEOF_DEVMODEW_300_W, "%d\n", dmW.dmSize);
57
58 /* "Modern" windows */
59 dmW.dmSize = SIZEOF_DEVMODEW_500_W;
60 ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dmW), "\n");
61 ok(dmW.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmW.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
62 ok(dmW.dmSize == SIZEOF_DEVMODEW_300_W, "%d\n", dmW.dmSize);
63
64 DeleteDC(icDisplay);
65
66 icDisplay = CreateICA("DISPLAY", NULL, NULL, NULL);
67 ok(icDisplay != NULL, "\n");
68
69 dmA.dmDriverExtra = 0x7777;
70
71 /* Try ridiculous size */
72 dmA.dmSize = 0x8888;
73 ok(EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA), "\n");
74 ok(dmA.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmA.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
75 ok(dmA.dmSize == SIZEOF_DEVMODEW_300_A, "%d\n", dmA.dmSize);
76 ok(dmA.dmDriverExtra == 0, "%d\n", dmA.dmDriverExtra);
77
78 /* Try a tiny size */
79 dmA.dmSize = 4;
80 ok(EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA), "\n");
81 ok(dmA.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmA.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
82 ok(dmA.dmSize == SIZEOF_DEVMODEW_300_A, "%d\n", dmA.dmSize);
83
84 /* Something in between */
85 dmA.dmSize = (SIZEOF_DEVMODEW_300_A + SIZEOF_DEVMODEW_400_A) / 2 ;
86 ok(EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA), "\n");
87 ok(dmA.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmA.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
88 ok(dmA.dmSize == SIZEOF_DEVMODEW_300_A, "%d\n", dmA.dmSize);
89
90 /* WINVER < 0x0400 */
91 dmA.dmSize = SIZEOF_DEVMODEW_300_A;
92 ok(EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA), "\n");
93 ok(dmA.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmA.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
94 ok(dmA.dmSize == SIZEOF_DEVMODEW_300_A, "%d\n", dmA.dmSize);
95
96 /* WINVER < 0x0500 */
97 dmA.dmSize = SIZEOF_DEVMODEW_400_A;
98 ok(EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA), "\n");
99 ok(dmA.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmA.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
100 ok(dmA.dmSize == SIZEOF_DEVMODEW_300_A, "%d\n", dmA.dmSize);
101
102 /* "Modern" windows */
103 dmA.dmSize = SIZEOF_DEVMODEW_500_A;
104 ok(EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA), "\n");
105 ok(dmA.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be %d.\n", dmA.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
106 ok(dmA.dmSize == SIZEOF_DEVMODEW_300_A, "%d\n", dmA.dmSize);
107
108 DeleteDC(icDisplay);
109 }