• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <vector>
18 
19 #include <android-base/logging.h>
20 #include <gtest/gtest.h>
21 #include <utils/StrongPointer.h>
22 
23 #include "android/net/wifi/nl80211/IClientInterface.h"
24 #include "android/net/wifi/nl80211/IWificond.h"
25 #include "wificond/tests/integration/process_utils.h"
26 
27 using android::net::wifi::nl80211::IClientInterface;
28 using android::net::wifi::nl80211::IWificond;
29 using android::net::wifi::nl80211::IWifiScannerImpl;
30 using android::wificond::tests::integration::ScopedDevModeWificond;
31 using std::unique_ptr;
32 using std::vector;
33 
34 namespace android {
35 namespace wificond {
36 namespace {
37 const char kInterfaceName[] = "wlan0";
38 
InitInterfaceAndReturnScanner(sp<IWificond> service)39 sp<IWifiScannerImpl> InitInterfaceAndReturnScanner(sp<IWificond> service) {
40   sp<IWifiScannerImpl> scanner;
41   sp<IClientInterface> client_interface;
42   if (!service->createClientInterface(
43       kInterfaceName, &client_interface).isOk()) {
44     LOG(FATAL) << "Failed to create client interface";
45     return nullptr;
46   }
47   if (client_interface == nullptr) {
48     LOG(FATAL) << "Failed to get a valid client interface handler";
49     return nullptr;
50   }
51   if (!client_interface->getWifiScannerImpl(&scanner).isOk()) {
52     LOG(FATAL) << "Failed to get a WifiScannerImpl handler";
53     return nullptr;
54   }
55   return scanner;
56 }
57 
58 }  // namespace
59 
TEST(ScannerTest,CanGetValidWifiScannerImpl)60 TEST(ScannerTest, CanGetValidWifiScannerImpl) {
61   ScopedDevModeWificond dev_mode;
62   sp<IWificond> service = dev_mode.EnterDevModeOrDie();
63   EXPECT_NE(nullptr, InitInterfaceAndReturnScanner(service).get());
64 }
65 
66 }  // namespace wificond
67 }  // namespace android
68