1#!/usr/bin/env python3.4 2# 3# Copyright 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 17import itertools 18import pprint 19import queue 20import time 21 22import acts.base_test 23import acts.signals as signals 24import acts.test_utils.wifi.wifi_test_utils as wutils 25import acts.utils 26 27from acts import asserts 28from acts.controllers.ap_lib import hostapd_constants 29from acts.test_decorators import test_tracker_info 30from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest 31 32WifiEnums = wutils.WifiEnums 33 34class WifiWpa3OweTest(WifiBaseTest): 35 """Tests for APIs in Android's WifiManager class. 36 37 Test Bed Requirement: 38 * At least one Android device and atleast two Access Points. 39 * Several Wi-Fi networks visible to the device. 40 """ 41 42 def setup_class(self): 43 super().setup_class() 44 45 self.dut = self.android_devices[0] 46 self.dut_client = self.android_devices[1] 47 wutils.wifi_test_device_init(self.dut) 48 wutils.wifi_test_device_init(self.dut_client) 49 req_params = ["owe_networks", "wpa3_personal"] 50 opt_param = [] 51 self.unpack_userparams( 52 req_param_names=req_params, opt_param_names=opt_param) 53 wutils.wifi_toggle_state(self.dut, True) 54 wutils.wifi_toggle_state(self.dut_client, True) 55 self.owe_2g = self.owe_networks[0]["2g"] 56 self.owe_5g = self.owe_networks[0]["5g"] 57 self.wpa3_personal_2g = self.wpa3_personal[0]["2g"] 58 self.wpa3_personal_5g = self.wpa3_personal[0]["5g"] 59 60 def setup_test(self): 61 for ad in self.android_devices: 62 ad.droid.wakeLockAcquireBright() 63 ad.droid.wakeUpNow() 64 wutils.wifi_toggle_state(ad, True) 65 66 def teardown_test(self): 67 for ad in self.android_devices: 68 ad.droid.wakeLockRelease() 69 ad.droid.goToSleepNow() 70 wutils.reset_wifi(self.dut) 71 wutils.reset_wifi(self.dut_client) 72 73 def on_fail(self, test_name, begin_time): 74 self.dut.cat_adb_log(test_name, begin_time) 75 self.dut.take_bug_report(test_name, begin_time) 76 77 """Helper Functions""" 78 79 """Tests""" 80 81 @test_tracker_info(uuid="a7755f1f-5740-4d45-8c29-3711172b1bd7") 82 def test_connect_to_owe_2g(self): 83 wutils.start_wifi_connection_scan_and_ensure_network_found(self.dut, 84 self.owe_2g[WifiEnums.SSID_KEY]) 85 wutils.connect_to_wifi_network(self.dut, self.owe_2g ) 86 87 @test_tracker_info(uuid="9977765e-03da-4614-ab96-4c1597101118") 88 def test_connect_to_owe_5g(self): 89 wutils.start_wifi_connection_scan_and_ensure_network_found(self.dut, 90 self.owe_5g[WifiEnums.SSID_KEY]) 91 wutils.connect_to_wifi_network(self.dut, self.owe_5g) 92 93 @test_tracker_info(uuid="3670702a-3d78-4184-b5e1-7fcf5fa48fd8") 94 def test_connect_to_wpa3_personal_2g(self): 95 wutils.start_wifi_connection_scan_and_ensure_network_found(self.dut, 96 self.wpa3_personal_2g[WifiEnums.SSID_KEY]) 97 wutils.connect_to_wifi_network(self.dut, self.wpa3_personal_2g) 98 99 @test_tracker_info(uuid="c4528eaf-7960-4ecd-8f11-d5439bdf1c58") 100 def test_connect_to_wpa3_personal_5g(self): 101 wutils.start_wifi_connection_scan_and_ensure_network_found(self.dut, 102 self.wpa3_personal_5g[WifiEnums.SSID_KEY]) 103 wutils.connect_to_wifi_network(self.dut, self.owe_5g) 104