def testRebootOSADB(self): """ reboot device by 'adb reboot' while setting up work profile :return: None """ if self.api.locate_apps("Work Sample MDM"): self.api.remove_managed_profile(True) self.api.clean_tasks() self.api.api_demo_launch() self.api.click_with_timeout("resourceId", self.api.ui.setup_managed_profile) if not self.api.is_android_L_build(): self.api.click_with_timeout("text", "No", 5) self.api.click_with_timeout("text", "Set up", 10) self.api.click_with_timeout("text", "OK") self.api.click_with_timeout("text", "OK") g_common_obj2.system_reboot(90) for _ in range(20): self.api = ApiImpl() self.api.d.wakeup() if self.api.check_ui_exists("resourceId", self.api.ui.lock_clock_view): break time.sleep(5) g_common_obj.set_vertical_screen() self.api.unlock_screen() if self.api.check_ui_exists("textContains", "isn't responding", 5): self.api.click_with_timeout("text", "OK") self.api.clean_tasks() assert self.api.check_ui_exists("description", "Apps"), "Fail to detect Apps Launcher"
def tearDown(self): print "[Teardown]: %s" % self._test_name super(ComposeUI, self).tearDown() self._composeui.delete_local_video() self.photos.rm_delete_photos() self.photos.refresh_sdcard() g_common_obj.set_vertical_screen()
def tearDown(self): super(MultiUserSupport, self).tearDown() # reboot device since there is a chance that we get error before switch back to owner user # that will impact some later testing g_common_obj2.system_reboot(90) for _ in range(20): self.api = ApiImpl() self.api.d.wakeup() if self.api.check_ui_exists("resourceId", self.api.ui.lock_clock_view): break time.sleep(5) g_common_obj.set_vertical_screen() print "[Teardown]: %s" % self._test_name
def test_videoplayback_interaction(self): ''' refer TC test_VideoPlayback_Interaction ''' print "[RunTest]: %s" % self.__str__() self.photos.launch_photos_am() self._composeui.rotate_during_video_playback() time.sleep(2) g_common_obj.set_vertical_screen() g_common_obj.assert_exp_happens() self._composeui.swipedown_notification_and_rotate_during_video_playback( ) time.sleep(2) g_common_obj.set_vertical_screen() g_common_obj.assert_exp_happens() self.photos.stop_photos_am()
def testReboot_OS(self): """ reboot device :return: None """ g_common_obj2.system_reboot(90) for _ in range(20): self.api = ApiImpl() self.api.d.wakeup() if self.api.check_ui_exists("resourceId", self.api.ui.lock_clock_view): break time.sleep(10) g_common_obj.set_vertical_screen() self.api.unlock_screen() if self.api.check_ui_exists("textContains", "isn't responding", 5): self.api.click_with_timeout("text", "OK") assert self.api.check_ui_exists( "description", "Apps", 5), "[ERROR]: fail to detect Apps launcher"
def testCreateWorkProfile_Remove_50_times(self): """ create and delete work profile for 50 times :return: None """ self.api.api_demo_launch() if self.api.check_ui_exists("textContains", "Device Owner", 5): self.api.click_with_timeout("resourceId", self.api.ui.device_provision) self.api.click_with_timeout("resourceId", self.api.ui.clear_device_owner_app) self.api.click_with_timeout("text", "Yes") g_common_obj2.system_reboot(90) for _ in range(20): self.api = ApiImpl() self.api.d = g_common_obj.get_device() self.api.d.wakeup() if self.api.check_ui_exists("resourceId", self.api.ui.lock_clock_view): break time.sleep(5) g_common_obj.set_vertical_screen() self.api.unlock_screen() for _ in range(50): if not self.api.locate_apps("Work Sample MDM"): self.api.setup_managed_profile(True) # time.sleep(5) # self.api.settings_sub_launch("Accounts") # assert self.api.check_ui_exists("text", "Accounts"), # "fail to launch settings at {0}".format(_) # assert self.api.check_ui_exists("text", "Work"), # "fail to detect work section in accounts at {0}".format(_) assert self.api.is_work_profile_enabled( ), "fail to detect work section in accounts at {0}".format(_) self.api.click_with_timeout("text", "Remove work profile") self.api.d.wait.update(timeout=3000) self.api.click_with_timeout("text", "Delete") self.api.d.wait.update(timeout=3000) assert self.api.check_ui_exists("text", "Accounts"), \ "fail to detect accounts after remove work profile at {0}".format(_) assert not self.api.check_ui_exists("text", "Work"), \ "fail to detect work section in accounts at {0}".format(_) self.api.clean_tasks()
def run(self): self.func.download_oem_content_artifactory('/IRDA_OEM_Customization/', 'OEM_file.zip') g_common_obj.root_on_device() self.func.mount_device() self.func.remove_folder() self.func.make_folder() self.func.push_oem_file() self.func.push_prop() self.func.setup_connection() self.func.unlock_screen() self.func.factory_reset() self.func.check_reset() self.func.wait_for_android_os() g_common_obj.root_on_device() self.func.mount_device() #self.func.setup_connection() g_common_obj.set_vertical_screen() self.func.skip_initial_screen_after_factory_reset()
def testFactoryResetSupport(self): """ verify that able to factory reset device successfully :return: None """ self.api.set_lock_swipe() self.api.clean_tasks() self.api.settings_sub_launch("Backup & reset") assert self.api.check_ui_exists("text", "Factory data reset", 5), "fail to detect factory data reset" self.api.click_with_timeout("text", "Factory data reset") self.api.click_with_timeout("resourceId", "com.android.settings:id/initiate_master_clear") assert self.api.check_ui_exists("resourceId", "com.android.settings:id/execute_master_clear", 5), \ "fail to detect erase everything" self.api.click_with_timeout("resourceId", "com.android.settings:id/execute_master_clear") time.sleep(600) # reboot device g_common_obj2.system_reboot(90) for _ in range(30): self.api = ApiImpl() self.api.d = g_common_obj.get_device() self.api.d.wakeup() if self.api.check_ui_exists("resourceId", "com.google.android.setupwizard:id/welcome_title"): break time.sleep(10) self.api.d.wakeup() g_common_obj.set_vertical_screen() assert self.api.check_ui_exists("resourceId", "com.google.android.setupwizard:id/welcome_title"), \ "fail to detect welcome title in setup wizard" # try to skip setup wizard by click four corner for i in range(5): self.api.d.wakeup() x = self.api.d.info['displayWidth'] y = self.api.d.info['displayHeight'] self.api.click_with_timeout("text", "Allow") if self.api.check_ui_exists("text", "GOT IT"): self.api.click_with_timeout("text", "GOT IT") break self.api.d.click(50, 50) self.api.d.click(x - 50, 50) self.api.d.click(x - 50, y - 50) self.api.d.click(50, y - 50) time.sleep(5) self.api.keep_awake()
def testPhoneFlashDUT(self): """ This test case is to test basic GOTA update function Test Case Precondition: The workstation installed phone fash tool Test Case Step: 1. test phone flash dut Expect Result: 1. it can phone flash DUT successfully The real implementation will be in SystemImpl class. """ print "[RunTest]: %s" % self.__str__() base = self.cfg.get("base") target = self.cfg.get("target") base_build = self.cfg.get("base_build") host_oem_file = self.cfg.get("host_oem_file") client_oem_file = self.cfg.get("client_oem_file") gota_test_run_by_testplan = self.cfg.get("gota_test_run_by_testplan") tmp_name = time.strftime('%Y-%m-%d_%H:%M:%S', time.localtime(time.time())) before_ota_info_file = "~/ota/" + "beforeOTA_" + tmp_name + ".log" self.gota.phone_flash_tool_build_zip_file_3(base_build) g_common_obj.root_on_device() self.gota.mount_device() self.system.adb_push_file(host_oem_file, client_oem_file) self.gota.factory_reset() self.gota.wait_for_android_os() self.gota.setup_connection() self.gota.push_uiautomator_jar() g_common_obj.set_vertical_screen() self.gota.skip_initial_screen_after_flash() self.gota.enable_developer_option() self.gota.keep_awake() self.gota.accept_unknow_resource() self.gota.close_lock_screen() self.gota.unverify_apps_over_USB()
def init_dut_squeence(self): """ seqeueence of predebugplan """ self.__init__() SampleApiDemoImpl().unlock() self.func.push_uiautomator_jar() g_common_obj.set_vertical_screen() self.enable_developer_option() self.keep_awake() self.func.wake_up() self.add_google_account() self.init_playstore() self.func.init_camera() self.init_chrome() self.func.init_photo() self.init_googlemap() self.init_hangout() self.init_playmusic() self.func.init_youtube()
def testCheckDeviceOwnerAfterGOTA(self): print "[RunTest]: %s" % self.__str__() #flash DUT base_build = self.cfg.get("base_build") self.gota.phone_flash_tool_build_zip_file(base_build) self.gota.push_uiautomator_jar() g_common_obj.set_vertical_screen() #check Connect AP before gota self.gota.launch_settings() print "self.ssid: %s" % self.ssid print "self.passwd: %s" % self.passwd if self.ssid == None: print "using default ap setting" self.gota.connect_AP("SHZ13F-OTC-irda101", "zxcvbnm!?") else: print "using config ap setting" self.gota.connect_AP(self.ssid, self.passwd) print "[Info] --- Connect ap before gota" #setup init DUT self.gota.enable_developer_option() self.gota.keep_awake() self.gota.close_lock_screen() self.gota.accept_unknow_resource() self.gota.unverify_apps_over_USB() self.d.press.back() self.d.press.back() #setup Sample MDM in oobe self.api.oobe_setup(True) #check Sample MDM(Profile Owner) before gota self.api.launch_app("Sample MDM") self.assertFalse( self.d(text="Sample MDM(Profile Owner)").exists, "[ERROR]:Fail to provision device as device owner") #check data in personal profile before gota self.gota.check_AFW_data_in_personal_profile_before_GOTA() #download and install GOTA package self.gota.download_package_and_auto_retry() self.gota.restart_and_install_package() #check Sample MDM(Profile Owner) after gota self.gota.check_AFW_devices_owner_after_GOTA()
def testDiskEncryptionStatus(self): """ verify the encryption status of device :return: """ ret = os.popen("adb -s {0} shell getprop ro.crypto.state".format(self.api.serial)).read().strip() if ret != 'encrypted': try: self.api.keep_awake() self.api.launch_app_by_intents("android.settings.SECURITY_SETTINGS", False) assert self.api.check_ui_exists("text", "Encryption", 5), "Fail to detect Encryption option" if not self.api.check_ui_exists("text", "Encrypted", 5): if self.api.check_ui_exists("text", "Encrypt phone"): self.api.click_with_timeout("text", "Encrypt phone") else: self.api.click_with_timeout("text", "Encrypt tablet") assert not self.api.check_ui_exists("resourceId", "com.android.settings:id/warning_low_charge"), \ "fail to encrypt device due to low battery" assert not self.api.check_ui_exists("resourceId", "com.android.settings:id/warning_unplugged"), \ "fail to encrypt due to need to replug in charger" self.api.click_with_timeout("resourceId", "com.android.settings:id/initiate_encrypt") self.api.click_with_timeout("resourceId", "com.android.settings:id/execute_encrypt") for _ in range(3): self.api.d.server.stop() finally: time.sleep(600) self.api = ApiImpl() g_common_obj2.system_reboot(90) for i in range(30): self.api.d = g_common_obj.get_device() self.api.d.wakeup() if self.api.check_ui_exists("resourceId", self.api.ui.lock_clock_view) or \ self.api.check_ui_exists("resourceId", "com.google.android.setupwizard:id/welcome_title"): break time.sleep(10) g_common_obj.set_vertical_screen() self.api.unlock_screen() ret = os.popen("adb -s {0} shell getprop ro.crypto.state".format(self.api.serial)).read().strip() assert ret == 'encrypted', "fail to encrypt device"
def testRotatingScreenAfterGOTA(self): """ This test case is to test rorating screen after gota Test Case Precondition: Test Case Step: 1. rotating screen after gota Expect Result: rotating successfully The real implementation will be in gota_Impl class. """ print "[RunTest]: %s" % self.__str__() self.d.orientation = "l" time.sleep(1) self.d.orientation = "u" time.sleep(1) self.d.orientation = "r" time.sleep(1) self.d.orientation = "n" g_common_obj.set_vertical_screen()
def testProvision_Device_with_Device_Owner(self): """ provision device with device owner during OOBE :return: None """ self.api.d.wakeup() self.function.push_uiautomator_jar() g_common_obj.set_vertical_screen() if not self.api.check_ui_exists("packageName", "com.google.android.setupwizard"): self.api.d.press.home() if self.api.check_ui_exists("description", "Apps"): self.api.clean_tasks() self.api.factory_reset() time.sleep(1200) self.api = ApiImpl() self.api.d.wakeup() g_common_obj.set_vertical_screen() else: while not self.api.check_ui_exists( "resourceId", "com.google.android.setupwizard:id/welcome_title"): self.api.d.press.back() assert self.api.check_ui_exists("resourceId", "com.google.android.setupwizard:id/welcome_title"), \ "[ERROR]: Please run test cases at the beginning of OOBE" # for unencrypted device, just bypass encryption when provision device # the encryption test cases will raise this problem if os.popen("adb -s {0} shell getprop ro.crypto.state".format( self.api.serial)).read().strip() == "unencrypted": os.popen("adb -s {0} root".format(self.api.serial)).read().strip() time.sleep(5) os.popen( "adb -s {0} shell setprop persist.sys.no_req_encrypt true". format(self.api.serial)).read().strip() time.sleep(5) self.api.oobe_setup(True) self.api.unlock_screen() self.api.clean_tasks() self.api.d.press.home() time.sleep(5) self.api.click_with_timeout("text", "GOT IT") try: self.api.api_demo_launch() assert self.api.check_ui_exists("textContains", "Device Owner", 5), \ "[ERROR]: fail to provision device as device owner" g_common_obj.set_vertical_screen() finally: self.api.keep_awake()
def tearDown(self): print "[Teardown]: %s" % self._test_name super(ComposeUI, self).tearDown() g_common_obj.set_vertical_screen()
def tearDownClass(cls): print "[tearDownClass]: %s" % cls.__name__ super(SettingMenuRotate, cls).tearDownClass() g_common_obj.set_vertical_screen()
def testWiFi_Connection_Pretest(self): """ Check WiFi connection in pretest :return: None """ # read wifi info from /etc/oat/sys.conf by default if it exist assert os.path.isfile( "/etc/oat/sys.conf" ), "[ERROR]: Missing config file /etc/oat/sys.config in host" cfg_file = "/etc/oat/sys.conf" self.ssid = self.config.read(cfg_file, 'wifisetting').get("ssid") self.password = self.config.read(cfg_file, 'wifisetting').get("passwd") self.security = self.config.read(cfg_file, 'wifisetting').get("security") self.retry_wifi = self.config.read('tests.tablet.dut_init.conf', 'init_list').get("connect_wifi") # check ui element "Apps" to make sure we are at oobe stage self.api.d.press.home() if self.api.check_ui_exists("description", "Apps"): self.api.set_lock_swipe() self.api.clean_tasks() self.api.settings_sub_launch("Backup & reset") assert self.api.check_ui_exists( "text", "Factory data reset", 5), "fail to detect factory data reset" self.api.click_with_timeout("text", "Factory data reset") self.api.click_with_timeout( "resourceId", "com.android.settings:id/initiate_master_clear") assert self.api.check_ui_exists("resourceId", "com.android.settings:id/execute_master_clear", 5), \ "fail to detect erase everything" self.api.click_with_timeout( "resourceId", "com.android.settings:id/execute_master_clear") time.sleep(600) # reboot device g_common_obj2.system_reboot(90) for _ in range(30): self.api = ApiImpl() self.api.d = g_common_obj.get_device() self.api.d.wakeup() if self.api.check_ui_exists( "resourceId", "com.google.android.setupwizard:id/welcome_title"): break time.sleep(10) self.api.d.wakeup() g_common_obj.set_vertical_screen() # keep device awake # self.api.keep_awake() # enable unknown sources self.api.unknown_source_control(True) # will check for 10 times and will back to welcome page if it's not for _ in range(10): if self.api.check_ui_exists( "resourceId", "com.google.android.setupwizard:id/welcome_title"): break # just back to welcome page self.api.d.press.back() # launch WiFi Settings by intent self.api.launch_app_by_intents("android.settings.WIFI_SETTINGS", False) assert self.api.check_ui_exists( "textMatches", "Wi.Fi"), "[ERROR]: fail to launch wifi settings" # try to connect wifi for retry in range(int(self.retry_wifi)): # turn on wifi if it is off if self.api.check_ui_exists("text", "Off"): self.api.d(text="Off").right(text="OFF").click() time.sleep(10) if self.api.d(resourceId="android:id/list").scrollable: self.api.d(scrollable=True).scroll.vert.to( text=self.ssid) # scroll to ssid if self.api.check_ui_exists("text", self.ssid): # if wifi ap is not hidden if self.api.check_ui_exists( "text", "Connected"): # break if wifi is connected break self.api.click_with_timeout("text", self.ssid) # input password if needed if self.api.check_ui_exists( "resourceId", "com.android.settings:id/password"): self.api.d(resourceId="com.android.settings:id/password" ).set_text(self.password) # click "Connect": a)first time to connect b)reconnect to wifi if failed before if self.api.check_ui_exists("text", "Connect"): self.api.click_with_timeout("text", "Connect") # click "Done" if wifi is connecting if self.api.check_ui_exists("text", "Done"): self.api.click_with_timeout("text", "Done") else: # connect to hidden wifi ap self.api.d.press.menu() self.api.d(text="Add network").click.wait() self.api.d(text="Enter the SSID").set_text(self.ssid) self.api.d(resourceId="com.android.settings:id/security", index=1).click.wait() self.api.d(text=self.security).click.wait() self.api.d( resourceId="com.android.settings:id/password").set_text( self.password) self.api.d(text="Save").click.wait() time.sleep(10) # wifi should be connected now assert self.api.check_ui_exists( "text", self.ssid), "[ERROR]: WiFi SSID does't exist" assert self.api.check_ui_exists( "text", "Connected"), "[ERROR]: Fail to connect WiFi" # back to oobe self.api.d.press.back()
def testPretest_for_reliability(self): """ provision device if needed """ # read wifi info from /etc/oat/sys.conf by default if it exist assert os.path.isfile( "/etc/oat/sys.conf" ), "[ERROR]: Missing config file /etc/oat/sys.config in host" cfg_file = "/etc/oat/sys.conf" self.ssid = self.config.read(cfg_file, 'wifisetting').get("ssid") self.password = self.config.read(cfg_file, 'wifisetting').get("passwd") self.security = self.config.read(cfg_file, 'wifisetting').get("security") self.retry_wifi = self.config.read('tests.tablet.dut_init.conf', 'init_list').get("connect_wifi") # check ui element "Apps" to make sure we are at oobe stage self.api.d.press.home() self.api.d.wait.update(timeout=5000) if self.api.check_ui_exists("description", "Apps"): # self.api.set_lock_swipe() # self.api.clean_tasks() # self.api.settings_sub_launch("Backup & reset") # assert self.api.check_ui_exists("text", "Factory data reset", 5), "fail to detect factory data reset" # self.api.click_with_timeout("text", "Factory data reset") # self.api.click_with_timeout("resourceId", "com.android.settings:id/initiate_master_clear") # assert self.api.check_ui_exists("resourceId", "com.android.settings:id/execute_master_clear", 5), \ # "fail to detect erase everything" # self.api.click_with_timeout("resourceId", "com.android.settings:id/execute_master_clear") self.api.factory_reset() time.sleep(600) # reboot device g_common_obj2.system_reboot(90) for _ in range(30): # self.api = ApiImpl() self.api.d = g_common_obj.get_device() self.api.d.wakeup() if self.api.check_ui_exists( "resourceId", "com.google.android.setupwizard:id/welcome_title"): break time.sleep(10) self.api.d.wakeup() g_common_obj.set_vertical_screen() # keep device awake # self.api.keep_awake() # enable unknown sources self.api.unknown_source_control(True) # will check for 10 times and will back to welcome page if it's not for _ in range(10): if self.api.check_ui_exists( "resourceId", "com.google.android.setupwizard:id/welcome_title"): break # just back to welcome page self.api.d.press.back() # launch WiFi Settings by intent self.api.launch_app_by_intents("android.settings.WIFI_SETTINGS", False) assert self.api.check_ui_exists( "textMatches", "Wi.Fi"), "[ERROR]: fail to launch wifi settings" # try to connect wifi for retry in range(int(self.retry_wifi)): # turn on wifi if it is off if self.api.check_ui_exists("text", "Off"): self.api.d(text="Off").right(text="OFF").click() time.sleep(10) if self.api.d(resourceId="android:id/list").scrollable: self.api.d(scrollable=True).scroll.vert.to( text=self.ssid) # scroll to ssid if self.api.check_ui_exists("text", self.ssid): # if wifi ap is not hidden if self.api.check_ui_exists( "text", "Connected"): # break if wifi is connected break self.api.click_with_timeout("text", self.ssid) # input password if needed if self.api.check_ui_exists( "resourceId", "com.android.settings:id/password"): self.api.d(resourceId="com.android.settings:id/password" ).set_text(self.password) # click "Connect": a)first time to connect b)reconnect to wifi if failed before if self.api.check_ui_exists("text", "Connect"): self.api.click_with_timeout("text", "Connect") # click "Done" if wifi is connecting if self.api.check_ui_exists("text", "Done"): self.api.click_with_timeout("text", "Done") else: # connect to hidden wifi ap self.api.d.press.menu() self.api.d(text="Add network").click.wait() self.api.d(text="Enter the SSID").set_text(self.ssid) self.api.d(resourceId="com.android.settings:id/security", index=1).click.wait() self.api.d(text=self.security).click.wait() self.api.d( resourceId="com.android.settings:id/password").set_text( self.password) self.api.d(text="Save").click.wait() time.sleep(10) # wifi should be connected now assert self.api.check_ui_exists( "text", self.ssid), "[ERROR]: WiFi SSID does't exist" assert self.api.check_ui_exists( "text", "Connected"), "[ERROR]: Fail to connect WiFi" # back to oobe self.api.d.wakeup() self.function.push_uiautomator_jar() g_common_obj.set_vertical_screen() while not self.api.check_ui_exists( "resourceId", "com.google.android.setupwizard:id/welcome_title"): self.api.d.wakeup() self.api.d.press.back() assert self.api.check_ui_exists("resourceId", "com.google.android.setupwizard:id/welcome_title"), \ "[ERROR]: Please run test cases at the beginning of OOBE" # for unencrypted device, just bypass encryption when provision device # the encryption test cases will raise this problem if os.popen("adb -s {0} shell getprop ro.crypto.state".format( self.api.serial)).read().strip() == "unencrypted": os.popen("adb -s {0} root".format(self.api.serial)).read().strip() time.sleep(5) os.popen( "adb -s {0} shell setprop persist.sys.no_req_encrypt true". format(self.api.serial)).read().strip() time.sleep(5) self.api.d.wakeup() self.api.oobe_setup(True) self.api.unlock_screen() self.api.clean_tasks() self.api.d.press.home() time.sleep(5) self.api.click_with_timeout("text", "GOT IT") try: self.api.unlock_screen() self.api.launch_app("Sample MDM") assert self.api.check_ui_exists("textContains", "Device Owner", 5), \ "[ERROR]: fail to provision device as device owner" g_common_obj.set_vertical_screen() finally: self.api.keep_awake() self.api.clean_tasks() self.api.enable_system_applications(False)
def tearDown(self): print "[tearDown]:%s" % self.__class__.__name__ super(GPUCompositionFallbackTest, self).tearDown() self.benchmark.clean() self.develop_settings.set_disable_hw_overlays('OFF') g_common_obj.set_vertical_screen()
def tearDown(self): print "[Teardown]: %s" % self._test_name super(ComposeUI, self).tearDown() ImageDetails.delete_picture() ImageDetails.set_workaround() g_common_obj.set_vertical_screen()
def tearDown(self): print "[tearDown]:%s" % self.__class__.__name__ self.benchmark.clean() g_common_obj.set_vertical_screen() super(GLBenchmarkEgyptHD, self).tearDown()
def change_to_vertical(self): """ change device to vertical """ g_common_obj.set_vertical_screen()
def set_orientation_n(self): """ @summary: set orientation as n """ #self.d.orientation = "n" g_common_obj.set_vertical_screen()
def change_to_vertical(self): """ judge wether is vertical,change to vertical if it not """ print "change to vertical" g_common_obj.set_vertical_screen()