Ejemplo n.º 1
0
 def test_get_memory_status(self):
     prefix = C_Memorry.PREFIX
     logging.info('{0}: START'.format(prefix))
     sleep(5)
     if wait_el_xpath_click(self.driver, C_Settings.PATH_MEMORY):
         sleep(5)
         if wait_el_xpath(self.driver, C_Memorry.PATH_DONUT) is not None:
             logging.info('{0}: There is no sd card.'.format(prefix))
             tv_total_memory = wait_el_xpath(self.driver,
                                             C_Memorry.PATH_TOTAL_MEMORY)
             tv_used = wait_el_xpath(self.driver, C_Memorry.PATH_USED)
             logging.info('{0}: {1} {2}'.format(
                 prefix, value(tv_used, Commands.TEXT),
                 value(tv_total_memory, Commands.TEXT)))
         else:
             logging.info('{0}: There is a sd card.')
             tv_used_c = wait_el_xpath(self.driver, C_Memorry.PATH_USED_C)
             tv_total_c = wait_el_xpath(self.driver, C_Memorry.PATH_TOTAL_C)
             logging.info('{0}: {1} {2}'.format(
                 prefix, value(tv_used_c, Commands.TEXT),
                 value(tv_total_c, Commands.TEXT)))
         sleep(2)
     else:
         self.fail('{0}: Memory load unsucceed.'.format(prefix))
     sleep(3)
     logging.info('{0}: END'.format(prefix))
Ejemplo n.º 2
0
  def test_multi_layers_no_reset(self):
    prefix = C_Maps.PREFIX
    logging.info('{0}: START'.format(prefix))
    sleep(3)
    if wait_el_xpath_click(self.driver, C_Maps.PATH_PAGE_SKIP, 3):
      logging.info('{0}:Launch Google Maps 1st time.'.format(prefix))
    else:
      logging.info('{0}: No need to initialize Google Maps.'.format(prefix))

    sleep(8)
    if wait_el_xpath_click(self.driver, C_Maps.PATH_BTN_COMPASS):

      map_list = [
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_DEFAULT),     # type_default
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_SATELLITE),   # type_satellite
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_TERRAIN)      # type_terrain
      ]
      details_list = [
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_TRANSIT),     # type_transit
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_TRAFFIC),     # type_traffic
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_BICYCLING)    # type_bicycling
      ]

      for m in map_list:
        action(m, Commands.CLICK)
        sleep(3)
        for d in details_list:
          action(d, Commands.CLICK)
          logging.info('{0}: {1} - {2}'.format(prefix, value(m, Commands.TEXT), value(d, Commands.TEXT)))
          sleep(3)
      wait_el_xpath_click(self.driver, C_Maps.PATH_BTN_CLOSE_COMPASS)
    else:
      nav_menu = wait_el_xpath(self.driver, C_Maps.PATH_NAV_MENU)
      if not nav_menu:
        logging.info('{0}: Navgiate menu load unsucceed.'.format(prefix))
        self.fail('{0}: Navgiate menu load unsucceed.'.format(prefix))
      else:
        action(nav_menu, Commands.CLICK)
        traffic_types = wait_els_xpath(self.driver, C_Maps.PATH_NAV_TYPES, 10)

        for type in traffic_types:
          logging.info('{0}: {1}'.format(prefix, value(type, Commands.TEXT)))
          action(type, Commands.CLICK)
          sleep(6)
          action(nav_menu, Commands.CLICK)

        action(traffic_types[0], Commands.CLICK)

        sleep(5)

    logging.info('{0}: END'.format(prefix))
Ejemplo n.º 3
0
    def test_bluetooth_enable(self):

        headset_name = C_Bluetooth.HEADSET_NAME
        prefix = C_Bluetooth.PREFIX_E
        logging.info('{0}: START'.format(prefix))
        switch_bluetooth = self.initB()
        if switch_bluetooth is None:
            self.fail('{0}: Bluetooth Switch load unsucceed.'.format(prefix))

        if value(switch_bluetooth,
                 Commands.TEXT) == C_Bluetooth.BLUETOOTH_DISABLED:
            action(switch_bluetooth, Commands.CLICK)
            logging.info('{0}: Bluetooth enable succeed.'.format(prefix))
        else:
            logging.info('{0}: Bluetooth is already enabled.'.format(prefix))

        sleep(5)
        while True:
            if wait_el_xpath_click(self.driver,
                                   C_Bluetooth.PATH_DEVICES_1ST_SETTINGS, 3):
                wait_el_xpath_click(self.driver, C_Bluetooth.PATH_BTN_FOGET)
                logging.info('{0}: Forget remmerbered devices.'.format(prefix))
                sleep(2)
            else:
                break

        wait_el_xpath_click(self.driver, C_Bluetooth.PATH_PAIR_NEW_DEVICE)
        if wait_el_xpath_click(self.driver, C_Bluetooth.PATH_HEADSET, 10):
            sleep(8)
            wait_el_xpath_click(self.driver, C_Bluetooth.PATH_BTN_PAIR)
            sleep(8)
            if wait_el_xpath(self.driver, C_Bluetooth.PATH_AVAILABLE_DEVICES,
                             3) is not None:
                logging.info(
                    '{0}: Pair with {1} unsucceed, Headset no response.'.
                    format(prefix, headset_name))
                self.fail('{0}: Pair with {1} unsucceed, Headset no response.'.
                          format(prefix, headset_name))
        else:
            self.fail('{0}: There is not a headset named {1}.'.format(
                prefix, headset_name))

        if wait_el_xpath(self.driver, C_Bluetooth.PATH_DEVICES_1ST_SETTINGS,
                         3) is None:
            logging.info('{0}: Pair with {1} unsucceed.'.format(
                prefix, headset_name))
            self.fail('{0}: {1} not found.'.format(
                prefix, C_Bluetooth.PATH_DEVICES_1ST_SETTINGS))
        else:
            logging.info('{0}: Pair with {1} succeed.'.format(
                prefix, headset_name))
        sleep(3)
        logging.info('{0}: END'.format(prefix))
Ejemplo n.º 4
0
    def test_wlan_disable(self):
        prefix = C_WLAN.PREFIX_D
        logging.info('{0}: START'.format(prefix))
        switch_wlan = self.initW()
        if switch_wlan is None:
            self.fail('{0}: WLAN Switch load unsucceed.'.format(prefix))

        if value(switch_wlan, Commands.TEXT) == C_WLAN.WLAN_ENABLED:
            action(switch_wlan, Commands.CLICK)
            logging.info('{0}: WLAN disable succeed.'.format(prefix))
        else:
            logging.info('{0}: WLAN is already disabled.'.format(prefix))
        sleep(3)
        logging.info('{0}: END'.format(prefix))
Ejemplo n.º 5
0
    def test_bluetooth_disable(self):

        prefix = C_Bluetooth.PREFIX_D
        logging.info('{0}: START'.format(prefix))
        switch_bluetooth = self.initB()
        if switch_bluetooth is None:
            self.fail('{0}: Bluetooth Switch load unsucceed.'.format(prefix))

        if value(switch_bluetooth,
                 Commands.TEXT) == C_Bluetooth.BLUETOOTH_ENABLED:
            action(switch_bluetooth, Commands.CLICK)
            logging.info('{0}: Bluetooth disable succeed.'.format(prefix))
        else:
            logging.info('{0}: Bluetooth is already disabled.'.format(prefix))
        sleep(3)
        logging.info('{0}: END'.format(prefix))
Ejemplo n.º 6
0
    def test_video_playback(self):
        prefix = C_Video.PREFIX
        play_minutes = C_Video.PLAY_MINUTES

        logging.info('{0}: START'.format(prefix))

        time.sleep(3)
        videos = wait_els_xpath(self.driver, C_Video.PATH_VIDEOS)
        if videos is None:
            logging.info('{0}: Check if there are videos'.format(prefix))
            self.fail("{0}: No Videos".format(prefix))

        logging.debug('{0}: Play each video for {1} minutes'.format(
            prefix, play_minutes / 3))
        for video in videos:
            logging.info('{0}: {1} is playing'.format(
                prefix, value(video, Commands.TEXT)))
            time.sleep(1)

            action(video, Commands.CLICK)
            timeout = time.time() + 20 * play_minutes

            select_play = wait_el_xpath(self.driver, C_Video.PATH_SELECT_PLAY,
                                        3)
            if select_play is not None:
                action(select_play, Commands.CLICK)
            wait_el_xpath_click(self.driver, C_Video.PATH_BTN_ALWAYS, 2)

            if wait_el_xpath_click(self.driver, C_Video.BTN_ALLOW, 3):
                logging.info('{0}: Permission Allowed.'.format(prefix))

            if wait_el_xpath_click(self.driver, C_Video.PATH_START_OVER, 3):
                logging.info('{0}: Start Over'.format(prefix))

            while time.time() < timeout:
                if (int(timeout - time.time())) % 20 == 0:
                    self.driver.get_window_size()
                    logging.info('{0}: Playing'.format(prefix))
                    time.sleep(5)

            if wait_el_xpath(self.driver, C_Video.PATH_VIDEOS) is None:
                self.driver.back()
            else:
                continue

        logging.info('{0}: END'.format(prefix))
Ejemplo n.º 7
0
    def test_music_palyback(self):
        prefix = C_Music.PREFIX
        logging.info('{0}: START'.format(prefix))
        if not wait_el_xpath_click(self.driver, C_Music.PATH_BTN_SKIP):
            logging.info(
                '{0}: No need to initialize Google Music.'.format(prefix))

        wait_el_xpath_click(self.driver, C_Music.PATH_NAV_LISTEN_NOW)
        time.sleep(3)
        if not wait_el_xpath_click(self.driver, C_Music.PATH_SHUFFLE_ALL):
            self.fail('{0}: If there are musics.'.format(prefix))
            logging.info('{0}: If there are musics.'.format(prefix))
        logging.info('{0}: Shuffle all of the music.'.format(prefix))
        btn_pause_play = wait_el_xpath(self.driver,
                                       C_Music.PATH_BTN_PAUSE_PLAY)

        while value(btn_pause_play,
                    Commands.TAG_NAME) == C_Music.STATUS_PLAYING:
            logging.info('{0}: Playing'.format(prefix))
            time.sleep(5)

        logging.info('{0}: END'.format(prefix))
Ejemplo n.º 8
0
    def test_wlan_enable(self):
        ap_point_name = C_WLAN.AP_POINT_NAME
        prefix = C_WLAN.PREFIX_E
        logging.info('{0}: START'.format(prefix))
        switch_wlan = self.initW()
        if switch_wlan is None:
            self.fail('{0}: WLAN Switch load unsucceed.'.format(prefix))

        if value(switch_wlan, Commands.TEXT) == C_WLAN.WLAN_DISABLED:
            action(switch_wlan, Commands.CLICK)
            logging.info('{0}: WLAN enable succeed.'.format(prefix))
            sleep(5)
        else:
            logging.info('{0}: WLAN is already enabled.'.format(prefix))
            sleep(3)

        ap_connected = wait_el_xpath(self.driver, C_WLAN.PATH_AP_CONNECTED)
        if ap_connected is not None:
            action(ap_connected, Commands.CLICK)
            wait_el_xpath_click(self.driver, C_WLAN.PATH_AP_FORGET)

        sleep(3)
        swipe_times = 10

        while True:
            ap_point = wait_el_xpath(self.driver, C_WLAN.PATH_AP_POINT, 3)
            if ap_point is None:
                add_network = wait_el_xpath(self.driver,
                                            C_WLAN.PATH_ADD_NETWORK, 3)
                if add_network is None:
                    if swipe_times != 0:
                        swipe_times = swipe_times - 1
                        logging.info('{0}: AP did not found'.format(prefix))
                        logging.info(
                            "{0}: Try swipe up to find the AP '{1}', times: {2}"
                            .format(prefix, ap_point_name, 10 - swipe_times))
                        MobileSwipe.swipe_up(self, self.driver, 800)
                        sleep(1)
                        continue
                    else:
                        logging.info('{0}: There is no AP named {1}'.format(
                            prefix, ap_point_name))
                        break
                else:
                    action(add_network, Commands.CLICK)
                    logging.info(
                        '{0}: Try to add network manually.'.format(prefix))
                    et_ssid = wait_el_xpath(self.driver, C_WLAN.PATH_ET_SSID)
                    action(et_ssid, Commands.CLICK)
                    action(et_ssid, Commands.CLEAR)
                    action(et_ssid, Commands.SEND_KEYS, ap_point_name)

                    wait_el_xpath_click(self.driver,
                                        C_WLAN.PATH_SPINNER_SECURITY)
                    wait_el_xpath_click(self.driver, C_WLAN.PATH_WPA_SECURITY)
                    wait_el_xpath_click(self.driver,
                                        C_WLAN.PATH_CHECKBOX_PW_SHOW)
                    et_pw = wait_el_xpath(self.driver, C_WLAN.PATH_ET_PW)
                    action(et_pw, Commands.CLEAR)
                    action(et_pw, Commands.CLICK)

                    # password: 173925239
                    password_str = C_WLAN.AP_PASSWORD
                    for s in password_str:
                        self.driver.press_keycode(Keycode.get(self, s))
                    wait_el_xpath_click(self.driver, C_WLAN.PATH_BTN_SAVE)
                    sleep(2)
                    break
            else:
                action(ap_point, Commands.CLICK)
                wait_el_xpath_click(self.driver, C_WLAN.PATH_CHECKBOX_PW_SHOW)
                et_pw = wait_el_xpath(self.driver, C_WLAN.PATH_ET_PW)
                action(et_pw, Commands.CLICK)
                action(et_pw, Commands.CLEAR)
                # password: 173925239
                password_str = C_WLAN.AP_PASSWORD
                for s in password_str:
                    self.driver.press_keycode(Keycode.get(self, s))
                wait_el_xpath_click(self.driver, C_WLAN.PATH_BTN_CONNECT)
                sleep(1)
                break

        sleep(8)
        self.driver.back()
        sleep(5)
        wifi_status = wait_el_xpath(self.driver, C_WLAN.PATH_WLAN_STATUS)
        if value(wifi_status, Commands.TEXT) == ap_point_name:
            logging.info('{0}: WLAN connect succeed.'.format(prefix))
        else:
            logging.info('{0}: WLAN connect unsucceed.'.format(prefix))
            self.fail('{0}: WLAN connect unsucceed.'.format(prefix))
        sleep(2)
        logging.info('{0}: END'.format(prefix))