def startApp(): """ Skip Calendar first launch screen """ d = g_common_obj.get_device() g_common_obj.launch_app_from_home_sc("News & Weather") time.sleep(2) if d(resourceId="com.google.android.apps.magazines:id/image_header_logo" ).exists: g_common_obj.back_home() return while d(resourceId="com.google.android.apps.genie.geniewidget:id/next" ).exists: d(resourceId="com.google.android.apps.genie.geniewidget:id/next" ).click() d.wait.update() if d( resourceId="com.google.android.apps.genie.geniewidget:id/done").\ wait.exists(timeout=60000): d(resourceId="com.google.android.apps.genie.geniewidget:id/done" ).click() if d(description="Close navigation drawer").exists: d(description="Close navigation drawer").click() d.wait.update() g_common_obj.back_home()
def basic_test(self): """ Basic funtion test """ g_common_obj.launch_app_from_home_sc("Slides") if not self._locator.btn_add.exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d( packageName="com.google.android.apps.docs.editors.slides" ).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/slides.png") self.d.press.back() return self._locator.btn_add.click() time.sleep(10) if not self._locator.btn_overflow.exists: print "[WARNING:UI is changed! Just test add function]" assert self.d( packageName="com.google.android.apps.docs.editors.slides" ).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/slides.png") self.d.press.back() return assert self._locator.btn_overflow.exists g_common_obj.back_home()
def startAppMusic(): d = g_common_obj.get_device() g_common_obj.launch_app_from_home_sc("Play Music") time.sleep(10) for _ in range(30): time.sleep(2) if not d(resourceId="com.google.android.music:id/tutorial_logo" ).exists: break assert not d( resourceId="com.google.android.music:id/tutorial_logo").exists if d(text="Skip").exists: d(text="Skip").click.wait() if d(text="Use Standard").exists: d(text="Use Standard").click.wait() if d(text="Done").exists: d(text="Done").click.wait() if d(resourceId="com.google.android.music:id/play_drawer_list").exists: d.press.back() if d(text="Got it").exists: d(text="Got it").click.wait() g_common_obj.launch_app_am( "com.google.android.music", "com.android.music.activitymanagement.TopLevelActivity") time.sleep(5) g_common_obj.back_home()
def startApp(): # click ok in youtube g_common_obj.launch_app_from_home_sc("YouTube") d = g_common_obj.get_device() time.sleep(5) d.watcher("SKIP_UPDATE").\ when(resourceId="com.google.android.youtube:id/later_button")\ .click(resourceId="com.google.android.youtube:id/later_button") if d(text="What to Watch").exists: g_common_obj.back_home() return for _ in range(60): if d(text="What to Watch").exists and not d(text="OK").exists: break if d(text="OK").exists: d(text="OK").click.wait() if d(text="Skip").exists: d(text="Skip").click.wait() if d(text="Retry").exists: d(text="Retry").click.wait() time.sleep(2) d.press.back() if d(description="YouTube").exists: d(description="YouTube").click.wait() time.sleep(2) if d(text="Skip").exists: d(text="Skip").click.wait() d.watcher("SKIP_UPDATE").remove() g_common_obj.back_home()
def setUp(self): """ @summary: set up @return: None """ super(CameraTest, self).setUp() self._test_name = __name__ self.logger.debug("[Setup]: %s" % self._test_name) self.case_result = -1 g_common_obj.root_on_device() g_common_obj.remount_device() self.camera_common = CameraCommon() self.multimedia_setting = MultiMediaSetting(self.camera_common.DEFAULT_CONFIG_FILE) self.host_path = self.camera_common.getTmpDir() self.multimedia_scale_test_helper = MultiMediaScaleTestHelper(self.host_path) self.multimedia_checkiq_helper = MultiMediaCheckiqHelper(self.host_path) self.android_version = MultiMediaSwitchCameraHelper(skip_import_camera=True).android_version.lower() self.multimedia_scale_test_helper.scale_test_prepare() self.camera_common.removeDeivceFile() self.camera_common.removeDeivceFile(self.multimedia_scale_test_helper.movies_folder_device_path + "*") self.camera_common.removeFile(self.host_path + "/*.mp4") self.camera_common.unlockScreen() self.d = g_common_obj.get_device() self.skipAccountLoginLyout() g_common_obj.back_home() if self.d(text="Got it").exists: self.d(text="Got it").click.wait()
def startApp(self): """ Skip Email first launch screen """ g_common_obj.launch_app_from_home_sc("Email") assert self.d(packageName = EmailImpl.mail_pkg_name).wait.exists() if self.d(textContains="Getting").exists: self.d(textContains="Getting").wait.gone(timeout=600000) assert not self.d(textContains="Getting").exists, \ "ERROR: SYNC for more than 10 mins" if self.d(resourceId="com.android.email:id/account_email").exists: self.d(resourceId="com.android.email:id/account_email").click() g_common_obj.adb_cmd_capture_msg( "input text " + self.cfg.get("email_account")) time.sleep(2) self.d(resourceId="com.android.email:id/next").click() self.d(resourceId="com.android.email:id/regular_password").\ wait.exists() self.d(resourceId="com.android.email:id/regular_password").click() time.sleep(2) g_common_obj.adb_cmd_capture_msg( "input text " + self.cfg.get("email_pwd")) time.sleep(2) self.d(resourceId="com.android.email:id/next").click() assert self.d(text="Account options").wait.exists(timeout=60000) for _ in (0, 10): if self.d( resourceId="com.android.email:id/next")\ .wait.exists(timeout=60000): self.d(resourceId="com.android.email:id/next").click() else: break assert self.d(text="Inbox").wait.exists(timeout=60000) g_common_obj.back_home()
def launch_home_screen(self): self.d.wakeup() g_common_obj.back_home() for _ in xrange(10): # max 10s timeout if self.d.exists(description="Apps"): break time.sleep(1) else: raise Exception("launch home screen fails")
def tearDown(self): """ @summary: tear tearDown @return: None """ super(BrightnessDim, self).tearDown() print "[Teardown]: %s" % self._test_name dbsetting.set_status_stay_awake(True) dbsetting.set_screen_off_timeout(1800000) g_common_obj.back_home()
def tearDown(self): """ @summary: tear tearDown @return: None """ super(BrightnessBSPTest, self).tearDown() print "[Teardown]: %s" % self._test_name g_common_obj.back_home() self.brightness.reset() self.brightness = None
def search_in_driver(self, input_key): """ search in keep """ print "[INFO] Test input in Drive" g_common_obj.launch_app_from_home_sc("Drive") #Skip set up screen while launch the music app in the first time time.sleep(5) self._locator.btn_search.click() self._locator.btn_search_text.clear_text() self._locator.btn_search_text.set_text(input_key) assert self.d(text=input_key).exists self._locator.btn_cancel_search.click() g_common_obj.back_home()
def startApp(): """ Skip Google Plus first launch screen """ d = g_common_obj.get_device() g_common_obj.launch_app_from_home_sc("Google+") time.sleep(10) while d(resourceId="com.google.android.apps.plus:id/warm_welcome_button" ).exists: d(resourceId="com.google.android.apps.plus:id/warm_welcome_button" ).click() d.wait.update() g_common_obj.back_home()
def __init__(self): super(SplitWindow, self).__init__() # Launch settings & chrome app before testing. SystemUiExtendImpl().close_all_recent_apps() launch_settings_am() self.html = html5 self.html.launch_chrome_am() g_common_obj.back_home() # Back to home screen self.width = self.d.info['displayWidth'] self.height = self.d.info['displayHeight'] self.recent_btn = self.d( resourceId="com.android.systemui:id/recent_apps") self.split_button = self.d( resourceId='com.android.systemui:id/docked_divider_handle') self._wait_time = 8 # wait for ui update
def tearDown(self): """ @summary: tearDown @return: None """ super(CameraTest, self).tearDown() self.logger.debug("[Teardown]: %s" % self._test_name) g_common_obj.stop_exp_handle() self.camera_common.removeDeivceFile() self.camera_common.removeDeivceFile(self.multimedia_scale_test_helper.movies_folder_device_path + "*") if self.multimedia_scale_test_helper.scale_test_teardown() == 1 or self.case_result == 0: self.reboot_device() time.sleep(3) g_common_obj.back_home()
def set_language_input(self, ime, keyboard): """ @summary: switch the input method and set the input method as ime """ if not self.change_the_keyboard(keyboard): self._locator.btn_choose_keyboard.click() self.add_input_ime(ime) self.change_the_keyboard(keyboard) if not self._locator.btn_keyboard_radio_info(keyboard): self._locator.btn_keyboard_radio(keyboard).click() self.d.press.back() error_mesg = "The keyboard [%s] method is not click" % keyboard time.sleep(3) assert self._locator.btn_keyboard_summary(keyboard).exists, error_mesg g_common_obj.back_home()
def __search_setup(self): """ @summary: setup search function """ website = self.search.cfg.get("check_web") webcheck = self.search.cfg.get("check_webcheck") contact = self.search.cfg.get("check_contact") if website != "" and webcheck != "": self.browser.browser_setup() self.browser.open_website(website) self.browser.web_check(webcheck) if contact != "": self.contacts.contact_add(contact) g_common_obj.back_home()
class InteractingWithAppDuringGOTA(UIATestBase): """ @summary: Test interacting app during gota """ def setUp(self): super(InteractingWithAppDuringGOTA, self).setUp() self._test_name = __name__ self.d = g_common_obj.get_device() print "[Setup]: %s" % self._test_name def tearDown(self): print "[Teardown]: %s" % self._test_name super(InteractingWithAppDuringGOTA, self).tearDown() def testInteractingWithAppDuringGOTA(self): """ This test case is to test interacting app during gota Test Case Precondition: Test Case Step: 1. cpen chrome when gota downloading Expect Result: 1. app open successfully 3. gota successfully The real implementation will be in gota_Impl class. """ print "[RunTest]: %s" % self.__str__() g_common_obj.launch_app_from_home_sc("Chrome") time.sleep(2) g_common_obj.back_home()
def startApp(): """ Skip Google Plus first launch screen """ d = g_common_obj.get_device() g_common_obj.launch_app_from_home_sc("Hangouts") time.sleep(10) if d(resourceId="android:id/up").exists: g_common_obj.back_home() return while d(resourceId="com.google.android.apps.hangouts:id/call_promo_no_thanks").exists: d(resourceId="com.google.android.apps.hangouts:id/call_promo_no_thanks").click() d.wait.update() while d(textContains="Skip").exists: d(textContains="Skip").click() g_common_obj.back_home()
def startApp(): """ Skip Gmail first launch screen """ g_common_obj.launch_app_from_home_sc("Gmail") time.sleep(10) d = g_common_obj.get_device() while d( resourceId="com.google.android.gm:id/welcome_tour_got_it").exists: d( resourceId="com.google.android.gm:id/welcome_tour_got_it").click() d.wait.update() while d(resourceId="com.google.android.gm:id/action_done").exists: d(resourceId="com.google.android.gm:id/action_done").click() d.wait.update() g_common_obj.back_home()
def launch_app_from_home_sc(self, appname, appgallery="Apps", inspection=None): """ Launch App from app gallery Parameter appname is the app's widget name in app gallery Parameter appgallery is the widget name of app in home screen Parameter inspection is the text to validate if given app launched Please be aware that this fucntion assumes: 1) There is a app gallery icon in home screen; 2) Your app widget could be found in home screen. If your app meets above 2 assumtions, then it could be a convenient function call for you. Otherwise you may consider write your own app launch steps or using launch_app_am function instead. """ iffind = False d = g_common_obj.get_device() g_common_obj.back_home() d(description="Apps").click.wait() if d(text="Widgets").exists: d(text="Widgets").click.wait() d(text="Apps").click.wait() if d(scrollable=True): d(scrollable=True).scroll.horiz.toBeginning(steps=20) for _ in range(5): if d(text=appname).exists: d(text=appname).click.wait() iffind = True break d(scrollable=True).scroll.horiz() if not iffind: for _ in range(5): if d(text=appname).exists: time.sleep(2) d(text=appname).click.wait() iffind = True break d(scrollable=True).scroll.horiz.backward() assert iffind == True if (inspection is not None): assert d(textMatches=inspection)
def setUp(self): super(UIATestBase, self).setUp() if 'TEST_DATA_ROOT' not in os.environ: raise Exception('env \'TEST_DATA_ROOT\' not defined !') # Contexts object is injected by nose reporter plugin. if hasattr(self, 'contexts'): g_common_obj.set_context(self.contexts) user_log_dir = os.environ.get('PYUNIT_USER_LOG_DIR', None) if (user_log_dir): g_common_obj.globalcontext.user_log_dir = user_log_dir # Start the execption handling. g_common_obj.start_exp_handle() g_common_obj.back_home()
def startApp(): """ Skip Calendar first launch screen """ d = g_common_obj.get_device() g_common_obj.launch_app_from_home_sc("Calendar") if d(resourceId="com.android.calendar:id/add_event_button").exists: return time.sleep(10) if d(resourceId="com.android.calendar:id/add_event_button").exists: return while d(resourceId="com.android.calendar:id/right_arrow").wait.exists( timeout=3000): d(resourceId="com.android.calendar:id/right_arrow").click() d.wait.update() if d( resourceId="com.android.calendar:id/done_button").\ wait.exists(timeout=60000): d(resourceId="com.android.calendar:id/done_button").click() g_common_obj.back_home()
def startApp(): """ Skip Calendar first launch screen """ d = g_common_obj.get_device() g_common_obj.launch_app_from_home_sc("Sheets") time.sleep(10) if d(descriptionContains="New File").exists: g_common_obj.back_home() return while d(resourceId="com.google.android.apps.docs.editors.sheets:id/next" ).exists: d(resourceId="com.google.android.apps.docs.editors.sheets:id/next" ).click() d.wait.update() if d( resourceId="com.google.android.apps.docs.editors.sheets:id/done").\ wait.exists(timeout=60000): d(resourceId="com.google.android.apps.docs.editors.sheets:id/done" ).click() g_common_obj.back_home()
def startApp(): d = g_common_obj.get_device() g_common_obj.launch_app_from_home_sc("Play Store") time.sleep(3) if d(textStartsWith="Just a sec").exists or d( text="Couldn't sign in").exists: d.press.back() assert False, "Account is not signed" for _ in range(30): if d(text="Accept").exists: d(text="Accept").click.wait() if d(className="android.widget.ImageButton").exists: break time.sleep(2) if d(className="android.widget.ImageButton").exists: d(className="android.widget.ImageButton").click.wait() if d(text="Settings").exists: d(text="Settings").click.wait() if d(text="Auto-update apps").exists: d(text="Auto-update apps").click.wait() if d(text="Do not auto-update apps").exists: d(text="Do not auto-update apps").click.wait() g_common_obj.back_home()
def browser_setup(self): """ @summary: close all browser tab and new a empty one """ self.d.watcher("SKIP_WELCOME").when(text="No Thanks").click(text="No Thanks") g_common_obj.back_home() self.launch_app_from_home_sc("Chrome") time.sleep(3) if self._locator.btn_chrome_accept.exists: self._locator.btn_chrome_accept.click() time.sleep(2) if self._locator.btn_chrome_setup.exists: self._locator.btn_chrome_account_skip.click() time.sleep(2) if self._locator.btn_chrome_account_done.exists: self._locator.btn_chrome_account_done.click() time.sleep(2) self.swipe_screen_down() assert self._locator.btn_url_bar.exists or \ self._locator.btn_new_tab.exists, \ "[FAILURE] Skip Welcome dialog failed!" self.open_new_tab() # self.skip_crash_report() self.d.watcher("SKIP_WELCOME").remove()
def tearDown(self): super(UIATestBase, self).tearDown() # Stop the execption handling. g_common_obj.stop_exp_handle() g_common_obj.back_home()
def startApp(): """ Skip the welcome screen while launch app for the first time """ # init chrome's two options g_common_obj.launch_app_from_home_sc("Chrome") time.sleep(10) d = g_common_obj.get_device() time.sleep(5) while d(text="Accept & continue").exists: d(text="Accept & continue").click.wait() if d(text="Done").exists: d(text="Done").click.wait() if d(text="No thanks").exists: d(text="No thanks").click.wait() if d(text="No Thanks").exists: d(text="No Thanks").click.wait() if d(description="More options").exists: d(description="More options").click.wait() if d(text="Settings").exists: d(text="Settings").click.wait() if d(text="Sign in to Chrome").exists: d(text="Sign in to Chrome").click.wait() if d(text="Add a Google Account").exists: d(text="Cancel").click.wait() else: d(text="Sign in").click.wait() if d(text="Basics").exists: if d(text="Basics").\ down(resourceId="com.android.chrome:id/header_title", \ textContains="@gmail.com") != None: d(text="Basics").down( resourceId="com.android.chrome:id/header_title", \ textContains="@gmail.com").click.wait() if d(textContains="Auto sign").exists: if d(textContains="Auto sign").\ right(resourceId="android:id/checkbox").checked: d(textContains="Auto sign").\ right(resourceId="android:id/checkbox").click() d.press.back() if d(text="Privacy").exists: d(text="Privacy").click.wait() if d(textContains="Navigation").exists: if d(textContains="Navigation").\ right(resourceId="android:id/checkbox").checked: d(textContains="Navigation").\ right(resourceId="android:id/checkbox").click.wait() if d(textContains="Search and").exists: if d(textContains="Search and").\ right(resourceId="android:id/checkbox").checked: d(textContains="Search and").\ right(resourceId="android:id/checkbox").click.wait() if d(textContains="Usage and crash").exists: if d(textContains="Usage and crash").\ right(resourceId="android:id/checkbox").checked: d(textContains="Usage and crash").\ right(resourceId="android:id/checkbox").click.wait() if d(text="Clear browsing data").exists: d(text="Clear browsing data").click.wait() if not d(text="Clear browsing history").checked: d(text="Clear browsing history").click.wait() if not d(text="Clear the cache").checked: d(text="Clear the cache").click.wait() if not d(textContains="Clear cookies").checked: d(textContains="Clear cookies").click.wait() if d(text="Clear").exists: d(text="Clear").click.wait() if d(text="Accept").exists: d(text="Accept").click.wait() g_common_obj.back_home()