msi: Set all folders' source paths to the root directory if the source type is compre...
[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 bufsize = 0, cb = 0;
48     LPRASDEVINFOA rasDevInfo;
49
50     if(!pRasEnumDevicesA) {
51         win_skip("Skipping RasEnumDevicesA tests, function not present\n");
52         return;
53     }
54
55     /* create the return buffer */
56     result = pRasEnumDevicesA(NULL, &bufsize, &cDevices);
57     trace("RasEnumDevicesA: buffersize %d\n", cb);
58     ok(result == ERROR_BUFFER_TOO_SMALL,
59     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
60
61     rasDevInfo = (LPRASDEVINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
62                                           max(bufsize,sizeof(RASDEVINFOA)));
63     if(!rasDevInfo) {
64         win_skip("failed to allocate buffer for RasEnumDevicesA tests\n");
65         return;
66     }
67
68     /* test first parameter */
69     cb = bufsize;
70     result = pRasEnumDevicesA(NULL, &cb, &cDevices);
71     ok(result == ERROR_BUFFER_TOO_SMALL,
72     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
73
74     rasDevInfo[0].dwSize = 0;
75     cb = bufsize;
76     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
77     todo_wine
78     ok(result == ERROR_INVALID_SIZE,
79     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
80
81     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) -1;
82     cb = bufsize;
83     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
84     todo_wine
85     ok(result == ERROR_INVALID_SIZE,
86     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
87
88     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) +1;
89     cb = bufsize;
90     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
91     todo_wine
92     ok(result == ERROR_INVALID_SIZE,
93     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
94
95     /* test second parameter */
96     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
97     result = pRasEnumDevicesA(rasDevInfo, NULL, &cDevices);
98     ok(result == ERROR_INVALID_PARAMETER,
99     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
100
101     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
102     cb = 0;
103     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
104     ok(result == ERROR_BUFFER_TOO_SMALL,
105     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
106
107     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
108     cb = bufsize -1;
109     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
110     ok(result == ERROR_BUFFER_TOO_SMALL,
111     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
112
113     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
114     cb = bufsize +1;
115     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
116     ok(result == ERROR_SUCCESS,
117     "Expected ERROR_SUCCESS, got %08d\n", result);
118
119     /* test third parameter */
120     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
121     cb = bufsize;
122     result = pRasEnumDevicesA(rasDevInfo, &cb, NULL);
123     ok(result == ERROR_INVALID_PARAMETER,
124     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
125
126     /* test combinations of invalid parameters */
127     result = pRasEnumDevicesA(NULL, NULL, &cDevices);
128     ok(result == ERROR_INVALID_PARAMETER,
129     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
130
131     result = pRasEnumDevicesA(NULL, &cb, NULL);
132     ok(result == ERROR_INVALID_PARAMETER,
133     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
134
135     cb = 0;
136     rasDevInfo[0].dwSize = 0;
137     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
138     todo_wine
139     ok(result == ERROR_INVALID_SIZE,
140     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
141
142     HeapFree(GetProcessHeap(), 0, rasDevInfo);
143 }
144
145 START_TEST(rasapi)
146 {
147     InitFunctionPtrs();
148
149     test_rasenum();
150 }