1#!/usr/bin/env python 2# 3# Copyright (C) 2018 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17 18import logging 19 20from vts.runners.host import const 21from vts.runners.host import test_runner 22from vts.testcases.template.hal_hidl_gtest import hal_hidl_gtest 23 24 25class VtsHalWifiSupplicantV1_0Host(hal_hidl_gtest.HidlHalGTest): 26 """Host test class to run the WiFi Supplicant V1.0 HAL's VTS tests.""" 27 28 WIFI_DIRECT_FEATURE_NAME = "android.hardware.wifi.direct" 29 30 def setUpClass(self): 31 """Disable android framework.""" 32 super(VtsHalWifiSupplicantV1_0Host, self).setUpClass() 33 self.dut = self.android_devices[0] 34 self.shell = self.dut.shell 35 self.dut.stop(True) 36 37 def tearDownClass(self): 38 """Enable android framework.""" 39 self.dut.start() 40 super(VtsHalWifiSupplicantV1_0Host, self).tearDownClass() 41 42 def CreateTestCases(self): 43 """Get all registered test components and create test case objects.""" 44 pm_list = self.shell.Execute("pm list features") 45 self._p2p_on = self.WIFI_DIRECT_FEATURE_NAME in pm_list[const.STDOUT][0] 46 logging.info("Wifi P2P Feature Supported: %s", self._p2p_on) 47 super(VtsHalWifiSupplicantV1_0Host, self).CreateTestCases() 48 49 # @Override 50 def CreateTestCase(self, path, tag=''): 51 """Create a list of VtsHalWifiSupplicantV1_0TestCase objects. 52 53 Args: 54 path: string, absolute path of a gtest binary on device 55 tag: string, a tag that will be appended to the end of test name 56 57 Returns: 58 A list of VtsHalWifiSupplicantV1_0TestCase objects 59 """ 60 gtest_cases = super(VtsHalWifiSupplicantV1_0Host, self).CreateTestCase(path, tag) 61 for gtest_case in gtest_cases: 62 if not self._p2p_on: 63 gtest_case.args += " --p2p_off" 64 return gtest_cases 65 66 67if __name__ == "__main__": 68 test_runner.main() 69