Exemple #1
0
    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()
 def test_verify_20_recent_apps(self):
     activity_string_template = "com.example.test$NR$/.MainActivity"
     app_string_template = "com.example.test$NR$"
     UiAutomatorUtils.close_all_tasks()
     for i in range(1, 21):
         package_name = app_string_template.replace("$NR$", str(i))
         activity_string = activity_string_template.replace("$NR$", str(i))
         AdbUtils.start_activity_from_shell(activity_string)
         self.d(packageName=package_name).wait.exists(timeout=3000)
         AdbUtils.force_stop_app(package_name)
     # wait a little for the tasks to be registered with the visual manager component
     nr_of_dismissed_tasks = 0
     # hack to count a large number of dismissed tasks
     while True:
         task_dismissed_at_current_step = UiAutomatorUtils.close_all_tasks()
         nr_of_dismissed_tasks += task_dismissed_at_current_step
         if task_dismissed_at_current_step == 0:
             break
     print nr_of_dismissed_tasks
     LOG.info("dismissed " + str(nr_of_dismissed_tasks) + " tasks")
     self.assertTrue(nr_of_dismissed_tasks >= 20,
                     "test was not able to dismiss 20 recent tasks")
Exemple #3
0
 def tearDown(self):
     #            UiAutomatorUtils.close_all_tasks()
     #            Settings.disable_location()
     Settings.disable_pin()
     UiAutomatorUtils.close_all_tasks()
Exemple #4
0
    def test_memtrack_effect_framerate(self):
        def run_memtrack():
            global memtrack_proc
            MemTrack.memtrack_proc = AdbUtils.get_adb_cmd_process(
                MemTrack.memtrack_loop_cmd)

        def run_jank_test():
            jank_runner = InstrumentationInterface()
            MemTrack.jank_test_output = jank_runner.run_instrumentation(
                "android.cts.jank.ui.CtsDeviceJankUi", "",
                "android.cts.jank/android.support.test.runner.AndroidJUnitRunner"
            )

        # must stop python uiautomator in order to run the jank test
        AdbUtils.kill_python_uiautomator_rpc_server_on_dut()

        # initial run of jank test
        run_jank_test()
        LOG.info("initial run of the jank test yielded: " +
                 MemTrack.jank_test_output)
        self.assertTrue(
            InstrumentationInterface.was_instrumentation_test_successful(
                MemTrack.jank_test_output),
            "initial run of the jank test was not successful")
        fps_values = re.findall("\|fps\|(\d+\.\d+)", MemTrack.jank_test_output)
        self.assertTrue(
            len(fps_values) > 0,
            "could not find fps information in jank test output")
        initial_fps_value = float(fps_values[0])

        UiAutomatorUtils.close_all_tasks()
        # must stop python uiautomator in order to run the jank test
        AdbUtils.kill_python_uiautomator_rpc_server_on_dut()

        # subsequent run of the jank test, with memtrack running along side
        memtrack_thread = Thread(target=run_memtrack)
        jank_thread = Thread(target=run_jank_test)
        LOG.info("Starting memtrack")
        memtrack_thread.start()
        time.sleep(0.5)  # allow memtrack to start before running the jank test
        LOG.info("Starting jank ui on dut")
        jank_thread.start()
        jank_thread.join()
        MemTrack.memtrack_proc.kill()  # kill memtrack so the thread will join
        memtrack_thread.join()

        LOG.info("second run of the jank test yielded: " +
                 MemTrack.jank_test_output)
        self.assertTrue(
            InstrumentationInterface.was_instrumentation_test_successful(
                MemTrack.jank_test_output),
            "second run of the jank test was not successful")
        fps_values = re.findall("\|fps\|(\d+\.\d+)", MemTrack.jank_test_output)
        self.assertTrue(
            len(fps_values) > 0,
            "could not find fps information in jank test output")
        second_fps_value = float(fps_values[0])

        LOG.info("initial fps value: %s, second fps value: %s" %
                 (initial_fps_value, second_fps_value))
        self.assertTrue(
            second_fps_value < initial_fps_value,
            "fps when running memtrack was not smaller than "
            "fps without running memtrack")
Exemple #5
0
 def tearDown(self):
     UiAutomatorUtils.close_all_tasks()