Exemple #1
0
class ComposeUI(UIATestBase):
    def setUp(self):
        super(ComposeUI, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self.d = g_common_obj.get_device()
        #         self.photos = get_photo_implement()
        self._composeui = ComposeUiImpl()
        config_handle = ConfigHandle()
        result = config_handle.check_apps("com.mxtech.videoplayer.ad")
        if result == 0:
            self._composeui.install_apk('Mxplayer')
        self.d.screen.on()
        self._qr = QRcode()
        self.extend_photos = PhotosExtendImpl()
        self.remote_path = self.extend_photos.push_videos(
            count=1, like='test_video_qr_middle', exts='.mp4')[0]
        adb32.screen_rotation(0)

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        super(ComposeUI, self).tearDown()
        os.remove("tmp.png")
        adb32.screen_rotation(0)

    def test_scaling_rotation_Video(self):
        ''' refer TC test_Scaling_Rotation_Video
        '''
        print "[RunTest]: %s" % self.__str__()
        self._composeui.play_video_command_mx(self.remote_path)
        time.sleep(2)
        if self.d(textContains="START OVER").exists:
            self.d(textContains="START OVER").click.wait()
        for i in [2, 1, 3, 0]:
            adb32.screen_rotation(i)
            time.sleep(1)
            if self.d(resourceId="com.mxtech.videoplayer.ad:id/ui_layout"
                      ).exists:
                self.d(resourceId="com.mxtech.videoplayer.ad:id/ui_layout"
                       ).pinch.Out(percent=120)
                time.sleep(2)
                assert self._qr.decode_image_qrcode(
                    self.d.screenshot("tmp.png")
                )[1] == "QRCODE_TEST_STRING", "The scaling of video playback failed!"
                self.d(resourceId="com.mxtech.videoplayer.ad:id/ui_layout"
                       ).pinch.In(percent=70, steps=5)
                time.sleep(2)
                assert self._qr.decode_image_qrcode(
                    self.d.screenshot("tmp.png")
                )[1] == "QRCODE_TEST_STRING", "The scaling of video playback failed!"
Exemple #2
0
class ComposeUI(UIATestBase):
    def setUp(self):
        super(ComposeUI, self).setUp()
        self._test_name = __name__
        self.d = g_common_obj.get_device()
        print "[Setup]: %s" % self._test_name
        self.photos = get_photo_implement()
        self._qr = QRcode()
        #         self.photos.rm_delete_photos()
        #         self.photos.refresh_sdcard()
        #         self._composeui = ComposeUiImpl()
        #         self._composeui.init_local_video()
        self.extend_photos = PhotosExtendImpl()
        self.remote_path = self.extend_photos.push_videos(like='test_video_qr',
                                                          exts='.mp4')[0]

    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.stop_app_am("com.google.android.apps.photos")
        try:
            os.remove(".tmp.png")
        except OSError:
            pass

    def test_videoplayback_forwardrewind(self):
        ''' refer TC test_VideoPlayback_ForwardRewind
        '''
        print "[RunTest]: %s" % self.__str__()
        #         self.photos.launch_photos_am()
        print "---------------GFX_forwardrewind--------------"
        #         from testlib.graphics.screenshot_for_liverpt import take_screenshot_for_liverpt
        #         take_screenshot_for_liverpt()
        self.photos.play_video_command(self.remote_path)
        #         take_screenshot_for_liverpt()
        self.photos.slide_video_processbar_forward()
        #         take_screenshot_for_liverpt()
        assert self._qr.decode_image_qrcode(self.d.screenshot(
            ".tmp.png"))[1] == "QRCODE_TEST_STRING", "Video playback failed!"
        self.photos.slide_video_processbar_backward()
        assert self._qr.decode_image_qrcode(self.d.screenshot(
            ".tmp.png"))[1] == "QRCODE_TEST_STRING", "Video playback failed!"
Exemple #3
0
class NotificationBar(UIATestBase):
    def setUp(self):
        super(NotificationBar, self).setUp()
        self._test_name = __name__
        self.d = g_common_obj.get_device()
        self._qr = QRcode()
        self.photos = get_photo_implement()
        print "[Setup]: %s" % self._test_name
        config = TestConfig()
        cfg_file = 'tests.tablet.artifactory.conf'
        cfg_arti = config.read(cfg_file, 'artifactory')
        config_handle = ConfigHandle()
        cfg_arti["location"] = config_handle.read_configuration(
            'artifactory', 'location', '/etc/oat/', 'sys.conf')
        cfg = config.read(cfg_file, 'content_picture')
        arti = Artifactory(cfg_arti.get('location'))
        pic_name = cfg.get("qr_image")
        file_path = arti.get(pic_name)
        g_common_obj.adb_cmd_common('push ' + file_path + ' /sdcard/Pictures')
        self.pic_path = '/sdcard/Pictures/' + os.path.basename(file_path)
#         self.systemui = SystemUiExtendImpl()
#         self.notifi_quick_settings = NotificationAndQuickSettingsImpl()
#         self.systemui.unlock_screen()

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        #         g_common_obj.set_vertical_screen()
        #         super(NotificationBar, self).tearDown()
        self.d.press.home()
        self.photos.rm_delete_photos()
        self.photos.refresh_sdcard()
        try:
            os.remove(".tmp.png")
        except OSError:
            pass

    def test_Shadow_NotificationBar(self):
        """
        1. Open an image file with QR code in it, pull down the notification bar and then take a screenshot.
        2. Use qrtools to read the QR code from the screenshot.
        """
        self.d.orientation = "n"
        _result = []
        for _ in range(0, 3):
            self.photos.open_image_command(self.pic_path)
            time.sleep(2)
            if self.d.open.notification():
                time.sleep(2)
                _result.append(
                    self._qr.decode_image_qrcode(self.d.screenshot(".tmp.png"))
                    [1] == "QRCODE_TEST_STRING")
            if _result[0]:
                break
        print _result
        assert True in _result, "The notification bar is not transparent!"
class VideoPlayback(UIATestBase):
    def setUp(self):
        super(VideoPlayback, self).setUp()
        self._test_name = __name__
        self.device = g_common_obj.get_device()
        print "[Setup]: %s" % self._test_name
        #         g_common_obj.root_on_device()
        #         g_common_obj.remount_device()
        self.photos = get_photo_implement()
        self.photosImpl = PhotosExtendImpl()
        self._qr = QRcode()
        self.photos.rm_delete_photos()
        self.photos.refresh_sdcard()
        self.remote_path = self.photosImpl.push_videos(
            count=1, like='test_video_qr_bottom', exts='.mp4')[0]
        special_actions.setup()

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        super(VideoPlayback, self).tearDown()
        self.photos.rm_delete_photos()
        self.photos.refresh_sdcard()
        try:
            os.remove(".tmp.png")
        except OSError:
            pass

    def test_AppTransparency_VideoPlayback(self):
        ''' refer TC test_AppTransparency_VideoPlayback
        '''
        print "[RunTest]: %s" % self.__str__()
        x, y = 0, self.device.info[
            'displayHeight'] / 2  # touch point for full screen playback.
        self.photos.play_video_command(self.remote_path)
        #         self.photos.launch_photos_am()
        #         self.photos.play_video()
        time.sleep(5)
        self.photos.pause_play_video()
        g_common_obj.adb_cmd_capture_msg("input touchscreen tap %s %s" %
                                         (x, y))
        time.sleep(5)
        assert self._qr.decode_image_qrcode(self.device.screenshot(".tmp.png"))[1] == "QRCODE_TEST_STRING",\
            "Video playback transparency test failed!"
class VideoPlayback(UIATestBase):
    @classmethod
    def setUpClass(cls):
        print "[setUpClass]: %s" % cls.__name__
        super(VideoPlayback, cls).setUpClass()
        cls.d = g_common_obj.get_device()
        g_common_obj.root_on_device()

    def setUp(self):
        print "[Setup]:%s" % self.__class__.__name__
        super(VideoPlayback, self).setUp()
        self.photos = get_photo_implement()
        self.bench = Gfxbench()
        self._qr = QRcode()
        self.extend_photos = PhotosExtendImpl()
        self.remote_path = self.extend_photos.push_videos(count=1,
                                                          like='test_video_qr',
                                                          exts='.mp4')[0]

    def tearDown(self):
        print "[tearDown]:%s" % self.__class__.__name__
        self.photos.rm_delete_photos()
        self.photos.refresh_sdcard()
        self.photos.stop_photos_am()
        try:
            os.remove(".tmp.png")
        except OSError:
            pass

    def test_AppSwitching(self):
        print "[RunTest]: %s" % self.__str__()
        self.photos.play_video_command(self.remote_path, 5)
        self.bench.setup()
        self.bench.run_test("ALU 2", 50000)
        time.sleep(10)
        self.photos.play_video_command(self.remote_path, 5)
        screen_temp = tempfile.mktemp(suffix='.png',
                                      prefix='screenshot_',
                                      dir='/tmp')
        g_common_obj.take_screenshot(screen_temp)
        ret, qrcode = self._qr.decode_image_qrcode(screen_temp)
        assert ret and qrcode == "QRCODE_TEST_STRING", "Video playback failed!"
class Fit(RenderAppTestBase):

    def setUp(self):
        super(Fit, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self.photos = get_photo_implement()
        self.d = g_common_obj.get_device()
        self.d.screen.on()
        self._qr = QRcode()
        self.extend_photos = PhotosExtendImpl()
        self.remote_path = self.extend_photos.push_videos(count=1, like='test_video_qr', exts='.mp4')[0]
        adb32.screen_rotation(0)

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        super(Fit, self).tearDown()
        self.photos.rm_delete_photos()
        self.photos.refresh_sdcard()
        g_common_obj.stop_app_am("com.google.android.apps.photos")
        try:
            os.remove(".tmp.png")
        except OSError:
            pass
        adb32.screen_rotation(0)

    def test_switch_portrait_landscape_apps_serval_times(self):
        ''' refer TC test_switch_portrait_landscape_apps_serval_times
        '''
        print "[RunTest]: %s" % self.__str__()
        n = 5
        self.photos.play_video_command(self.remote_path)
        while n > 0:
            for i in [2, 1, 3, 0]:
                adb32.screen_rotation(i)
                time.sleep(10)
                assert self._qr.decode_image_qrcode(self.d.screenshot(".tmp.png"))[1] == "QRCODE_TEST_STRING", "Video playback failed!"
            n = n - 1
class ImageViewingSuspendResumeByCommandTest(PhotoTestBase):
    def setUp(self):
        print "[Setup]:%s" % self.__class__.__name__
        super(ImageViewingSuspendResumeByCommandTest, self).setUp()
        self.photos = PhotosExtendImpl()
        #         self.camera = CameraExtendImpl()
        self.systemui = SystemUiExtendImpl()
        self.photosImpl = get_photo_implement()
        self.qrcodeImpl = QRcode()
        self.device = g_common_obj.get_device()
        self.systemui.unlock_screen()
        self.device.screen.on()
        #         self.device.press.menu()
        self.photosImpl.rm_delete_photos()
        self.photosImpl.refresh_sdcard()
        self.photos.clean()
        #         self.camera.clean()

        self.qrcode = "QRCODE_TEST_STRING"
        config = TestConfig()
        cfg_file = 'tests.tablet.artifactory.conf'
        cfg_arti = config.read(cfg_file, 'artifactory')
        config_handle = ConfigHandle()
        cfg_arti["location"] = config_handle.read_configuration(
            'artifactory', 'location', '/etc/oat/', 'sys.conf')

        cfg = config.read(cfg_file, 'content_picture')
        self.qrcode = cfg.get("imageviewing_qrcode")
        print "[Debug] qrcode:%s" % (self.qrcode)
        arti = Artifactory(cfg_arti.get('location'))
        pic_name = cfg.get("qr_image")
        file_path = arti.get(pic_name)
        g_common_obj.adb_cmd_common('push ' + file_path + ' /sdcard/Pictures')
        self.photosImpl.refresh_sdcard()
        special_actions.setup()
        self.photosImpl.launch_photos_am()
        self.mark_time = logcat.get_device_time_mark()

    def tearDown(self):
        print "[tearDown]:%s" % self.__class__.__name__
        self.photosImpl.rm_delete_photos()
        self.photosImpl.refresh_sdcard()
        #         fatal_msg = logcat.get_device_log(self.mark_time, filters='*:F')
        #         assert len(fatal_msg) == 0,\
        #             "occurred Fatal error during testing:\n%s" % (fatal_msg)
        super(ImageViewingSuspendResumeByCommandTest, self).tearDown()
        try:
            os.remove(".tmp.png")
        except OSError:
            pass

    @classmethod
    def tearDownClass(cls):
        print "[tearDownClass]: %s" % cls.__name__
        super(ImageViewingSuspendResumeByCommandTest, cls).tearDownClass()

    def test_ImageViewing_SuspendResumeByCommand_20times(self):
        """
        test_ImageViewing_SuspendResumeByCommand_20times

        Steps:
        1. Launch Photos app to view an image.
        Image viewed in Photos app.
        2. Launch a terminal/CMD and input command "adb shell input keyevent KEYCODE_POWER" to suspend/resume the devices for 20 times.
        No error & hung up & panic occur.
        """
        print "[RunTest]: %s" % self.__str__()

        print """[Step] 1. Launch Photos app to view an image.
        Image viewed in Photos app."""
        self.photosImpl.launch_photos_am()
        self.photosImpl.open_a_picture()
        #         self.qrcodeImpl.verify_qrcode_marked_image(self.qrcode,set_wallpaper=False)
        print """[Step] 2. Launch a terminal/CMD and input command "adb shell input keyevent KEYCODE_POWER" to suspend/resume the devices for 20 times.
        No error & hung up & panic occur."""
        #         cmd_power = "input keyevent KEYCODE_POWER"
        #         cmd_menu = "input keyevent KEYCODE_MENU"
        for i in range(1, 21):
            print "[Debug] %s times" % (i)
            #             g_common_obj.adb_cmd(cmd_power)
            #             time.sleep(1)
            #             assert not is_device_screen_on(), "[FAILURE] Failed suspend device"
            self.device.wakeup()
            time.sleep(3)
            #             g_common_obj.adb_cmd(cmd_power)
            #             g_common_obj.adb_cmd(cmd_menu)
            #             time.sleep(1)
            #             assert is_device_screen_on(), "[FAILURE] Failed resume device"
            #             self.qrcodeImpl.verify_qrcode_marked_image(self.qrcode,set_wallpaper=False)
            assert self.qrcodeImpl.decode_image_qrcode(self.device.screenshot(".tmp.png"))[1] == "QRCODE_TEST_STRING",\
                "Imageviewing failed after resuming DUT in test cycle %s" % (i)
            time.sleep(1)
            self.device.sleep()
            time.sleep(3)