mshtml: Added IHTMLElement::get_offsetHeight implementation.
[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 #include "raserror.h"
28
29 static HMODULE hmodule;
30 static DWORD (WINAPI *pRasEnumDevicesA)(LPRASDEVINFOA, LPDWORD, LPDWORD);
31
32 #define RASAPI32_GET_PROC(func) \
33     p ## func = (void*)GetProcAddress(hmodule, #func); \
34     if(!p ## func) \
35         trace("GetProcAddress(%s) failed\n", #func);
36
37 static void InitFunctionPtrs(void)
38 {
39     hmodule = LoadLibraryA("rasapi32.dll");
40
41     RASAPI32_GET_PROC(RasEnumDevicesA)
42 }
43
44 static void test_rasenum(void)
45 {
46     DWORD result;
47     DWORD cDevices = 0;
48     DWORD bufsize = 0, cb = 0;
49     LPRASDEVINFOA rasDevInfo;
50
51     if(!pRasEnumDevicesA) {
52         win_skip("Skipping RasEnumDevicesA tests, function not present\n");
53         return;
54     }
55
56     /* create the return buffer */
57     result = pRasEnumDevicesA(NULL, &bufsize, &cDevices);
58     if(ERROR_RASMAN_CANNOT_INITIALIZE == result) {
59         win_skip("RAS configuration problem\n");
60         return;
61     }
62     trace("RasEnumDevicesA: returned %d buffersize %d\n", result, cb);
63     ok(result == ERROR_BUFFER_TOO_SMALL,
64     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
65
66     rasDevInfo = (LPRASDEVINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
67                                           max(bufsize,sizeof(RASDEVINFOA)));
68     if(!rasDevInfo) {
69         win_skip("failed to allocate buffer for RasEnumDevicesA tests\n");
70         return;
71     }
72
73     /* test first parameter */
74     cb = bufsize;
75     result = pRasEnumDevicesA(NULL, &cb, &cDevices);
76     ok(result == ERROR_BUFFER_TOO_SMALL,
77     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
78
79     rasDevInfo[0].dwSize = 0;
80     cb = bufsize;
81     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
82     todo_wine
83     ok(result == ERROR_INVALID_SIZE,
84     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
85
86     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) -1;
87     cb = bufsize;
88     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
89     todo_wine
90     ok(result == ERROR_INVALID_SIZE,
91     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
92
93     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) +1;
94     cb = bufsize;
95     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
96     todo_wine
97     ok(result == ERROR_INVALID_SIZE,
98     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
99
100     /* test second parameter */
101     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
102     result = pRasEnumDevicesA(rasDevInfo, NULL, &cDevices);
103     ok(result == ERROR_INVALID_PARAMETER,
104     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
105
106     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
107     cb = 0;
108     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
109     ok(result == ERROR_BUFFER_TOO_SMALL,
110     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
111
112     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
113     cb = bufsize -1;
114     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
115     ok(result == ERROR_BUFFER_TOO_SMALL,
116     "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
117
118     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
119     cb = bufsize +1;
120     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
121     ok(result == ERROR_SUCCESS,
122     "Expected ERROR_SUCCESS, got %08d\n", result);
123
124     /* test third parameter */
125     rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
126     cb = bufsize;
127     result = pRasEnumDevicesA(rasDevInfo, &cb, NULL);
128     ok(result == ERROR_INVALID_PARAMETER,
129     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
130
131     /* test combinations of invalid parameters */
132     result = pRasEnumDevicesA(NULL, NULL, &cDevices);
133     ok(result == ERROR_INVALID_PARAMETER,
134     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
135
136     result = pRasEnumDevicesA(NULL, &cb, NULL);
137     ok(result == ERROR_INVALID_PARAMETER,
138     "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
139
140     cb = 0;
141     rasDevInfo[0].dwSize = 0;
142     result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
143     todo_wine
144     ok(result == ERROR_INVALID_SIZE,
145     "Expected ERROR_INVALID_SIZE, got %08d\n", result);
146
147     HeapFree(GetProcessHeap(), 0, rasDevInfo);
148 }
149
150 START_TEST(rasapi)
151 {
152     InitFunctionPtrs();
153
154     test_rasenum();
155 }