1#!/usr/bin/env python3 2# 3# Copyright (C) 2020 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6# use this file except in compliance with the License. You may obtain a copy of 7# 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, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations under 15# the License. 16""" 17Script for verifying that we can invoke methods of the WlanFacade. 18 19""" 20import array 21 22from acts import asserts, signals 23from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest 24from acts_contrib.test_utils.abstract_devices.wlan_device import create_wlan_device 25 26 27class WlanFacadeTest(WifiBaseTest): 28 29 def setup_class(self): 30 super().setup_class() 31 if len(self.fuchsia_devices) < 1: 32 raise signals.TestAbortClass( 33 "Sorry, please try verifying FuchsiaDevice is in your " 34 "config file and try again.") 35 self.dut = create_wlan_device(self.fuchsia_devices[0]) 36 37 def test_get_phy_id_list(self): 38 result = self.dut.device.sl4f.wlan_lib.wlanPhyIdList() 39 error = result['error'] 40 asserts.assert_true(error is None, error) 41 42 self.log.info('Got Phy IDs %s' % result['result']) 43 return True 44 45 def test_get_country(self): 46 wlan_lib = self.dut.device.sl4f.wlan_lib 47 48 result = wlan_lib.wlanPhyIdList() 49 error = result['error'] 50 asserts.assert_true(error is None, error) 51 phy_id = result['result'][0] 52 53 result = wlan_lib.wlanGetCountry(phy_id) 54 error = result['error'] 55 asserts.assert_true(error is None, error) 56 57 country_bytes = result['result'] 58 country_string = str(array.array('b', country_bytes), 59 encoding='us-ascii') 60 self.log.info('Got country %s (%s)', country_string, country_bytes) 61 return True 62 63 def test_get_dev_path(self): 64 wlan_lib = self.dut.device.sl4f.wlan_lib 65 66 result = wlan_lib.wlanPhyIdList() 67 error = result['error'] 68 asserts.assert_true(error is None, error) 69 phy_id = result['result'][0] 70 71 result = wlan_lib.wlanGetDevPath(phy_id) 72 error = result['error'] 73 asserts.assert_true(error is None, error) 74 75 dev_path = result['result'] 76 self.log.info('Got device path: %s', dev_path) 77 return True 78