Revert "winex11.drv: Optimise getting the bits of a DIB after calling SetDIBits."
[wine] / dlls / rasapi32 / tests / rasapi.c
1 /*
2 * Unit test suite for rasapi32 functions
3 *
4 * Copyright 2008 Austin English
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <wine/test.h>
24 #include <windef.h>
25 #include <winbase.h>
26 #include "ras.h"
27
28 static HMODULE hmodule;
29 static DWORD (WINAPI *pRasEnumDevicesA)(LPRASDEVINFOA, LPDWORD, LPDWORD);
30
31 #define RASAPI32_GET_PROC(func) \
32     p ## func = (void*)GetProcAddress(hmodule, #func); \
33     if(!p ## func) \
34         trace("GetProcAddress(%s) failed\n", #func);
35
36 static void InitFunctionPtrs(void)
37 {
38     hmodule = LoadLibraryA("rasapi32.dll");
39
40     RASAPI32_GET_PROC(RasEnumDevicesA)
41 }
42
43 static void test_rasenum(void)
44 {
45     DWORD result;
46     DWORD cDevices = 0;
47     DWORD cb = 0;
48     RASDEVINFOA rasDevInfo;
49     rasDevInfo.dwSize = sizeof(rasDevInfo);
50
51     if(!pRasEnumDevicesA) {
52         win_skip("Skipping RasEnumDevicesA tests, function not present\n");
53         return;
54     }
55
56     /* test first parameter */
57     result = pRasEnumDevicesA(NULL, &cb, &cDevices);
58     trace("RasEnumDevicesA: buffersize %d\n", cb);
59     ok(result == ERROR_BUFFER_TOO_SMALL,
60     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
61
62     cb = sizeof(rasDevInfo);
63     result = pRasEnumDevicesA(NULL, &cb, &cDevices);
64     ok(result == ERROR_BUFFER_TOO_SMALL,
65     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
66
67     rasDevInfo.dwSize = 0;
68     result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
69     todo_wine
70     ok(result == ERROR_INVALID_SIZE,
71     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
72
73     rasDevInfo.dwSize = sizeof(rasDevInfo) -1;
74     result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
75     todo_wine
76     ok(result == ERROR_INVALID_SIZE,
77     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
78
79     rasDevInfo.dwSize = sizeof(rasDevInfo) +1;
80     result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
81     todo_wine
82     ok(result == ERROR_INVALID_SIZE,
83     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
84
85     /* test second parameter */
86     rasDevInfo.dwSize = sizeof(rasDevInfo);
87     result = pRasEnumDevicesA(&rasDevInfo, NULL, &cDevices);
88     ok(result == ERROR_INVALID_PARAMETER,
89     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
90
91     cb = 0;
92     result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
93     ok(result == ERROR_BUFFER_TOO_SMALL,
94     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
95
96     cb = sizeof(rasDevInfo) -1;
97     result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
98     ok(result == ERROR_BUFFER_TOO_SMALL,
99     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
100
101     cb = sizeof(rasDevInfo) +1;
102     result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
103     todo_wine
104     ok(result == ERROR_BUFFER_TOO_SMALL,
105     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
106
107     /* test third parameter */
108     cb = sizeof(rasDevInfo);
109     result = pRasEnumDevicesA(&rasDevInfo, &cb, NULL);
110     ok(result == ERROR_INVALID_PARAMETER,
111     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
112
113     /* test combinations of invalid parameters */
114     result = pRasEnumDevicesA(NULL, NULL, &cDevices);
115     ok(result == ERROR_INVALID_PARAMETER,
116     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
117
118     result = pRasEnumDevicesA(NULL, &cb, NULL);
119     ok(result == ERROR_INVALID_PARAMETER,
120     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
121
122     cb = 0;
123     rasDevInfo.dwSize = 0;
124     result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
125     todo_wine
126     ok(result == ERROR_INVALID_SIZE,
127     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
128 }
129
130 START_TEST(rasapi)
131 {
132     InitFunctionPtrs();
133
134     test_rasenum();
135 }