class PhotosExtendImpl(PhotosImpl):
    """ Photos uiautomator """

    config_file = 'tests.common.photos.conf'

    HostPhotoPagerActivity = "com.google.android.apps.photos.viewer.pager.HostPhotoPagerActivity"

    class HomeUI(object):
        """Home UI Elements"""
        def __init__(self, device):
            self.device = device

        @property
        def list_item(self):
            return self.device(className='android.view.View')

        @property
        def first_item(self):
            return self.device(
                resourceId="com.google.android.apps.plus:id/tile_row"
            )[0].child(index=0)

    class ViewUI(object):
        """View UI elements"""
        def __init__(self, device):
            self.device = device

        @property
        def play(self):
            return self.device(resourceId="com.google.android.apps.plus:"
                               "id/photo_view_pager")\
                .child(description="Play video")

        @property
        def is_video(self):
            return self.device(resourceId="com.google.android.apps.plus:"
                               "id/photo_view_pager")\
                .child(description="Play video")\
                .exists

        def show_more(self):
            if not self.device(description="More options").exists\
                    and not self.device(text="Help").exists:
                self.device().click()
            self.device(description="More options").click()

        @property
        def option_slideshow(self):
            self.show_more()
            return self.device(textContains="Slideshow")

        @property
        def option_set_as(self):
            self.show_more()
            return self.device(textContains="Set as")

    def __init__(self):
        super(PhotosExtendImpl, self).__init__()
        self.configer = TestConfig()
        self.config = self.configer.read(self.config_file, "Photos")
        config_handle = ConfigHandle()
        self.config["artifactory_location"] = config_handle.read_configuration(
            'artifactory', 'location', '/etc/oat', 'sys.conf')
        self.dut_photos_dir = self.config.get("photos_dir")
        self.dut_video_dir = self.config.get("video_dir")
        self.arti = Artifactory(self.config.get("artifactory_location"))
        self._home = PhotosExtendImpl.HomeUI(self.d)
        self._view = PhotosExtendImpl.ViewUI(self.d)
        self.qrcodeImpl = QRcode()

    def launch(self):
        """launch APP"""
        g_common_obj.launch_app_am(
            'com.google.android.apps.plus',
            'com.google.android.apps.photos.phone.PhotosHomeActivity')
        time.sleep(4)
        if self.d(text="Later").exists:
            self.d(text="Later").click()
            time.sleep(2)
        time.sleep(5)
        self.d.wait.update()

    def click_list_item(self, index):
        """click list item"""
        print "[Debug] click_list_item index:%s" % (index)
        self._home.list_item[index].click()

    def find_video(self):
        """find video item"""
        print "[Debug] find_video"
        for i in range(self._home.list_item.count):
            self._home.list_item[i].click()
            time.sleep(2)
            _, activity = SystemUi.get_current_focus()
            if activity != self.HostPhotoPagerActivity:
                continue
            if self._view.is_video:
                self.d.press.back()
                time.sleep(2)
                print "video index:%s" % (i)
                return i
            self.d.press.back()
        assert False, "There is no video items"

    def find_photo(self):
        print "[Debug] find_photo"
        for i in range(self._home.list_item.count):
            self._home.list_item[i].click()
            time.sleep(2)
            _, activity = SystemUi.get_current_focus()
            if activity != self.HostPhotoPagerActivity:
                continue
            if not self._view.is_video:
                self.d.press.back()
                time.sleep(2)
                print "photo index:%s" % (i)
                return i
            self.d.press.back()
        assert False, "There is no photo items"

    def setup(self):
        """setup environment"""
        self.launch()
        time.sleep(2)
        device = self.d
        if device(textContains="No thanks").exists:
            device(textContains="No thanks").click()

        special_actions.setup()

    def play_video(self, secs=None, timeout=None):
        """click play video"""

        print "[Debug] play_video"
        mark_time = logcat.get_device_time_mark()
        pre_dump = self.d.dump()
        pre_focus = SystemUi.get_current_focus()
        print pre_focus

        self._view.play.click.wait()
        if secs:
            time.sleep(secs)
        end_dump = self.d.dump()
        end_focus = SystemUi.get_current_focus()
        print end_focus

        seq_match = difflib.SequenceMatcher(None, pre_dump, end_dump)
        ratio = round(seq_match.ratio(), 2) * 100
        print "ratio:%s" % ratio

        if ratio == 100 and pre_focus == end_focus:
            assert False, "[FAILURE] Play video No any reply"
        if not secs:
            start_time = time.time()
            play_done = False
            while time.time() - start_time < timeout:
                time.sleep(10)
                if self._view.play.exists:
                    play_done = True
                    break
            assert play_done, "[FAILURE] Play video time out"

        errmsg = logcat.get_device_log(mark_time, filters='MediaPlayer:E *:S')
        assert not errmsg, "[FAILURE] Found Errors in Logcat during Play Video\n%s" % (
            errmsg)

    def check_video_icons(self):
        x = self.d.info.get("displayWidth")
        y = self.d.info.get("displayHeight")
        self.d.click(x / 2, y / 2)
        time.sleep(3)
        assert self.d(resourceId="com.google.android.apps.plus:id/videoplayer"
                      ).exists, "Video is not shown on the screen"

    def push_pictures(self, count=1, exts=None):
        remote_pictures = []
        pictures = self.configer.read(self.config_file, "Pictures")
        if exts:
            pictures = {
                k: v
                for k, v in pictures.iteritems() if v.lower().endswith(exts)
            }
        if count > len(pictures.items()):
            assert False, \
                "[FAILURE] There are not enough resource."

        for _, value in pictures.iteritems():
            pic_path = self.arti.get(value)
            ret = g_common_obj.push_file(pic_path, self.dut_photos_dir)
            remote_pictures.append(self.dut_video_dir + '/' +
                                   os.path.basename(pic_path))
            assert ret, 'Failed push %s' % (pic_path)
            count -= 1
            if count == 0:
                break

        cmd = \
            "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file://%s"\
            % (self.dut_photos_dir)
        g_common_obj.adb_cmd_capture_msg(repr(cmd))
        print "[Debug] pushed %s" % (remote_pictures)
        return remote_pictures

    def push_qrcode_pictures(self, count=1, exts=None, mark_count=1):
        remote_pictures = []
        pictures = self.configer.read(self.config_file, "Pictures")
        if exts:
            pictures = {
                k: v
                for k, v in pictures.iteritems() if v.lower().endswith(exts)
            }
        if count > len(pictures.items()):
            assert False, \
                "[FAILURE] There are not enough resource."

        for _, value in pictures.iteritems():
            pic_path = self.arti.get(value)
            qrcode = id_generator()
            pic_path = self.qrcodeImpl.mark_image_qrcode(pic_path,
                                                         code=qrcode,
                                                         count=mark_count)
            ret = g_common_obj.push_file(pic_path, self.dut_photos_dir)

            remote_pictures.append({
                'qrcode':
                qrcode,
                'path':
                self.dut_video_dir + '/' + os.path.basename(pic_path)
            })
            assert ret, 'Failed push %s' % (pic_path)
            remove_temp_file(pic_path)
            count -= 1
            if count == 0:
                break

        cmd = \
            "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file://%s"\
            % (self.dut_photos_dir)
        g_common_obj.adb_cmd_capture_msg(repr(cmd))
        print "[Debug] pushed %s" % (remote_pictures)
        return remote_pictures

    def push_specified_qrcode_pictures(self, count=1, exts=None, mark_count=1):
        remote_pictures = []
        pictures = self.configer.read(self.config_file, "Pictures")
        if exts:
            pictures = {
                k: v
                for k, v in pictures.iteritems() if v.lower().endswith(exts)
            }
        if count > len(pictures.items()):
            assert False, \
                "[FAILURE] There are not enough resource."

        for _, value in pictures.iteritems():
            pic_path = self.arti.get(value)
            qrcode = "ABCDEFGHIJ"
            pic_path = qrcode_obj.mark_image_qrcode(pic_path,
                                                    code=qrcode,
                                                    count=mark_count)
            ret = g_common_obj.push_file(pic_path, self.dut_photos_dir)

            remote_pictures.append({
                'qrcode':
                qrcode,
                'path':
                self.dut_video_dir + '/' + os.path.basename(pic_path)
            })
            assert ret, 'Failed push %s' % (pic_path)
            remove_temp_file(pic_path)
            count -= 1
            if count == 0:
                break

        cmd = \
            "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file://%s"\
            % (self.dut_photos_dir)
        g_common_obj.adb_cmd_capture_msg(repr(cmd))
        print "[Debug] pushed %s" % (remote_pictures)
        return remote_pictures

    def push_videos(self, count=1, like=None, exts=None):
        remote_videos = []
        videos = self.configer.read(self.config_file, "Videos")
        if like:
            videos = {
                k: v
                for k, v in videos.iteritems()
                if v.lower().find(like.lower()) != -1
            }
        if exts:
            videos = {
                k: v
                for k, v in videos.iteritems() if v.lower().endswith(exts)
            }
#         if like and exts:
#             videos = { k:v for k, v in videos.iteritems() if os.path.basename(v) == like + exts }

        if count > len(videos.items()):
            assert False, \
                '[FAILURE] The video is not in config file ' + self.config_file

        for _, value in videos.iteritems():
            pic_path = self.arti.get(value)
            ret = g_common_obj.push_file(
                pic_path,
                self.dut_video_dir + '/' + os.path.basename(pic_path))
            assert ret, 'Failed push %s' % (pic_path)
            remote_videos.append(self.dut_video_dir + '/' +
                                 os.path.basename(pic_path))
            count -= 1
            if count == 0:
                break

        cmd = \
            "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file://%s"\
            % (self.dut_video_dir)
        g_common_obj.adb_cmd_capture_msg(repr(cmd))
        print "[Debug] pushed %s" % (remote_videos)
        return remote_videos

    def slideshow(self, duration):
        print "[Debug] slideshow"
        pre_screen = tempfile.mktemp(suffix='.png',
                                     prefix='screen_',
                                     dir='/tmp')
        end_screen = tempfile.mktemp(suffix='.png',
                                     prefix='screen_',
                                     dir='/tmp')

        def action():
            self._home.first_item.click()
            self.d.wait.update()
            self._view.option_slideshow.click()

        action()
        start_time = time.time()
        self.d.screenshot(pre_screen)
        while time.time() - start_time < duration:
            time.sleep(6)
            self.d.wait.idle(timeout=3000)
            self.d.screenshot(end_screen)
            if filecmp.cmp(pre_screen, end_screen):
                self.d.press.back()
                action()
            self.d.wait.idle(timeout=3000)
            self.d.screenshot(pre_screen)
        self.d.press.back()

    def setwallpaper(self):
        print "[Debug] setwallpaper"
        if self.d(text="More options").exists:
            self.d(text="More options").click()
        self._view.option_set_as.click()
        if self.d(text='More').exists:
            self.d(text='More').click()
            time.sleep(1)
        self.d(text='Wallpaper').click()
        time.sleep(3)
        self.d(text='Set wallpaper').click()
        time.sleep(3)
        if self.d(text="Set wallpaper").exists:
            self.d(text='Set wallpaper').click()
            time.sleep(6)

    def verify_wallpaper(self, qrcode):
        home_screen = tempfile.mktemp(suffix='.png',
                                      prefix='screen_',
                                      dir='/tmp')
        self.d.press.home()
        time.sleep(1)
        self.d.screenshot(home_screen)
        _, decode = qrcode_obj.decode_image_qrcode(home_screen)
        print "[Debug] verify_wallpaper qrcode:%s decode:%s" % (qrcode, decode)
        assert decode == qrcode, \
            "[FAILURE] Failed verify wallpaper qrcode:%s decode:%s" % (qrcode, decode)
        remove_temp_file(home_screen)

    def verify_imageview(self):
        home_screen = tempfile.mktemp(suffix='.png',
                                      prefix='screen_',
                                      dir='/tmp')
        decode = ''

        for _ in range(10):
            self.d.screenshot(home_screen)
            ret, decode = qrcode_obj.decode_image_qrcode(home_screen)
            print "[Debug]", ret, decode

            if ret is False or decode == 'NULL':
                special_actions.zoom_in()
                continue
            break

        remove_temp_file(home_screen)
        return decode

    def clean(self):
        for each in [self.dut_photos_dir, self.dut_video_dir]:
            cmd = \
                "rm -rf %s/*; sync; "\
                "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file://%s"\
                % (each, each)
            g_common_obj.adb_cmd_capture_msg(repr(cmd))
        special_actions.clean()
Beispiel #2
0
class ImageView(UIATestBase):

    PHOTO_PATH = "/sdcard/Pictures"
    VIDEO_PATH = "/sdcard/Movies"
    ACCEPTABLE_VALUE = 5

    def setUp(self):
        super(ImageView, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        g_common_obj.root_on_device()
        self.d = g_common_obj.get_device()
        self.photosImpl = get_photo_implement()
        self.qr = QRcode()
        self.photosImpl.rm_delete_photos()
        self.photosImpl.stop_photos_am()

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        super(ImageView, self).tearDown()
        self.photosImpl.rm_delete_photos()
        remove_aosp_launcher()

    def test_MoreThan10JPEGImagesOfDifferentResolution(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "jpg_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_MoreThan10BMPImages(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "bmp_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_MoreThan10BMPImagesOfDifferentResolution(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "bmp_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_MoreThan10GIFImagesOfDifferentResolution(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "gif_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_MoreThan10PNGImagesOfDifferentResolution(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "png_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_MoreThan10PNGImages(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "png_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_MoreThan10WBMPImagesOfDifferentResolution(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "wbmp_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_MoreThan10WEBPImagesOfDifferentResolution(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "webp_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_AddDisplayEffect_DragProgressBar(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        allEffects = PARENT_EFFECTS + LIGHT_CHILD_EFFECTS + COLOR_CHILD_EFFECTS
        useEffects = []
        loopNum = 5
        for _ in range(loopNum):
            index = random.randint(0, len(allEffects) - 1)
            useEffects.append(allEffects[index])
        useEffects.sort()
        for useEffect in useEffects:
            MinOrMax = [0, 100]
            index = random.randint(0, len(MinOrMax) - 1)
            effectVolume = MinOrMax[index]
            self.photosImpl.change_display_effect(effType=useEffect,
                                                  effVol=effectVolume)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE,\
            "Failed! No effects on the saving pic."

    def test_ImageEdit_AddSaturationEffect(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        # ---------------Grag to left or right---------------
        index = random.randint(0, 1)
        if index == 0:
            effectVolume = random.randint(0, 49)
        else:
            effectVolume = random.randint(50, 100)
        self.photosImpl.change_display_effect(effType='Saturation',
                                              effVol=effectVolume)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) > 0, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_AddShadowEffect(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        # ---------------Grag to left or right---------------
        effectVolume = [0, 100][random.randint(0, 1)]
        self.photosImpl.change_display_effect(effType='Shadows',
                                              effVol=effectVolume)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_AddVignetteEffect_BlueImageEditingAndSwitching(self):
        from testlib.graphics.extend_systemui_impl import SystemUiExtendImpl
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_blue",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        settings_pkgName = "com.android.settings"
        g_common_obj.adb_cmd_capture_msg(
            "am start %s" % settings_pkgName)  # launch settings app previously
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effType='Vignette', effVol=100)
        SystemUiExtendImpl().switch_recent_app(name='Settings')
        SystemUiExtendImpl().switch_recent_app(name='Photos')
        time.sleep(2)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_BMP_CancelEdit(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_001",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.change_display_effect(effVol=100)
            self.photosImpl.undo_edit()
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_BMP_Zoom_ByGesture(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_001",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.pic_zoom_out(300)
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_EditPNGImage_CancelEdit(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.change_display_effect(effVol=100)
            self.photosImpl.undo_edit()
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_GIF_Zoom_ByGesture(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_002",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.pic_zoom_in(300)
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_JPEG_Rotate_LeftRight(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_003",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.click_crop_tools()
            time.sleep(1)
            for _ in range(4):
                self.photosImpl.rotate_90_degrees()
                time.sleep(.5)
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_JPG_Rotate(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_003",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        time.sleep(1)
        # --------Rotate left or right--------
        i = [1, 3][random.randint(0, 1)]
        for _ in range(i):
            self.photosImpl.rotate_90_degrees()
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_JPG_Zoom_ByBoth(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_003",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.view_a_picture_fullscreen()
            self.photosImpl.pic_zoom_in(300)
            self.photosImpl.pic_zoom_out(300)
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_PNG_AddShadowEffect_2MBImage(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effType='Shadows', effVol=100)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_PNG_Rotate(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        time.sleep(1)
        # --------Rotate left or right--------
        i = [1, 3][random.randint(0, 1)]
        for _ in range(i):
            self.photosImpl.rotate_90_degrees()
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_PNG_SaveEdit(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effVol=100)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_PNG_Zoom_ByGesture(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.pic_zoom_out(300)
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_Rotate90degree_SaveImage(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_blue",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        time.sleep(1)
        self.photosImpl.rotate_90_degrees()
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) > 0, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_WBMP_Rotate(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_006",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        time.sleep(1)
        # --------Rotate left or right--------
        i = [1, 3][random.randint(0, 1)]
        for _ in range(i):
            self.photosImpl.rotate_90_degrees()
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result_by_screenshot(self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_WEBP_Rotate(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_007",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        time.sleep(1)
        # --------Rotate left or right--------
        i = [1, 3][random.randint(0, 1)]
        for _ in range(i):
            self.photosImpl.rotate_90_degrees()
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result_by_screenshot(self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_WEBP_Zoom_ByGesture(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_007",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.pic_zoom_in(300)
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_BWeffect_MoreThan5MB(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_morethan5mb",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        for eff in ['Whites', 'Blacks']:
            self.photosImpl.change_display_effect(effType=eff, effVol=100)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_BMP_Check4M(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_bmp4mb",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.view_a_picture_fullscreen()
        except:
            raise Exception("Test failed!")

    def test_imagedelete_press_menu_select_photo_delete(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_bmp4mb",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        bef_del = self.photosImpl.check_pic_number(self.PHOTO_PATH)
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.delete_a_picture()
        aft_del = self.photosImpl.check_pic_number(self.PHOTO_PATH)
        assert bef_del != aft_del, "Fail to delete pic!"

    def test_imageedit_blueimage_addvignetteeffect(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_blue",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effType='Vignette', effVol=100)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_WBMP_Zoom_ByBoth(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_006",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.view_a_picture_fullscreen()
            self.photosImpl.pic_zoom_in(300)
            self.photosImpl.pic_zoom_out(300)
        except:
            raise Exception("Test failed!")

    def test_imageedit_addeffects_setwallpaper(self):
        print "[RunTest]: %s" % self.__str__()
        if "com.android.launcher3" not in pkgmgr.get_packages():
            launch_aosp_home()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effType='Vignette', effVol=100)
        self.photosImpl.save_changes()
        self.photosImpl.click_crop_tools()
        self.photosImpl.rotate_right_45_degrees()
        self.photosImpl.save_picture_after_rotation()
        org_image = self.photosImpl.only_pull_saved_pic(self.PHOTO_PATH)
        out_image = self.qr.mark_image_qrcode(str(org_image))
        self.photosImpl.stop_photos_am()
        self.photosImpl.rm_delete_photos()
        self.photosImpl.deploy_photo_content(directory=self.PHOTO_PATH,
                                             local_file=out_image)
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.set_picture_as_wallpaper()
        self.qr.verify_qrcode_marked_image(qrcode="9876543210",
                                           set_wallpaper=True)

    def test_imageedit_addstraighteneffect_lessthan20kb(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_blue",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        time.sleep(1)
        # --------Rotate left or right--------
        i = [1, 3][random.randint(0, 1)]
        for _ in range(i):
            self.photosImpl.rotate_90_degrees()
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) > 0, \
            "Failed! No effects on the saving pic."

    def test_MoreThan1000Images(self):
        from testlib.graphics.common import busybox_obj
        from testlib.util.config import TestConfig

        print "[RunTest]: %s" % self.__str__()
        # Prepare for 1000 imgs.
        self.photosImpl.deploy_photo_content("Pictures",
                                             "picture_morethan1000",
                                             self.PHOTO_PATH)
        pics = TestConfig().read(
            CONFIG_FILE, "Pictures").get("picture_morethan1000").split('/')[-1]
        busybox_obj.setup()
        cmd = "busybox tar xvf %s/%s -C %s" % (self.PHOTO_PATH, pics,
                                               self.PHOTO_PATH)
        chk_cmd = "\'ls %s/1000/ | grep -c png\'" % self.PHOTO_PATH
        clean_cmd = "rm -rf %s/%s" % (self.PHOTO_PATH, pics)
        busybox_obj.adb_busybox_cmd(cmd)
        rst = 0
        while rst != 1000:
            rst = int(g_common_obj.adb_cmd_capture_msg(chk_cmd))
            time.sleep(5)
        else:
            print "1000 pic prepared."
        g_common_obj.adb_cmd_capture_msg(clean_cmd)
        time.sleep(3)
        self.photosImpl.refresh_sdcard()
        time.sleep(10)
        try:
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture('1000')
            self.d.press.back()
            _index = random.randint(1, 30)
            sw_num = random.randint(1, 5)
            for i in range(sw_num):
                self.d().swipe.up()
                time.sleep(1)
            self.d(index=_index).click.wait()
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_Add_Effect_Rotate(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.change_display_effect(effType='Vignette',
                                                  effVol=80)
            adb32.screen_rotation(1)
            adb32.screen_rotation(0)
        except:
            raise Exception("Test failed!")
        finally:
            adb32.screen_rotation(0)

    def test_ImageEdit_AddStraightenEffect(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        self.photosImpl.rotate_right_45_degrees()
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) > self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_AddVignetteEffect(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effType='Vignette', effVol=80)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_BMP_Check1K(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_bmp1k",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_BMP_Crop(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_001",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        self.photosImpl.rotate_right_45_degrees()
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result_by_screenshot(self.PHOTO_PATH) > self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_BMP_SaveEdit(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_001",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effType='Vignette', effVol=88)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result_by_screenshot(self.PHOTO_PATH) > self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_CorpUprightRectangular(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        self.photosImpl.crop_to_center(start_corner="left_bottom")
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_CropMoreThan8times_Rotate(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.click_crop_tools()
            for i in range(9):
                self.photosImpl.rotate_90_degrees()
                time.sleep(.5)
            self.photosImpl.save_picture_after_rotation()
            assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) > 0, \
                "Failed! No effects on the saving pic."
        except:
            raise Exception("Test failed in round 1.")
        self.photosImpl.rm_delete_photos()

        try:
            adb32.screen_rotation(1)
            self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.click_crop_tools()
            for i in range(9):
                self.photosImpl.rotate_90_degrees()
                time.sleep(.5)
            self.photosImpl.save_picture_after_rotation()
            assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) > 0, \
                "Failed! No effects on the saving pic."
        except:
            raise Exception("Test failed in round 2.")
        finally:
            adb32.screen_rotation(0)

    def test_ImageEdit_JPG_1K_Check(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_jpg1k",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_JPG_2M_Check(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_jpg2m",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_JPG_CancelEdit(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_003",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.change_display_effect(effVol=100)
            self.photosImpl.undo_edit()
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_JPG_Crop(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_003",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        self.photosImpl.crop_to_center(start_corner="left_top")
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_JPG_SaveEdit(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_003",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effType='Vignette', effVol=22)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_PanoramicImage_AddEffect(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_panoramic",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effType='Warmth', effVol=77)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_PersonFaceImage2MB_AddBWOrSharpnessEffects(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_face",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.change_display_effect(effType='Blacks', effVol=99)
        self.photosImpl.change_display_effect(effType='Whites', effVol=99)
        self.photosImpl.save_changes()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_PNG_Crop(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        self.photosImpl.crop_to_center(start_corner="right_top")
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_Rotate_Left(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        self.photosImpl.rotate_90_degrees()
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_Rotate_Right(self):
        print "[RunTest]: %s" % self.__str__()
        self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                             self.PHOTO_PATH)
        self.photosImpl.refresh_sdcard()
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        self.photosImpl.click_crop_tools()
        for i in range(3):
            self.photosImpl.rotate_90_degrees()
            time.sleep(.5)
        self.photosImpl.save_picture_after_rotation()
        assert self.photosImpl.check_saved_pic_result(picPath=self.PHOTO_PATH) >= self.ACCEPTABLE_VALUE, \
            "Failed! No effects on the saving pic."

    def test_ImageEdit_ThumbMD_All_Rotate(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "jpg_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            adb32.screen_rotation(1)
        except:
            raise Exception("Test failed!")
        finally:
            adb32.screen_rotation(0)

    def test_ImageEdit_ThumbMD_One_Rotate(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            adb32.screen_rotation(1)
        except:
            raise Exception("Test failed!")
        finally:
            adb32.screen_rotation(0)

    def test_ImageView_Webp_Check(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_007",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_ImageView_Webp_Thumbnail_LPCheck(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_webp2m",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.view_a_picture_fullscreen()
        except:
            raise Exception("Test failed!")

    def test_ImageView_Wbmp_2K_Check(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_wbmp2k",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_ImageView_Wbmp_300K_Check(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures",
                                                 "picture_wbmp300k",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_ImageView_Webp_1K_Check(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_webp1k",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_ImageView_Webp_2M_Check(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_webp2m",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_BMP_Check8M(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_bmp8mb",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_ImageEdit_PNG_AllTransParent_Check(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures",
                                                 "picture_transparent",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
        except:
            raise Exception("Test failed!")

    def test_MoreThan10GIFImages(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "gif_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.view_a_picture_fullscreen()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_MoreThan10JPEGImages(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("PicturesFolder",
                                                 "jpg_10resolution",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.view_a_picture_fullscreen()
            for _ in range(9):
                self.d().swipe.left(steps=10)
                time.sleep(2)
        except:
            raise Exception("Test failed!")

    def test_ImageView_Thumbnail_Mode(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_005",
                                                 self.PHOTO_PATH)
            self.photosImpl.refresh_sdcard()
            self.photosImpl.launch_photos_am()
        except:
            raise Exception("Test failed!")

    def test_ImageZoom_JPEG(self):
        print "[RunTest]: %s" % self.__str__()
        try:
            self.photosImpl.deploy_photo_content("Pictures", "picture_004",
                                                 self.PHOTO_PATH)
            self.photosImpl.launch_photos_am()
            self.photosImpl.open_a_picture()
            self.photosImpl.pic_zoom_out(30)
        except:
            raise Exception("Test failed!")