Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
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()
Ejemplo n.º 3
0
    def test_google_cloud_messaging_disable_wifi(self):
        try:
#             Settings.disable_wifi()
#             time.sleep(4)  # wait for wifi to be switched off
            message_text = self.gen_unique_google_cloud_message()
#             AdbUtils.start_activity_with_package_name(Messaging.gcm_receiver_package, "--pct-syskeys 0 -v 500")
            g_common_obj.launch_app_am('gcm.play.android.samples.com.gcmquickstart', 'gcm.play.android.samples.com.gcmquickstart.MainActivity')
            time.sleep(5)
            self.assertTrue(self.d(packageName=Messaging.gcm_receiver_package).wait.exists(timeout=20000),
                            "google cloud messaging receiver app failed to start on DUT")
            Settings.disable_wifi()
            time.sleep(5)
            self.send_google_cloud_message_from_host(message_text)
            time.sleep(5)  # wait a little before turning on wifi
            Settings.enable_wifi()
            time.sleep(30)  # wait more time for WiFi reconnection in a congested wireless environment
            GPS_Common().check_if_wifi_connected()
            self.wait_for_gcm_message(message_text)
        finally:
            Settings.enable_wifi()
            ShellUtils.clean_local_dir(Environment.tmp_dir_path)
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def tearDown(self):
     #            UiAutomatorUtils.close_all_tasks()
     #            Settings.disable_location()
     Settings.disable_pin()
     UiAutomatorUtils.close_all_tasks()
Ejemplo n.º 6
0
            # 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
        finally:
            Settings.remove_trusted_place()
            self.d.press.home()
            Settings.disable_pin()
Ejemplo n.º 7
0
    def test_take_bug_report(self):
        GPS_Common().check_if_wifi_connected()
        ga_st = EnvironmentUtils.check_if_google_account_added()
        if not ga_st:
            self.func.add_google_account_mr1(self.username, self.passwd)
        Settings.turn_on_account_auto_sync()
        Settings.take_bug_report()
        # a popup for taking a bug report should appear
        if EnvironmentUtils.get_android_version() == "N":
            self.assertTrue(
                self.d(text=SETTINGS_TAKE_BUG_REPORT_POPUP_REPORT_BUTTON_TXT_N
                       ).wait.exists(timeout=3000))
            self.d(text=SETTINGS_TAKE_BUG_REPORT_POPUP_REPORT_BUTTON_TXT_N
                   ).click()
        else:
            self.assertTrue(
                self.d(text=SETTINGS_TAKE_BUG_REPORT_POPUP_REPORT_BUTTON_TXT).
                wait.exists(timeout=3000))
            self.d(
                text=SETTINGS_TAKE_BUG_REPORT_POPUP_REPORT_BUTTON_TXT).click()
        poll_waiting_tries_for_notification = 30
        found_bug_report_notification = False
        while poll_waiting_tries_for_notification > 0:
            self.d.open.notification()
            time.sleep(10)
            while self.d(textContains="is being generated").exists:
                LOG.info("Waiting for bug report to be generated.")
                time.sleep(10)
#             if self.d(text=SETTINGS_TAKE_BUG_REPORT_NOTIFICATION_TXT).wait.exists(timeout=3000):
            if self.d(textStartsWith="Bug report").wait.exists(timeout=3000):
                # bug report was completed
                found_bug_report_notification = True
                break
            self.d.press.home()  # close notifications
            poll_waiting_tries_for_notification -= 1
        self.assertTrue(
            found_bug_report_notification,
            "a notification for the bugreport should have appeared")
        # StatusBar.open_notifications()  # notifications already opened after break in for
        #         self.assertTrue(self.d(text=SETTINGS_TAKE_BUG_REPORT_NOTIFICATION_TXT).wait.exists(timeout=3000),
        self.assertTrue(
            self.d(textStartsWith="Bug report").wait.exists(timeout=3000),
            "a bug report notification should exist in the notifications bar")
        #         self.d(text=SETTINGS_TAKE_BUG_REPORT_NOTIFICATION_TXT).click()
        self.d(textStartsWith="Bug report").click()
        # popup to warn not to share sensitive data with untrusted parties
        SystemPopupsAndDialogs.popup_ok()
        # popup for choosing wich app will handle the bugreport
        # there are different types of popup for different Android versions and devices
        SystemPopupsAndDialogs.open_resource_with(GMAIL_APP_NAME)
        time.sleep(15)
        # gmail application must open with attached bug report information
        self.assertTrue(
            self.d(packageName=GMAIL_PACKAGE_NAME).wait.exists(timeout=5000),
            "gmail should have opened displaying the send bug report mail")
        time.sleep(5)
        SystemPopupsAndDialogs.popup_skip()
        # Gmail app setup
        time.sleep(5)
        if self.d(resourceId="com.google.android.gm:id/welcome_tour_skip"
                  ).exists:
            self.d(resourceId="com.google.android.gm:id/welcome_tour_skip"
                   ).click.wait()
        if self.d(resourceId="com.google.android.gm:id/action_done").exists:
            self.d(resourceId="com.google.android.gm:id/action_done"
                   ).click.wait()
            self.d.press.back()

        Gmail.select_sync_account_now()
        time.sleep(20)
        self.assertTrue(
            self.d(textStartsWith=GMAIL_TAKE_BUG_REPORT_ATTACHEMENT_PREFIX_TXT
                   ).wait.exists(timeout=50000),
            "mail should have an attachement containing bugreport details")
Ejemplo n.º 8
0
 def test_data_usage_new_installed_app(self):
     ApiTestsInterface.args_template = Template('$args')
     instrumentation_args = '-e apTestPage "https://www.youtube.com/" -e waitBeforeLogCheck 15000'
     surf_internet_result = ApiTestsInterface.run_instrumentation(class_name="WebViewTestsDriver",
                                                                  method_name="testStreamPlayback",
                                                                  instrumentation_args=instrumentation_args,
                                                                  runner_name="WifiEncryptionTestRunner")
     ApiTestsInterface.was_instrumentation_test_successful(surf_internet_result)
     self.assertTrue(ApiTestsInterface.was_instrumentation_test_successful(surf_internet_result),
                     "Internet browsing was not successful")
     try:
         data_usage = Settings.get_data_usage_values()
         Settings.go_to_main_screen()
         Settings.disable_wifi()
         Settings.go_to_main_screen()
         time.sleep(5)
         final_data_usage = Settings.get_data_usage_values()
         self.assertTrue("ApiTests" in data_usage.keys(), "could not find browsing app in initial data usage stats")
         LOG.info("initial ApiTests data usage: " + str(data_usage["ApiTests"]))
         self.assertTrue("ApiTests" in final_data_usage.keys(),
                         "could not find browsing app in final data usage stats")
         LOG.info("final ApiTests data usage: " + str(final_data_usage["ApiTests"]))
     finally:
         Settings.go_to_main_screen()
         Settings.enable_wifi()
Ejemplo n.º 9
0
 def test_data_usage(self):
     data_usage = Settings.get_data_usage_info()
     print data_usage
     self.assertTrue(len(data_usage) > 0)