예제 #1
0
 def test_long_loop_read_of_memtrack(self):
     null_pipe = open(os.devnull, 'w')
     AdbUtils._run_adb_cmd("dmesg -c", add_ticks=False)
     long_loop_read_proc_cmd = 'for i in 1 2 3 4 5 6 7 8 9 10; do while :; ' \
                               'do cat /sys/class/drm/card0/gfx_memtrack/* > /dev/null; done & done'
     long_loop_proc = subprocess.Popen(long_loop_read_proc_cmd,
                                       shell=True,
                                       stdout=null_pipe,
                                       stderr=subprocess.STDOUT)
     try:
         # launch youtube and watch a video
         UiAutomatorUtils.launch_activity_with_data_uri(
             MemTrack.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))
         # let the youtube play for some time
         time.sleep(10)
         # check for potential errors
         error_msgs_cmd = "dmesg"
         output = AdbUtils._run_adb_cmd(error_msgs_cmd, add_ticks=False)
         self.assertTrue(" trace " not in output)
         self.assertTrue(" bug " not in output)
         self.assertTrue(" stack " not in output)
     finally:
         long_loop_proc.terminate()
         os.kill(long_loop_proc.pid, signal.SIGTERM)
         ShellUtils.kill_processes_containing_string("gfx_memtrack")
예제 #2
0
    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")
예제 #3
0
 def test_memtrack_test_from_android_tree(self):
     root_cmd = "root"
     AdbUtils.run_adb_cmd(root_cmd, adb_shell=False)
     set_permissions_cmd = "chmod 755 /data/memtrack_test"
     AdbUtils.run_adb_cmd(set_permissions_cmd)
     run_memtrack_cmd = "/data/memtrack_test"
     output = AdbUtils.run_adb_cmd(run_memtrack_cmd)
     #assert "/system/bin/" in output
     assert "init" in output
     # assert the output has at least 2 lines
     lines = output.splitlines()
     assert len(lines) > 2
     # assert that a line has 8 columns
     assert len(lines[0].split()) == 8
예제 #4
0
 def test_loop_read_of_memtrack(self):
     egl_mtrack_dumpsys_meminfo = AdbUtils.run_adb_cmd(
         'dumpsys meminfo | grep "EGL mtrack"')
     LOG.info("EGL mtrack: " + egl_mtrack_dumpsys_meminfo)
     self.assertTrue(" 0 " not in egl_mtrack_dumpsys_meminfo)
     AdbUtils._run_adb_cmd("dmesg -c", add_ticks=False)
     loop_read_cmd = 'for i in 1 2 3 4 5 6 7 8 9 10; do sh -c "cat /sys/class/drm/card0/gfx_memtrack/*" & done'
     output = AdbUtils.run_adb_cmd(loop_read_cmd)
     if Environment.file_not_found_cmd_output in output:
         return
     self.assertTrue("No such file or directory" not in output)
     self.assertTrue("Total used GFX Shmem" in output)
     error_msgs_cmd = "dmesg"
     output = AdbUtils._run_adb_cmd(error_msgs_cmd, add_ticks=False)
     self.assertTrue(" trace " not in output)
     self.assertTrue(" bug " not in output)
     self.assertTrue(" stack " not in output)
예제 #5
0
 def test_dumpsys_memtrack_reporting(self):
     dumpsys_cmd = "dumpsys meminfo"
     output = AdbUtils.run_adb_cmd(dumpsys_cmd)
     self.assertTrue("Total PSS by category:" in output)
     self.assertTrue(": Dalvik" in output and ": Native" in output
                     and ": Ashmem" in output and ": GL" in output)
     self.assertTrue("Total RAM:" in output and "Free RAM:" in output
                     and "Used RAM:" in output and "Lost RAM:" in output)
예제 #6
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)
예제 #7
0
 def wait_for_gcm_message(self, message_text):
     # wait for message to arrive on DUT
     for i in range(15):
         time.sleep(10)
         messages_received = AdbUtils._run_adb_cmd("logcat -d | grep " + Messaging.gcm_receiver_tag,
                                                  adb_shell=False, add_ticks=False)
         if message_text in messages_received:
             LOG.info("google cloud message was received on DUT")
             return
     self.assertTrue(False, "did not receive any google cloud message")
예제 #8
0
 def test_skia_lib_existance(self):
     try:
         check_so_lib_cmd = "ls /system/lib | grep skia"
         output = AdbUtils._run_adb_cmd(check_so_lib_cmd, add_ticks=False)
         self.assertTrue("libskia.so" in output,
                         "could not find libskia.so in /system/lib")
         AdbUtils.pull("/system/bin/bootanimation",
                       os.path.split(self._bin_path)[0])
         #             ndk_depends_abs_path = os.path.join(Environment.tmp_dir_path, Skia_Lib.ndk_depends_bin)
         ndk_depends_abs_path = self._bin_path
         bootanimation_bin_path = os.path.join(
             os.path.split(self._bin_path)[0], Skia_Lib.bootanimation_bin)
         output = ShellUtils.run_shell_cmd(ndk_depends_abs_path + " " +
                                           bootanimation_bin_path)
         self.assertTrue(
             "libskia.so" in output,
             "could not find libskia.so in bootanimation dependecies")
     finally:
         ShellUtils.clean_local_dir(Environment.tmp_dir_path)
예제 #9
0
 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")
예제 #10
0
    def test_screen_size_reporting(self):
        metrics = SystemUtils.get_display_metrics()
        print metrics
        reported_density_info = SystemUtils.get_property('ro.sf.lcd_density', 'ro.sf')
        platform_name = SystemUtils.get_platform_name()
        current_platform = PlatformCatalogue.find_platform(platform_name)
        if current_platform is not None:
            lcd_density_info = current_platform.get_property("ro.sf.lcd_density_info")
            print "reported density info: ", reported_density_info
            print "expected density info: ", lcd_density_info
            reported_density = self.get_density_value(reported_density_info)
            lcd_density = self.get_density_value(lcd_density_info)
            if lcd_density_info is not None:
                self.assertTrue(reported_density ==  lcd_density, "reported info: "
                                + reported_density_info + " ; expected info: " + lcd_density_info)
            elif reported_density_info is not None:
                self.assertTrue(str(current_platform.screenWidth) + " x " + str(current_platform.screenHeight)
                                in reported_density_info)
            test_width = None
            test_height = None
            if lcd_density_info is None:
                test_width = current_platform.screenWidth
                test_height = current_platform.screenHeight
            else:
                test_width, test_height = SystemUtils.get_screen_size_from_lcd_density_info(lcd_density_info)
            print "testing values for screen size: " + str(test_width) + " x " + str(test_height)
            screen_size_instrumentation_test = "am instrument -e class com.intel.test.apitests.tests" \
                                               ".DisplayMetricsTestDriver#testDisplayInterfaceSize -e args" \
                                               ' "DisplayWidth:$WIDTH$ DisplayHeight:$HEIGHT$" -w com.intel.test' \
                                               ".apitests/com.intel.test.apitests.runners.GenericArgumentPassingTestRunner"
            test_cmd = screen_size_instrumentation_test.replace('$WIDTH$', str(test_width)) \
                .replace('$HEIGHT$', str(test_height))
            test_output = AdbUtils.run_adb_cmd(test_cmd)
            print test_output
            self.assertTrue('OK' in test_output)
        else:
#             shell_prop_density_info = SystemUtils.get_property("ro.sf.lcd_density", "density")
            shell_prop_density_info = g_common_obj.adb_cmd_capture_msg("wm size")
            print shell_prop_density_info
            test_width, test_height = SystemUtils.get_screen_size_from_lcd_density_info(shell_prop_density_info)
            print test_width, test_height
            reported_height = metrics["heightPixels"]
            reported_width = metrics["widthPixels"]
            print reported_width
            print reported_height
            try:
                self.assertTrue(abs(int(reported_width) - int(test_width)) <= int(test_width) / 15)
                self.assertTrue(abs(int(reported_height) - int(test_height)) <= int(test_height) / 15)
            except:
                self.assertTrue(abs(int(reported_width) - int(test_height)) <= int(test_width) / 15)
                self.assertTrue(abs(int(reported_height) - int(test_width)) <= int(test_height) / 15)
예제 #11
0
    def test_SmartLock_TrustedLocation(self):
        trusted_place = "Havana, Cuba"
        try:
            # Enable location
            LOG.info("Enabling location")
            Settings.enable_location()

            # Enable screen lock pin and add a trusted place (current location)
            LOG.info("Enabling PIN screen lock")
            Settings.enable_pin()
            LOG.info("Adding trusted place - current location")
            Settings.add_trusted_place()

            self.d.press.home()
            # Lock the screen
            LOG.info("Locking the screen")
            self.d.press.power()
            time.sleep(5)

            # Unlock the device
            LOG.info("Unlocking the screen")
            UiAutomatorUtils.unlock_screen()

            LOG.info("Checking the PIN keyguard in NOT present")
            assert not self.d(
                resourceId=ANDROID_KEYGUARD_PIN_VIEW_RESID
            ).wait.exists(
                timeout=5000
            ), "The keyguard should not be present in the current trusted place"
            time.sleep(3)

            #Below "if" codes is to handle an info window of trusted unlocking.
            if self.d(resourceId=SETTINGS_TRUSTED_FIRST_TIME_RESID).exists:
                self.d(resourceId=SETTINGS_TRUSTED_FIRST_TIME_RESID).click()

            # Remove the current trusted place
            LOG.info("Removing the current trusted place")
            Settings.remove_trusted_place()

            # Add a trusted place in another location
            LOG.info("Adding trusted place - {0}".format(trusted_place))
            Settings.add_trusted_place(trusted_place)

            self.d.press.home()
            # Lock the screen
            LOG.info("Locking the screen")
            self.d.press.power()
            time.sleep(2)

            # Unlock the device
            LOG.info("unlocking the screen")
            UiAutomatorUtils.unlock_screen()

            LOG.info(
                "Checking the PIN keyguard is present in a non-trusted place")
            assert self.d(
                resourceId=ANDROID_KEYGUARD_PIN_VIEW_RESID).wait.exists(
                    timeout=5000
                ), "The keyguard should appear when not in a trusted location"

            # Input the PIN via shell
            AdbUtils.input_text(TEST_PIN)
            time.sleep(1)
            self.d.press.enter()
            time.sleep(3)

            # Remove the trusted place
            LOG.info("Removing the trusted place - {0}".format(trusted_place))
            Settings.remove_trusted_place(trusted_place)
        except Exception, e:
            AdbUtils.input_text(TEST_PIN)
            time.sleep(3)
            self.d.press.enter()
            time.sleep(5)
            raise e
예제 #12
0
 def run_memtrack():
     global memtrack_proc
     MemTrack.memtrack_proc = AdbUtils.get_adb_cmd_process(
         MemTrack.memtrack_loop_cmd)
예제 #13
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")
예제 #14
0
    def test_crash_reporting_bugreport(self):
        bug_report_filename = "bug_report_test.rpt"
        bugreport_sections = {
            "UPTIME": 0,
            "MMC PERF": 0,
            "MEMORY INFO": 0,
            "CPU INFO": 0,
            "PROCRANK": 0,
            "VIRTUAL MEMORY STATS": 0,
            "VMALLOC INFO": 0,
            "SLAB INFO": 0,
            "ZONEINFO": 0,
            "PAGETYPEINFO": 0,
            "BUDDYINFO": 0,
            "FRAGMENTATION INFO": 0,
            "KERNEL WAKELOCKS": 0,
            "KERNEL WAKE SOURCES": 0,
            "KERNEL CPUFREQ": 0,
            "KERNEL SYNC": 0,
            "KERNEL LOG": 0,
            "SHOW MAP": 0,
            "PROCESSES": 0,
            "SYSTEM LOG": 0,
            "EVENT LOG": 0,
            "pid": 0,
            "NETWORK": 0,
            "QTAGUID": 0,
            "IP RULES": 0,
            "ROUTE TABLE": 0,
            "CACHE": 0,
            "SYSTEM PROPERTIES": 0,
            "VOLD DUMP": 0,
            "BINDER": 0,
            "DUMPSYS": 0,
            "APP": 0
        }

        def manage_bugreport_line(bugreport_line):
            for section in bugreport_sections.keys():
                if section in line:
                    bugreport_sections[section] += 1

        try:
            cmd = "bugreport > " + bug_report_filename
            AdbUtils.run_adb_cmd(cmd, False)
            report_file = open(bug_report_filename)
            statinfo = os.stat(bug_report_filename)
            self.assertTrue(statinfo.st_size > 5000000L)  # magic size number
            for line in report_file:
                if "-----" in line:
                    manage_bugreport_line(line)
        finally:
            os.remove(bug_report_filename)
        missing_section = False
        for key, value in bugreport_sections.iteritems():
            if value == 0:
                missing_section = True
                LOG.info("found missing section " + str(key))


#         self.assertFalse(missing_section)