1#!/usr/bin/env python 2# 3# Copyright (C) 2019 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_2Host(hal_hidl_gtest.HidlHalGTest): 26 """Host test class to run the WiFi Supplicant V1.2 HAL's VTS tests.""" 27 28 WIFI_DIRECT_FEATURE_NAME = "android.hardware.wifi.direct" 29 30 def CreateTestCases(self): 31 """Get all registered test components and create test case objects.""" 32 pm_list = self.shell.Execute("pm list features") 33 self._p2p_on = self.WIFI_DIRECT_FEATURE_NAME in pm_list[const.STDOUT][0] 34 logging.info("Wifi P2P Feature Supported: %s", self._p2p_on) 35 super(VtsHalWifiSupplicantV1_2Host, self).CreateTestCases() 36 37 # @Override 38 def CreateTestCase(self, path, tag=''): 39 """Create a list of VtsHalWifiSupplicantV1_2TestCase objects. 40 41 Args: 42 path: string, absolute path of a gtest binary on device 43 tag: string, a tag that will be appended to the end of test name 44 45 Returns: 46 A list of VtsHalWifiSupplicantV1_2TestCase objects 47 """ 48 gtest_cases = super(VtsHalWifiSupplicantV1_2Host, self).CreateTestCase(path, tag) 49 for gtest_case in gtest_cases: 50 if not self._p2p_on: 51 gtest_case.args += " --p2p_off" 52 return gtest_cases 53 54 55if __name__ == "__main__": 56 test_runner.main() 57