Exemplo n.º 1
0
 def setUp(self):
     super(DebugModeSimulateSecondaryDisplayDrag, self).setUp()
     self._test_name = __name__
     print "[Setup]: %s" % self._test_name
     self._debugmodeDrag = DebugModeDragImpl()
     self._debugmode = DebugModeImpl()
     adb32.screen_rotation(0)
Exemplo n.º 2
0
 def __init__(self):
     self.device = g_common_obj.get_device()
     self._locator = Locator(self.device)
     self.debugmode = DebugModeImpl()
Exemplo n.º 3
0
class DebugModeSleepImpl:
    '''
    classdocs
    '''
    def __init__(self):
        self.device = g_common_obj.get_device()
        self._locator = Locator(self.device)
        self.debugmode = DebugModeImpl()

    def launch_settings_am(self):
        """ Launch Settings via adb am command
        """
        print "Launch Settings by adb am"
        g_common_obj.launch_app_am("com.android.settings",
                                   "com.android.settings.Settings")
        self._locator.wait_exist(self._locator.performance_tests)

    @staticmethod
    def stop_settings_am():
        """ Stop Settings via adb am command
        """
        print "Stop Settings by adb am"
        g_common_obj.stop_app_am("com.android.settings")

    def change_to_vertical(self):
        """ change device to vertical
        """
        g_common_obj.set_vertical_screen()

    def power_off_device(self):
        g_common_obj.adb_cmd("input keyevent 26")

    def power_on_device(self):
        """ Unlock screen by via input keyevent 82
        """
        self.device.wakeup()
        print "Unlock screen via input keyevent 82"
        cmd = 'input keyevent 82; echo $?'
        result_list = g_common_obj.adb_cmd_capture_msg(cmd).split('\r\n')
        suc = False
        if len(result_list):
            ret = result_list[-1].rstrip()
            suc = (int(ret) == 0)

    def check_resolution(self, keyword1, keyword2):
        get_cmd = "settings get global overlay_display_devices"
        msg = g_common_obj.adb_cmd_capture_msg(repr(get_cmd))
        remsg1 = msg.find(keyword1)
        remsg2 = msg.find(keyword2)
        return remsg1, remsg2, msg

    def choose_simulate_secondary_displays(self):
        y = self.device.info["displayHeight"]
        x = self.device.info["displayWidth"]
        if not self.device(text="Developer options").exists:
            self.device(scrollable=True).scroll.to(text="Developer options")
        time.sleep(1)
        self._locator.developer_options.click.wait()
        if not self._locator.simulate_secondary_displays.exists:
            self.device(scrollable=True).scroll.vert.to(
                textContains="Simulate secondary displays")
        self._locator.simulate_secondary_displays.drag.to(x / 2, y / 2)
        time.sleep(3)

    def change_simulate_None(self):
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_None.click.wait()

    def change_simulate_720x480(self):
        print "[debug] change resolution to 720x480"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720x480.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()
        y = self.device.info["displayHeight"]
        self.device.drag(0, y / 10, 0, y / 5)

    def change_simulate_720x480_secure(self):
        print "[debug] change resolution to 720x480 secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720x480_secure.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()
        y = self.device.info["displayHeight"]
        self.device.drag(0, y / 10, 0, y / 5)

    def change_simulate_1280x720(self):
        print "[debug] change resolution to 1280x720"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_1280x720.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()
        y = self.device.info["displayHeight"]
        self.device.drag(0, y / 10, 0, y / 5)

    def change_simulate_1280x720_secure(self):
        print "[debug] change resolution to 1280x720 secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1280x720_secure.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()
        y = self.device.info["displayHeight"]
        self.device.drag(0, y / 10, 0, y / 5)

    def change_simulate_1920x1080(self):
        print "[debug] change resolution to 1920x1080"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1920x1080.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()
        y = self.device.info["displayHeight"]
        self.device.drag(0, y / 10, 0, y / 5)

    def change_simulate_1920x1080_secure(self):
        print "[debug] change resolution to 1920x1080 secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_1920x1080_secure.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()
        y = self.device.info["displayHeight"]
        self.device.drag(0, y / 10, 0, y / 5)

    def change_simulate_1280x720_and_1920x1080(self):
        print "[debug] change resolution to 1280x720 and 1920x1080"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_1280x720_and_1920x1080.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "1920x1080")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()
        y = self.device.info["displayHeight"]
        self.device.drag(0, y / 10, 0, y / 5)

    def change_simulate_480p(self):
        print "[debug] change resolution to 480p"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_480p.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_480p_secure(self):
        print "[debug] change resolution to 480p secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_480p_secure.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_720p(self):
        print "[debug] change resolution to 720p"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720p.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_720p_secure(self):
        print "[debug] change resolution to 720p secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720p_secure.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_1080p(self):
        print "[debug] change resolution to 1080p"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1080p.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_1080p_secure(self):
        print "[debug] change resolution to 1080p secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1080p_secure.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_4K(self):
        print "[debug] change resolution to 4K"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("3840x2160", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_4K_secure(self):
        print "[debug] change resolution to 4K secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K_secure.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("3840x2160", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_4K_upscaled(self):
        print "[debug] change resolution to 4K upscaled"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K_upscaled.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_4K_upscaled_secure(self):
        print "[debug] change resolution to 4K upscaled secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K_upscaled_secure.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()

    def change_simulate_720p_1080p_dualscreen(self):
        print "[debug] change resolution to btn_720p_1080p_dualscreen"
        self._locator.simulate_secondary_displays.click.wait()
        print "--------------GFX_SimulateSecondaryDisplay_Sleep--------------------"
        from testlib.graphics.screenshot_for_liverpt import take_screenshot_for_liverpt
        take_screenshot_for_liverpt()
        self._locator.btn_720p_1080p_dualscreen.click.wait()
        self.power_off_device()
        time.sleep(1)
        self.power_on_device()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "1920x1080")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
        self.debugmode.set_secondary_displays_none()
Exemplo n.º 4
0
class DebugModeSimulateSecondaryDisplayDrag(UIATestBase):
    def setUp(self):
        super(DebugModeSimulateSecondaryDisplayDrag, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self._debugmodeDrag = DebugModeDragImpl()
        self._debugmode = DebugModeImpl()
        adb32.screen_rotation(0)

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        super(DebugModeSimulateSecondaryDisplayDrag, self).tearDown()
        self._debugmode.set_secondary_displays_none()
        adb32.screen_rotation(0)

    def test_DebugMode_SimulateSecondaryDisplay_Drag(self):
        ''' refer TC test_DebugMode_SimulateSecondaryDisplay_Drag
        '''
        print "[RunTest]: %s" % self.__str__()
        version_array = osversion.get_android_version()
        androidversion = version_array[0]
        if androidversion in (5, 6, 7, 8):
            print "osversion is M,N,O"
            self._debugmodeDrag.launch_settings_am()
            self._debugmodeDrag.choose_simulate_secondary_displays()
            self._debugmodeDrag.change_simulate_720p_1080p_dualscreen()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_4K_upscaled_secure()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_4K_upscaled()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_4K_secure()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_4K()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_1080p_secure()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_1080p()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_720p_secure()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_720p()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_480p_secure()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_480p()
            self._debugmodeDrag.change_simulate_None()
            self._debugmodeDrag.stop_settings_am()
        else:
            print "osversion is %s" % (androidversion)
            self._debugmodeDrag.launch_settings_am()
            self._debugmodeDrag.choose_simulate_secondary_displays()
            self._debugmodeDrag.change_simulate_1280x720_and_1920x1080()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_1920x1080_secure()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_1920x1080()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_1280x720_secure()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_1280x720()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_720x480_secure()
            self._debugmodeDrag.drag_simulated_secondary_display()
            self._debugmodeDrag.change_simulate_720x480()
            self._debugmodeDrag.change_simulate_None()
            self._debugmodeDrag.stop_settings_am()
Exemplo n.º 5
0
class DebugModeRotationImpl:

    '''
    classdocs
    '''

    def __init__(self):
        self.device = g_common_obj.get_device()
        self._locator = Locator(self.device)
        self.debugmode = DebugModeImpl()

    def launch_settings_am(self):
        """ Launch Settings via adb am command
        """
        print "Launch Settings by adb am"
        g_common_obj.launch_app_am(
            "com.android.settings", "com.android.settings.Settings")
        self._locator.wait_exist(self._locator.performance_tests)

    @staticmethod
    def stop_settings_am():
        """ Stop Settings via adb am command
        """
        print "Stop Settings by adb am"
        g_common_obj.stop_app_am("com.android.settings")

    def change_orientation(self, orientation):
        for _ in range(0, 3):
            self.device.orientation = orientation
            if self.device.orientation == orientation:
                break

    def change_to_vertical(self):
        """ judge wether is vertical,change to vertical if it not
        """
        print "change to vertical"
        width = self.device.info["displayWidth"]
        height = self.device.info["displayHeight"]
        orientation = self.device.info["displayRotation"]
        if width > height and orientation == 0:
            self.change_orientation("r")
        elif width > height and orientation > 0:
            self.change_orientation("n")
        self.device.freeze_rotation()

    def change_to_landscape(self):
        """ judge wether is landscape,change to landscape if it not
        """
        print "change to landscape"
        y = self.device.info["displayHeight"]
        x = self.device.info["displayWidth"]
        orientation = self.device.info["displayRotation"]
        if y > x and orientation == 0:
            self.change_orientation("l")
        elif y > x and orientation > 0:
            self.change_orientation("n")
        self.device.freeze_rotation()

    def drag_simulated_secondary_display(self):
        y = self.device.info["displayHeight"]
        self.device.drag(0, 50, 0, y)

    def check_resolution(self, keyword1, keyword2):
        get_cmd = "settings get global overlay_display_devices"
        msg = g_common_obj.adb_cmd_capture_msg(repr(get_cmd))
        remsg1 = msg.find(keyword1)
        remsg2 = msg.find(keyword2)
        return remsg1, remsg2, msg

    def choose_simulate_secondary_displays(self):
        y = self.device.info["displayHeight"]
        x = self.device.info["displayWidth"]
        if self.device().scroll.to(textContains="Developer options"):
            self._locator.developer_options.click.wait()
        else:
            self.device().scroll.to(textContains="System")
            time.sleep(1)
            self.device(textContains="System").click()
            time.sleep(1)
            self._locator.developer_options.click.wait()
        self._locator.developer_options.click.wait()
        if not self._locator.simulate_secondary_displays.exists:
            self.device(scrollable=True).scroll.vert.to(textContains="Simulate secondary displays")
        self._locator.simulate_secondary_displays.drag.to(x / 2, y / 2)
        time.sleep(3)

    def change_simulate_None(self):
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_None.click.wait()

    def change_simulate_720x480(self):
        print "[debug] change resolution to 720x480"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720x480.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert  remsg1 != -1 and remsg2 == -1 , "dumpsys msg is %s" % msg
        self.change_to_vertical()

    def change_simulate_720x480_secure(self):
        print "[debug] change resolution to 720x480 secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720x480_secure.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()

    def change_simulate_1280x720(self):
        print "[debug] change resolution to 1280x720"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_1280x720.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert  remsg1 != -1 and remsg2 == -1 , "dumpsys msg is %s" % msg
        self.change_to_vertical()

    def change_simulate_1280x720_secure(self):
        print "[debug] change resolution to 1280x720 secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1280x720_secure.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()

    def change_simulate_1920x1080(self):
        print "[debug] change resolution to 1920x1080"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1920x1080.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert  remsg1 != -1 and remsg2 == -1 , "dumpsys msg is %s" % msg
        self.change_to_vertical()

    def change_simulate_1920x1080_secure(self):
        print "[debug] change resolution to 1920x1080 secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_1920x1080_secure.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()

    def change_simulate_1280x720_and_1920x1080(self):
        print "[debug] change resolution to 1280x720 and 1920x1080"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_1280x720_and_1920x1080.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "1920x1080")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()

    def change_simulate_480p(self):
        print "[debug] change resolution to 480p"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_480p.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert  remsg1 != -1 and remsg2 == -1 , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_480p_secure(self):
        print "[debug] change resolution to 480p secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_480p_secure.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_720p(self):
        print "[debug] change resolution to 720p"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720p.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert  remsg1 != -1 and remsg2 == -1 , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_720p_secure(self):
        print "[debug] change resolution to 720p secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720p_secure.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_1080p(self):
        print "[debug] change resolution to 1080p"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1080p.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert  remsg1 != -1 and remsg2 == -1 , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_1080p_secure(self):
        print "[debug] change resolution to 1080p secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1080p_secure.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_4K(self):
        print "[debug] change resolution to 4K"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("3840x2160", "secure")
        assert  remsg1 != -1 and remsg2 == -1 , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_4K_secure(self):
        print "[debug] change resolution to 4K secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K_secure.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("3840x2160", "secure")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_4K_upscaled(self):
        print "[debug] change resolution to 4K upscaled"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K_upscaled.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert  remsg1 != -1 and remsg2 == -1 , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_4K_upscaled_secure(self):
        print "[debug] change resolution to 4K upscaled secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K_upscaled_secure.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()

    def change_simulate_720p_1080p_dualscreen(self):
        print "[debug] change resolution to btn_720p_1080p_dualscreen"
        self._locator.simulate_secondary_displays.click.wait()
        # print "--------------GFX_SimulateSecondaryDisplay_Rotation--------------------"
        # from testlib.graphics.screenshot_for_liverpt import take_screenshot_for_liverpt
        # take_screenshot_for_liverpt()
        self._locator.btn_720p_1080p_dualscreen.click.wait()
        self.change_to_landscape()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "1920x1080")
        assert not (remsg1 == -1 or remsg2 == -1) , "dumpsys msg is %s" % msg
        self.change_to_vertical()
        self.debugmode.set_secondary_displays_none()
Exemplo n.º 6
0
class DebugModeDragImpl:
    '''
    classdocs
    '''
    def __init__(self):
        self.device = g_common_obj.get_device()
        self._locator = Locator(self.device)
        self.debugmode = DebugModeImpl()

    def launch_settings_am(self):
        """ Launch Settings via adb am command
        """
        print "Launch Settings by adb am"
        g_common_obj.launch_app_am("com.android.settings",
                                   "com.android.settings.Settings")
        self._locator.wait_exist(self._locator.performance_tests)

    @staticmethod
    def stop_settings_am():
        """ Stop Settings via adb am command
        """
        print "Stop Settings by adb am"
        g_common_obj.stop_app_am("com.android.settings")

    def change_to_vertical(self):
        """ change device to vertical
        """
        g_common_obj.set_vertical_screen()

    def drag_simulated_secondary_display(self):
        y = self.device.info["displayHeight"]
        self.device.drag(0, 100, 0, y)
        self.debugmode.set_secondary_displays_none()

    def check_resolution(self, keyword1, keyword2):
        get_cmd = "settings get global overlay_display_devices"
        msg = g_common_obj.adb_cmd_capture_msg(repr(get_cmd))
        remsg1 = msg.find(keyword1)
        remsg2 = msg.find(keyword2)
        return remsg1, remsg2, msg

    def choose_simulate_secondary_displays(self):
        y = self.device.info["displayHeight"]
        x = self.device.info["displayWidth"]
        if self.device().scroll.to(textContains="Developer options"):
            self._locator.developer_options.click.wait()
        else:
            self.device().scroll.to(textContains="System")
            time.sleep(1)
            self.device(textContains="System").click()
            time.sleep(1)
            self._locator.developer_options.click.wait()
        if not self._locator.simulate_secondary_displays.exists:
            self.device(scrollable=True).scroll.vert.to(
                textContains="Simulate secondary displays")
        self._locator.simulate_secondary_displays.drag.to(x / 2, y / 2)
        time.sleep(3)

    def change_simulate_None(self):
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_None.click.wait()

    def change_simulate_720x480(self):
        print "[debug] change resolution to 720x480"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720x480.click.wait()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg

    def change_simulate_720x480_secure(self):
        print "[debug] change resolution to 720x480 secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720x480_secure.click.wait()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg

    def change_simulate_1280x720(self):
        print "[debug] change resolution to 1280x720"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_1280x720.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg

    def change_simulate_1280x720_secure(self):
        print "[debug] change resolution to 1280x720 secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1280x720_secure.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg

    def change_simulate_1920x1080(self):
        print "[debug] change resolution to 1920x1080"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1920x1080.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg

    def change_simulate_1920x1080_secure(self):
        print "[debug] change resolution to 1920x1080 secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_1920x1080_secure.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg

    def change_simulate_1280x720_and_1920x1080(self):
        print "[debug] change resolution to 1280x720 and 1920x1080"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_1280x720_and_1920x1080.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "1920x1080")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg

    def change_simulate_480p(self):
        print "[debug] change resolution to 480p"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_480p.click.wait()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg

    def change_simulate_480p_secure(self):
        print "[debug] change resolution to 480p secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_480p_secure.click.wait()
        remsg1, remsg2, msg = self.check_resolution("720x480", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg

    def change_simulate_720p(self):
        print "[debug] change resolution to 720p"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720p.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg

    def change_simulate_720p_secure(self):
        print "[debug] change resolution to 720p secure"
        self._locator.simulate_secondary_displays.click.wait()
        self._locator.btn_720p_secure.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg

    def change_simulate_1080p(self):
        print "[debug] change resolution to 1080p"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1080p.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg

    def change_simulate_1080p_secure(self):
        print "[debug] change resolution to 1080p secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_1080p_secure.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg

    def change_simulate_4K(self):
        print "[debug] change resolution to 4K"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K.click.wait()
        remsg1, remsg2, msg = self.check_resolution("3840x2160", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg

    def change_simulate_4K_secure(self):
        print "[debug] change resolution to 4K secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K_secure.click.wait()
        remsg1, remsg2, msg = self.check_resolution("3840x2160", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg

    def change_simulate_4K_upscaled(self):
        print "[debug] change resolution to 4K upscaled"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K_upscaled.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert remsg1 != -1 and remsg2 == -1, "dumpsys msg is %s" % msg

    def change_simulate_4K_upscaled_secure(self):
        print "[debug] change resolution to 4K upscaled secure"
        self._locator.simulate_secondary_displays.click()
        self._locator.btn_4K_upscaled_secure.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1920x1080", "secure")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg

    def change_simulate_720p_1080p_dualscreen(self):
        print "[debug] change resolution to btn_720p_1080p_dualscreen"
        self._locator.simulate_secondary_displays.click.wait()
        # if not self._locator.btn_720p_1080p_dualscreen:
        #    self.device(scrollable=True).scroll.vert.to(text="720p, 1080p (dual screen)")
        self._locator.btn_720p_1080p_dualscreen.click.wait()
        remsg1, remsg2, msg = self.check_resolution("1280x720", "1920x1080")
        assert not (remsg1 == -1 or remsg2 == -1), "dumpsys msg is %s" % msg
 def setUp(self):
     super(DebugModeSimulateSecondaryDisplaySleep, self).setUp()
     self._test_name = __name__
     print "[Setup]: %s" % self._test_name
     self._debugmodeSleep = DebugModeSleepImpl()
     self._debugmode = DebugModeImpl()
class DebugModeSimulateSecondaryDisplaySleep(UIATestBase):
    def setUp(self):
        super(DebugModeSimulateSecondaryDisplaySleep, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self._debugmodeSleep = DebugModeSleepImpl()
        self._debugmode = DebugModeImpl()

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        super(DebugModeSimulateSecondaryDisplaySleep, self).tearDown()
        self._debugmode.set_secondary_displays_none()

    def test_DebugMode_SimulateSecondaryDisplay_Sleep(self):
        ''' refer TC test_DebugMode_SimulateSecondaryDisplay
        '''
        print "[RunTest]: %s" % self.__str__()
        version_array = osversion.get_android_version()
        androidversion = version_array[0]
        if androidversion == 7:
            print "osversion is N"
            self._debugmodeSleep.launch_settings_am()
            self._debugmodeSleep.change_to_vertical()
            self._debugmodeSleep.choose_simulate_secondary_displays()
            self._debugmodeSleep.change_simulate_720p_1080p_dualscreen()
            self._debugmodeSleep.change_simulate_4K_upscaled_secure()
            self._debugmodeSleep.change_simulate_4K_upscaled()
            self._debugmodeSleep.change_simulate_4K_secure()
            self._debugmodeSleep.change_simulate_4K()
            self._debugmodeSleep.change_simulate_1080p_secure()
            self._debugmodeSleep.change_simulate_1080p()
            self._debugmodeSleep.change_simulate_720p_secure()
            self._debugmodeSleep.change_simulate_720p()
            self._debugmodeSleep.change_simulate_480p_secure()
            self._debugmodeSleep.change_simulate_480p()
            self._debugmodeSleep.change_simulate_None()
            self._debugmodeSleep.stop_settings_am()
        elif androidversion == 6:
            print "osversion is M"
            self._debugmodeSleep.launch_settings_am()
            self._debugmodeSleep.change_to_vertical()
            self._debugmodeSleep.choose_simulate_secondary_displays()
            self._debugmodeSleep.change_simulate_720p_1080p_dualscreen()
            self._debugmodeSleep.change_simulate_4K_upscaled_secure()
            self._debugmodeSleep.change_simulate_4K_upscaled()
            self._debugmodeSleep.change_simulate_4K_secure()
            self._debugmodeSleep.change_simulate_4K()
            self._debugmodeSleep.change_simulate_1080p_secure()
            self._debugmodeSleep.change_simulate_1080p()
            self._debugmodeSleep.change_simulate_720p_secure()
            self._debugmodeSleep.change_simulate_720p()
            self._debugmodeSleep.change_simulate_480p_secure()
            self._debugmodeSleep.change_simulate_480p()
            self._debugmodeSleep.change_simulate_None()
            self._debugmodeSleep.stop_settings_am()
        elif androidversion == 5:
            print "osversion is L"
            self._debugmodeSleep.launch_settings_am()
            self._debugmodeSleep.change_to_vertical()
            self._debugmodeSleep.choose_simulate_secondary_displays()
            self._debugmodeSleep.change_simulate_720x480()
            self._debugmodeSleep.change_simulate_1280x720()
            self._debugmodeSleep.change_simulate_1280x720_secure()
            self._debugmodeSleep.change_simulate_1920x1080()
            self._debugmodeSleep.change_simulate_1920x1080_secure()
            self._debugmodeSleep.change_simulate_1280x720_and_1920x1080()
            self._debugmodeSleep.change_simulate_720x480_secure()
            self._debugmodeSleep.change_simulate_None()
            self._debugmodeSleep.stop_settings_am()
        else:
            print "osversion is %s" % (androidversion)
            self._debugmodeSleep.launch_settings_am()
            self._debugmodeSleep.change_to_vertical()
            self._debugmodeSleep.choose_simulate_secondary_displays()
            self._debugmodeSleep.change_simulate_720x480()
            self._debugmodeSleep.change_simulate_1280x720()
            self._debugmodeSleep.change_simulate_1280x720_secure()
            self._debugmodeSleep.change_simulate_1920x1080()
            self._debugmodeSleep.change_simulate_1920x1080_secure()
            self._debugmodeSleep.change_simulate_1280x720_and_1920x1080()
            self._debugmodeSleep.change_simulate_720x480_secure()
            self._debugmodeSleep.change_simulate_None()
            self._debugmodeSleep.stop_settings_am()