Пример #1
0
class GMSBehavior(UIATestBase):
    """
    @summary: test cases for GMSBehavior
    """
    def setUp(self):
        super(GMSBehavior, self).setUp()
        self._test_name = __name__
        self.api = ApiImpl()
        self.api.unlock_screen()
        self.api.clean_tasks()
        print "[Setup]: %s" % self._test_name

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

    def testGMS_Account_Add(self):
        """
        verify that able to add google account in device owner
        :return: None
        """
        assert os.path.isfile(
            "/etc/oat/sys.conf"), "/etc/oat/sys.conf doesn't exists"
        account = self.config.read("/etc/oat/sys.conf",
                                   "google_account").get("user_name")
        password = self.config.read("/etc/oat/sys.conf",
                                    "google_account").get("password")
        self.api.settings_sub_launch("Accounts")
        if self.api.check_ui_exists("text", "Google"):
            self.api.click_with_timeout("text", "Google")
            time.sleep(2)
            self.api.d.press.menu()
            self.api.click_with_timeout("text", "Remove account")
            self.api.click_with_timeout("text", "Remove account")
            time.sleep(5)
        self.api.clean_tasks()
        self.api.add_google_account(account, password, False)
        self.api.d.press.home()
        self.api.clean_tasks()
        self.api.settings_sub_launch("Accounts")
        assert self.api.check_ui_exists(
            "text", "Google"), "fail to detect google account"

    def testGMS_Account_Remove(self):
        """
        verify that able to remove google account in device owner
        :return: None
        """
        account = self.config.read("/etc/oat/sys.conf",
                                   "google_account").get("user_name")
        password = self.config.read("/etc/oat/sys.conf",
                                    "google_account").get("password")
        self.api.settings_sub_launch("Accounts")
        if not self.api.check_ui_exists("text", "Google"):
            self.api.clean_tasks()
            self.api.add_google_account(account, password, False)
            self.api.clean_tasks()
            self.api.settings_sub_launch("Accounts")
        self.api.click_with_timeout("text", "Google")
        time.sleep(5)
        self.api.d.press.menu()
        self.api.click_with_timeout("text", "Remove account")
        self.api.click_with_timeout("text", "Remove account")
        time.sleep(5)
        assert not self.api.check_ui_exists(
            "text", "Google"), "fail to remove google account"
Пример #2
0
class SetupManagedProfile(UIATestBase):
    """
    @summary: Test cases for setup managed profile
    """
    def setUp(self):
        super(SetupManagedProfile, self).setUp()
        self.api = ApiImpl()
        self.function = Function()
        self.api.unlock_screen()
        self.api.clean_tasks()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name

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

    def testSetup_Managed_Profile(self):
        """
        set up manged profile
        :return: None
        """
        self.api.settings_sub_launch("Accounts")
        if self.api.check_ui_exists("text", "Work", 5):
            self.api.click_with_timeout("text", "Remove work profile")
            self.api.click_with_timeout("text", "Delete", 10)
            time.sleep(5)
        self.api.remove_other_users_by_id()
        self.api.setup_managed_profile()
        for _ in range(5):
            self.api.d.press.home()
            self.api.api_demo_po_launch()
            if self.api.check_ui_exists("textContains", "Profile Owner"):
                break
            time.sleep(3)
        assert self.api.check_ui_exists(
            "textContains",
            "Profile Owner"), "[ERROR]: fail to launch Work Sample MDM"

    def testDisable_Managed_Profile(self):
        """
        disable manage profile
        :return: None
        """
        self.api.remove_managed_profile()
        all_users = None
        for _ in range(5):
            all_users = repr(
                os.popen("adb -s {0} shell pm list users".format(
                    self.api.serial)).read().strip())
            if all_users.find("Work profile") == -1 and all_users.find(
                    "HiProfileOwner") == -1:
                break
            time.sleep(3)
        assert all_users is not None, "[ERROR]: fail to get user info"
        assert all_users.find(
            "Work profile") == -1, "[ERROR]: still able to find Work profile"
        assert all_users.find(
            "HiProfileOwner"
        ) == -1, "[ERROR]: still able to find HiProfileOwner"

    def testAccount_Migrate(self):
        """
        migrate account
        :return: None
        """
        assert os.path.isfile(
            "/etc/oat/sys.conf"
        ), "[ERROR]: Missing config file /etc/oat/sys.config in host"
        cfg_file = "/etc/oat/sys.conf"
        account = self.config.read(cfg_file, "google_account").get("user_name")
        password = self.config.read(cfg_file, "google_account").get("password")
        # if self.api.locate_apps("Work Sample MDM"):
        if self.api.is_work_profile_enabled():
            self.api.remove_managed_profile()
        if self.api.is_android_L_build():
            self.function.add_google_account_mr1(account, password)
        else:
            self.api.add_google_account(account, password, False)
        self.api.clean_tasks()
        self.api.launch_app_by_intents("android.settings.SETTINGS", False)
        if not self.api.check_ui_exists("text", "Accounts"):
            self.api.d(scrollable=True).scroll.vert.to(text="Accounts")
        self.api.click_with_timeout("text", "Accounts")
        assert self.api.check_ui_exists(
            "text", "Google"), "[ERROR]: fail to add google account"
        assert not self.api.check_ui_exists(
            "text", "Work"), "[ERROR]: Work profile already created"
        self.api.api_demo_launch()
        if self.api.is_android_L_build(
        ):  # TODO: change the entry if sample mdm got update for L
            self.api.click_with_timeout("resourceId",
                                        self.api.ui.create_and_delete_profile)
        else:
            self.api.click_with_timeout("resourceId",
                                        self.api.ui.setup_managed_profile)
            if self.api.check_ui_exists("resourceId",
                                        "com.intel.afw.mdm:id/content_edit",
                                        10):
                self.api.d(resourceId="com.intel.afw.mdm:id/content_edit"
                           ).set_text(account)
        self.api.click_with_timeout("text", "Yes")
        if self.api.is_android_L_build():
            assert self.api.check_ui_exists(
                "textContains",
                account), "[ERROR]: fail to detect google account"
            self.api.click_with_timeout("textContains", account)
            self.api.click_with_timeout("text", "Create Managed Profile")
        self.api.click_with_timeout("text", "Set up")
        self.api.click_with_timeout("text", "OK")
        self.api.check_ui_exists("text", "Setup all done", 30)
        for _ in range(5):
            self.api.d.press.home()
            self.api.api_demo_po_launch()
            if self.api.check_ui_exists("textContains", "Profile Owner"):
                break
            time.sleep(3)
        assert self.api.check_ui_exists(
            "textContains",
            "Profile Owner"), "[ERROR]: fail to launch Work Sample MDM"
        self.api.clean_tasks()
        time.sleep(15)
        for _ in range(5):
            self.api.clean_tasks()
            self.api.launch_app_by_intents("android.settings.SETTINGS", False)
            if not self.api.check_ui_exists("text", "Accounts"):
                self.api.d(scrollable=True).scroll.vert.to(text="Accounts")
            self.api.click_with_timeout("text", "Accounts")
            if self.api.check_ui_exists("text",
                                        "Work") and self.api.check_ui_exists(
                                            "text", "Google"):
                break
            time.sleep(5)
        assert self.api.check_ui_exists(
            "text", "Work"), "[ERROR]: fail to detect work profile"
        assert self.api.check_ui_exists(
            "text", "Google"), "[ERROR]: fail to detect google account"
        assert self.api.d(text="Remove work profile").up(
            text="Google").exists, "[ERROR]: fail to migrate account"
Пример #3
0
class GMSBehavior(UIATestBase):
    """
    @summary: check app behavior under work profile
    """

    def setUp(self):
        super(GMSBehavior, self).setUp()
        self._test_name = __name__
        self.api = ApiImpl()
        self.api.unlock_screen()
        self.api.clean_tasks()
        print "[Setup]: %s" % self._test_name

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

    def testGMS_Account_WorkProfile_Add(self):
        """
        verify that able to add google account in profile owner
        :return: None
        """
        assert os.path.isfile("/etc/oat/sys.conf"), "/etc/oat/sys.conf doesn't exists"
        account = self.config.read("/etc/oat/sys.conf", "google_account").get("user_name")
        password = self.config.read("/etc/oat/sys.conf", "google_account").get("password")
        self.api.launch_app_by_intents("android.settings.SYNC_SETTINGS", False)
        self.api.d(packageName="com.android.settings").wait.exists(timeout=5000)
        if not self.api.check_ui_exists("text", "Accounts"):
            self.api.settings_launch()
            if not self.api.check_ui_exists("text", "Accounts") and self.api.d(scrollable=True).exists:
                self.api.d(scrollable=True).scroll.vert.to(textContains="Accounts")
            self.api.click_with_timeout("text", "Accounts")
        for _ in range(5):
            if not self.api.check_ui_exists("text", "Google"):
                break
            self.api.click_with_timeout("text", "Google")
            time.sleep(2)
            self.api.d.press.menu()
            self.api.click_with_timeout("text", "Remove account")
            self.api.click_with_timeout("text", "Remove account")
            time.sleep(5)
        self.api.clean_tasks()
        self.api.add_google_account(account, password, True)
        self.api.d.press.home()
        self.api.clean_tasks()
        self.api.settings_sub_launch("Accounts")
        assert self.api.check_ui_exists("text", "Google"), "fail to detect google account"

    def testGMS_Account_WorkProfile_Remove(self):
        """
        verify that able to remove google account in profile owner
        :return: None
        """
        account = self.config.read("/etc/oat/sys.conf", "google_account").get("user_name")
        password = self.config.read("/etc/oat/sys.conf", "google_account").get("password")
        self.api.settings_sub_launch("Accounts")
        if not self.api.check_ui_exists("text", "Google"):
            self.api.clean_tasks()
            self.api.add_google_account(account, password, True)
            self.api.clean_tasks()
            self.api.settings_sub_launch("Accounts")
        self.api.click_with_timeout("text", "Google")
        time.sleep(5)
        self.api.d.press.menu()
        self.api.click_with_timeout("text", "Remove account")
        self.api.click_with_timeout("text", "Remove account")
        time.sleep(5)
        assert not self.api.check_ui_exists("text", "Google"), "fail to remove google account"