예제 #1
0
def connect_to_ap(serial, condition, mode='bg', security='none',
                  dut_security=None, ddwrt_ap_name='ddwrt',
                  ddwrt_ap_pass='******', encryption=None, iteration=1,
                  q=None):
    for _ in range(0, iteration):
        # configure ap
        ap_steps.setup(mode, security, encryption=encryption,
                       wifi_password=ddwrt_ap_pass, new_ssid=ddwrt_ap_name,
                       serial=serial)()

        # turn display on, if turned off
        ui_steps.wake_up_device(serial=serial)()

        # ensure the device is unlocked
        ui_steps.unlock_device(serial=serial, pin=wifi_defaults.wifi['pin'])()

        # go to home screen
        ui_steps.press_home(serial=serial)()

        # make sure there are no saved networks
        wifi_generic_steps.clear_saved_networks(serial=serial)()

        # add the Wi-Fi network
        wifi_generic_steps.add_network(ssid=ddwrt_ap_name,
                                       security=dut_security,
                                       password=ddwrt_ap_pass, serial=serial)()

        # wait until the device connects to a wifi network
        wifi_generic_steps.wait_until_connected(serial=serial)()

        # check we are connected to the correct network.
        wifi_generic_steps.check_connection_info(serial=serial,
                                                 SSID=ddwrt_ap_name,
                                                 state='CONNECTED/CONNECTED')()

        # check connection
        obj = wifi_generic_steps.ping_gateway(serial=serial)
        obj()
        if 'passed' in obj.resolution.lower():
            return True if q is None else q.put(['Pass'])
        else:
            return False if q is None else q.put(['Success'])
예제 #2
0
        ui_steps.press_home(serial=serial)()

        # make sure there are no saved networks
        wifi_generic_steps.clear_saved_networks(serial=serial)()

        # add the Wi-Fi network
        wifi_generic_steps.add_network(ssid=ddwrt_ap_name,
                                       security=dut_security,
                                       serial=serial)()

        # wait until the device connects to a wifi network
        wifi_generic_steps.wait_until_connected(serial=serial)()

        # check we are connected to the correct network.
        wifi_generic_steps.check_connection_info(serial=serial,
                                                 SSID=ddwrt_ap_name,
                                                 state='CONNECTED/CONNECTED')()

        # check connection
        wifi_generic_steps.ping_gateway(serial=serial)()

        # Check and ping ipv6
        wifi_generic_steps.check_ipv6_address(
            serial=serial,
            ipv6_prefix=ipv6_prefix,
            ap_ipv6_address=ap_ipv6_address)()

    except:
        raise Exception("Error at iteration {0} \n {1}".format(
            i, traceback.print_exc()))
예제 #3
0
                                   password=ddwrt_ap_pass,
                                   identity=radius_identity,
                                   EAP_method=EAP_method,
                                   phase_2_auth=phase_2_auth,
                                   user_certificate=user_certificate,
                                   serial=serial)()

# wait until the device connects to a wifi network
wifi_generic_steps.wait_until_connected(serial=serial)()
time.sleep(2)
# verify the ping
wifi_steps.ping_gateway(serial=serial, trycount=10, timeout=30)()
# check we are connected to the correct network
wifi_generic_steps.check_connection_info(serial=serial,
                                         SSID=ddwrt_ap_name,
                                         state='CONNECTED/CONNECTED',
                                         Security=conf_security,
                                         pairwise_cipher=pairwise_cipher)()

(URL, IP) = wifi_generic_steps.create_download_url(file_name,
                                                   file_size,
                                                   local_path=".",
                                                   protocol=protocol,
                                                   port=port_number,
                                                   serial=serial)()

# start download
wifi_steps.download_file(URL,
                         file_name,
                         file_size,
                         protocol,
wifi_generic_steps.clear_saved_networks(serial = serial)()

# add 1st Wi-Fi network
wifi_generic_steps.add_network(ssid = ref_ap_name,
                               security = ref_ap_security,
                               password = ref_ap_pw,
                               serial = serial)()
for x in range(0, 11):

    # wait until the device connects to a wifi network
    wifi_generic_steps.wait_until_connected(serial=serial)()

    finish = time.time() + int(duration)
    print "Runnign stability test for " + duration + " seconds"
    while finish > time.time():
        # check we are connected to the correct network.
        wifi_generic_steps.check_connection_info(serial=serial,
                                                 SSID=ref_ap_name,
                                                 state='CONNECTED/CONNECTED')()

        wifi_generic_steps.ping_gateway(serial=serial, trycount="30")()

        print "Connection status OK at " + str(finish - time.time())

    print 'Opening web page repeated count = %d' %(x)
    adb_steps.command(serial=serial, command="am start -a android.intent.action.VIEW -d http://www.google.com")()
    time.sleep(20)
    adb_steps.command(serial=serial, command="am force-stop com.android.chrome")()

    ##### test end #####
예제 #5
0
    def verify_scenario(self):
        if self.scenario in ["Owner-Turn-WiFi-OFF", "CLI-Turn-WiFi-OFF",
                             "Owner-Activate-AM", "CLI-Activate-AM"]:
            wifi_state_to_check = "DISCONNECTED/"
            p2p_state_to_check = "DISCONNECTED/"

        elif self.scenario in ["Owner-Disconnect-Wifi", "CLI-Disconnect-Wifi",
                               "Owner-Scan-WiFi", "CLI-Scan-WiFi"]:
            wifi_state_to_check = "DISCONNECTED"
            p2p_state_to_check = "CONNECTED/CONNECTED"

        elif self.scenario in ["Owner-Deactivate-AM", "CLI-Deactivate-AM",
                               "Owner-Generate-P2P-Traffic", "CLI-Generate-P2P-Traffic",
                               "CLI-Connect-P2P", "Owner-Accept-Connect",
                               "Owner-Generate-WiFi-Traffic", "CLI-Generate-WiFi-Traffic",
                               "CLI-Connect-timeout", "Owner-Connect-timeout",
                               "CLI-Reconnect-Persistent-P2P",
                               "Owner-Reconnect-Persistent-P2P",
                               "Owner-Remove-Group", "Owner-P2P-Twoway-Traffic"]:
            if self.final_states['2_wifi_connected']:
                wifi_state_to_check = "CONNECTED/CONNECTED"
            else:
                wifi_state_to_check = "DISCONNECTED/"
            p2p_state_to_check = "CONNECTED/CONNECTED"

        elif self.scenario in ["CLI-Leave-Group","Owner-Dismiss-CLI",
                               "Owner-Reject-Connect"]:
            if self.final_states['2_wifi_connected']:
                wifi_state_to_check = "CONNECTED/CONNECTED"
            else:
                wifi_state_to_check = "DISCONNECTED/"
            p2p_state_to_check = "DISCONNECTED/"

        elif self.scenario in ["Owner-Connect-WiFi", "CLI-Connect-WiFi"]:
            wifi_state_to_check = "CONNECTED/CONNECTED"
            p2p_state_to_check = "CONNECTED/CONNECTED"


        # check wifi transfer
        if self.states['4_wifi_traffic']:
            psteps.interpret_step(self.step_id_wifi)

        # check p2p transfer
        if self.states['5_p2p_traffic']:
            psteps.interpret_step(self.step_id_p2p)

        while True:
            if self.verify_disconnect:
                time.sleep(10)
            else:
                break

        # check wifi connection

        wifi_generic_steps.check_connection_info(state=wifi_state_to_check,
                                                 regex = True,
                                                 serial = self.action_serial)()

        # check p2p connection
        wifi_generic_steps.p2p_check_connection_info(state=p2p_state_to_check,
                                                go_serial = self.go_serial,
                                                timeout = 10,
                                                regex = True,
                                                slave_serial = self.cli_serial)()

        # check AM
        if self.final_states['1_am'] != wifi_utils.check_airplane_mode_on(serial = self.am_serial):
            return False
        return True
예제 #6
0
''' test start '''

# turn display on, if turned off
ui_steps.wake_up_device(serial=args["serial"])()

# ensure the device is unlocked
ui_steps.unlock_device(serial=args["serial"], pin=wifi_defaults.wifi['pin'])()


# go to home screen
ui_steps.press_home(serial=args["serial"])()

for x in xrange(int(script_params["iterations"])):
    # Turn ON the wifi and check if it is successfully turned ON
    wifi_generic_steps.set_wifi(serial=args["serial"],
                                state="ON", use_adb=False)()

    time.sleep(3)

    # Turn OFF the wifi and check if it is successfully turned turned OFF
    wifi_generic_steps.set_wifi(serial=args["serial"],
                                state="OFF", use_adb=False)()

    time.sleep(3)

    # Check for the connection status
    wifi_generic_steps.check_connection_info(serial=args["serial"],
                                             state='DISCONNECTED/DISCONNECTED')()

''' test end '''
# ensure the device is unlocked
ui_steps.unlock_device(serial=serial, pin=wifi_defaults.wifi['pin'])()

# go to home screen
ui_steps.press_home(serial=serial)()

# make sure there are no saved networks
wifi_generic_steps.clear_saved_networks(serial=serial)()

conf = wifi_utils.get_connection_content(serial=serial)
conf_dict = wifi_utils.get_connection_info(conf)

# get the MAC address and check there is no IP Address
wifi_generic_steps.check_connection_info(serial=serial,
                                         MAC=conf_dict['MAC'],
                                         ip_address="None")()

# add the Wi-Fi network
wifi_generic_steps.add_network(ssid=ddwrt_ap_name,
                               security=dut_security,
                               password=ddwrt_ap_pass,
                               serial=serial)()

# wait until the device connects to a wifi network
wifi_generic_steps.wait_until_connected(serial=serial)()

# check we are connected to the correct network and the MAC is the same
wifi_generic_steps.check_connection_info(serial=serial,
                                         SSID=ddwrt_ap_name,
                                         MAC=conf_dict['MAC'])()
wifi_generic_steps.clear_saved_networks(serial=serial)()

# make sure there are no p2p connections
wifi_generic_steps.p2p_disconect_all(serial=serial)()

# set the airplane mode off
wifi_generic_steps.set_airplane_mode(serial=serial, state="OFF")()

# create the hot spot
wifi_generic_steps.configure_hotSpot(serial=serial,
                                     hotSpot_name=hotSpot_name,
                                     hotSpot_security=hotSpot_security,
                                     hotSpot_band=hotSpot_band,
                                     hotSpot_pass=hotSpot_pass)()

# turn on the HotSpot
wifi_generic_steps.set_hotSpot(serial=serial, hotSpot_state="ON")()

# turn on the airplane mode
wifi_generic_steps.set_airplane_mode(serial=serial, state="ON")()

# verify the status of the wifi
wifi_generic_steps.check_connection_info(serial=serial,
                                         state="DISCONNECTED/DISCONNECTED")()

# turn off the airplane mode
wifi_generic_steps.set_airplane_mode(serial=serial, state="OFF")()

# turn off the HotSpot
wifi_generic_steps.set_hotSpot(serial=serial, hotSpot_state="OFF")()
예제 #9
0
# ensure the device is unlocked
ui_steps.unlock_device(serial = serial, pin=wifi_defaults.wifi['pin'])()

# go to home screen
ui_steps.press_home(serial = serial)()

# make sure there are no saved networks
wifi_generic_steps.clear_saved_networks(serial = serial)()

# turn wifi on and off
wifi_generic_steps.set_wifi(state="OFF", serial = serial)()
wifi_generic_steps.set_wifi(state="ON", serial = serial)()

# check the DUT is scanning
count = 0
while count < int(iterations):
    time.sleep(5)
    if device_info.dessert in ["N", "O"]:
        wifi_generic_steps.check_connection_info(serial=serial,
                                                 state='DISCONNECTED/DISCONNECTED',
                                                 timeout=10)()
    else:
        wifi_generic_steps.check_connection_info(serial = serial,
                                                state='DISCONNECTED/SCANNING',
                                                timeout=10)()
    count += 1


##### test end #####
예제 #10
0
                                             password='******',
                                             serial=serial)()

    wifi_generic_steps.wait_until_connected(serial=serial)()

    # add the 5GHz Wi-Fi network
    wifi_generic_steps.connect_with_password(ap_name=new_ssid + '5',
                                             password='******',
                                             serial=serial)()

    # wait until the device connects to a wifi network
    wifi_generic_steps.wait_until_connected(serial=serial)()

    # check we are connected to the 5GHz network.
    wifi_generic_steps.check_connection_info(serial=serial,
                                             SSID=new_ssid + '5',
                                             state='CONNECTED/CONNECTED')()

    # avoid the bug which always shows last AP to which the DUT was connected <= verify_dumpsys = False
    wifi_generic_steps.set_wifi_frequency_band(serial=serial,
                                               frequency_band='2',
                                               wait_time=wait_time,
                                               verify_dumpsys=False)()

    # wait until the device connects to a wifi network
    time.sleep(5)
    wifi_generic_steps.wait_until_connected(serial=serial)()

    # check we are connected to the 2.4GHz network.
    wifi_generic_steps.check_connection_info(serial=serial,
                                             SSID=new_ssid,
예제 #11
0
# turn display on, if turned off
ui_steps.wake_up_device(serial=serial)()

# ensure the device is unlocked
ui_steps.unlock_device(serial=serial, pin=wifi_defaults.wifi['pin'])()

# go to home screen
ui_steps.press_home(serial=serial)()

# make sure the test SSID is not saved in the known list
wifi_generic_steps.remove_network(ap_name=ddwrt_ap_name, serial=serial)()

# try to connect to the AP with wrong password
wifi_generic_steps.add_network(ssid=ddwrt_ap_name,
                               security=dut_security,
                               password=ddwrt_ap_pass,
                               serial=serial)()

# verify on DUT that the connection to AP is not successful
wifi_generic_steps.check_connection_info(SSID=ddwrt_ap_name,
                                         state="DISCONNECTED/SCANNING",
                                         serial=serial)()

####investigate if it is necessary
# check that the SSID is "remembered" on DUT
wifi_generic_steps.wifi_check_SSID_known(ap_name=ddwrt_ap_name,
                                         serial=serial)()

##### test end #####
예제 #12
0
wifi_generic_steps.add_network(
    ssid="SSG_LAB_VAL_S3",
    security="WPA2",
    password="******",
    #identity = radius_identity,
    #EAP_method = EAP_method,
    #phase_2_auth = phase_2_auth,
    #user_certificate = user_certificate,
    serial=serial)()

# wait until the device connects to a wifi network
wifi_generic_steps.wait_until_connected(serial=serial)()

# check we are connected to the correct network
wifi_generic_steps.check_connection_info(serial=serial,
                                         SSID="SSG_LAB_VAL_S3",
                                         state='CONNECTED/CONNECTED',
                                         Security="WPA_PSK")()
#pairwise_cipher=pairwise_cipher)()

#Download from external network SED network

uidevice = ui_device(serial=serial)
dut = Adb(serial=serial)
#Download a big file over wifi.

download = "am start -a android.intent.action.VIEW -d ftp://speedtest.tele2.net/100MB.zip"
#dut.run_cmd(download)
if uidevice(packageName="com.estrongs.android.pop").exists:
    uidevice(packageName="com.estrongs.android.pop", text="Hide").click()

예제 #13
0
               hidden_ssid="1")()

#wait for the SSID to disappear from AP list
#wifi_generic_steps.scan_and_check_ap(ddwrt_ap_name, trycount=30, should_exist=False, serial = serial)()

# add the hidden Wi-Fi network
wifi_generic_steps.add_network(ssid=ddwrt_ap_name,
                               security=dut_security,
                               password=ddwrt_ap_pass,
                               serial=serial)()

# wait until the device connects to the wifi network
wifi_generic_steps.wait_until_connected(serial=serial)()

# check we are connected to the correct network
if security_check:
    wifi_generic_steps.check_connection_info(serial=serial,
                                             SSID=ddwrt_ap_name,
                                             state='CONNECTED/CONNECTED',
                                             Security=security_check_alt
                                             or security_check,
                                             group_cipher=group_cipher,
                                             pairwise_cipher=pairwise_cipher)()
else:
    wifi_generic_steps.check_connection_info(serial=serial,
                                             SSID=ddwrt_ap_name,
                                             state='CONNECTED/CONNECTED',
                                             group_cipher=group_cipher,
                                             pairwise_cipher=pairwise_cipher)()
##### test end #####
                               serial = serial)()

# verify that DUT is not connected
wifi_generic_steps.check_wifi_state_disconnected(ap_name = ddwrt_ap_name,
                                    security = 'wpa',
                                    encryption = encryption,
                                    wrong_password = True,
                                    serial = serial)()

if test_type == "auto_roam":
    # wait until the device automatically roams to the remembered wifi network
    wifi_generic_steps.wait_until_connected(serial = serial, timeout=300)()

    # check we are connected to the correct network.
    wifi_generic_steps.check_connection_info(serial = serial,
                                            SSID = ddwrt_ap_name+"_virt",
                                            state='CONNECTED/CONNECTED')()

elif test_type == "manual_roam":
    # add the physical wifi network
    wifi_generic_steps.add_network(ssid = ddwrt_ap_name+"_virt",
                               security = dut_security,
                               password = ddwrt_ap_pass,
                               identity = radius_identity,
                               EAP_method = EAP_method,
                               phase_2_auth = phase_2_auth,
                               user_certificate = user_certificate,
                               serial = serial)()

    # wait until the device connects to a wifi network
    wifi_generic_steps.wait_until_connected(serial = serial)()
예제 #15
0
wifi_generic_steps.clear_saved_networks(serial=args["serial"])()

if script_params["execute_add_network_and_test_ping"] == "True":

    # add the Wi-Fi network
    wifi_generic_steps.add_network(ssid=script_params["ap_name"],
                                   security=script_params["dut_security"],
                                   password=script_params["passphrase"],
                                   serial=args["serial"])()

    # wait until the device connects to a wifi network
    wifi_generic_steps.wait_until_connected(serial=args["serial"])()

    # check we are connected to the correct network.
    wifi_generic_steps.check_connection_info(serial=args["serial"],
                                             SSID=script_params["ap_name"],
                                             state='CONNECTED/CONNECTED')()

    # check connection
    wifi_generic_steps.ping_gateway(trycount=5, serial=args["serial"])()

    if script_params["iterate_connect_disconnect"] == "True":
        for x in xrange(int(script_params["iterations"])):
            # Turn ON the wifi and check if it is successfully turned ON
            wifi_generic_steps.set_wifi(serial=args["serial"],
                                        state="OFF",
                                        use_adb=False)()

            time.sleep(3)

            # Check for the connection status
예제 #16
0
    ssid=ddwrt_ap_name if str(new_ssid).lower() == "none" else new_ssid,
    security=dut_security,
    password=ddwrt_ap_pass,
    identity=radius_identity,
    EAP_method=EAP_method,
    phase_2_auth=phase_2_auth,
    user_certificate=user_certificate,
    ca_certificate=ca_certificates,
    serial=serial)()

# wait until the device connects to a wifi network
wifi_generic_steps.wait_until_connected(serial=serial)()

# check we are connected to the correct network.
wifi_generic_steps.check_connection_info(
    serial=serial,
    SSID=ddwrt_ap_name if str(new_ssid).lower() == "none" else new_ssid,
    state='CONNECTED/CONNECTED')()

# check connection
wifi_generic_steps.ping_gateway(trycount=trycount, serial=serial)()

ap_steps.setup(
    mode,
    security,
    ssh_host=ipv4_class,
    encryption=encryption,
    wifi_password=ddwrt_ap_pass,
    radius_ip=radius_ip,
    radius_secret=radius_secret,
    new_ssid=ddwrt_ap_name if str(new_ssid).lower() == "none" else new_ssid,
    channel_bw=channel_bw,
예제 #17
0
                                   password=ap_pass,
                                   identity=radius_identity,
                                   EAP_method=EAP_method,
                                   phase_2_auth=phase_2_auth,
                                   user_certificate=user_certificate,
                                   serial=serial)()

# config AP2 virt disabled
ap_steps.setup_virtual_interface(enable=False,
                                 interface5ghz=interface5ghz_ap2,
                                 virt_if_idx=virt_if_idx,
                                 reload_ap=False,
                                 serial=serial)()

wifi_generic_steps.check_connection_info(serial=serial,
                                         SSID=ap_name_virt_1,
                                         state='CONNECTED/CONNECTED',
                                         timeout=180)()

# WiFI off
wifi_generic_steps.set_wifi(serial=serial, state="OFF")()
# verify that DUT is not connected
wifi_generic_steps.check_wifi_state_disconnected(ap_name=ap_name_virt_1,
                                                 security='wpa',
                                                 encryption=encryption,
                                                 serial=serial)()
wifi_generic_steps.check_wifi_state_disconnected(ap_name=ap_name_virt_2,
                                                 security='wpa',
                                                 encryption=encryption,
                                                 serial=serial)()

# WiFI on