Wifi test script cleanup.
b/26118510

This cleans up all existing wifi tests except autojoin and wifi
scanner tests.

Change-Id: I4e1f2bcd3ae3da56669fcc30e54428e20337b8fc
diff --git a/acts/framework/acts/test_utils/wifi_test_utils.py b/acts/framework/acts/test_utils/wifi_test_utils.py
index 54119f3..6f818a5 100755
--- a/acts/framework/acts/test_utils/wifi_test_utils.py
+++ b/acts/framework/acts/test_utils/wifi_test_utils.py
@@ -479,28 +479,28 @@
             raise WifiTestUtilsError("Failed to remove network {}.".format(n))
 
 def wifi_forget_network(ad, net_ssid):
-  """Remove configured Wifi network on an android device.
+    """Remove configured Wifi network on an android device.
 
-  Args:
-    ad: android_device object for forget network.
-    net_ssid: ssid of network to be forget
+    Args:
+        ad: android_device object for forget network.
+        net_ssid: ssid of network to be forget
 
-  Raises:
-    WifiTestUtilsError is raised if forget network operation failed.
-  """
-  droid, ed = ad.droid, ad.ed
-  droid.wifiToggleState(True)
-  networks = droid.wifiGetConfiguredNetworks()
-  if not networks:
-    return
-  for n in networks:
-    if net_ssid in n[WifiEnums.SSID_KEY]:
-      droid.wifiForgetNetwork(n['networkId'])
-      try:
-        event = ed.pop_event(WifiEventNames.WIFI_FORGET_NW_SUCCESS,
-            SHORT_TIMEOUT)
-      except Empty:
-        raise WifiTestUtilsError("Failed to remove network {}.".format(n))
+    Raises:
+        WifiTestUtilsError is raised if forget network operation failed.
+    """
+    droid, ed = ad.droid, ad.ed
+    droid.wifiToggleState(True)
+    networks = droid.wifiGetConfiguredNetworks()
+    if not networks:
+        return
+    for n in networks:
+        if net_ssid in n[WifiEnums.SSID_KEY]:
+            droid.wifiForgetNetwork(n['networkId'])
+            try:
+                event = ed.pop_event(WifiEventNames.WIFI_FORGET_NW_SUCCESS,
+                        SHORT_TIMEOUT)
+            except Empty:
+                raise WifiTestUtilsError("Failed to remove network %s." % n)
 
 def wifi_test_device_init(ad):
     """Initializes an android device for wifi testing.
@@ -524,7 +524,7 @@
     msg = "Failed to clear configured networks."
     assert not ad.droid.wifiGetConfiguredNetworks(), msg
     ad.droid.wifiEnableVerboseLogging(1)
-    msg = "Failed to enable WiFi verbose loggin."
+    msg = "Failed to enable WiFi verbose logging."
     assert ad.droid.wifiGetVerboseLoggingLevel() == 1, msg
     ad.droid.wifiScannerToggleAlwaysAvailable(False)
     # We don't verify the following settings since they are not critical.
@@ -535,16 +535,16 @@
     ad.adb.shell("halutil -country %s" % WifiEnums.CountryCode.US)
 
 def sort_wifi_scan_results(results, key="level"):
-  """Sort wifi scan results by key.
+    """Sort wifi scan results by key.
 
-  Args:
-    results: A list of results to sort.
-    key: Name of the field to sort the results by.
+    Args:
+        results: A list of results to sort.
+        key: Name of the field to sort the results by.
 
-  Returns:
-    A list of results in sorted order.
-  """
-  return sorted(results, lambda d: (key not in d, d[key]))
+    Returns:
+        A list of results in sorted order.
+    """
+    return sorted(results, lambda d: (key not in d, d[key]))
 
 def start_wifi_connection_scan(ad):
     """Starts a wifi connection scan and wait for results to become available.
@@ -675,12 +675,12 @@
     droid, ed = ad.droid, ad.ed
     droid.wifiStartTrackingStateChange()
     while check_connection_count > 0:
-      connect_network = ed.pop_event("WifiNetworkConnected", 120)
-      log.info("connect_network {}".format(connect_network))
-      if (WifiEnums.SSID_KEY in connect_network['data']
-                            and connect_network['data'][WifiEnums.SSID_KEY] == network_ssid):
-        return True
-      check_connection_count -= 1
+        connect_network = ed.pop_event("WifiNetworkConnected", 120)
+        log.info("connect_network {}".format(connect_network))
+        if (WifiEnums.SSID_KEY in connect_network['data']
+            and connect_network['data'][WifiEnums.SSID_KEY] == network_ssid):
+                return True
+        check_connection_count -= 1
     droid.wifiStopTrackingStateChange()
     return False
 
@@ -700,13 +700,13 @@
     scan_time = 0
     scan_channels = []
     if "band" in scan_setting and "channels" not in scan_setting:
-      scan_channels = wifi_chs.band_to_freq(scan_setting["band"])
+        scan_channels = wifi_chs.band_to_freq(scan_setting["band"])
     elif "channels" in scan_setting and "band" not in scan_setting:
-      scan_channels = scan_setting["channels"]
+        scan_channels = scan_setting["channels"]
     scan_time = len(scan_channels) * stime_channel
     for channel in scan_channels:
-      if channel in WifiEnums.DFS_5G_FREQUENCIES:
-        scan_time += 132 #passive scan time on DFS
+        if channel in WifiEnums.DFS_5G_FREQUENCIES:
+            scan_time += 132 #passive scan time on DFS
     return scan_time, scan_channels
 
 def start_wifi_track_bssid(ad, track_setting):
diff --git a/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py b/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py
index 0f50b4b..225c783 100644
--- a/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py
+++ b/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py
@@ -14,17 +14,13 @@
 #   limitations under the License.
 
 import pprint
+import random
 import time
 
-from random import shuffle
-
-from acts.base_test import BaseTestClass
-from acts.test_utils.wifi_test_utils import eap_connect
-from acts.test_utils.wifi_test_utils import expand_enterprise_config_by_phase2
-from acts.test_utils.wifi_test_utils import reset_wifi
-from acts.test_utils.wifi_test_utils import verify_wifi_connection_info
-from acts.test_utils.wifi_test_utils import wifi_test_device_init
-from acts.test_utils.wifi_test_utils import WifiEnums
+import acts.base_test
+import acts.signals.generated_test as generated_test
+import acts.test_utils.wifi_test_utils as wutils
+import acts.test_utils.wifi_test_utils.WifiEnums as WifiEnums
 
 # EAP Macros
 EAP = WifiEnums.Eap
@@ -33,7 +29,7 @@
 # Enterprise Config Macros
 Ent = WifiEnums.Enterprise
 
-class WifiEnterpriseRoamingTest(BaseTestClass):
+class WifiEnterpriseRoamingTest(acts.base_test.BaseTestClass):
 
     def __init__(self, controllers):
         BaseTestClass.__init__(self, controllers)
@@ -43,7 +39,7 @@
 
     def setup_class(self):
         self.dut = self.android_devices[0]
-        wifi_test_device_init(self.dut)
+        wutils.wifi_test_device_init(self.dut)
         req_params = (
             "ent_roaming_ssid",
             "bssid_a",
@@ -95,7 +91,7 @@
         return True
 
     def teardown_class(self):
-        reset_wifi(self.dut)
+        wutils.reset_wifi(self.dut)
         self.droid.disableDevicePassword()
         self.ed.clear_all_events()
         self.set_attns("default")
@@ -104,7 +100,7 @@
         self.droid.wifiStartTrackingStateChange()
         self.droid.wakeLockAcquireBright()
         self.droid.wakeUpNow()
-        reset_wifi(self.dut)
+        wutils.reset_wifi(self.dut)
         self.ed.clear_all_events()
         return True
 
@@ -138,8 +134,8 @@
         """
         configs = [self.config_tls]
                    # self.config_sim
-        configs += expand_enterprise_config_by_phase2(self.config_ttls)
-        configs += expand_enterprise_config_by_phase2(self.config_peap)
+        configs += wutils.expand_enterprise_config_by_phase2(self.config_ttls)
+        configs += wutils.expand_enterprise_config_by_phase2(self.config_peap)
         return configs
 
     def gen_eap_roaming_test_name(self, config):
@@ -171,7 +167,7 @@
         try:
             self.droid.wakeLockAcquireBright()
             self.droid.wakeUpNow()
-            verify_wifi_connection_info(self.dut, expected_con)
+            wutils.verify_wifi_connection_info(self.dut, expected_con)
             expected_bssid = expected_con[WifiEnums.BSSID_KEY]
             self.log.info("Roamed to %s successfully" % expected_bssid)
         finally:
@@ -198,8 +194,11 @@
             WifiEnums.BSSID_KEY: self.bssid_b,
         }
         self.set_attns("a_on_b_off")
-        assert eap_connect(config, self.dut, validate_con=False)
-        verify_wifi_connection_info(self.dut, expected_con_to_a)
+        self.assert_true(
+            wutils.eap_connect(config, self.dut, validate_con=False),
+            "Failed to connect to %s" % config
+            )
+        wutils.verify_wifi_connection_info(self.dut, expected_con_to_a)
         self.log.info("Roaming from %s to %s" % (self.bssid_a, self.bssid_b))
         self.trigger_roaming_and_validate("b_on_a_off", expected_con_to_b)
         self.log.info("Roaming from %s to %s" % (self.bssid_b, self.bssid_a))
@@ -207,10 +206,11 @@
         return True
 
     """ Tests Begin """
+    @generated_test
     def test_roaming_with_different_auth_method(self):
         eap_configs = self.gen_eap_configs()
         self.log.info("Testing %d different configs." % len(eap_configs))
-        shuffle(eap_configs)
+        random.shuffle(eap_configs)
         failed = self.run_generated_testcases(
             self.roaming_between_a_and_b_logic,
             eap_configs,
@@ -218,5 +218,4 @@
         msg = ("The following configs failed enterprise roaming test: %s" %
                pprint.pformat(failed))
         self.assert_true(len(failed) == 0, msg)
-        return True
     """ Tests End """
diff --git a/acts/tests/google/wifi/WifiEnterpriseTest.py b/acts/tests/google/wifi/WifiEnterpriseTest.py
index 71de194..625926c 100755
--- a/acts/tests/google/wifi/WifiEnterpriseTest.py
+++ b/acts/tests/google/wifi/WifiEnterpriseTest.py
@@ -15,19 +15,13 @@
 #   limitations under the License.
 
 import pprint
+import random
 import time
 
-from queue import Empty
-from random import shuffle
-
-from acts.base_test import BaseTestClass
-from acts.test_utils.wifi_test_utils import eap_connect
-from acts.test_utils.wifi_test_utils import expand_enterprise_config_by_phase2
-from acts.test_utils.wifi_test_utils import reset_wifi
-from acts.test_utils.wifi_test_utils import start_wifi_connection_scan
-from acts.test_utils.wifi_test_utils import wifi_test_device_init
-from acts.test_utils.wifi_test_utils import WifiEnums
-from acts.test_utils.wifi_test_utils import WifiEventNames
+import acts.base_test
+import acts.signals.generated_test as generated_test
+import acts.test_utils.wifi_test_utils as wutils
+import acts.test_utils.wifi_test_utils.WifiEnums as WifiEnums
 
 # EAP Macros
 EAP = WifiEnums.Eap
@@ -35,11 +29,8 @@
 
 # Enterprise Config Macros
 Ent = WifiEnums.Enterprise
-# Event name macros
-Event = WifiEventNames
 
-
-class WifiEnterpriseTest(BaseTestClass):
+class WifiEnterpriseTest(acts.base_test.BaseTestClass):
 
     def __init__(self, controllers):
         BaseTestClass.__init__(self, controllers)
@@ -52,7 +43,7 @@
 
     def setup_class(self):
         self.dut = self.android_devices[0]
-        wifi_test_device_init(self.dut)
+        wutils.wifi_test_device_init(self.dut)
         required_userparam_names = (
             "ca_cert",
             "client_cert",
@@ -138,7 +129,7 @@
         return True
 
     def teardown_class(self):
-        reset_wifi(self.dut)
+        wutils.reset_wifi(self.dut)
         self.droid.disableDevicePassword()
         self.ed.clear_all_events()
 
@@ -146,7 +137,7 @@
         self.droid.wifiStartTrackingStateChange()
         self.droid.wakeLockAcquireBright()
         self.droid.wakeUpNow()
-        reset_wifi(self.dut)
+        wutils.reset_wifi(self.dut)
         self.ed.clear_all_events()
         return True
 
@@ -167,7 +158,7 @@
         Returns:
             True if connection failed as expected, False otherwise.
         """
-        verdict = eap_connect(config, ad)
+        verdict = wutils.eap_connect(config, ad)
         self.assert_true(not verdict, "Connection should have failed.")
         self.log.info("Connection failed as expected.")
         return True
@@ -200,8 +191,8 @@
         """
         configs = [self.config_tls]
                    # self.config_sim
-        configs += expand_enterprise_config_by_phase2(self.config_ttls)
-        configs += expand_enterprise_config_by_phase2(self.config_peap)
+        configs += wutils.expand_enterprise_config_by_phase2(self.config_ttls)
+        configs += wutils.expand_enterprise_config_by_phase2(self.config_peap)
         return configs
 
     def gen_passpoint_configs(self):
@@ -213,7 +204,7 @@
             passpoint networks.
         """
         configs = [self.config_passpoint_tls]
-        configs += expand_enterprise_config_by_phase2(self.config_passpoint_ttls)
+        configs += wutils.expand_enterprise_config_by_phase2(self.config_passpoint_ttls)
         return configs
 
     def gen_negative_configs(self, configs, neg_params):
@@ -324,6 +315,7 @@
         return name
 
     """Tests"""
+    @generated_test
     def test_eap_connect(self):
         """Test connecting to enterprise networks of different authentication
         types.
@@ -344,17 +336,17 @@
         """
         eap_configs = self.gen_eap_configs()
         self.log.info("Testing %d different configs." % len(eap_configs))
-        shuffle(eap_configs)
+        random.shuffle(eap_configs)
         failed = self.run_generated_testcases(
-            eap_connect,
+            wutils.eap_connect,
             eap_configs,
             self.dut,
             name_func=self.gen_eap_test_name)
         msg = ("The following configs failed EAP connect test: %s" %
                pprint.pformat(failed))
         self.assert_true(len(failed) == 0, msg)
-        return True
 
+    @generated_test
     def test_eap_connect_negative(self):
         """Test connecting to enterprise networks.
 
@@ -367,7 +359,7 @@
         """
         neg_eap_configs = self.gen_negative_eap_configs()
         self.log.info("Testing %d different configs." % len(neg_eap_configs))
-        shuffle(neg_eap_configs)
+        random.shuffle(neg_eap_configs)
         def name_gen(config, ad):
             name = self.gen_eap_test_name(config, ad)
             name += "-with_wrong-{}".format(config["invalid_field"])
@@ -380,8 +372,8 @@
         msg = ("The following configs failed negative EAP connect test: %s" %
                pprint.pformat(failed))
         self.assert_true(len(failed) == 0, msg)
-        return True
 
+    @generated_test
     def test_passpoint_connect(self):
         """Test connecting to enterprise networks of different authentication
         types with passpoint support.
@@ -403,17 +395,17 @@
             "Passpoint is not supported on device %s" % self.dut.model)
         passpoint_configs = self.gen_passpoint_configs()
         self.log.info("Testing %d different configs." % len(passpoint_configs))
-        shuffle(passpoint_configs)
+        random.shuffle(passpoint_configs)
         failed = self.run_generated_testcases(
-            eap_connect,
+            wutils.eap_connect,
             passpoint_configs,
             self.dut,
             name_func=self.gen_passpoint_test_name)
         msg = ("The following configs failed passpoint connect test: %s" %
                pprint.pformat(failed))
         self.assert_true(len(failed) == 0, msg)
-        return True
 
+    @generated_test
     def test_passpoint_connect_negative(self):
         """Test connecting to enterprise networks.
 
@@ -428,7 +420,7 @@
             "Passpoint is not supported on device %s" % self.dut.model)
         neg_passpoint_configs = self.gen_negative_passpoint_configs()
         self.log.info("Testing %d different configs." % len(neg_passpoint_configs))
-        shuffle(neg_passpoint_configs)
+        random.shuffle(neg_passpoint_configs)
         def name_gen(config, ad):
             name = self.gen_passpoint_test_name(config, ad)
             name += "-with_wrong-{}".format(config["invalid_field"])
@@ -441,7 +433,3 @@
         msg = ("The following configs failed negative passpoint connect test: "
                "%s") % pprint.pformat(failed)
         self.assert_true(len(failed) == 0, msg)
-        return True
-
-if __name__ == "__main__":
-    pass
diff --git a/acts/tests/google/wifi/WifiManagerTest.py b/acts/tests/google/wifi/WifiManagerTest.py
index 10fcbd5..b08b3c1 100755
--- a/acts/tests/google/wifi/WifiManagerTest.py
+++ b/acts/tests/google/wifi/WifiManagerTest.py
@@ -17,23 +17,15 @@
 import itertools
 import pprint
 import time
-import traceback
-
 from queue import Empty
 
-from acts.base_test import BaseTestClass
-from acts.test_utils.wifi_test_utils import match_networks
-from acts.test_utils.wifi_test_utils import reset_wifi
-from acts.test_utils.wifi_test_utils import start_wifi_connection_scan
-from acts.test_utils.wifi_test_utils import wifi_forget_network
-from acts.test_utils.wifi_test_utils import wifi_test_device_init
-from acts.test_utils.wifi_test_utils import wifi_toggle_state
-from acts.test_utils.wifi_test_utils import WifiEnums
-from acts.test_utils.wifi_test_utils import WifiEventNames
-from acts.utils import find_field
-from acts.utils import trim_model_name
+import acts.base_test
+import acts.signals.generated_test as generated_test
+import acts.test_utils.wifi_test_utils as wutils
+import acts.test_utils.wifi_test_utils.WifiEnums as WifiEnums
+import acts.test_utils.wifi_test_utils.WifiEventNames as WifiEventNames
 
-class WifiManagerTest(BaseTestClass):
+class WifiManagerTest(acts.base_test.BaseTestClass):
 
     def __init__(self, controllers):
         BaseTestClass.__init__(self, controllers)
@@ -50,7 +42,7 @@
 
     def setup_class(self):
         self.dut = self.android_devices[0]
-        wifi_test_device_init(self.dut)
+        wutils.wifi_test_device_init(self.dut)
         req_params = (
             "iot_networks",
             "open_network",
@@ -62,7 +54,7 @@
             "Failed to unpack user params")
         self.assert_true(len(self.iot_networks) > 0,
             "Need at least one iot network with psk.")
-        self.assert_true(wifi_toggle_state(self.dut, True),
+        self.assert_true(wutils.wifi_toggle_state(self.dut, True),
             "Failed to turn on wifi before tests.")
         self.iot_networks = self.iot_networks + [self.open_network]
         self.iperf_server = self.iperf_servers[0]
@@ -77,7 +69,7 @@
     def teardown_test(self):
         self.droid.wakeLockRelease()
         self.droid.goToSleepNow()
-        reset_wifi(self.dut)
+        wutils.reset_wifi(self.dut)
         self.iperf_server.stop()
 
     """Helper Functions"""
@@ -102,7 +94,7 @@
         SSID = network[WifiEnums.SSID_KEY]
         try:
             ed.clear_all_events()
-            start_wifi_connection_scan(ad)
+            wutils.start_wifi_connection_scan(ad)
             droid.wifiStartTrackingStateChange()
             self.assert_true(droid.wifiConnect(network),
                 "wifi connect returned false.")
@@ -117,8 +109,7 @@
                                                    port_arg)
                 self.log.debug(pprint.pformat(data))
         except Empty:
-            self.log.error("Failed to connect to {}".format(SSID))
-            self.log.debug(traceback.format_exc())
+            self.log.exception("Failed to connect to {}".format(SSID))
         finally:
             droid.wifiStopTrackingStateChange()
         return result
@@ -146,10 +137,11 @@
     def test_toggle_state(self):
         """Test toggling wifi"""
         self.log.debug("Going from on to off.")
-        assert wifi_toggle_state(self.dut, False)
+        self.assert_true(wutils.wifi_toggle_state(self.dut, False),
+                         "Failed to turn wifi off.")
         self.log.debug("Going from off to on.")
-        assert wifi_toggle_state(self.dut, True)
-        return True
+        self.assert_true(wutils.wifi_toggle_state(self.dut, True),
+                         "Failed to turn wifi on.")
 
     def test_toggle_with_screen(self):
         """Test toggling wifi with screen on/off"""
@@ -160,26 +152,28 @@
         time.sleep(wait_time)
         self.log.debug("Going from on to off.")
         try:
-            assert wifi_toggle_state(self.dut, False)
+            self.assert_true(wutils.wifi_toggle_state(self.dut, False),
+                             "Failed to turn wifi off.")
             time.sleep(wait_time)
             self.log.debug("Going from off to on.")
-            assert wifi_toggle_state(self.dut, True)
+            self.assert_true(wutils.wifi_toggle_state(self.dut, True),
+                             "Failed to turn wifi on.")
         finally:
             self.droid.wakeLockRelease()
             time.sleep(wait_time)
             self.droid.goToSleepNow()
-        return True
 
     def test_scan(self):
         """Test wifi connection scan can start and find expected networks."""
-        wifi_toggle_state(self.dut, True)
+        wutils.wifi_toggle_state(self.dut, True)
         self.log.debug("Start regular wifi scan.")
-        start_wifi_connection_scan(self.dut)
+        wutils.start_wifi_connection_scan(self.dut)
         wifi_results = self.droid.wifiGetScanResults()
         self.log.debug("Scan results: %s" % wifi_results)
-        condition = {WifiEnums.SSID_KEY: self.open_network[WifiEnums.SSID_KEY]}
-        assert match_networks(condition, wifi_results)
-        return True
+        ssid = self.open_network[WifiEnums.SSID_KEY]
+        condition = {WifiEnums.SSID_KEY: ssid}
+        self.assert_true(wutils.match_networks(condition, wifi_results),
+                         "Can not find expected network %s" % ssid)
 
     def test_add_network(self):
         """Test wifi connection scan."""
@@ -190,19 +184,20 @@
         self.log.debug(("Configured networks after adding: %s" %
                         configured_networks))
         condition = {WifiEnums.SSID_KEY: ssid}
-        assert match_networks(condition, configured_networks)
-        return True
+        self.assert_true(wutils.match_networks(condition, configured_networks),
+                         ("Could not find expected network %s in configured "
+                          "networks.") % ssid)
 
     def test_forget_network(self):
         self.assert_true(self.test_add_network(), "Failed to add network.")
         ssid = self.open_network[WifiEnums.SSID_KEY]
-        wifi_forget_network(self.dut, ssid)
+        wutils.wifi_forget_network(self.dut, ssid)
         configured_networks = self.droid.wifiGetConfiguredNetworks()
         for nw in configured_networks:
             self.assert_true(nw[WifiEnums.BSSID_KEY] != ssid,
                 "Found forgotten network %s in configured networks." % ssid)
-        return True
 
+    @generated_test
     def test_iot_with_password(self):
         params = list(itertools.product(self.iot_networks, self.android_devices))
         name_gen = lambda p : "test_connection_to-%s" % p[0][WifiEnums.SSID_KEY]
@@ -211,16 +206,18 @@
             params,
             name_func=name_gen)
         self.assert_true(not failed, "Failed ones: {}".format(failed))
-        return True
 
     def test_tdls_supported(self):
-        model = trim_model_name(self.dut.model)
+        model = acts.utils.trim_model_name(self.dut.model)
         self.log.debug("Model is %s" % model)
         if model in self.tdls_models:
-            assert self.droid.wifiIsTdlsSupported()
+            self.assert_true(self.droid.wifiIsTdlsSupported(),
+                             ("TDLS should be supported on %s, but device is "
+                              "reporting not supported.") % model)
         else:
-            assert not self.droid.wifiIsTdlsSupported()
-        return True
+            self.assert_true(not self.droid.wifiIsTdlsSupported(),
+                             ("TDLS should not be supported on %s, but device "
+                              "is reporting supported.") % model)
 
     # TODO(angli): Actually connect to a network and do an http request between
     # iterations.
@@ -265,8 +262,4 @@
                 "Idle time decreased: previous %d, now %d" % (idle_time,
                     new_idle_time))
             idle_time = new_idle_time
-            start_wifi_connection_scan(self.dut)
-        return True
-
-if __name__ == "__main__":
-    pass
+            wutils.start_wifi_connection_scan(self.dut)
diff --git a/acts/tests/google/wifi/WifiRttManagerTest.py b/acts/tests/google/wifi/WifiRttManagerTest.py
index 68a36ec..c3d0954 100644
--- a/acts/tests/google/wifi/WifiRttManagerTest.py
+++ b/acts/tests/google/wifi/WifiRttManagerTest.py
@@ -15,17 +15,13 @@
 # the License.
 
 import pprint
+import queue
 
-from queue import Empty
-from acts.base_test import BaseTestClass
+import acts.base_test
+import acts.test_utils.wifi_test_utils as wutils
+import acts.test_utils.wifi_test_utils.WifiEnums as WifiEnums
+import acts.utils.trim_model_name as trim_model_name
 from acts.controllers.android import SL4AAPIError
-from acts.test_utils.wifi_test_utils import match_networks
-from acts.test_utils.wifi_test_utils import SPEED_OF_LIGHT
-from acts.test_utils.wifi_test_utils import start_wifi_single_scan
-from acts.test_utils.wifi_test_utils import start_wifi_connection_scan
-from acts.test_utils.wifi_test_utils import trim_model_name
-from acts.test_utils.wifi_test_utils import wifi_test_device_init
-from acts.test_utils.wifi_test_utils import WifiEnums
 
 # Macros for RttParam keywords
 RttParam = WifiEnums.RttParam
@@ -42,7 +38,7 @@
 class WifiRTTRangingError (Exception):
      """Error in WifiScanner Rtt."""
 
-class WifiRttManagerTest(BaseTestClass):
+class WifiRttManagerTest(acts.base_test.BaseTestClass):
     """Tests for wifi's RttManager APIs."""
     tests = None
     MAX_RTT_AP = 10
@@ -60,7 +56,7 @@
 
     def setup_class(self):
         self.dut = self.android_devices[0]
-        wifi_test_device_init(self.dut)
+        wutils.wifi_test_device_init(self.dut)
         required_params = (
             "support_models",
             "stress_num",
@@ -165,7 +161,7 @@
                     r[RttParam.margin] = RTT_MARGIN_OF_ERROR[bw_mode]
             self.log.debug(pprint.pformat(event))
             return event
-        except Empty:
+        except queue.Empty:
             self.log.error("Waiting for RTT event timed out.")
             return None
 
@@ -208,7 +204,7 @@
         Returns:
             A list of networks that have RTTResponders.
         """
-        start_wifi_connection_scan(self.dut)
+        wutils.start_wifi_connection_scan(self.dut)
         networks = self.droid.wifiGetScanResults()
         rtt_networks = []
         for nw in networks:
@@ -230,7 +226,7 @@
             "periodInMs": 10000,
             "numBssidsPerScan": 32
         }
-        idx = start_wifi_single_scan(self.android_devices[0], s)["Index"]
+        idx = wutils.start_wifi_single_scan(self.android_devices[0], s)["Index"]
         self.log.info("Scan index is %d" % idx)
         event_name = "WifiScannerScan%donFullResult" % idx
         def condition(event):
@@ -248,7 +244,7 @@
             self.log.info("Found %d networks in total." % total_network_cnt)
             self.log.debug(rtt_networks)
             return rtt_networks
-        except Empty:
+        except queue.Empty:
             self.log.error("Timed out waiting for gscan result.")
 
     def process_rtt_events(self, events):
@@ -297,7 +293,7 @@
                             out_of_range += 1
                         continue
                     # Check if the RTT value is in range.
-                    d = (value / 2) / 1E10 * SPEED_OF_LIGHT
+                    d = (value / 2) / 1E10 * wutils.SPEED_OF_LIGHT
                     is_rtt_valid = (acd - margin) <= d <= (acd + margin)
                     if not is_rtt_valid:
                         self.log.warning(
@@ -483,11 +479,11 @@
             All the non-RTT networks show up in scan results and their
             "is80211McRTTResponder" is False.
         """
-        start_wifi_connection_scan(self.dut)
+        wutils.start_wifi_connection_scan(self.dut)
         scan_results = self.droid.wifiGetScanResults()
         self.log.debug(scan_results)
         for n in visible_networks:
-            self.assert_true(match_networks(n, scan_results),
+            self.assert_true(wutils.match_networks(n, scan_results),
                 "Network %s was not discovered properly." % n)
         return True
 
@@ -505,7 +501,6 @@
         results = self.get_rtt_results([p])
         self.assert_true(results, "Did not get any result.")
         self.log.info(pprint.pformat(results))
-        return True
 
     def test_rtt_ranging_single_AP_stress(self):
         """Stress test for Rtt against one AP.
@@ -533,7 +528,6 @@
             else:
                 self.log.warning("Did not get result for iteration %d." % i)
         frate = self.process_rtt_events(all_results)
-        return True
 
     def test_regular_scan_then_rtt_ranging_stress(self):
         """Stress test for regular scan then start rtt ranging against the RTT
@@ -551,7 +545,6 @@
         """
         scan_func = self.regular_scan_for_rtt_networks
         self.scan_then_rtt_ranging_stress_logic(scan_func)
-        return True
 
     def test_gscan_then_rtt_ranging_stress(self):
         """Stress test for gscan then start rtt ranging against the RTT
@@ -568,4 +561,3 @@
         """
         scan_func = self.gscan_for_rtt_networks
         self.scan_then_rtt_ranging_stress_logic(scan_func)
-        return True