1 /* 2 * Wlanapi - tests 3 * 4 * Copyright 2009 Christoph von Wittich 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 <apitest.h> 22 23 #include <wlanapi.h> 24 25 static const GUID InterfaceGuid = {0x439b20af, 0x8955, 0x405b, {0x99, 0xf0, 0xa6, 0x2a, 0xf0, 0xc6, 0x8d, 0x43}}; 26 27 static void WlanOpenHandle_test(void) 28 { 29 DWORD ret; 30 DWORD dwNegotiatedVersion; 31 HANDLE hClientHandle; 32 33 /* correct call to determine if WlanSvc is running */ 34 ret = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, &hClientHandle); 35 if (ret == ERROR_SERVICE_EXISTS) 36 { 37 skip("Skipping wlanapi tests, WlanSvc is not running\n"); 38 return; 39 } 40 ok(ret == ERROR_SUCCESS, "WlanOpenHandle failed, error %ld\n", ret); 41 WlanCloseHandle(hClientHandle, NULL); 42 43 /* invalid pdwNegotiatedVersion */ 44 ret = WlanOpenHandle(1, NULL, NULL, &hClientHandle); 45 ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); 46 47 /* invalid hClientHandle */ 48 ret = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, NULL); 49 ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); 50 51 /* invalid pReserved */ 52 ret = WlanOpenHandle(1, (PVOID) 1, &dwNegotiatedVersion, &hClientHandle); 53 ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); 54 } 55 56 static void WlanCloseHandle_test(void) 57 { 58 DWORD ret; 59 HANDLE hClientHandle = (HANDLE)(ULONG_PTR)0xdeadbeefdeadbeef; 60 61 /* invalid pReserved */ 62 ret = WlanCloseHandle(hClientHandle, (PVOID) 1); 63 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 64 65 /* invalid hClientHandle */ 66 ret = WlanCloseHandle(NULL, NULL); 67 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 68 69 /* invalid hClientHandle */ 70 ret = WlanCloseHandle(hClientHandle, NULL); 71 ok(ret == ERROR_INVALID_HANDLE, "expected failure\n"); 72 } 73 74 static void WlanConnect_test(void) 75 { 76 DWORD ret; 77 WLAN_CONNECTION_PARAMETERS pConnectParams; 78 79 /* invalid pReserved */ 80 ret = WlanConnect((HANDLE) -1, &InterfaceGuid, &pConnectParams, (PVOID) 1); 81 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 82 83 /* invalid InterfaceGuid */ 84 ret = WlanConnect((HANDLE) -1, NULL, &pConnectParams, NULL); 85 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 86 87 /* invalid hClientHandle */ 88 ret = WlanConnect(NULL, &InterfaceGuid, &pConnectParams, NULL); 89 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 90 91 /* invalid connection parameters */ 92 ret = WlanConnect((HANDLE) -1, &InterfaceGuid, NULL, NULL); 93 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 94 } 95 96 static void WlanDisconnect_test(void) 97 { 98 DWORD ret; 99 100 /* invalid pReserved */ 101 ret = WlanDisconnect((HANDLE) -1, &InterfaceGuid, (PVOID) 1); 102 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 103 104 /* invalid InterfaceGuid */ 105 ret = WlanDisconnect((HANDLE) -1, NULL, NULL); 106 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 107 108 /* invalid hClientHandle */ 109 ret = WlanDisconnect(NULL, &InterfaceGuid, NULL); 110 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 111 } 112 113 static void WlanScan_test(void) 114 { 115 DWORD ret; 116 DOT11_SSID Ssid; 117 WLAN_RAW_DATA RawData; 118 119 /* invalid pReserved */ 120 ret = WlanScan((HANDLE) -1, &InterfaceGuid, &Ssid, &RawData, (PVOID) 1); 121 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 122 123 /* invalid InterfaceGuid */ 124 ret = WlanScan((HANDLE) -1, NULL, &Ssid, &RawData, NULL); 125 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 126 127 /* invalid hClientHandle */ 128 ret = WlanScan(NULL, &InterfaceGuid, &Ssid, &RawData, NULL); 129 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 130 } 131 132 static void WlanRenameProfile_test(void) 133 { 134 DWORD ret; 135 136 /* invalid pReserved */ 137 ret = WlanRenameProfile((HANDLE) -1, &InterfaceGuid, L"test", L"test1", (PVOID) 1); 138 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 139 140 /* invalid InterfaceGuid */ 141 ret = WlanRenameProfile((HANDLE) -1, NULL, L"test", L"test1", NULL); 142 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 143 144 /* invalid strOldProfileName */ 145 ret = WlanRenameProfile((HANDLE) -1, &InterfaceGuid, NULL, L"test1", NULL); 146 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 147 148 /* invalid strNewProfileName */ 149 ret = WlanRenameProfile((HANDLE) -1, &InterfaceGuid, L"test", NULL, NULL); 150 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 151 } 152 153 static void WlanDeleteProfile_test(void) 154 { 155 DWORD ret; 156 157 /* invalid pReserved */ 158 ret = WlanDeleteProfile((HANDLE) -1, &InterfaceGuid, L"test", (PVOID) 1); 159 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 160 161 /* invalid InterfaceGuid */ 162 ret = WlanDeleteProfile((HANDLE) -1, NULL, L"test", NULL); 163 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 164 165 /* invalid strProfileName */ 166 ret = WlanDeleteProfile((HANDLE) -1, &InterfaceGuid, NULL, NULL); 167 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 168 } 169 170 static void WlanGetProfile_test(void) 171 { 172 DWORD ret; 173 WCHAR *strProfileXml; 174 175 /* invalid pReserved */ 176 ret = WlanGetProfile((HANDLE) -1, &InterfaceGuid, L"", (PVOID) 1, &strProfileXml, NULL, NULL); 177 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 178 179 /* invalid InterfaceGuid */ 180 ret = WlanGetProfile((HANDLE) -1, NULL, L"test", NULL, &strProfileXml, NULL, NULL); 181 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 182 183 /* invalid pstrProfileXml */ 184 ret = WlanGetProfile((HANDLE) -1, &InterfaceGuid, L"test", NULL, NULL, NULL, NULL); 185 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 186 } 187 188 static void WlanEnumInterfaces_test(void) 189 { 190 DWORD ret; 191 PWLAN_INTERFACE_INFO_LIST pInterfaceList; 192 193 /* invalid pReserved */ 194 ret = WlanEnumInterfaces((HANDLE) -1, (PVOID) 1, &pInterfaceList); 195 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 196 197 /* invalid pInterfaceList */ 198 ret = WlanEnumInterfaces((HANDLE) -1, NULL, NULL); 199 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 200 } 201 202 static void WlanGetInterfaceCapability_test(void) 203 { 204 DWORD ret; 205 PWLAN_INTERFACE_CAPABILITY pInterfaceCapability; 206 207 /* invalid pReserved */ 208 ret = WlanGetInterfaceCapability((HANDLE) -1, &InterfaceGuid, (PVOID) 1, &pInterfaceCapability); 209 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 210 211 /* invalid InterfaceGuid */ 212 ret = WlanGetInterfaceCapability((HANDLE) -1, NULL, NULL, &pInterfaceCapability); 213 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 214 215 /* invalid pInterfaceCapability */ 216 ret = WlanGetInterfaceCapability((HANDLE) -1, &InterfaceGuid, NULL, NULL); 217 ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n"); 218 } 219 220 221 START_TEST(wlanapi) 222 { 223 WlanOpenHandle_test(); 224 WlanCloseHandle_test(); 225 WlanConnect_test(); 226 WlanDisconnect_test(); 227 WlanScan_test(); 228 WlanRenameProfile_test(); 229 WlanDeleteProfile_test(); 230 WlanGetProfile_test(); 231 WlanEnumInterfaces_test(); 232 WlanGetInterfaceCapability_test(); 233 } 234