def test_wifi_tethering_5ghz_connect_disconnect_devices(self):
        """ Steps:

            1. Start wifi hotspot with 5ghz band
            2. Connect and disconnect multiple devices randomly
            3. Verify the correct functionality
        """
        wutils.toggle_wifi_off_and_on(self.hotspot_device)
        self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
        self._connect_disconnect_devices()
        wutils.stop_wifi_tethering(self.hotspot_device)
    def on_retry(self):
        """Function to control test logic on retried tests.

        This function is automatically executed on tests that are being
        retried. In this case the function resets wifi, toggles it off and on
        and sets a retry_flag to enable further tweaking the test logic on
        second attempts.
        """
        self.retry_flag = True
        for dev in self.android_devices:
            wutils.reset_wifi(dev)
            wutils.toggle_wifi_off_and_on(dev)
    def wifi_tethering_5ghz_traffic_between_2tethered_devices(self):
        """ Steps:

            1. Start wifi hotspot with 5ghz band
            2. Connect 2 tethered devices to the hotspot device
            3. Send traffic between the tethered devices
        """
        wutils.toggle_wifi_off_and_on(self.hotspot_device)
        self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
        self._test_traffic_between_two_tethered_devices(
            self.tethered_devices[0], self.arduino_wifi_dongles[0])
        wutils.stop_wifi_tethering(self.hotspot_device)
示例#4
0
    def stress_toggle_wifi(self, stress_count):
        """Toggle WiFi in a loop.

        Args:
            stress_count: Number of times to toggle WiFi OFF and ON.

        """
        for count in range(stress_count):
            self.log.debug("stress_toggle_wifi: Iteration %d" % count)
            wifi_utils.toggle_wifi_off_and_on(self.dut)

        if not self.dut.droid.wifiGetisWifiEnabled():
            raise signals.TestFailure("WiFi did not turn on after toggling it"
                                      " %d times" % self.stress_count)
示例#5
0
    def test_wifi_tethering_2ghz_traffic_between_2tethered_devices(self):
        """ Steps:

            1. Start wifi hotspot with 2G band
            2. Connect 2 tethered devices to the hotspot device
            3. Ping interfaces between the tethered devices
        """
        asserts.skip_if(not hasattr(self, 'arduino_wifi_dongles'),
                        "No wifi dongles connected. Skipping test")
        wutils.toggle_wifi_off_and_on(self.hotspot_device)
        self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
        self._test_traffic_between_two_tethered_devices(
            self.tethered_devices[0], self.arduino_wifi_dongles[0])
        wutils.stop_wifi_tethering(self.hotspot_device)
示例#6
0
    def start_subscription_provisioning(self, state):
        """Start subscription provisioning with a default provider."""

        self.unpack_userparams(('osu_configs', ))
        asserts.assert_true(
            len(self.osu_configs) > 0, "Need at least one osu config.")
        osu_config = self.osu_configs[OSU_BOINGO]
        # Clear all previous events.
        self.dut.ed.clear_all_events()
        self.dut.droid.startSubscriptionProvisioning(osu_config)
        start_time = time.time()
        while time.time() < start_time + OSU_TEST_TIMEOUT:
            dut_event = self.dut.ed.pop_event("onProvisioningCallback",
                                              DEFAULT_TIMEOUT * 18)
            if dut_event['data']['tag'] == 'success':
                self.log.info("Passpoint Provisioning Success")
                # Reset WiFi after provisioning success.
                if state == RESET:
                    wutils.reset_wifi(self.dut)
                    time.sleep(DEFAULT_TIMEOUT)
                # Toggle WiFi after provisioning success.
                elif state == TOGGLE:
                    wutils.toggle_wifi_off_and_on(self.dut)
                    time.sleep(DEFAULT_TIMEOUT)
                break
            if dut_event['data']['tag'] == 'failure':
                raise signals.TestFailure(
                    "Passpoint Provisioning is failed with %s" %
                    dut_event['data']['reason'])
                break
            if dut_event['data']['tag'] == 'status':
                self.log.info("Passpoint Provisioning status %s" %
                              dut_event['data']['status'])
                if int(dut_event['data']['status']) == 7:
                    self.ui.run(self.dut.serial, self.passpoint_workflow)
        # Clear all previous events.
        self.dut.ed.clear_all_events()

        # Verify device connects to the Passpoint network.
        time.sleep(DEFAULT_TIMEOUT)
        current_passpoint = self.dut.droid.wifiGetConnectionInfo()
        if current_passpoint[
                WifiEnums.SSID_KEY] not in osu_config["expected_ssids"]:
            raise signals.TestFailure("Device did not connect to the %s"
                                      " passpoint network" %
                                      osu_config["expected_ssids"])
        # Delete the Passpoint profile.
        self.get_configured_passpoint_and_delete()
        wutils.wait_for_disconnect(self.dut)
    def test_wifi_tethering_5ghz_ping_hotspot_interfaces(self):
        """ Steps:

            1. Start wifi hotspot with 5ghz band
            2. Connect tethered device to hotspot device
            3. Ping 'wlan0' and 'rmnet_data' interface's IPv4
               and IPv6 interfaces on hotspot device from tethered device
        """
        wutils.toggle_wifi_off_and_on(self.hotspot_device)
        self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
        wutils.wifi_connect(self.tethered_devices[0], self.network)
        result = self._ping_hotspot_interfaces_from_tethered_device(
            self.tethered_devices[0])
        wutils.stop_wifi_tethering(self.hotspot_device)
        return result
示例#8
0
    def test_toggle_wifi_call(self):
        """Test to toggle WiFi and then perform WiFi connection and
           cellular calls.

        Steps:
            1. Attach device to voice subscription network.
            2. Connect to a WiFi network.
            3. Toggle WiFi OFF and ON.
            4. Verify device auto-connects to the WiFi network.
            5. Verify device is attached to voice network.
            6. Make short sequence voice calls.

        """
        self.setup_cellular_voice_calling()
        self.connect_to_wifi(self.dut, self.network)
        wifi_utils.toggle_wifi_off_and_on(self.dut)
        self.validate_cellular_and_wifi()
示例#9
0
    def test_wifi_tethering_data_usage_limit_downlink(self):
        """ Verify connectivity when data usage limit reached

        Steps:
            1. Set the data usage limit to current data usage + 10MB
            2. Start wifi tethering and connect a dut to the SSID
            3. Download 20MB data on tethered device
            4. File download stops and data limit reached
            5. Verify data usage limit
        """
        # connect device to wifi hotspot
        ad = self.tethered_devices[0]
        wutils.toggle_wifi_off_and_on(self.dut)
        wutils.start_wifi_tethering(self.dut,
                                    self.network[wutils.WifiEnums.SSID_KEY],
                                    self.network[wutils.WifiEnums.PWD_KEY],
                                    ttutils.WIFI_CONFIG_APBAND_2G)
        wutils.wifi_connect(ad, self.network)

        # get pre mobile data usage
        total_pre = self._get_total_data_usage_for_device(cconst.TYPE_MOBILE)

        # set data usage limit to current usage limit + 10MB
        self.log.info("Setting data usage limit to %sMB" %
                      (total_pre + INC_DATA))
        self.dut.droid.connectivitySetDataUsageLimit(
            self.sub_id, str(int((total_pre + INC_DATA) * BYTE_TO_MB_ANDROID)))

        # download file from tethered device
        http_file_download_by_chrome(ad,
                                     self.download_file,
                                     self.file_size,
                                     timeout=120)
        total_pst = self._get_total_data_usage_for_device(cconst.TYPE_MOBILE)

        # verify data usage
        connectivity_status = wutils.validate_connection(ad)
        self.dut.droid.connectivityFactoryResetNetworkPolicies(self.sub_id)
        wutils.stop_wifi_tethering(self.dut)
        self.log.info("Expected data usage: %s" % (total_pre + INC_DATA))
        self.log.info("Actual data usage: %s" % total_pst)
        asserts.assert_true(
            not connectivity_status,
            "Device has internet connectivity after reaching data limit")
        return total_pst - total_pre - INC_DATA < DATA_USG_ERR
示例#10
0
    def test_reconnect_toggle_wifi(self):
        """Connect to multiple networks, turn off/on wifi, then reconnect to
           a previously connected network.

        Steps:
        1. Connect to a 2GHz network.
        2. Connect to a 5GHz network.
        3. Turn WiFi OFF/ON.
        4. Reconnect to the non-current network.

        """
        connect_2g_data = self.get_connection_data(self.dut, self.wpapsk_2g)
        connect_5g_data = self.get_connection_data(self.dut, self.wpapsk_5g)
        wutils.toggle_wifi_off_and_on(self.dut)
        reconnect_to = self.get_enabled_network(connect_2g_data,
                                                connect_5g_data)
        reconnect = self.connect_to_wifi_network_with_id(
            reconnect_to[WifiEnums.NETID_KEY],
            reconnect_to[WifiEnums.SSID_KEY])
        if not reconnect:
            raise signals.TestFailure("Device did not connect to the correct"
                                      " network after toggling WiFi.")
示例#11
0
    def test_change_wifi_hotspot_ssid_when_hotspot_enabled(self):
        """ Steps:

            1. Start wifi tethering
            2. Verify wifi Ap configuration
            3. Change the SSID of the wifi hotspot while hotspot is on
            4. Verify the new SSID in wifi ap configuration
            5. Restart tethering and verify that the tethered device is able
               to connect to the new SSID
        """
        wutils.toggle_wifi_off_and_on(self.hotspot_device)
        dut = self.hotspot_device

        # start tethering and verify the wifi ap configuration settings
        self._start_wifi_tethering()
        wifi_ap = dut.droid.wifiGetApConfiguration()
        asserts.assert_true(
            wifi_ap[wutils.WifiEnums.SSID_KEY] == \
                self.network[wutils.WifiEnums.SSID_KEY],
            "Configured wifi hotspot SSID did not match with the expected SSID")
        wutils.wifi_connect(self.tethered_devices[0], self.network)

        # update the wifi ap configuration with new ssid
        config = {wutils.WifiEnums.SSID_KEY: self.new_ssid}
        config[wutils.WifiEnums.PWD_KEY] = self.network[
            wutils.WifiEnums.PWD_KEY]
        config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_2G
        self._save_wifi_softap_configuration(dut, config)

        # start wifi tethering with new wifi ap configuration
        wutils.stop_wifi_tethering(dut)
        self._turn_on_wifi_hotspot(dut)

        # verify dut can connect to new wifi ap configuration
        new_network = {wutils.WifiEnums.SSID_KEY: self.new_ssid,
                       wutils.WifiEnums.PWD_KEY: \
                       self.network[wutils.WifiEnums.PWD_KEY]}
        wutils.wifi_connect(self.tethered_devices[0], new_network)
        wutils.stop_wifi_tethering(self.hotspot_device)
示例#12
0
    def test_ipv6_tethering(self):
        """ IPv6 tethering test

        Steps:
            1. Start wifi tethering on hotspot device
            2. Verify IPv6 address on hotspot device (VZW & TMO only)
            3. Connect tethered device to hotspot device
            4. Verify IPv6 address on the client's link properties (VZW only)
            5. Verify ping on client using ping6 which should pass (VZW only)
            6. Disable mobile data on provider and verify that link properties
               does not have IPv6 address and default route (VZW only)
        """
        # Start wifi tethering on the hotspot device
        wutils.toggle_wifi_off_and_on(self.hotspot_device)
        self._start_wifi_tethering()

        # Verify link properties on hotspot device
        self.log.info("Check IPv6 properties on the hotspot device. "
                      "Verizon & T-mobile should have IPv6 in link properties")
        self._verify_ipv6_tethering(self.hotspot_device)

        # Connect the client to the SSID
        wutils.wifi_connect(self.tethered_devices[0], self.network)

        # Need to wait atleast 2 seconds for IPv6 address to
        # show up in the link properties
        time.sleep(WAIT_TIME)

        # Verify link properties on tethered device
        self.log.info("Check IPv6 properties on the tethered device. "
                      "Device should have IPv6 if carrier is Verizon")
        self._verify_ipv6_tethering(self.tethered_devices[0])

        # Verify ping6 on tethered device
        ping_result = self._verify_ping(self.tethered_devices[0],
                                        wutils.DEFAULT_PING_ADDR, True)
        if self._supports_ipv6_tethering(self.hotspot_device):
            asserts.assert_true(ping_result, "Ping6 failed on the client")
        else:
            asserts.assert_true(not ping_result, "Ping6 failed as expected")

        # Disable mobile data on hotspot device
        # and verify the link properties on tethered device
        self.log.info("Disabling mobile data to verify ipv6 default route")
        self.hotspot_device.droid.telephonyToggleDataConnection(False)
        asserts.assert_equal(
            self.hotspot_device.droid.telephonyGetDataConnectionState(),
            tel_defines.DATA_STATE_CONNECTED, "Could not disable cell data")

        time.sleep(
            WAIT_TIME)  # wait until the IPv6 is removed from link properties

        result = self.tethered_devices[
            0].droid.connectivityHasIPv6DefaultRoute()
        self.hotspot_device.droid.telephonyToggleDataConnection(True)
        if result:
            asserts.fail(
                "Found IPv6 default route in link properties:Data off")
        self.log.info("Did not find IPv6 address in link properties")

        # Disable wifi tethering
        wutils.stop_wifi_tethering(self.hotspot_device)