Example #1
0
 def test_screenshot_app_rotate(self):
     app_start_cmd = "am start -n com.intel.test.apitests/.ApiTests"
     AdbUtils.run_adb_cmd(app_start_cmd)
     time.sleep(5)
     screenshoter = ScreenshotUtils()
     OrientationChanger.change_orientation("n")
     screenshoter.take_screenshot()
     screenshot_width_n = screenshoter.screen_width
     screenshot_height_n = screenshoter.screen_height
     print "natural orientation dimensions: ", screenshot_width_n, screenshot_height_n
     OrientationChanger.change_orientation("l")
     screenshoter.take_screenshot()
     screenshot_width_l = screenshoter.screen_width
     screenshot_height_l = screenshoter.screen_height
     print "left orientation dimensions: ", screenshot_width_l, screenshot_height_l
     self.assertTrue(screenshot_height_n == screenshot_width_l)
     self.assertTrue(screenshot_height_l == screenshot_width_n)
Example #2
0
 def test_verify_screenshot_width_height(self):
     screen_shooter = ScreenshotUtils()
     try:
         screen_shooter.take_screenshot()
         print "screenshot: ", screen_shooter.screen_width, screen_shooter.screen_height
         #             shell_prop_density_info = SystemUtils.get_property("ro.sf.lcd_density_info", "density")
         shell_prop_density_info = g_common_obj.adb_cmd_capture_msg(
             "wm size")
         test_width, test_height = SystemUtils.get_screen_size_from_lcd_density_info(
             shell_prop_density_info)
         print "shell prop:", test_width, test_height
         assert {
             int(screen_shooter.screen_width),
             int(screen_shooter.screen_height)
         } == {int(test_width), int(test_height)}
     finally:
         pass
Example #3
0
class DebugMode(UIATestBase):
    def setUp(self):
        super(DebugMode, self).setUp()
        self.__test_name = __name__
        print "Setup: %s" % self.__test_name
        self._cts_test = CTS_Impl()
        UiAutomatorUtils.unlock_screen()
        resource.disable_app_verification()
        self.screenshooter = ScreenshotUtils()
        _apk_path = resource.get_resource_from_atifactory\
        ("tests.tablet.artifactory.conf", "SDK_API", "api_test")
        g_common_obj.adb_cmd_common("install -r %s" % _apk_path)

    def test_gpu_overdraw(self):
        try:
            # enable showing of overdraw areas
            g_common_obj.get_device().orientation = 'n'
            Settings.enable_gpu_overdraw_show_overdraw_areas()
            self.screenshooter.take_screenshot()
            total_nr_of_pixels = self.screenshooter.screen_width * self.screenshooter.screen_height
            dark_red_pixels = self.screenshooter.get_dark_red_pixels_from_current_screenshot(
            )
            nr_of_dark_red_pixels = len(dark_red_pixels)
            LOG.info("dark red overdraw pixels nr.: " +
                     str(nr_of_dark_red_pixels))
            percent_of_dark_red_pixels = nr_of_dark_red_pixels * 100.0 / total_nr_of_pixels
            LOG.info("dark red percent: " + str(percent_of_dark_red_pixels))
            self.assertTrue(percent_of_dark_red_pixels < 15,
                            "dark red pixels must be under 15%")
            # enable showing of deuteranomaly
            Settings.enable_gpu_overdraw_show_deuteranomaly()
            self.screenshooter.take_screenshot()
            dark_red_pixels = self.screenshooter.get_dark_red_pixels_from_current_screenshot(
            )
            nr_of_dark_red_pixels = len(dark_red_pixels)
            LOG.info("dark red deuteranomaly pixels nr.: " +
                     str(nr_of_dark_red_pixels))
            percent_of_dark_red_pixels = nr_of_dark_red_pixels * 100.0 / total_nr_of_pixels
            LOG.info("dark red percent: " + str(percent_of_dark_red_pixels))
            self.assertTrue(percent_of_dark_red_pixels < 15,
                            "dark red pixels must be under 15%")
        finally:
            # disable gpu_overdraw
            Settings.disable_gpu_overdraw()

    def test_show_GPU_view_updates(self):
        def get_gpu_update_pixels(x, y, color):
            return color[0] >= 245 and color[1] <= 150 and color[2] <= 150

        Settings.enable_gpu_show_updates()
        time.sleep(3)
        try:
            for i in range(5):
                self.screenshooter.take_screenshot()
                show_update_pixels = self.screenshooter.search_for_pixels(
                    get_gpu_update_pixels)
                pixels_percent = 1.0 * len(show_update_pixels) / (
                    self.screenshooter.screen_width *
                    self.screenshooter.screen_height) * 100
                LOG.info("Percent of update pixels: " + str(pixels_percent))
                if pixels_percent >= 60:
                    return  # Number of update pixels greater than 60%. Test passed.
                ScreenSwiper.swipe_up()
            self.assertTrue(False, "Could not find any update pixels")
        finally:
            UiAutomatorUtils.close_all_tasks()
            Settings.enable_gpu_show_updates()
Example #4
0
class ImmersiveMode(UIATestBase):
    def setUp(self):
        super(ImmersiveMode, self).setUp()
        self.__test_name = __name__
        print "Setup: %s" % self.__test_name
        self.d = g_common_obj.get_device()
        UiAutomatorUtils.unlock_screen()
        resource.disable_app_verification()
        self.screenshooter = ScreenshotUtils()
        for i in ["temple_run", "immersive_ui"]:
            _apk_path = resource.get_resource_from_atifactory\
            ("tests.tablet.artifactory.conf", "ImmersiveMode", i)
            g_common_obj.adb_cmd_common("install -r %s" % _apk_path)

    def test_immersive_mode(self):
        UiAutomatorUtils.launch_app_from_apps_menu(
            SYSTEM_OS_IMMERSIVE_APP_SHORTCUT_NAME)
        # enter immersive mode
        self.assertTrue(
            self.d(text=SYSTEM_OS_ENTER_IMMERSIVE_MODE_TXT).wait.exists(
                timeout=4000))
        self.d(text=SYSTEM_OS_ENTER_IMMERSIVE_MODE_TXT).click()
        # wait for immersive mode
        time.sleep(3)
        self.screenshooter.take_screenshot()
        StatusBar.open_notifications(nr_of_swipes=2)
        time.sleep(1)
        self.screenshooter.take_screenshot()
        # check if status bar is showing after swipe
        self.assertFalse(self.screenshooter.same_screenshots(-1, -2))

    immersive_3d_app_package = "com.imangi.templerun2"

    def test_immersive_mode_3D_game(self):
        AdbUtils.start_activity_with_package_name(
            ImmersiveMode.immersive_3d_app_package, "--pct-syskeys 0 -v 500")
        time.sleep(20)
        if self.d(resourceId="com.google.android.play.games:id/info").exists:
            self.d(resourceId="android:id/button1").click.wait()
            self.d(resourceId="android:id/button2").click()
        if self.d(
                resourceId=
                "com.google.android.googlequicksearchbox:id/screen_assist_opt_in_no"
        ).exists:
            self.d(
                resourceId=
                "com.google.android.googlequicksearchbox:id/screen_assist_opt_in_no"
            ).click()
        if self.d(resourceId="android:id/button2").exists:
            self.d(resourceId="android:id/button2").click()
        width, height = DeviceInfo.get_device_screen_dimensions()
        # start the game by clicking randomly
        time.sleep(60)
        self.assertTrue(
            self.d(packageName=ImmersiveMode.immersive_3d_app_package).wait.
            exists(timeout=20000), "3D app failed to start on DUT")
        for i in range(1, height, height / 10):
            AdbUtils.tap(width / 2, i)
            time.sleep(2)
        for i in range(5):
            time.sleep(1)
            if i % 2 == 0:
                ScreenSwiper.swipe_left()
            else:
                ScreenSwiper.swipe_right()
        StatusBar.open_notifications(1)
        #         self.assertTrue(self.d(packageName=STATUS_BAR_PACKAGE).wait.exists(timeout=10000),
        #                         "system bar could not be opened")
        _check_status_bar_cmd = "dumpsys SurfaceFlinger | grep '| StatusBar'"
        assert g_common_obj.adb_cmd_capture_msg(
            _check_status_bar_cmd), "system bar could not be opened"
        self.d.press.back()
        self.d.press.home()


#         self.screenshooter.take_screenshot()
#         # crop a small upper corner area area
#         system_bar_obscured_crop = self.screenshooter.crop_upper_right_corner(25)
#         system_bar_hidden = False
#         for i in range(5):
#             time.sleep(5)
#             self.screenshooter.take_screenshot()
#             system_bar_hidden_crop = self.screenshooter.crop_upper_right_corner(25)
#             if not self.screenshooter.compare_color_lists(system_bar_hidden_crop, system_bar_obscured_crop):
#                 system_bar_hidden = True
#                 break
#         self.assertTrue(system_bar_hidden, "system bar did not dissapear after 25 seconds")
Example #5
0
class Screenshot(UIATestBase):

    youtube_sample_video = "http://www.youtube.com/watch?v=YRhFSWz_J3I"

    def setUp(self):
        super(Screenshot, self).setUp()
        self.__test_name = __name__
        print "Setup: %s" % self.__test_name
        self.d = g_common_obj.get_device()
        resource.disable_app_verification()
        UiAutomatorUtils.unlock_screen()
        self.screenshooter = ScreenshotUtils()
        for i in ["api_test", "system_api"]:
            _apk_path = resource.get_resource_from_atifactory\
            ("tests.tablet.artifactory.conf", "SDK_API", i)
            g_common_obj.adb_cmd_common("install -r %s" % _apk_path)

    def tearDown(self):
        self.d.freeze_rotation(False)
        ScreenshotUtils().remove_all_screenshots()

    def test_screenshot_app_rotate(self):
        app_start_cmd = "am start -n com.intel.test.apitests/.ApiTests"
        AdbUtils.run_adb_cmd(app_start_cmd)
        time.sleep(5)
        screenshoter = ScreenshotUtils()
        OrientationChanger.change_orientation("n")
        screenshoter.take_screenshot()
        screenshot_width_n = screenshoter.screen_width
        screenshot_height_n = screenshoter.screen_height
        print "natural orientation dimensions: ", screenshot_width_n, screenshot_height_n
        OrientationChanger.change_orientation("l")
        screenshoter.take_screenshot()
        screenshot_width_l = screenshoter.screen_width
        screenshot_height_l = screenshoter.screen_height
        print "left orientation dimensions: ", screenshot_width_l, screenshot_height_l
        self.assertTrue(screenshot_height_n == screenshot_width_l)
        self.assertTrue(screenshot_height_l == screenshot_width_n)

    def test_screenshot_video_playback(self):
        UiAutomatorUtils.launch_activity_with_data_uri(
            Screenshot.youtube_sample_video)
        if self.d(text=OS_OPEN_JUST_ONCE_TXT).wait.exists(timeout=3000):
            self.d(text=OS_OPEN_JUST_ONCE_TXT).click()
        self.assertTrue(
            self.d(packageName=YOUTUBE_PACKAGE_NAME).wait.exists(
                timeout=10000))
        # wait for the video to start
        time.sleep(10)
        self.screenshooter.take_screenshot()
        # wait for misc error messages to appear
        time.sleep(2)
        self.assertTrue(
            self.d(packageName=YOUTUBE_PACKAGE_NAME).wait.exists(timeout=1000))

    def test_verify_screenshot_width_height(self):
        screen_shooter = ScreenshotUtils()
        try:
            screen_shooter.take_screenshot()
            print "screenshot: ", screen_shooter.screen_width, screen_shooter.screen_height
            #             shell_prop_density_info = SystemUtils.get_property("ro.sf.lcd_density_info", "density")
            shell_prop_density_info = g_common_obj.adb_cmd_capture_msg(
                "wm size")
            test_width, test_height = SystemUtils.get_screen_size_from_lcd_density_info(
                shell_prop_density_info)
            print "shell prop:", test_width, test_height
            assert {
                int(screen_shooter.screen_width),
                int(screen_shooter.screen_height)
            } == {int(test_width), int(test_height)}
        finally:
            pass