示例#1
0
 def set_workaround():
     """ Reset the workaround to let the picture display after push
     """
     cmd = 'am broadcast -a android.intent.action.MEDIA_MOUNTED \
            -d file:///sdcard/Pictures'
     g_common_obj.adb_cmd(cmd)
示例#2
0
 def Turn_Off_Location(self):
     g_common_obj.adb_cmd(
         "am start -a android.settings.LOCATION_SOURCE_SETTINGS")
     if self.device(className="android.widget.Switch").checked:
         self.device(className="android.widget.Switch").click()
     time.sleep(3)
示例#3
0
 def clear_app_data(self, app_package):
     g_common_obj.adb_cmd("pm clear %s" % app_package)
     time.sleep(2)
 def tearDown(self):
     print "[Teardown]: %s" % self._test_name
     super(MeituPic, self).tearDown()
     g_common_obj.adb_cmd('rm /sdcard/Pictures/*')
     g_common_obj.adb_cmd('rm /sdcard/DCIM/Camera/*')
     self._meitupic_edit.uninstall_app()
示例#5
0
 def grant_permissions_for_chrome_app(self):
     g_common_obj.adb_cmd(
         "pm grant com.android.chrome android.permission.READ_EXTERNAL_STORAGE"
     )
示例#6
0
 def screenshot_png(self, screenshot_name):
     self.adb_root()
     sc_cmd = "/system/bin/screencap -p sdcard/Pictures/%s.png" % screenshot_name
     g_common_obj.adb_cmd(sc_cmd)
     self.set_workaround()
示例#7
0
 def clean_workaround():
     """ Clean the workaround to avoid other file affect.
     """
     cmd = 'rm -rf sdcard/Pictures/*'
     g_common_obj.adb_cmd(cmd)
 def resume(self):
     cmdstr = "am start %s" % (self.pkg_name)
     g_common_obj.adb_cmd(cmdstr)
示例#9
0
 def delete_screenshot_file(self, base_path, file_name):
     #delet png file into /sdcard/Picture
     print "[INFO] adb shell rm %s%s" % (base_path, file_name)
     g_common_obj.adb_cmd("rm %s%s" % (base_path, file_name))
     g_common_obj.adb_cmd("am broadcast -a android.intent.action.MEDIA_MOUNTED --ez read-only false -d file://sdcard ")
示例#10
0
 def delete_picture():
     """ delete the test picture
     """
     cmd = 'rm -rf /sdcard/Pictures/*'
     g_common_obj.adb_cmd(cmd)
示例#11
0
 def make_a_screenshot(self, name):
     g_common_obj.adb_cmd("screencap /sdcard/Pictures/%s" % name)
     print "[INFO] screenshot successfully"
 def launch(self):
     """launch APP"""
     cmdstr = "am start -S -n %s/%s" % (self.PKG_NAME, self.ACTIVITY)
     return g_common_obj.adb_cmd(cmdstr)
示例#13
0
 def clear_app(self, app_package):
     g_common_obj.adb_cmd("pm clear %s" % app_package)
示例#14
0
 def unset_airplane(self):
     """ unset airplane mode
     """
     cmd = "settings put global airplane_mode_on 1"
     g_common_obj.adb_cmd(cmd)
示例#15
0
 def tearDown(self):
     print "[Teardown]: %s" % self._test_name
     super(Picsay, self).tearDown()
     g_common_obj.adb_cmd('rm -rf /sdcard/Pictures/*')
     os.system('rm *.png')
     self._picsay.uninstall_app()
示例#16
0
    def test_HDMI_Resume(self):
        """
        test_HDMI_Resume
        """
        print "[RunTest]: %s" % self.__str__()

        print """[Step] 1. Launch photos and capture decode QRcodepicture."""
        self.HDMI_switch_card.switch_on()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.view_a_picture_fullscreen()
        success = False
        self.error_string = ""
        for i in range(self.retry_num):
            print "[capture_decode]:%s times" % (i + 1)
            success, self.error_string = self.HDMI_capture_decode.capture_decode(
                self.qrcode)
            print success, self.error_string
            if success == True:
                break
            else:
                try:
                    picname = g_common_obj.globalcontext.user_log_dir + "/hdmipicture.png"
                    cmd = "mv " + self.HDMI_capture_decode.get_path(
                    ) + "saveimages/fail_0_0.png %s" % (picname)
                    print os.system(cmd)
                except Exception as e:
                    print e.message, e.args
        assert success, self.error_string
        print """[Step] 2. Press Power button.
            DUT screen turned Off."""
        g_common_obj.adb_cmd("input keyevent 26")
        assert not is_device_screen_on(), \
            "[FAILURE] Failed DUT screen turned Off."
        time.sleep(5)
        print """[Step] 3. Press Power button.
            DUT screen turned On."""
        g_common_obj.adb_cmd("input keyevent 26")
        print """[Step] 4. Recheck QRcodepicture in display and dut."""
        success = False
        self.error_string = ""
        for i in range(self.retry_num):
            print "[capture_decode]:%s times" % (i + 1)
            success, self.error_string = self.HDMI_capture_decode.capture_decode(
                self.qrcode)
            print success, self.error_string
            if success == True:
                break
            else:
                try:
                    picname = g_common_obj.globalcontext.user_log_dir + "/hdmipicture.png"
                    cmd = "mv " + self.HDMI_capture_decode.get_path(
                    ) + "saveimages/fail_0_0.png %s" % (picname)
                    print os.system(cmd)
                except Exception as e:
                    print e.message, e.args
        assert success, self.error_string
        print "check dut QRcode picture"
        g_common_obj.assert_exp_happens()
        self.photosImpl.stop_photos_am()
        self.HDMI_switch_card.switch_off()
示例#17
0
 def adb_busybox_cmd_nomsg(self, cmd, time_out=90):
     """adb shell busybox cmd"""
     cmd = cmd.replace('busybox', self.dut_bin)
     return g_common_obj.adb_cmd(cmd, time_out)
示例#18
0
 def grant_permission(self, package, permission):
     g_common_obj.adb_cmd("pm grant %s %s" % (package, permission))
示例#19
0
 def _adb_reboot(self):
     g_common_obj.adb_cmd("reboot")
     time.sleep(3)
     self._check_display_status("on", self.SET_TIMEOUT)
     g_common_obj.root_on_device()
示例#20
0
 def close_chrome_tabs(self):
     g_common_obj.adb_cmd("rm -rf /data/data/com.android.chrome/app_tabs/")
示例#21
0
def launch_settings_am(subsettings=''):
    activityName = "com.android.settings.Settings" \
        if subsettings == '' else "com.android.settings.Settings\$%s" % subsettings
    cmdstr = 'am start -S -n com.android.settings/%s' % activityName
    g_common_obj.adb_cmd('\'' + cmdstr + '\'')
    time.sleep(1)
示例#22
0
 def capture_screen_shot(self, remote_path="/sdcard/Pictures/screen.png"):
     """ capture screen shot
     """
     cmd = "screencap -p " + remote_path
     assert g_common_obj.adb_cmd(
         cmd) == 0, "The screen shot not captured correct"
示例#23
0
    def init_chrome(self):
        # init chrome's two options
        g_common_obj.launch_app_from_home_sc("Chrome")
        time.sleep(5)
        while self.d(text="Accept & continue").exists:
            self.d(text="Accept & continue").click.wait()
        if self.d(text="Done").exists:
            self.d(text="Done").click.wait()
        if self.d(text="No thanks").exists:
            self.d(text="No thanks").click.wait()
        if self.d(text="No Thanks").exists:
            self.d(text="No Thanks").click.wait()
        if self.d(description="More options").exists:
            self.d(description="More options").click.wait()
        if self.d(text="Cancel").exists:
            self.d(text="Cancel").click.wait()
        if self.d(resourceId="com.android.chrome:id/menu_button").exists:
            self.d(resourceId="com.android.chrome:id/menu_button").click.wait()
        if self.d(text="Settings").exists:
            self.d(text="Settings").click.wait()
        if self.d(text="Sign in to Chrome").exists:
            self.d(text="Sign in to Chrome").click.wait()
            if self.d(text="Add a Google Account").exists:
                self.d(text="Cancel").click.wait()
            else:
                self.d(text="Sign in").click.wait()
        if self.check_if_app_not_first_init("Chrome") is False:
            self.d.press.recent()
            self.d(text="Chrome", resourceId="com.android.systemui:id/activity_description").click.wait()
            if self.d(text="Basics").down(resourceId="com.android.chrome:id/header_title",
                                          textContains="@gmail.com") != None:
                self.d(text="Basics").down(resourceId="com.android.chrome:id/header_title",
                                           textContains="@gmail.com").click.wait()
            if self.d(textContains="Auto sign").right(resourceId="android:id/checkbox").checked:
                self.d(textContains="Auto sign").right(resourceId="android:id/checkbox").click()
        else:
            self.d.press.recent()
            self.d(text="Chrome", resourceId="com.android.systemui:id/activity_description").click.wait()
            pass
        if self.d(resourceId="com.android.chrome:id/menu_button").exists:
            self.d(resourceId="com.android.chrome:id/menu_button").click.wait()
        self.d(text="Privacy").click.wait()
        if self.d(textContains="Navigation").right(resourceId="android:id/checkbox").checked:
            self.d(textContains="Navigation").right(resourceId="android:id/checkbox").click.wait()
        if self.d(textContains="Search and").right(resourceId="android:id/checkbox").checked:
            self.d(textContains="Search and").right(resourceId="android:id/checkbox").click.wait()
        if self.d(textContains="Usage and crash reports").right(resourceId="android:id/checkbox").checked:
            self.d(textContains="Usage and crash reports").right(resourceId="android:id/checkbox").click.wait()
        if self.d(text="CLEAR BROWSING DATA...").exists:
            self.d(text="CLEAR BROWSING DATA...").click.wait()
        # if self.d(text="Clear browsing data").exists:
        if self.d(text="Clear browsing history").exists:
            if not self.d(text="Clear browsing history").checked:
                self.d(text="Clear browsing history").click.wait()
        if self.d(text="Clear the cache").exists:
            if not self.d(text="Clear the cache").checked:
                self.d(text="Clear the cache").click.wait()
        if self.d(textContains="Clear cookies").exists:
            if not self.d(textContains="Clear cookies").checked:
                self.d(textContains="Clear cookies").click.wait()
        if self.d(text="Clear").exists:
            self.d(text="Clear").click.wait()
        if self.d(text="Accept").exists:
            self.d(text="Accept").click.wait()
        self.d.press.back()
        self.d.press.back()

        url = "http://www.youtube.com/watch?v=OYotwvVzBm4"
        for i in range(3):
            self.d(resourceId="com.android.chrome:id/url_bar").clear_text()
            if self.d(resourceId="com.android.chrome:id/website_settings_connection_message").exists:
                self.d.press.back()
            self.d(resourceId="com.android.chrome:id/url_bar").set_text(url)
            self.d.press.enter()
        time.sleep(2)
        for i in range(10):
            if self.d(resourceId="com.android.chrome:id/url_bar", text="m.youtube.com").exists:
                g_common_obj.adb_cmd("am force-stop com.android.chrome")
                return
            if self.d(textStartsWith="Open with", resourceId="android:id/title").exists:
                self.d(textContains="Chrome").click.wait()
                if self.d(text="Always").exists:
                    self.d(text="Always").click.wait()
                    if self.d(description="Web View").exists:
                        self.d.press.back()
                time.sleep(5)
                if self.d(text="OK").exists:
                    self.d(text="OK").click.wait()
                g_common_obj.adb_cmd("am force-stop com.android.chrome")
                return
            time.sleep(3)
        g_common_obj.adb_cmd("am force-stop com.android.chrome")
示例#24
0
 def resume(self):
     """Resume app"""
     cmdstr = "am start %s/%s" % ('com.android.chrome',
                                  'com.google.android.apps.chrome.Main')
     g_common_obj.adb_cmd(cmdstr)
示例#25
0
 def delete_the_exported_vcf_file(self, contactfile):
     g_common_obj.adb_cmd("rm /sdcard/%s" % contactfile)
     print "[INFO] exprted vcf file %s is deleted successfully" % contactfile
示例#26
0
 def __back_key():
     """
     press back key
     """
     g_common_obj.adb_cmd("input keyevent 4")
示例#27
0
 def resume(self):
     """resume app"""
     cmdstr = "am start %s" % (self.PKG_NAME)
     g_common_obj.adb_cmd(cmdstr)
示例#28
0
 def clean_up_camera_data(self):
     """
     @summary: clean Up Camera Data
     """
     g_common_obj.stop_app_am(self.PACKAGE_NAME_AOSPCAMERA)
     g_common_obj.adb_cmd("pm clear %s" % self.ACTIVITY_NAME_AOSPCAMERA)
示例#29
0
 def kill_uiautomator(self):
     _uiautomator_pid = shell_command(
         "adb shell ps | grep -i uiautomator | awk '{print $2}'")[1][0]
     g_common_obj.adb_cmd("kill %s" % _uiautomator_pid)