コード例 #1
0
class DesktopSystemTest(ParametrizedTestCase):
    def setUp(self):
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest("process monitor stop")

        self.d = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.mouse = AdbMouse()
        self.mouse.move(1920, 1080)
        self.adb_tools = AdbTools()

        self.BaseImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "dependency", "BaseImage")
        self.FailureIamgePath = os.path.join(
            os.path.abspath(os.path.dirname("__file__")), "test-reports", "FailureImage"
        )
        self.TmpImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "TmpImage")

        if not os.path.exists(self.TmpImagePath):
            os.mkdir(self.TmpImagePath)
        if not os.path.exists(os.path.join(self.TmpImagePath, "croped")):
            os.mkdir(os.path.join(self.TmpImagePath, "croped"))

        #         self.account.sleep()
        #         self.account.wakeup()
        #         self.account.login()
        Button1 = self.d(resourceId="com.yunpc.yunosloginui:id/avatar")
        start = time.time()
        while time.time() - start < constants.Time_Out:
            if not Button1.exists:
                break
            else:
                time.sleep(1)
        self.adb_tools.adb_shell("am force-stop com.alibaba.micropc.appstore")
        AppStoreIcon = self.d(text=u"应用商店", className="android.widget.TextView")
        if not AppStoreIcon.exists:
            start2 = time.time()
            while time.time() - start2 < constants.Time_Out:
                if Button1.exists:
                    break
                else:
                    time.sleep(1)
            if not AppStoreIcon.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self, name)

    def tearDown(self):
        self.adb_tools.adb_shell("am force-stop com.alibaba.micropc.appstore")
        if os.path.exists(self.TmpImagePath):
            shutil.rmtree(self.TmpImagePath)
        time.sleep(1)

    def test_StatusBar(self):
        logger.info("Enter -- MUAT:DesktopSystemTest:test_StatusBar")
        BaseImg = os.path.join(self.BaseImagePath, "test_StatusBar.jpg")
        name = "test_StatusBar_%s.jpg" % time.strftime("%Y%m%d%H%M%S", time.localtime())
        img = os.path.join(self.TmpImagePath, name)
        self.d.screenshot(img)
        cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
        CropImage(img, cropedImgPath, 0, 0, 1810, 25)
        if not CompareImage(cropedImgPath, BaseImg, 0.9):
            shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
            path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
            self.fail("The failure file path is %s") % path

        logger.info("Exit -- MUAT:DesktopSystemTest:test_StatusBar")

    def test_TaskBar(self):
        logger.info("Enter -- MUAT:DesktopSystemTest:test_TaskBar")

        AppStoreIcon = self.d(text=u"应用商店", className="android.widget.TextView")
        click_x = AppStoreIcon.info["visibleBounds"]["left"] + 5
        click_y = AppStoreIcon.info["visibleBounds"]["top"] + 5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        appstoreWindow = self.d(className="android.widget.FrameLayout", packageName="com.alibaba.micropc.appstore")
        start = time.time()
        while time.time() - start < constants.Time_Out:
            if appstoreWindow.exists:
                break
            else:
                time.sleep(1)
        if not appstoreWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)

        self.assertTrue(appstoreWindow.exists)
        self.mouse.click(
            appstoreWindow.info["visibleBounds"]["left"] + 10,
            appstoreWindow.info["visibleBounds"]["top"] + 10,
            constants.MouseLeftKey,
        )

        hideButton = self.d(packageName="com.alibaba.micropc.appstore", resourceId="android:id/pc_hide")
        if hideButton.exists:
            hideButton.click()
            start = time.time()
            while time.time() - start < constants.Time_Out:
                if not hideButton.exists:
                    break
                else:
                    time.sleep(1)
            if self.d(className="android.widget.FrameLayout", packageName="com.alibaba.micropc.appstore").exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self, name)

            self.assertFalse(
                self.d(className="android.widget.FrameLayout", packageName="com.alibaba.micropc.appstore").exists
            )
            BaseImg = os.path.join(self.BaseImagePath, "test_TaskBar.jpg")
            name = "test_TaskBar_%s.jpg" % time.strftime("%Y%m%d%H%M%S", time.localtime())
            img = os.path.join(self.TmpImagePath, name)
            self.d.screenshot(img)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, 0, 1035, 70, 1080)
            if not CompareImage(cropedImgPath, BaseImg, 0.9):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                self.fail("The failure file path is %s") % os.path.join(
                    self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")
                )
            self.mouse.click(35, 1050, constants.MouseLeftKey)
            start = time.time()
            while time.time() - start < constants.Time_Out:
                if hideButton.exists:
                    break
                else:
                    time.sleep(1)
            if not self.d(className="android.widget.FrameLayout", packageName="com.alibaba.micropc.appstore").exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self, name)
            self.assertTrue(
                self.d(className="android.widget.FrameLayout", packageName="com.alibaba.micropc.appstore").exists
            )

        closeButton = self.d(packageName="com.alibaba.micropc.appstore", resourceId="android:id/pc_close")
        if closeButton.exists:
            closeButton.click()
        else:
            self.mouse.click(35, 1050, constants.MouseLeftKey)
            start = time.time()
            while time.time() - start < constants.Time_Out:
                if hideButton.exists:
                    break
                else:
                    time.sleep(1)
            closeButton = self.d(packageName="com.alibaba.micropc.appstore", resourceId="android:id/pc_close")
            closeButton.click()
        logger.info("Exit -- MUAT:DesktopSystemTest:test_TaskBar")

    def test_DragIcon(self):
        logger.info("Enter -- MUAT:DesktopSystemTest:test_DragIcon")
        AppStoreIcon = self.d(text=u"应用商店", className="android.widget.TextView")
        if AppStoreIcon.exists:
            oldX = AppStoreIcon.info["visibleBounds"]["left"]
            oldY = AppStoreIcon.info["visibleBounds"]["top"]
            self.mouse.pressmove(
                AppStoreIcon.info["visibleBounds"]["left"] + 5,
                AppStoreIcon.info["visibleBounds"]["top"] + 5,
                300,
                300,
                constants.MouseLeftKey,
            )
            time.sleep(5)
            newAppStoreIcon = self.d(text=u"应用商店", className="android.widget.TextView")
            if not newAppStoreIcon.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self, name)
            self.assertTrue(newAppStoreIcon.exists)
            if newAppStoreIcon.exists:
                self.assertNotEqual(oldX, newAppStoreIcon.info["visibleBounds"]["left"])
                self.assertNotEqual(oldY, newAppStoreIcon.info["visibleBounds"]["top"])
                self.mouse.pressmove(
                    newAppStoreIcon.info["visibleBounds"]["left"] + 5,
                    newAppStoreIcon.info["visibleBounds"]["top"] + 5,
                    -300,
                    -300,
                    constants.MouseLeftKey,
                )
        logger.info("Exit -- MUAT:DesktopSystemTest:test_DragIcon")

    def test_DoubleClickIcon(self):
        logger.info("Enter -- MUAT:DesktopSystemTest:test_DoubleClickIcon")
        AppStoreIcon = self.d(text=u"应用商店", className="android.widget.TextView")
        if AppStoreIcon.exists:
            self.mouse.doubleclick(
                AppStoreIcon.info["visibleBounds"]["left"] + 5,
                AppStoreIcon.info["visibleBounds"]["top"] + 5,
                constants.MouseLeftKey,
            )
            AppStoreWindow = self.d(className="android.widget.FrameLayout", packageName="com.alibaba.micropc.appstore")
            start = time.time()
            while time.time() - start < constants.Time_Out:
                if AppStoreWindow.exists:
                    break
                else:
                    time.sleep(1)
            if not AppStoreWindow.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self, name)
            self.assertTrue(AppStoreWindow.exists)
            if AppStoreWindow.exists:
                closeButton = self.d(
                    resourceId="android:id/pc_close",
                    className="android.widget.ImageView",
                    packageName="com.alibaba.micropc.appstore",
                )
                if closeButton.exists:
                    logger.debug("click close button: (%s)" % (closeButton.info["packageName"]))
                    closeButton.click()
                    # time.sleep(5)
        logger.info("Exit -- MUAT:DesktopSystemTest:test_DoubleClickIcon")

    def test_StartAppFromLMClick(self):
        logger.info("Enter -- MUAT:DesktopSystemTest:test_StartAppFromLMClick")

        # click the applist
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)

        # get applist picture
        BaseImg = os.path.join(self.BaseImagePath, "applist_browser.jpg")
        name = "test_StartAppFromLMClick_%s.jpg" % time.strftime("%Y%m%d%H%M%S", time.localtime())
        img = os.path.join(self.TmpImagePath, name)
        self.d.screenshot(img)
        cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
        # (1292, 315) = 1920 - 120 * 5 - 18 - 10; 1080 - 136 * 5 - 18 - 25 - 42
        # (1892, 995) = 1920 - 18 - 10; 1080 - 18 - 25 - 42
        # region = array(5,5), with each 120 * 136
        CropImage(img, cropedImgPath, 1292, 315, 1892, 995)

        # find required image
        # compare pic rect of base image, it is 64*64 pix
        ret = FindImage(cropedImgPath, BaseImg, (28, 24, 92, 88), 50)
        if not ret:
            shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
            path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
            self.fail("The failure file path is %s" % path)
        else:
            # mouse left click the item
            self.mouse.click(1292 + ret[0], 315 + ret[1], constants.MouseLeftKey)

        # verify the item
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        start = time.time()
        while time.time() - start < constants.Time_Out:
            if BrowserWindow.exists:
                break
            else:
                time.sleep(1)
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            closeButton = self.d(
                resourceId="android:id/pc_close",
                className="android.widget.ImageView",
                packageName="org.chromium.chrome",
            )
            if closeButton.exists:
                logger.debug("click close button: (%s)" % (closeButton.info["packageName"]))
                closeButton.click()
        logger.info("Exit -- MUAT:DesktopSystemTest:test_StartAppFromLMClick")

    def test_StartAppFromRMClick(self):
        logger.info("Enter -- MUAT:DesktopSystemTest:test_StartAppFromRMClick")

        # click the applist
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)

        # get applist picture
        BaseImg = os.path.join(self.BaseImagePath, "applist_browser.jpg")
        name = "test_StartAppFromRMClick_%s.jpg" % time.strftime("%Y%m%d%H%M%S", time.localtime())
        img = os.path.join(self.TmpImagePath, name)
        self.d.screenshot(img)
        cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
        # (1292, 315) = 1920 - 120 * 5 - 18 - 10; 1080 - 136 * 5 - 18 - 25 - 42
        # (1892, 995) = 1920 - 18 - 10; 1080 - 18 - 25 - 42
        # region = array(5,5), with each 120 * 136
        CropImage(img, cropedImgPath, 1292, 315, 1892, 995)

        # find required image
        # compare pic rect of base image, it is 64*64 pix
        ret = FindImage(cropedImgPath, BaseImg, (28, 24, 92, 88), 50)
        if not ret:
            shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
            path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
            self.fail("The failure file path is %s" % path)
        else:
            # mouse right click the item
            self.mouse.click(1292 + ret[0], 315 + ret[1], constants.MouseRightKey)
            time.sleep(1)
            # mouse left click start item
            self.mouse.click(1292 + ret[0] + 20, 315 + ret[1] + 20, constants.MouseLeftKey)

        # verify the item
        # time.sleep(2)
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        start = time.time()
        while time.time() - start < constants.Time_Out:
            if BrowserWindow.exists:
                break
            else:
                time.sleep(1)
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            closeButton = self.d(
                resourceId="android:id/pc_close",
                className="android.widget.ImageView",
                packageName="org.chromium.chrome",
            )
            if closeButton.exists:
                logger.debug("click close button: (%s)" % (closeButton.info["packageName"]))
                closeButton.click()
        logger.info("Exit -- MUAT:DesktopSystemTest:test_StartAppFromRMClick")

    def test_AddAPPIconToDesktop(self):
        logger.info("Enter -- MUAT:DesktopSystemTest:test_AddAPPIconToDesktop")

        # remove the shortcut from Desktop first
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        BrowserIcon = self.d(text=u"浏览器", className="android.widget.TextView")
        if BrowserIcon.exists:
            BrowserIcon_bounds = BrowserIcon.info["bounds"]
            self.mouse.click(
                (BrowserIcon_bounds["left"] + BrowserIcon_bounds["right"]) / 2,
                (BrowserIcon_bounds["top"] + BrowserIcon_bounds["bottom"]) / 2,
                constants.MouseRightKey,
            )
            time.sleep(0.2)
            self.mouse.click(
                (BrowserIcon_bounds["left"] + BrowserIcon_bounds["right"]) / 2 + 50,
                (BrowserIcon_bounds["top"] + BrowserIcon_bounds["bottom"]) / 2 + 50,
                constants.MouseLeftKey,
            )
            time.sleep(0.2)
            deleteButton = self.d(text=u"删除", className="android.widget.Button")
            if deleteButton.exists:
                deleteButton.click()
                time.sleep(0.2)

        # click the applist
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)

        # get applist picture
        BaseImg = os.path.join(self.BaseImagePath, "applist_browser.jpg")
        name = "test_AddAPPIconToDesktop_%s.jpg" % time.strftime("%Y%m%d%H%M%S", time.localtime())
        img = os.path.join(self.TmpImagePath, name)
        self.d.screenshot(img)
        cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
        # (1292, 315) = 1920 - 120 * 5 - 18 - 10; 1080 - 136 * 5 - 18 - 25 - 42
        # (1892, 995) = 1920 - 18 - 10; 1080 - 18 - 25 - 42
        # region = array(5,5), with each 120 * 136
        CropImage(img, cropedImgPath, 1292, 315, 1892, 995)

        # find required image
        # compare pic rect of base image, it is 64*64 pix
        ret = FindImage(cropedImgPath, BaseImg, (28, 24, 92, 88), 50)
        if not ret:
            shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
            path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
            self.fail("The failure file path is %s" % path)
        else:
            # mouse click and move the item to desktop
            self.mouse.pressmove(1292 + ret[0], 315 + ret[1], 0, -315 - ret[1], constants.MouseLeftKey)
            time.sleep(0.2)

        # verify the item
        time.sleep(2)
        BrowserIcon = self.d(text=u"浏览器", className="android.widget.TextView")
        if not BrowserIcon.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(BrowserIcon.exists)
        logger.info("Exit -- MUAT:DesktopSystemTest:test_APPAddShortcutToDesktop")
コード例 #2
0
class MultiWindowsTest(ParametrizedTestCase):
    def setUp(self):
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest('process monitor stop')

        self.d      = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.adb_tools = AdbTools()
        self.mouse = AdbMouse()

#         self.account.sleep()
#         self.account.wakeup()
#         self.account.login()
        Button1=self.d(resourceId='com.yunpc.yunosloginui:id/avatar')
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if not Button1.exists:
                break
            else:
                time.sleep(1)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="org.chromium.chrome")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        self.adb_tools.adb_shell('am force-stop org.chromium.chrome')
        Browser_Icon = self.d(text=u"浏览器",resourceId='com.aliyun.lightdesk:id/tag_name', className="android.widget.TextView")
        if not Browser_Icon.exists:
            self.d.click(57,10)
            time.sleep(2)
            self.d.click(68,141)
            start2=time.time()
            while time.time()-start2<constants.Time_Out:
                if  Button1.exists:
                    break
                else:
                    time.sleep(1)
            if self.mon and not self.mon.running_status:
                self.skipTest('process monitor stop')

            self.d      = AutomationDevice().get_device()
            self.account = Account(self.d)
            self.mouse = AdbMouse()
            self.adb_tools = AdbTools()
        

            self.account.wakeup()
            self.account.login()
            Button1=self.d(resourceId='com.yunpc.yunosloginui:id/avatar')
            start=time.time()
            while time.time()-start<constants.Time_Out:
                if not Button1.exists:
                    break
                else:
                    time.sleep(1)
            #time.sleep(5)
            self.d.click(950,562)
            time.sleep(1)
            Button1=self.d(resourceId='android:id/button1',className='android.widget.Button',packageName='android')
            if Button1.exists:
                Button1.click()
            time.sleep(1)
            if not Browser_Icon.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(Browser_Icon.exists)
        
        

    def tearDown(self):
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="org.chromium.chrome")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        self.adb_tools.adb_shell('am force-stop org.chromium.chrome')

#     def test_DragWindow(self):
#         logger.info('Enter -- MUAT:MultiWindowsTest:test_DragWindow')
#       
#         BrowserIcon = self.d(text=u"浏览器", className="android.widget.TextView")
#         click_x = BrowserIcon.info['visibleBounds']['left'] +5
#         click_y = BrowserIcon.info['visibleBounds']['top'] +5
#         self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
#             
#         BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="com.android.browser")
#         self.assertTrue(BrowserWindow.exists)
#         if BrowserWindow.exists:
#             #BrowserWindow = self.d(text=u"浏览器", resourceId="android:id/pc_title", className="android.widget.TextView", packageName="com.android.browser")
#             LowerRightCoordinate_X = BrowserWindow.info['visibleBounds']['right'] - 1
#             LowerRightCoordinate_Y = BrowserWindow.info['visibleBounds']['bottom'] - 1
#             Target_X = LowerRightCoordinate_X + 100
#             Target_Y = LowerRightCoordinate_Y + 100
#                 
#             # drag
#             self.assertTrue(self.d.drag(LowerRightCoordinate_X, LowerRightCoordinate_Y, Target_X, Target_Y))
#             time.sleep(2)
#             # new coordinate
#             #EndBrowserWindow = self.d(text=u"浏览器", resourceId="android:id/pc_title", className="android.widget.TextView", packageName="com.android.browser")
#             EndBrowserWindow = self.d(className="android.widget.FrameLayout", packageName="com.android.browser")
#             End_X = EndBrowserWindow.info['visibleBounds']['right'] -1 
#             End_Y = EndBrowserWindow.info['visibleBounds']['bottom'] -1
#     
#             # assert the math abs < 5 
#             self.assertTrue(abs(Target_X - End_X) < 5)
#             self.assertTrue(abs(Target_Y - End_Y) < 5)
#                 
#             self.assertTrue(self.d.drag(End_X, End_Y, LowerRightCoordinate_X, LowerRightCoordinate_Y))
#                             
#         logger.info('Exit -- MUAT:MultiWindowsTest:test_DragWindow')
          
          
    def test_ZoomInWindows(self):
        logger.info('Enter -- MUAT:MultiWindowsTest:test_ZoomInWindows')
             
        BrowserIcon = self.d(text=u"浏览器",resourceId='com.aliyun.lightdesk:id/tag_name', className="android.widget.TextView")
        click_x = BrowserIcon.info['visibleBounds']['left'] +5
        click_y = BrowserIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
             
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            LowerRightCoordinate_X = BrowserWindow.info['visibleBounds']['right'] - 1
            LowerRightCoordinate_Y = BrowserWindow.info['visibleBounds']['bottom'] - 1
            Target_X = LowerRightCoordinate_X + 100
            Target_Y = LowerRightCoordinate_Y + 100
                 
            # drag
            self.assertTrue(self.d.drag(LowerRightCoordinate_X, LowerRightCoordinate_Y, Target_X, Target_Y))
            time.sleep(2)
            # new coordinate
            EndBrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            End_X = EndBrowserWindow.info['visibleBounds']['right'] -1 
            End_Y = EndBrowserWindow.info['visibleBounds']['bottom'] -1
     
            # assert the math abs < 5 
            #self.assertTrue(abs(Target_X - End_X) < 5)
            #self.assertTrue(abs(Target_Y - End_Y) < 5)
                 
            self.assertTrue(self.d.drag(End_X, End_Y, LowerRightCoordinate_X, LowerRightCoordinate_Y))
        logger.info('Exit -- MUAT:MultiWindowsTest:test_ZoomInWindows')
                 
    def test_ZoomOutWindows(self):
        logger.info('Enter -- MUAT:MultiWindowsTest:test_ZoomOutWindows')
        BrowserIcon = self.d(text=u"浏览器",resourceId='com.aliyun.lightdesk:id/tag_name', className="android.widget.TextView")
        click_x = BrowserIcon.info['visibleBounds']['left'] +5
        click_y = BrowserIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
             
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            LowerRightCoordinate_X = BrowserWindow.info['visibleBounds']['right'] - 1
            LowerRightCoordinate_Y = BrowserWindow.info['visibleBounds']['bottom'] - 1
            Target_X = LowerRightCoordinate_X - 100
            Target_Y = LowerRightCoordinate_Y - 100
                 
            # drag
            self.assertTrue(self.d.drag(LowerRightCoordinate_X, LowerRightCoordinate_Y, Target_X, Target_Y))
            time.sleep(2)
            # new coordinate
            EndBrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            End_X = EndBrowserWindow.info['visibleBounds']['right'] -1 
            End_Y = EndBrowserWindow.info['visibleBounds']['bottom'] -1
     
            # assert the math abs < 5 
            #self.assertTrue(abs(Target_X - End_X) < 5)
            #self.assertTrue(abs(Target_Y - End_Y) < 5)
                  
            self.assertTrue(self.d.drag(End_X, End_Y, LowerRightCoordinate_X, LowerRightCoordinate_Y))
                                  
        logger.info('Exit -- MUAT:MultiWindowsTest:test_ZoomOutWindows')
          
    def test_ElongateWindow(self):
        logger.info('Enter -- MUAT:MultiWindowsTest:test_ElongateWindow')
        BrowserIcon = self.d(text=u"浏览器",resourceId='com.aliyun.lightdesk:id/tag_name', className="android.widget.TextView")
        click_x = BrowserIcon.info['visibleBounds']['left'] +5
        click_y = BrowserIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
              
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            LowerRightCoordinate_X = BrowserWindow.info['visibleBounds']['right'] - 100
            LowerRightCoordinate_Y = BrowserWindow.info['visibleBounds']['bottom'] - 1
            Target_X = LowerRightCoordinate_X
            Target_Y = LowerRightCoordinate_Y + 100
      
            # drag
            self.assertTrue(self.d.drag(LowerRightCoordinate_X, LowerRightCoordinate_Y, Target_X, Target_Y))
      
            time.sleep(2)
      
            # new coordinate
            EndBrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            End_X = EndBrowserWindow.info['visibleBounds']['right'] -1 
            End_Y = EndBrowserWindow.info['visibleBounds']['bottom'] -1
      
            # assert the math abs < 5 
            self.assertTrue(abs(Target_Y - End_Y) < 5)
                  
            self.assertTrue(self.d.drag(End_X-100, End_Y, LowerRightCoordinate_X, LowerRightCoordinate_Y))
        logger.info('Exit -- MUAT:MultiWindowsTest:test_ElongateWindow')                
                  
    def test_WidenWindow(self):
        logger.info('Enter -- MUAT:MultiWindowsTest:test_WidenWindow')
        BrowserIcon = self.d(text=u"浏览器",resourceId='com.aliyun.lightdesk:id/tag_name', className="android.widget.TextView")
        click_x = BrowserIcon.info['visibleBounds']['left'] +5
        click_y = BrowserIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
              
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            LowerRightCoordinate_X = BrowserWindow.info['visibleBounds']['right'] - 1
            LowerRightCoordinate_Y = BrowserWindow.info['visibleBounds']['bottom'] - 100
            Target_X = LowerRightCoordinate_X + 100
            Target_Y = LowerRightCoordinate_Y
      
            # drag
            self.assertTrue(self.d.drag(LowerRightCoordinate_X, LowerRightCoordinate_Y, Target_X, Target_Y))
      
            time.sleep(2)
      
            # new coordinate
            EndBrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            End_X = EndBrowserWindow.info['visibleBounds']['right'] -1 
            End_Y = EndBrowserWindow.info['visibleBounds']['bottom'] -1
      
            # assert the math abs < 5 
            self.assertTrue(abs(Target_X - End_X) < 5)
      
            self.assertTrue(self.d.drag(End_X, End_Y-100, LowerRightCoordinate_X, LowerRightCoordinate_Y))
                                  
        logger.info('Exit -- MUAT:MultiWindowsTest:test_WidenWindow')
      
    def test_F11ToFullScreen(self):
        logger.info('Enter -- MUAT:MultiWindowsTest:test_F11ToFullScreen')
        BrowserIcon = self.d(text=u"浏览器",resourceId='com.aliyun.lightdesk:id/tag_name', className="android.widget.TextView")
        click_x = BrowserIcon.info['visibleBounds']['left'] +5
        click_y = BrowserIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
              
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            WindowTop = BrowserWindow.info['visibleBounds']['top']
            WindowLeft = BrowserWindow.info['visibleBounds']['left']
            WindowRight = BrowserWindow.info['visibleBounds']['right']
            WindowBottom = BrowserWindow.info['visibleBounds']['bottom']
                  
            # not full screen
            self.assertNotEqual(WindowTop, 0)
            self.assertNotEqual(WindowLeft, 0)
            self.assertNotEqual(WindowRight, 1920)
            self.assertNotEqual(WindowBottom, 1080)
                  
            # press F11 key
            self.assertTrue(self.d.press(0x8d))
      
            time.sleep(2)
      
            # new coordinate
            EndBrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            NewWindowTop = EndBrowserWindow.info['visibleBounds']['top']
            NewWindowLeft = EndBrowserWindow.info['visibleBounds']['left']
            NewWindowRight = EndBrowserWindow.info['visibleBounds']['right']
            NewWindowBottom = EndBrowserWindow.info['visibleBounds']['bottom']
                  
            # full screen
            self.assertEqual(NewWindowTop, 0)
            self.assertEqual(NewWindowLeft, 0)
            self.assertEqual(NewWindowRight, 1920)
            self.assertEqual(NewWindowBottom, 1080)
            if not self.d.press(0x8d):
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(self.d.press(0x8d))
                  
        logger.info('Exit -- MUAT:MultiWindowsTest:test_F11ToFullScreen')
             
             
    def test_maximization(self):
        logger.info('Enter -- MUAT:MultiWindowsTest:test_maximization')
        BrowserIcon = self.d(text=u"浏览器", resourceId='com.aliyun.lightdesk:id/tag_name',className="android.widget.TextView")
        click_x = BrowserIcon.info['visibleBounds']['left'] +5
        click_y = BrowserIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
            
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            oldWindowTop = BrowserWindow.info['visibleBounds']['top']
            oldWindowLeft = BrowserWindow.info['visibleBounds']['left']
            oldWindowLeft1 = BrowserWindow.info['visibleBounds']['left']
            oldWindowRight = BrowserWindow.info['visibleBounds']['right']
            oldWindowRight1 = BrowserWindow.info['visibleBounds']['right']
            oldWindowBottom = BrowserWindow.info['visibleBounds']['bottom']
                
            # not maximization
            self.assertNotEqual(oldWindowTop, 0)
            self.assertNotEqual(oldWindowLeft, 0)
            self.assertNotEqual(oldWindowRight, 1920)
            self.assertNotEqual(oldWindowBottom, 1080)
                
            # maxmiun the window
            max_button = self.d(packageName="org.chromium.chrome", resourceId='android:id/pc_max')
            if max_button.exists:
                max_button.click()
                start=time.time()
                while time.time()-start<constants.Time_Out:
                    if oldWindowLeft1==0 and oldWindowRight1==1920:
                        break
                    else:
                        time.sleep(1)
                        oldWindowLeft1 = BrowserWindow.info['visibleBounds']['left']
                        oldWindowRight1 = BrowserWindow.info['visibleBounds']['right']
    
            # new coordinate
            EndBrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            NewWindowTop = EndBrowserWindow.info['visibleBounds']['top']
            NewWindowLeft = EndBrowserWindow.info['visibleBounds']['left']
            NewWindowRight = EndBrowserWindow.info['visibleBounds']['right']
            NewWindowBottom = EndBrowserWindow.info['visibleBounds']['bottom']
                
            # full screen
            # the topbar height 22px
            # the taskbar height 42px (1080-42=1038) 
            self.assertTrue(abs(NewWindowTop - 18) < 5)
            self.assertEqual(NewWindowLeft, 0)
            self.assertEqual(NewWindowRight, 1920)
            self.assertTrue(abs(NewWindowBottom- 1048) < 5)
                
            # reclick the max button
            if max_button.exists:
                max_button.click()
                start=time.time()
                while time.time()-start<constants.Time_Out:
                    if not NewWindowLeft==0:
                        break
                    else:
                        time.sleep(1)
                        NewWindowLeft = EndBrowserWindow.info['visibleBounds']['left']
                        
            # restore the window
            EndBrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            NewWindowTop = EndBrowserWindow.info['visibleBounds']['top']
            NewWindowLeft = EndBrowserWindow.info['visibleBounds']['left']
            NewWindowRight = EndBrowserWindow.info['visibleBounds']['right']
            NewWindowBottom = EndBrowserWindow.info['visibleBounds']['bottom']
            self.assertEqual(NewWindowTop, oldWindowTop)
            self.assertEqual(NewWindowLeft, oldWindowLeft)
            self.assertEqual(NewWindowRight, oldWindowRight)
            self.assertEqual(NewWindowBottom, oldWindowBottom)
                            
        logger.info('Exit -- MUAT:MultiWindowsTest:test_maximization')
            
    def test_minimization(self):
        logger.info('Enter -- MUAT:MultiWindowsTest:test_minimization')
        BrowserIcon = self.d(text=u"浏览器",resourceId='com.aliyun.lightdesk:id/tag_name', className="android.widget.TextView")
        click_x = BrowserIcon.info['visibleBounds']['left'] +5
        click_y = BrowserIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
           
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            oldWindowTop = BrowserWindow.info['visibleBounds']['top']
            oldWindowLeft = BrowserWindow.info['visibleBounds']['left']
            oldWindowRight = BrowserWindow.info['visibleBounds']['right']
            oldWindowBottom = BrowserWindow.info['visibleBounds']['bottom']
               
            # not maximization
            self.assertNotEqual(oldWindowTop, 0)
            self.assertNotEqual(oldWindowLeft, 0)
            self.assertNotEqual(oldWindowRight, 1920)
            self.assertNotEqual(oldWindowBottom, 1080)
               
            # hide the window
            hide_button = self.d(packageName="org.chromium.chrome", resourceId='android:id/pc_hide')
            if hide_button.exists:
                hide_button.click()
                start=time.time()
                while time.time()-start<constants.Time_Out:
                    if not hide_button.exists:
                        break
                    else:
                        time.sleep(1)
   
            # check hide window
            if self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome").exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertFalse(self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome").exists)
                                               
            # click the browser in the taskbar
            self.mouse.click(100, 1080-25, constants.MouseLeftKey)
            start=time.time()
            while time.time()-start<constants.Time_Out:
                if  hide_button.exists:
                    break
                else:
                    time.sleep(1)
   
            # restore the window
            EndBrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
            NewWindowTop = EndBrowserWindow.info['visibleBounds']['top']
            NewWindowLeft = EndBrowserWindow.info['visibleBounds']['left']
            NewWindowRight = EndBrowserWindow.info['visibleBounds']['right']
            NewWindowBottom = EndBrowserWindow.info['visibleBounds']['bottom']
            self.assertEqual(NewWindowTop, oldWindowTop)
            self.assertEqual(NewWindowLeft, oldWindowLeft)
            self.assertEqual(NewWindowRight, oldWindowRight)
            self.assertEqual(NewWindowBottom, oldWindowBottom)
                                      
        logger.info('Exit -- MUAT:MultiWindowsTest:test_minimization')
コード例 #3
0
class InputTest(ParametrizedTestCase):
    def setUp(self):
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest('process monitor stop')

        self.d      = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.mouse = AdbMouse()
        self.mouse.move(1920, 1080)
        self.adb_tools = AdbTools()
        
        self.BaseImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "dependency", "BaseImage")
        self.FailureIamgePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "FailureImage")
        self.TmpImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "TmpImage")
        
        if not os.path.exists(self.TmpImagePath):
            os.mkdir(self.TmpImagePath)
        if not os.path.exists(os.path.join(self.TmpImagePath, "croped")):
            os.mkdir(os.path.join(self.TmpImagePath, "croped"))

        Button1=self.d(resourceId='com.yunpc.yunosloginui:id/avatar')
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if not Button1.exists:
                break
            else:
                time.sleep(1)
        self.adb_tools.adb_shell('am force-stop com.yunpc.note')  
        
    def tearDown(self):
        self.adb_tools.adb_shell('am force-stop com.yunpc.note')    
        if os.path.exists(self.TmpImagePath):
            shutil.rmtree(self.TmpImagePath)
        self.mouse.click(1724, 10, constants.MouseLeftKey)
#         time.sleep(1)
        self.mouse.click(1744, 100, constants.MouseLeftKey)
        

    def test_PressNum(self):
        logger.info('Enter -- MUAT:InputTest:test_PressNumTest')
        self.adb_tools.adb_shell('am start -n com.yunpc.note/.app.ui.activity.MainActivityNew')
        time.sleep(2)
        self.d(resourceId='android:id/pc_max',packageName='com.yunpc.note').click()
        edit_text=self.d(resourceId='com.yunpc.note:id/et',packageName='com.yunpc.note')
        self.assertTrue(edit_text.exists)
        self.mouse.click(1724, 10, constants.MouseLeftKey)
        time.sleep(1)
        self.mouse.click(1744, 45, constants.MouseLeftKey)
        time.sleep(5)
#         self.d.press(59)
#         time.sleep(3)
        self.d.press(43)
        self.d.press(43)
        time.sleep(0.5)
        self.d.press(8)
        time.sleep(1)
        BaseImg = os.path.join(self.BaseImagePath, "test_note_sgn.jpg")
        name = "test_note_sgn_%s.jpg" % time.strftime('%Y%m%d%H%M%S', time.localtime())
        img = os.path.join(self.TmpImagePath, name)
        self.d.screenshot(img)
        cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
        CropImage(img, cropedImgPath, 0, 0, 1759, 200)
        if not CompareImage(cropedImgPath, BaseImg, 0.9):
            shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
            self.adb_tools.adb_shell('am force-stop com.yunpc.note')  
            self.adb_tools.adb_shell('am start -n com.yunpc.note/.app.ui.activity.MainActivityNew')
            time.sleep(2)
            self.d(resourceId='android:id/pc_max',packageName='com.yunpc.note').click()
            edit_text=self.d(resourceId='com.yunpc.note:id/et',packageName='com.yunpc.note')
            self.assertTrue(edit_text.exists)
            self.d.press(59)
            time.sleep(2)
            self.d.press(43)
            self.d.press(43)
            time.sleep(0.5)
            self.d.press(8)
            self.d.screenshot(img)
            time.sleep(1)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, 0, 0, 1759, 200)
            if not CompareImage(cropedImgPath, BaseImg, 0.9):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
                self.fail("The failure file path is %s") % path
        CloseButton=self.d(resourceId='android:id/pc_close',packageName='com.yunpc.note')
        if CloseButton.exists:
            CloseButton.click()
            self.d(resourceId='android:id/button3',packageName='com.yunpc.note').click()
        time.sleep(1)
        logger.info("Exit -- MUAT:InputTest:test_PressNumTest")
              
    def test_PressSpace(self):
        logger.info('Enter -- MUAT:InputTest:test_PressSpaceTest')
        self.adb_tools.adb_shell('am start -n com.yunpc.note/.app.ui.activity.MainActivityNew')
        time.sleep(2)
        self.d(resourceId='android:id/pc_max',packageName='com.yunpc.note').click()
        edit_text=self.d(resourceId='com.yunpc.note:id/et',packageName='com.yunpc.note')
        self.assertTrue(edit_text.exists)
        self.mouse.click(1724, 10, constants.MouseLeftKey)
        time.sleep(1)
        self.mouse.click(1744, 45, constants.MouseLeftKey)  
        time.sleep(5)
#         self.d.press(59)
#         time.sleep(3)       
        self.d.press(42)
        self.d.press(37)
        self.d.press(42)
        self.d.press(37)
        time.sleep(0.5)
        self.d.press(62)
        time.sleep(1)
        BaseImg = os.path.join(self.BaseImagePath, "test_note_sgs.jpg")
        name = "test_note_sgs%s.jpg" % time.strftime('%Y%m%d%H%M%S', time.localtime())
        img = os.path.join(self.TmpImagePath, name)
        self.d.screenshot(img)
        cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
        CropImage(img, cropedImgPath,  0, 0, 1759, 200)
        if not CompareImage(cropedImgPath, BaseImg, 0.9):
            shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
            self.adb_tools.adb_shell('am force-stop com.yunpc.note')  
            self.adb_tools.adb_shell('am start -n com.yunpc.note/.app.ui.activity.MainActivityNew')
            time.sleep(2)
            self.d(resourceId='android:id/pc_max',packageName='com.yunpc.note').click()
            edit_text=self.d(resourceId='com.yunpc.note:id/et',packageName='com.yunpc.note')
            self.assertTrue(edit_text.exists)
            self.d.press(59)
            time.sleep(2)
            self.d.press(42)
            self.d.press(37)
            self.d.press(42)
            self.d.press(37)
            time.sleep(0.5)
            self.d.press(62)
            time.sleep(1)
            self.d.screenshot(img)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, 0, 0, 1759, 200)
            if not CompareImage(cropedImgPath, BaseImg, 0.9):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
                self.fail("The failure file path is %s") % path
        CloseButton=self.d(resourceId='android:id/pc_close',packageName='com.yunpc.note')
        if CloseButton.exists:
            CloseButton.click()
            time.sleep(1)
            self.d(resourceId='android:id/button3',packageName='com.yunpc.note').click()
        time.sleep(1)
        logger.info("Exit -- MUAT:InputTest:test_PressSpaceTest")
        
    def test_ConvertTest(self):
        logger.info('Enter -- MUAT:InputTest:test_ConvertTest')
        self.adb_tools.adb_shell('am start -n com.yunpc.note/.app.ui.activity.MainActivityNew')
        time.sleep(2)
        self.d(resourceId='android:id/pc_max',packageName='com.yunpc.note').click()
        edit_text=self.d(resourceId='com.yunpc.note:id/et',packageName='com.yunpc.note')
        self.assertTrue(edit_text.exists)
        self.mouse.click(1724, 10, constants.MouseLeftKey)
        time.sleep(1)
        self.mouse.click(1744, 45, constants.MouseLeftKey)
        time.sleep(5)
        self.d.press(42)
        self.d.press(37)
        self.d.press(42)
        self.d.press(37)
        time.sleep(0.5)
        self.d.press(62)
        BaseImg = os.path.join(self.BaseImagePath, "test_note_sgc.jpg")
        name = "test_note_sgc_%s.jpg" % time.strftime('%Y%m%d%H%M%S', time.localtime())
        img = os.path.join(self.TmpImagePath, name)
        self.d.screenshot(img)
        cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
        CropImage(img, cropedImgPath, 0, 0, 1759, 200)
        if not CompareImage(cropedImgPath, BaseImg, 0.9):
            shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
            self.adb_tools.adb_shell('am force-stop com.yunpc.note')  
            self.adb_tools.adb_shell('am start -n com.yunpc.note/.app.ui.activity.MainActivityNew')
            time.sleep(2)
            self.d(resourceId='android:id/pc_max',packageName='com.yunpc.note').click()
            edit_text=self.d(resourceId='com.yunpc.note:id/et',packageName='com.yunpc.note')
            self.assertTrue(edit_text.exists)
            self.d.press(59)
            time.sleep(2)
            self.d.press(42)
            self.d.press(37)
            self.d.press(42)
            self.d.press(37)
            time.sleep(0.5)
            self.d.press(62)
            time.sleep(1)
            self.d.screenshot(img)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, 0, 0, 1759, 200)
            if not CompareImage(cropedImgPath, BaseImg, 0.9):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
                self.fail("The failure file path is %s") % path
        CloseButton=self.d(resourceId='android:id/pc_close',packageName='com.yunpc.note')
        if CloseButton.exists:
            CloseButton.click()
            time.sleep(1)
            self.d(resourceId='android:id/button3',packageName='com.yunpc.note').click()
        time.sleep(3)
        logger.info("Exit -- MUAT:InputTest:test_ConvertTest")
               
    def test_CapsLockTest(self):
        logger.info('Enter -- MUAT:InputTest:test_CapsLockTest')
        self.adb_tools.adb_shell('am start -n com.yunpc.note/.app.ui.activity.MainActivityNew')
        time.sleep(2)
        self.d(resourceId='android:id/pc_max',packageName='com.yunpc.note').click()
        edit_text=self.d(resourceId='com.yunpc.note:id/et',packageName='com.yunpc.note')
        self.assertTrue(edit_text.exists)
        self.mouse.click(1724, 10, constants.MouseLeftKey)
        self.mouse.click(1724, 43, constants.MouseLeftKey)
        time.sleep(5)
        self.d.press(32,1)
        self.d.press(32,1)
        self.d.press(32,1)
        self.d.press(32,1)
        time.sleep(1)
        BaseImg = os.path.join(self.BaseImagePath, "test_note_sgcl.jpg")
        name = "test_note_sgcl_%s.jpg" % time.strftime('%Y%m%d%H%M%S', time.localtime())
        img = os.path.join(self.TmpImagePath, name)
        self.d.screenshot(img)
        cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
        CropImage(img, cropedImgPath, 0, 0, 1759, 200)
        if not CompareImage(cropedImgPath, BaseImg, 0.9):
            shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
            self.adb_tools.adb_shell('am force-stop com.yunpc.note')  
            self.adb_tools.adb_shell('am start -n com.yunpc.note/.app.ui.activity.MainActivityNew')
            time.sleep(2)
            self.d(resourceId='android:id/pc_max',packageName='com.yunpc.note').click()
            edit_text=self.d(resourceId='com.yunpc.note:id/et',packageName='com.yunpc.note')
            self.assertTrue(edit_text.exists)
            self.d.press(59)
            time.sleep(2)
            self.d.press(32,1)
            self.d.press(32,1)
            self.d.press(32,1)
            self.d.press(32,1)
            time.sleep(1)
            self.d.screenshot(img)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, 0, 0, 1759, 200)
            if not CompareImage(cropedImgPath, BaseImg, 0.9):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
                self.fail("The failure file path is %s") % path
          
        CloseButton=self.d(resourceId='android:id/pc_close',packageName='com.yunpc.note')
        if CloseButton.exists:
            CloseButton.click()
            time.sleep(1)
            self.d(resourceId='android:id/button3',packageName='com.yunpc.note').click()
        time.sleep(1)
        logger.info("Exit -- MUAT:InputTest:test_CapsLockTest")      
コード例 #4
0
class YoukuTest(ParametrizedTestCase):

    def setUp(self):
        
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest('process monitor stop')

        self.d      = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.mouse = AdbMouse()
        self.adb_tools = AdbTools()

#         self.account.sleep()
#         self.account.wakeup()
#         self.account.login()
#         time.sleep(5)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.youku.phone.x86")
        #self.assertTure(closeButton.exists)
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            time.sleep(2)
        else:
            #logger.info("error---------->No closeButton")
            pass

        self.adb_tools.adb_shell("am force-stop com.youku.phone.x86")
        time.sleep(2)


    def test_OpenAndExit(self):

        logger.info('Enter -- MUAT:YoukuTest:test_OpenAndExit')

        #self.adb_tools.adb_shell("am start -n com.youku.phone.x86/.ActivityWelcome")
        #self.adb_tools.adb_shell('am start -n com.youku.phone.x86/com.youku.phone.x86.ActivityWelcome')
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        youku=self.d(text=u'优酷',resourceId='com.aliyun.lightdesk:id/gv_item_appname')
        click_x = youku.info['visibleBounds']['left'] +5
        click_y = youku.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        #如果弹出安全提示对话框则点击同意
        # agree_btn = self.d(resourceId="com.youku.phone.x86:id/app_agreement_done_textview", className="android.widget.TextView", PackageName="com.youku.phone.x86")
        # self.assertEqual(agree_btn.info['text'], u'同意')
        if self.d(resourceId="com.youku.phone.x86:id/app_agreement_done_textview", className="android.widget.TextView", packageName="com.youku.phone.x86").exists:
            self.d(resourceId="com.youku.phone.x86:id/app_agreement_done_textview", className="android.widget.TextView", packageName="com.youku.phone.x86").click()
            time.sleep(3)
        else:
            pass
        #click 我的
        myyouku = self.d(resourceId="com.youku.phone.x86:id/text_myyouku", className="android.widget.TextView", packageName="com.youku.phone.x86")
        self.assertEqual(myyouku.info['text'], u'我的')
        if myyouku.exists:
            myyouku.click()
            time.sleep(1)
        #click 首页
        youkutitle = self.d(resourceId="com.youku.phone.x86:id/text_youkutitle", className="android.widget.TextView")
        self.assertEqual(youkutitle.info['text'], u'首页')
        if youkutitle.exists:
            youkutitle.click()
            time.sleep(1)
        #click 推荐
        youkuguess = self.d(resourceId="com.youku.phone.x86:id/text_youkuguess")
        self.assertEqual(youkuguess.info['text'], u'推荐')
        if youkuguess.exists:
            youkuguess.click()
            time.sleep(1)
        #click 频道
        userlike = self.d(resourceId="com.youku.phone.x86:id/text_userlike")
        self.assertEqual(userlike.info['text'], u'频道')
        if userlike.exists:
            userlike.click()
            time.sleep(1)
        #exit youku app
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.youku.phone.x86")
        #self.assertTure(closeButton.exists)
        if closeButton.exists:
            #logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            time.sleep(2)
        else:
            #logger.info("error---------->No closeButton")
            pass


        logger.info('Exit -- MUAT:YoukuTest:test_OpenAndExit')

    def test_PlayAndPause(self):

        logger.info('Enter -- MUAT:YoukuTest:test_PlayAndPause')

        #self.adb_tools.adb_shell("am start -n com.youku.phone.x86.x86/.ActivityWelcome")
        #self.adb_tools.adb_shell('am start -n com.youku.phone.x86/com.youku.phone.x86.ActivityWelcome')
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        youku=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'优酷')
        click_x = youku.info['visibleBounds']['left'] +5
        click_y = youku.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(5)
        #如果弹出安全提示对话框则点击同意
        # agree_btn = self.d(resourceId="com.youku.phone.x86:id/app_agreement_done_textview", className="android.widget.TextView", PackageName="com.youku.phone.x86")
        # self.assertEqual(agree_btn.info['text'], u'同意')
        if self.d(resourceId="com.youku.phone.x86:id/app_agreement_done_textview", className="android.widget.TextView", packageName="com.youku.phone.x86").exists:
            self.d(resourceId="com.youku.phone.x86:id/app_agreement_done_textview", className="android.widget.TextView", packageName="com.youku.phone.x86").click()
            time.sleep(3)
        else:
            pass

        #click 我的
        myyouku = self.d(resourceId="com.youku.phone.x86:id/text_myyouku", className="android.widget.TextView", packageName="com.youku.phone.x86")
        self.assertEqual(myyouku.info['text'], u'我的')
        # logger.info('myyouku info is (%s)' % (myyouku.info['text']))
        if myyouku.exists:
            myyouku.click()
            time.sleep(1)
        #click 首页
        youkutitle = self.d(resourceId="com.youku.phone.x86:id/text_youkutitle", className="android.widget.TextView")
        self.assertEqual(youkutitle.info['text'], u'首页')
        if youkutitle.exists:
            youkutitle.click()
            time.sleep(1)

        #点击首页左侧的视频,进入视频播放界面
        text_youkutitle = self.d(resourceId="com.youku.phone.x86:id/text_youkutitle", className="android.widget.TextView")
        self.assertEqual(text_youkutitle.info['selected'], True)
        if text_youkutitle.exists:
            text_youkutitle.click()
            time.sleep(1)

        video = self.d(resourceId="com.youku.phone.x86:id/homepage_gallery_item_imageview", className="android.widget.ImageView")
        self.assertTrue(video.exists)
        if video.exists:
            video.click()
            #广告45s
            time.sleep(45)
            #视频播放1分钟
            time.sleep(30)
        #调出暂停按钮,点击按钮使食品暂停
        left_border = self.d(resourceId='android:id/left_border', className='android.widget.ImageView')
        self.assertTrue(left_border.exists)
        if left_border.exists:
            pause_btn_x = left_border.info['visibleBounds']['right'] + 60
            pause_btn_y = left_border.info['visibleBounds']['bottom'] - 60
            time.sleep(2)
            self.mouse.doubleclick(pause_btn_x, pause_btn_y, constants.MouseLeftKey)
            time.sleep(15)
            self.mouse.doubleclick(pause_btn_x, pause_btn_y, constants.MouseLeftKey)




        logger.info('Exit -- MUAT:YoukuTest:test_PlayAndPause')

    def test_FastForwardAndRewind(self):
        logger.info('Enter -- MUAT:YoukuTest:test_FastForwardAndRewind')

        #self.adb_tools.adb_shell("am start -n com.youku.phone.x86/.ActivityWelcome")
        #self.adb_tools.adb_shell('am start -n com.youku.phone.x86/com.youku.phone.x86.ActivityWelcome')
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        youku=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'优酷')
        click_x = youku.info['visibleBounds']['left'] +5
        click_y = youku.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(5)
        #如果弹出安全提示对话框则点击同意
        # agree_btn = self.d(resourceId="com.youku.phone.x86:id/app_agreement_done_textview", className="android.widget.TextView", PackageName="com.youku.phone.x86")
        # self.assertEqual(agree_btn.info['text'], u'同意')
        if self.d(resourceId="com.youku.phone.x86:id/app_agreement_done_textview", className="android.widget.TextView", packageName="com.youku.phone.x86").exists:
            self.d(resourceId="com.youku.phone.x86:id/app_agreement_done_textview", className="android.widget.TextView", packageName="com.youku.phone.x86").click()
            time.sleep(3)
        else:
            pass

        #click 我的
        myyouku = self.d(resourceId="com.youku.phone.x86:id/text_myyouku", className="android.widget.TextView")
        self.assertEqual(myyouku.info['text'], u'我的')
        if not myyouku.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
            time.sleep(2)
        elif myyouku.exists:
            myyouku.click()
            time.sleep(1)
        #click 首页
        youkutitle = self.d(resourceId="com.youku.phone.x86:id/text_youkutitle", className="android.widget.TextView")
        self.assertEqual(youkutitle.info['text'], u'首页')
        if youkutitle.exists:
            youkutitle.click()
            time.sleep(1)

        #点击首页左侧的视频,进入视频播放界面
        text_youkutitle = self.d(resourceId="com.youku.phone.x86:id/text_youkutitle", className="android.widget.TextView")
        self.assertEqual(text_youkutitle.info['selected'], True)
        if text_youkutitle.exists:
            text_youkutitle.click()
            time.sleep(1)

        video = self.d(resourceId="com.youku.phone.x86:id/homepage_gallery_item_imageview", className="android.widget.ImageView")
        self.assertTrue(video.exists)
        if video.exists:
            video.click()
        #广告45s
        time.sleep(60)
        #视频播放1分钟
        time.sleep(30)

        left_border = self.d(resourceId="android:id/left_border", className="android.widget.ImageView")
        Sx = left_border.info['visibleBounds']['right'] + 200
        Sy = (left_border.info['visibleBounds']['top'] + left_border.info['visibleBounds']['bottom'])/2
        Ex = Sx + 400
        Ey = Sy

        self.d.swipe(Sx, Sy, Ex, Ey, steps=10)
        time.sleep(10)
        self.d.swipe(Ex, Ey, Sx, Sy, steps=10)
        time.sleep(10)

        logger.info('Exit -- MUAT:YoukuTest:test_FastForwardAndRewind')
    def tearDown(self):

        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.youku.phone.x86")
        #self.assertTure(closeButton.exists)
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            time.sleep(2)
        else:
            #logger.info("error---------->No closeButton")
            pass
        # self.adb_tools.adb_shell("am force-stop com.youku.phone.x86")
        self.adb_tools.adb_shell("am force-stop com.youku.phone.x86")
#         self.account.sleep()
        
コード例 #5
0
class PaintTest(ParametrizedTestCase):
    def setUp(self):
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest('process monitor stop')

        self.d      = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.mouse = AdbMouse()
        self.adb_tools = AdbTools()
        
        self.BaseImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "dependency", "BaseImage")
        self.FailureIamgePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "FailureImage")
        self.TmpImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "TmpImage")
        
        if not os.path.exists(self.TmpImagePath):
            os.mkdir(self.TmpImagePath)
        if not os.path.exists(os.path.join(self.TmpImagePath, "croped")):
            os.mkdir(os.path.join(self.TmpImagePath, "croped"))

        self.account.sleep()
        self.account.wakeup()
        self.account.login()
        Button1=self.d(resourceId='com.yunpc.yunosloginui:id/avatar')
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if not Button1.exists:
                break
            else:
                time.sleep(1)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            self.adb_tools.adb_shell('am force-stop com.paint.board')
        
    def tearDown(self):
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            time.sleep(1)
        if closeButton.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
            self.adb_tools.adb_shell('am force-stop com.paint.board')
            self.assertFalse(closeButton.exists)
        if os.path.exists(self.TmpImagePath):
            shutil.rmtree(self.TmpImagePath)
        self.account.sleep()
            
    def test_OpenAndExit(self):
        logger.info('Enter -- MUAT:PaintTest:test_OpenAndExit')
        # click the applist
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow = self.d(className="android.widget.FrameLayout", packageName="com.paint.board")
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if  PaintWindow.exists:
                break
            else:
                time.sleep(1)
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(PaintWindow.exists)
        if PaintWindow.exists:
            closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
            if closeButton.exists:
                logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
                closeButton.click()
        logger.info('Exit -- MUAT:PaintTest:test_OpenAndExit')
         
    def test_OpenPic(self):
        logger.info('Enter -- MUAT:PaintTest:test_OpenPic')
        # click the applist
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        #max window
        self.d(resourceId='android:id/pc_max',packageName='com.paint.board').click()
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            #open jpg
            fileButton.click()
            click_x = editButton.info['visibleBounds']['left']
            click_y = editButton.info['visibleBounds']['bottom'] +40
            self.d.click(click_x,click_y)
            time.sleep(1)
            customer=self.d(resourceId='android:id/custom',className='android.widget.FrameLayout')
            self.d.drag(customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['bottom']-170,customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['top']+10,10)
            self.d.drag(customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['bottom']-170,customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['top']+10,10)
            fileName=self.d(resourceId='com.paint.board:id/filedialogitem_name',text='jpg.jpg')
            self.assertTrue(fileName.exists)
            file_x=fileName.info['visibleBounds']['left']+5
            file_y=fileName.info['visibleBounds']['top']+5
            self.d.click(file_x,file_y)
            #self.mouse.doubleclick(file_x, file_y, constants.MouseLeftKey)
            time.sleep(1)
            #self.d(resourceId='com.paint.board:id/filedialogitem_img',packageName='com.paint.board').click()
            self.d(text=u'打开',resourceId='com.paint.board:id/dia_postive').click()
            time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/t_tab',text='jpg.jpg').exists)
            #open png
            fileButton.click()
            click_x = editButton.info['visibleBounds']['left']
            click_y = editButton.info['visibleBounds']['bottom'] +40
            self.d.click(click_x,click_y)
            time.sleep(1)
            customer=self.d(resourceId='android:id/custom',className='android.widget.FrameLayout')
            self.d.drag(customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['bottom']-170,customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['top']+10,20)
            self.d.drag(customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['bottom']-170,customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['top']+10,20)
            fileName=self.d(resourceId='com.paint.board:id/filedialogitem_name',text='png.png')
            self.assertTrue(fileName.exists)
            file_x=fileName.info['visibleBounds']['left']+5
            file_y=fileName.info['visibleBounds']['top']+5
            self.d.click(file_x,file_y)
            time.sleep(1)
            self.d(text=u'打开',resourceId='com.paint.board:id/dia_postive').click()
            time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/t_tab',text='png.png').exists)
            
        if PaintWindow.exists:
            closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
            if closeButton.exists:
                logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
                closeButton.click()
        logger.info('Exit -- MUAT:PaintTest:test_OpenPic')
 
    def test_NewFile(self):
        logger.info('Enter -- MUAT:PaintTest:test_NewFile')
        # click the applist
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            fileButton.click()
            click_x = editButton.info['visibleBounds']['left']
            click_y = editButton.info['visibleBounds']['bottom'] +10
            self.d.click(click_x,click_y)
            time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/paint_view').exists)
        if PaintWindow.exists:
            closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
            if closeButton.exists:
                logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
                closeButton.click()
        logger.info('Exit -- MUAT:PaintTest:test_NewFile')
         
    def test_CloseFile(self):
        logger.info('Enter -- MUAT:PaintTest:test_CloseFile')
        # click the applist
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            fileButton.click()
            click_x = editButton.info['visibleBounds']['left']
            click_y = editButton.info['visibleBounds']['bottom'] +10
            self.d.click(click_x,click_y)
            time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/paint_view').exists)
            paint_board=self.d(resourceId='com.paint.board:id/paint_view')
            swipe_start_x=paint_board.info['visibleBounds']['left']+50
            swipe_start_y=paint_board.info['visibleBounds']['top']+50
            swipe_end_x=swipe_start_x + 200
            swipe_end_y=swipe_start_y + 200
            self.d.swipe(swipe_start_x,swipe_start_y,swipe_end_x,swipe_end_y,10)
            closeButton=self.d(resourceId='com.paint.board:id/b_tab')
            if closeButton.exists:
                closeButton.click()
                time.sleep(2)
                self.assertTrue(self.d(resourceId='android:id/message',text=u'是否保存?').exists)
                self.d(resourceId='android:id/button2',text=u'是').click()
                time.sleep(1)
                saveButton=self.d(resourceId='com.paint.board:id/dia_postive')
                if saveButton.exists:
                    saveButton.click()
                    time.sleep(1)
                    ok=self.d(resourceId='android:id/button1',text=u'确认')
                    if ok.exists:
                        ok.click()
                        time.sleep(1)
                        self.assertFalse(self.d(resourceId='com.paint.board:id/paint_view').exists)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        logger.info('Exit -- MUAT:PaintTest:test_CloseFile')
              
    def test_SaveFile(self):
        logger.info('Enter -- MUAT:PaintTest:test_SaveFile')
        # click the applist
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            fileButton.click()
            time.sleep(1)
            click_new_x = fileButton.info['visibleBounds']['right']
            click_new_y = fileButton.info['visibleBounds']['bottom'] +10
            self.d.click(click_new_x, click_new_y)
            time.sleep(2)
            self.assertTrue(self.d(resourceId='com.paint.board:id/paint_view').exists)
            paint_board=self.d(resourceId='com.paint.board:id/paint_view')
            swipe_start_x=paint_board.info['visibleBounds']['left']+50
            swipe_start_y=paint_board.info['visibleBounds']['top']+50
            swipe_end_x=swipe_start_x + 200
            swipe_end_y=swipe_start_y + 300
            self.d.swipe(swipe_start_x,swipe_start_y,swipe_end_x,swipe_end_y,10)
            time.sleep(1)
            fileButton.click()
            time.sleep(1)
            click_save_x = fileButton.info['visibleBounds']['right']
            click_save_y = fileButton.info['visibleBounds']['bottom'] +60
            self.d.click(click_save_x,click_save_y)
            time.sleep(1)
            saveButton=self.d(resourceId='com.paint.board:id/dia_postive')
            if saveButton.exists:
                saveButton.click()
                time.sleep(1)
                ok=self.d(resourceId='android:id/button1',text=u'确认')
                if ok.exists:
                    ok.click()
                    time.sleep(1)
            closeButton=self.d(resourceId='com.paint.board:id/b_tab')
            if closeButton.exists:
                closeButton.click()
                time.sleep(2)
                self.assertFalse(self.d(resourceId='android:id/message',text=u'是否保存?').exists)
                self.assertFalse(self.d(resourceId='com.paint.board:id/paint_view').exists)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        logger.info('Exit -- MUAT:PaintTest:test_SaveFile')
         
    def test_CopyPic(self):
        logger.info('Enter -- MUAT:PaintTest:test_CopyPic')
        # click the applist
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        self.assertTrue(self.d.press(0x8d))
        time.sleep(1)
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            fileButton.click()
            click_open_x = fileButton.info['visibleBounds']['right']
            click_open_y = fileButton.info['visibleBounds']['bottom'] +35
            self.d.click(click_open_x,click_open_y)
            time.sleep(1)
            customer=self.d(resourceId='android:id/custom',className='android.widget.FrameLayout')
            self.d.drag(customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['bottom']-170,customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['top']+10,10)
            self.d.drag(customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['bottom']-170,customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['top']+10,10)
            fileName=self.d(resourceId='com.paint.board:id/filedialogitem_name',text='jpg.jpg')
            self.assertTrue(fileName.exists)
            file_x=fileName.info['visibleBounds']['left']+5
            file_y=fileName.info['visibleBounds']['top']+5
            self.d.click(file_x,file_y)
            #self.mouse.doubleclick(file_x, file_y, constants.MouseLeftKey)
            time.sleep(1)
            #self.d(resourceId='com.paint.board:id/filedialogitem_img',packageName='com.paint.board').click()
            self.d(text=u'打开',resourceId='com.paint.board:id/dia_postive').click()
            time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/t_tab',text='jpg.jpg').exists)
            self.assertTrue(self.d(resourceId='com.paint.board:id/paint_view').exists)
            paint_board=self.d(resourceId='com.paint.board:id/paint_view')
            choose_button=self.d(resourceId='com.paint.board:id/b_choose',packageName='com.paint.board')
            choose_button.click()
            self.d.click(choose_button.info['visibleBounds']['right'],choose_button.info['visibleBounds']['bottom']+10)
            time.sleep(1)
#             swipe_start_x=paint_board.info['visibleBounds']['left']+50
#             swipe_start_y=paint_board.info['visibleBounds']['top']+50
#             swipe_end_x=swipe_start_x + 200
#             swipe_end_y=swipe_start_y + 200
            self.d.swipe(500,500,750,750,10)
            time.sleep(1)
            editButton.click()
            self.d.click(editButton.info['visibleBounds']['right'],editButton.info['visibleBounds']['bottom']+40)
            fileButton.click()
            time.sleep(1)
            self.d.click(fileButton.info['visibleBounds']['right'],fileButton.info['visibleBounds']['bottom']+10)
            editButton.click()
            time.sleep(1)
            self.d.click(editButton.info['visibleBounds']['right'],editButton.info['visibleBounds']['bottom']+60)
            time.sleep(1)
            BaseImg = os.path.join(self.BaseImagePath, "test_CopyPic.jpg")
            name = "test_CopyPic_%s.jpg" % time.strftime('%Y%m%d%H%M%S', time.localtime())
            img = os.path.join(self.TmpImagePath, name)
            self.d.screenshot(img)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, 360,147,1560,1047)
            #比较上一步裁剪后的图片与基准图片
            if not CompareImage(cropedImgPath, BaseImg, 0.5):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
                self.fail("The failure file path is %s" % path)
            self.assertTrue(self.d.press(0x8d))
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        logger.info('Exit -- MUAT:PaintTest:test_CopyPic')
         
    def test_CutPic(self):
        logger.info('Enter -- MUAT:PaintTest:test_CutPic')
        # click the applist
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        self.assertTrue(self.d.press(0x8d))
        time.sleep(1)
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            fileButton.click()
            click_new_x = fileButton.info['visibleBounds']['right']
            click_new_y = fileButton.info['visibleBounds']['bottom'] +35
            self.d.click(click_new_x,click_new_y)
            time.sleep(1)
            customer=self.d(resourceId='android:id/custom',className='android.widget.FrameLayout')
            self.d.drag(customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['bottom']-170,customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['top']+10,10)
            self.d.drag(customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['bottom']-170,customer.info['visibleBounds']['right']-100,customer.info['visibleBounds']['top']+10,10)
            fileName=self.d(resourceId='com.paint.board:id/filedialogitem_name',text='jpg.jpg')
            self.assertTrue(fileName.exists)
            file_x=fileName.info['visibleBounds']['left']+5
            file_y=fileName.info['visibleBounds']['top']+5
            self.d.click(file_x,file_y)
            #self.mouse.doubleclick(file_x, file_y, constants.MouseLeftKey)
            time.sleep(1)
            #self.d(resourceId='com.paint.board:id/filedialogitem_img',packageName='com.paint.board').click()
            self.d(text=u'打开',resourceId='com.paint.board:id/dia_postive').click()
            time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/t_tab',text='jpg.jpg').exists)
            self.assertTrue(self.d(resourceId='com.paint.board:id/paint_view').exists)
            paint_board=self.d(resourceId='com.paint.board:id/paint_view')
            choose_button=self.d(resourceId='com.paint.board:id/b_choose',packageName='com.paint.board')
            choose_button.click()
            self.d.click(choose_button.info['visibleBounds']['right'],choose_button.info['visibleBounds']['bottom']+10)
            time.sleep(1)
#             swipe_start_x=paint_board.info['visibleBounds']['left']+50
#             swipe_start_y=paint_board.info['visibleBounds']['top']+50
#             swipe_end_x=swipe_start_x + 200
#             swipe_end_y=swipe_start_y + 200
            self.d.swipe(500,500,750,750,10)
            time.sleep(1)
            editButton.click()
            self.d.click(editButton.info['visibleBounds']['right'],editButton.info['visibleBounds']['bottom']+10)
            time.sleep(1)
            BaseImg = os.path.join(self.BaseImagePath, "test_CutPic.jpg")
            name = "test_CutPic_%s.jpg" % time.strftime('%Y%m%d%H%M%S', time.localtime())
            img = os.path.join(self.TmpImagePath, name)
            self.d.screenshot(img)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, 360,147,1560,1047)
            #比较上一步裁剪后的图片与基准图片
            if not CompareImage(cropedImgPath, BaseImg, 0.5):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
                self.fail("The failure file path is %s" % path)
            self.assertTrue(self.d.press(0x8d))
                 
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        logger.info('Exit -- MUAT:PaintTest:test_CutPic')
        
    def test_Pen(self):
        logger.info('Enter -- MUAT:PaintTest:test_Pen')
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            fileButton.click()
            click_new_x = editButton.info['visibleBounds']['left']
            click_new_y = editButton.info['visibleBounds']['bottom'] +10
            self.d.click(click_new_x,click_new_y)
            #time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/paint_view').exists)
            pencil=self.d(resourceId='com.paint.board:id/b_status',packageName='com.paint.board')
            pencil.click()
            time.sleep(1)
            #choose pencil
            choose_pencil_x=pencil.info['visibleBounds']['right']
            choose_pencil_y=pencil.info['visibleBounds']['bottom']+74
            self.d.click(choose_pencil_x,choose_pencil_y)
            time.sleep(1)
            paint_board=self.d(resourceId='com.paint.board:id/paint_view')
            swipe_start_x=paint_board.info['visibleBounds']['left']+50
            swipe_start_y=paint_board.info['visibleBounds']['top']+50
            swipe_end_x=swipe_start_x + 200
            swipe_end_y=swipe_start_y + 200
            self.d.swipe(swipe_start_x,swipe_start_y,swipe_end_x,swipe_end_y,20)
            time.sleep(0.5)
            #compare cutpic with baseimage
            BaseImg = os.path.join(self.BaseImagePath, "test_Pencil.jpg")
            name = "test_Pencil_%s.jpg" % time.strftime('%Y%m%d%H%M%S', time.localtime())
            img = os.path.join(self.TmpImagePath, name)
            self.d.screenshot(img)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, paint_board.info['visibleBounds']['left'],paint_board.info['visibleBounds']['top'],paint_board.info['visibleBounds']['right'],paint_board.info['visibleBounds']['bottom'])
            if not CompareImage(cropedImgPath, BaseImg, 0.9):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
                self.fail("The failure file path is %s" % path)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        logger.info('Exit -- MUAT:PaintTest:test_Pen')
        
    def test_FullScreen(self):
        logger.info('Enter -- MUAT:PaintTest:test_FullScreen')
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        self.assertTrue(self.d.press(0x8d))
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            fileButton.click()
            click_new_x = editButton.info['visibleBounds']['left']
            click_new_y = editButton.info['visibleBounds']['bottom'] +10
            self.d.click(click_new_x,click_new_y)
            #time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/paint_view').exists)
        self.assertTrue(self.d.press(0x8d))
        self.assertTrue(PaintWindow.exists)
        
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        logger.info('Exit -- MUAT:PaintTest:test_FullScreen')
        
    def test_InsertText(self):
        logger.info('Enter -- MUAT:PaintTest:test_InsertText')
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            fileButton.click()
            click_new_x = editButton.info['visibleBounds']['left']
            click_new_y = editButton.info['visibleBounds']['bottom'] +10
            self.d.click(click_new_x,click_new_y)
            #time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/paint_view').exists)
            self.d(resourceId='com.paint.board:id/b_7',packageName='com.paint.board').click()
            paint_board=self.d(resourceId='com.paint.board:id/paint_view')
            drag_start_x=paint_board.info['visibleBounds']['left']+50
            drag_start_y=paint_board.info['visibleBounds']['top']+50
            drag_end_x=drag_start_x + 200
            drag_end_y=drag_start_y + 200
            self.d.drag(drag_start_x,drag_start_y,drag_end_x,drag_end_y,20)
            time.sleep(0.5)
            self.d.click(drag_start_x + 5,drag_start_y + 5)
            time.sleep(1)
            self.d.press(48)
            self.d.press(48)
            self.d.press(62)
            self.d.click(drag_end_x,drag_end_y)
            time.sleep(1)
            #compare cutpic with baseimage
            BaseImg = os.path.join(self.BaseImagePath, "test_Paint_Text.jpg")
            name = "test_Paint_Text_%s.jpg" % time.strftime('%Y%m%d%H%M%S', time.localtime())
            img = os.path.join(self.TmpImagePath, name)
            self.d.screenshot(img)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, paint_board.info['visibleBounds']['left'],paint_board.info['visibleBounds']['top'],paint_board.info['visibleBounds']['right'],paint_board.info['visibleBounds']['bottom'])
            if not CompareImage(cropedImgPath, BaseImg, 0.9):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
                self.fail("The failure file path is %s" % path)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            logger.info('Exit -- MUAT:PaintTest:test_InsertText')
            
    def test_DrawCircle(self):
        logger.info('Enter -- MUAT:PaintTest:test_DrawCircle')
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        paint=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text=u'画图')
        click_x = paint.info['visibleBounds']['left'] +5
        click_y = paint.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        time.sleep(2)
        PaintWindow=self.d(resourceId='android:id/pc_title',packageName='com.paint.board')
        if not PaintWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertTrue(PaintWindow.exists)
        fileButton=self.d(resourceId='com.paint.board:id/b_file',text=u'文件')
        editButton=self.d(resourceId='com.paint.board:id/b_edit',text=u'编辑')
        if fileButton.exists:
            fileButton.click()
            click_new_x = editButton.info['visibleBounds']['left']
            click_new_y = editButton.info['visibleBounds']['bottom'] +10
            self.d.click(click_new_x,click_new_y)
            #time.sleep(1)
            self.assertTrue(self.d(resourceId='com.paint.board:id/paint_view').exists)
            circle_button=self.d(resourceId='com.paint.board:id/b_shape',packageName='com.paint.board')
            circle_button.click()
            self.d.click(circle_button.info['visibleBounds']['right']+10,circle_button.info['visibleBounds']['bottom']+10)
            time.sleep(0.5)
            paint_board=self.d(resourceId='com.paint.board:id/paint_view')
            swipe_start_x=paint_board.info['visibleBounds']['left']+50
            swipe_start_y=paint_board.info['visibleBounds']['top']+50
            swipe_end_x=swipe_start_x + 200
            swipe_end_y=swipe_start_y + 200
            self.d.swipe(swipe_start_x,swipe_start_y,swipe_end_x,swipe_end_y,20)
            time.sleep(0.5)
            #compare cutpic with baseimage
            BaseImg = os.path.join(self.BaseImagePath, "test_Circle.jpg")
            name = "test_Circle_%s.jpg" % time.strftime('%Y%m%d%H%M%S', time.localtime())
            img = os.path.join(self.TmpImagePath, name)
            self.d.screenshot(img)
            cropedImgPath = os.path.join(self.TmpImagePath, "croped", name.replace(".jpg", "_croped.jpg"))
            CropImage(img, cropedImgPath, paint_board.info['visibleBounds']['left'],paint_board.info['visibleBounds']['top'],paint_board.info['visibleBounds']['right'],paint_board.info['visibleBounds']['bottom'])
            if not CompareImage(cropedImgPath, BaseImg, 0.9):
                shutil.copy(cropedImgPath, os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg")))
                path = os.path.join(self.FailureIamgePath, name.replace(".jpg", "_failure.jpg"))
                self.fail("The failure file path is %s" % path)
        
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.paint.board")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            logger.info('Exit -- MUAT:PaintTest:test_DrawCircle')
コード例 #6
0
class StressVdiTest(ParametrizedTestCase):
    def setUp(self):
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest('process monitor stop')

        self.d      = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.adb_tools = AdbTools()
        self.mouse = AdbMouse()

        self.account.sleep()
        self.account.wakeup()
        self.account.login()
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.yunos.acdp")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()

    def tearDown(self):
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.yunos.acdp")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        self.account.sleep()

    def test_LoginWin7(self):
        logger.info('Enter -- MUAT:StressVdiTest:test_LoginWin7')
   
        # open yunpc application
        YunPCIcon = self.d(text=u"云PC", className="android.widget.TextView")
        click_x = YunPCIcon.info['visibleBounds']['left'] +5
        click_y = YunPCIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        logger.info('StressVdiTest:test_LoginWin7: open yunpc application')
        time.sleep(2)
         
        YunPCWindow = self.d(className="android.widget.FrameLayout", packageName="com.yunos.acdp")
        self.assertTrue(YunPCWindow.exists)
        
        for cnt in range(2):
            if YunPCWindow.exists:
                # click the bg image enter Win7 login page
                VMWindow= self.d(resourceId="com.yunos.acdp:id/yunpc_bg", className="android.widget.LinearLayout", packageName="com.yunos.acdp")
                click_x= (VMWindow.info['visibleBounds']['left'] + VMWindow.info['visibleBounds']['right']) / 2
                click_y= (VMWindow.info['visibleBounds']['top'] + VMWindow.info['visibleBounds']['bottom']) / 2
                self.mouse.click(click_x, click_y, constants.MouseLeftKey)
                time.sleep(4)
                 
#                 # login Win7
#                 CanvasPage= self.d(resourceId="com.yunos.acdp:id/vnc_canvas", className="android.view.View", packageName="com.yunos.acdp")
#                 # enter passws
#                 CanvasPage.set_text(constants.TEST_PASSWD)
#                 time.sleep(1)
                
    
#                 # click login, enter button offset (930, 560)
#                 click_x= CanvasPage.info['visibleBounds']['left'] + 930
#                 click_y= CanvasPage.info['visibleBounds']['top'] + 560
#                 self.mouse.click(click_x, click_y, constants.MouseLeftKey)
#                 time.sleep(4)
                # screenshot for check
                name = '%s-%s.png' % (time.strftime('%Y%m%d%H%M%S', time.localtime()), cnt)
                logger.info('StressVdiTest:test_LoginWin7: screen shot name: (%s)' % (name))
                self.d.screenshot('%s-%s.png' % (time.strftime('%Y%m%d%H%M%S', time.localtime()), cnt))
                
                self.d.press(0x84, 0x1000|0x02)
                time.sleep(1)

        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.yunos.acdp")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()

        logger.info('Exit -- MUAT:StressVdiTest:test_LoginWin7')
コード例 #7
0
class BrowserProTest(ParametrizedTestCase):
    def setUp(self):
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest('process monitor stop')

        self.d      = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.mouse = AdbMouse()
        self.adb_tools = AdbTools()
        
        self.BaseImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "dependency", "BaseImage")
        self.FailureIamgePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "FailureImage")
        self.TmpImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "TmpImage")
        
        if not os.path.exists(self.TmpImagePath):
            os.mkdir(self.TmpImagePath)
        if not os.path.exists(os.path.join(self.TmpImagePath, "croped")):
            os.mkdir(os.path.join(self.TmpImagePath, "croped"))

        self.account.sleep()
        self.account.wakeup()
        self.account.login()
        Button1=self.d(resourceId='com.yunpc.yunosloginui:id/avatar')
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if not Button1.exists:
                break
            else:
                time.sleep(1)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="org.chromium.chrome")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
        self.adb_tools.adb_shell('am force-stop org.chromium.chrome')
        #time.sleep(3)
        
        Browser_Icon = self.d(text=u"浏览器",resourceId='com.aliyun.lightdesk:id/tag_name', className="android.widget.TextView")
        if not Browser_Icon.exists:
#             self.d.click(57,10)
#             time.sleep(1)
#             self.d.click(68,141)
#             start=time.time()
#             while time.time()-start<constants.Time_Out:
#                 if  Button1.exists:
#                     break
#                 else:
#                     time.sleep(1)

            if self.mon and not self.mon.running_status:
                self.skipTest('process monitor stop')

            self.d      = AutomationDevice().get_device()
            self.account = Account(self.d)
            self.mouse = AdbMouse()
            self.adb_tools = AdbTools()
        
            self.BaseImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "dependency", "BaseImage")
            self.FailureIamgePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "FailureImage")
            self.TmpImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "TmpImage")
        
            if not os.path.exists(self.TmpImagePath):
                os.mkdir(self.TmpImagePath)
            if not os.path.exists(os.path.join(self.TmpImagePath, "croped")):
                os.mkdir(os.path.join(self.TmpImagePath, "croped"))

            self.account.wakeup()
            self.account.login()
            Button1=self.d(resourceId='com.yunpc.yunosloginui:id/avatar')
            start=time.time()
            while time.time()-start<constants.Time_Out:
                if not Button1.exists:
                    break
                else:
                    time.sleep(1)
            #time.sleep(5)
            self.d.click(950,562)
            time.sleep(1)
            Button1=self.d(resourceId='android:id/button1',className='android.widget.Button',packageName='android')
            if Button1.exists:
                Button1.click()
            time.sleep(1)
            if not Browser_Icon.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(Browser_Icon.exists)

    def tearDown(self):
        Button1=self.d(resourceId='android:id/button1',className='android.widget.Button',packageName='android')
        if Button1.exists:
            Button1.click()
            self.adb_tools.adb_shell('am start -n org.chromium.chrome/.browser.ChromeTabbedActivity')
            start=time.time()
            while time.time()-start<constants.Time_Out:
                if  self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="org.chromium.chrome").exists:
                    break
                else:
                    time.sleep(1)
        
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="org.chromium.chrome")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            time.sleep(1)
        if closeButton.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
        self.assertFalse(closeButton.exists)
        self.adb_tools.adb_shell('am force-stop org.chromium.chrome')
        if os.path.exists(self.TmpImagePath):
            shutil.rmtree(self.TmpImagePath)
            
    def test_CostTime(self):
        logger.info('Enter -- MUAT:BrowserTest:test_CostTime')
        BrowserIcon = self.d(text=u"浏览器", resourceId='com.aliyun.lightdesk:id/tag_name',className="android.widget.TextView")
        if not BrowserIcon.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserIcon.exists)
        click_x = BrowserIcon.info['visibleBounds']['left'] +5
        click_y = BrowserIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if  self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome").exists:
                break
            else:
                time.sleep(1)
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            maxButton = self.d(resourceId="android:id/pc_max", className="android.widget.ImageView", packageName="org.chromium.chrome")
            logger.debug('click max button: (%s)' % (maxButton.info['packageName']))
            maxButton.click()
            blankpage = self.d(resourceId="org.chromium.chrome:id/ntp_scrollview")
            if blankpage.exists:
                self.assertEqual(blankpage.info['contentDescription'], u"打开新的标签页")
            address = self.d(resourceId="org.chromium.chrome:id/url_bar")
            if address.exists:
                self.assertEqual(address.info['text'], u"搜索或输入网址")
#                 address.clear_text()
#                 address.set_text("www.taobao.com")
#                 self.d.press(0x42)
                MenuButton=self.d(resourceId='org.chromium.chrome:id/menu_button',packageName='org.chromium.chrome')
                if MenuButton.exists:
                    MenuButton.click()
                    time.sleep(1)
                    self.d(resourceId='org.chromium.chrome:id/menu_item_text',packageName='org.chromium.chrome').click()
                    BookMark=self.d(resourceId='org.chromium.chrome:id/highlight')
                    if BookMark.exists:
                        BookMark.click()
                        time.sleep(1)
                StopButton=self.d(description=u'停止加载网页',resourceId='org.chromium.chrome:id/refresh_button')
                start=time.time()
                while time.time()-start<constants.TIME_OUT:
                    if not StopButton.exists:
                        break
                    else:
                        time.sleep(0.5)
                logger.info( time.time()-start)
                 
            closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="org.chromium.chrome")
            if closeButton.exists:
                logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
                closeButton.click()
        logger.info('Exit -- MUAT:BrowserTest:test_CostTime')
         
        
    def test_Fps(self):
        logger.info('Enter -- MUAT:BrowserTest:test_Fps')
        BrowserIcon = self.d(text=u"浏览器", resourceId='com.aliyun.lightdesk:id/tag_name',className="android.widget.TextView")
        if not BrowserIcon.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserIcon.exists)
        click_x = BrowserIcon.info['visibleBounds']['left'] +5
        click_y = BrowserIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if  self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome").exists:
                break
            else:
                time.sleep(1)
        BrowserWindow = self.d(className="android.widget.FrameLayout", packageName="org.chromium.chrome")
        if not BrowserWindow.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(BrowserWindow.exists)
        if BrowserWindow.exists:
            maxButton = self.d(resourceId="android:id/pc_max", className="android.widget.ImageView", packageName="org.chromium.chrome")
            logger.debug('click max button: (%s)' % (maxButton.info['packageName']))
            maxButton.click()
            blankpage = self.d(resourceId="org.chromium.chrome:id/ntp_scrollview")
            if blankpage.exists:
                self.assertEqual(blankpage.info['contentDescription'], u"打开新的标签页")
            address = self.d(resourceId="org.chromium.chrome:id/url_bar")
            if address.exists:
                self.assertEqual(address.info['text'], u"搜索或输入网址")
                MenuButton=self.d(resourceId='org.chromium.chrome:id/menu_button',packageName='org.chromium.chrome')
                if MenuButton.exists:
                    MenuButton.click()
                    time.sleep(1)
                    self.d(resourceId='org.chromium.chrome:id/menu_item_text',packageName='org.chromium.chrome').click()
                    BookMark=self.d(resourceId='org.chromium.chrome:id/highlight')
                    if BookMark.exists:
                        BookMark.click()
                        time.sleep(1)
                StopButton=self.d(description=u'停止加载网页',resourceId='org.chromium.chrome:id/refresh_button')
                start=time.time()
                while time.time()-start<constants.TIME_OUT:
                    if not StopButton.exists:
                        break
                    else:
                        time.sleep(0.5)
                detect_re = re.compile(r'D.UIAutomatorStub.*swipe')
                wanted_re = re.compile(r'MPT: sf post one frame at (.*)$')
                adb_log = AdbLog(mode=AdbLog.MODE_RE | AdbLog.MODE_NEED_DETECT | AdbLog.MODE_NEED_CONTINUE, wanted_re=wanted_re, detect_re=detect_re, logger=logger)
                adb_log.clear()
                adb_log.start()
                self.d.swipe(200,900,200,500)
                 
                self.mouse.wheel(860,500,constants.MouseWheelDown,70,5)
                self.mouse.wheel(860,500,constants.MouseWheelUp,60,5)
                # check the log and get the data
                while True:
                    if adb_log.result and len(adb_log.result) >= 3:
                        break
                    else:
                        time.sleep(1)
                adb_log.stop_log()
                adb_log.join()
 
                # store the result
                start_time = 0
                end_time = 0
                fps = 0
                try:
                    length = len(adb_log.result)
                    if length >=3:
                        start_time      = int(adb_log.result[1][0])
                        end_time        = int(adb_log.result[-1][0])
                        fps             = (length - 1) * 1000 / (end_time - start_time)
                    else:
                        logger.error('not enough data for calc fps: (%s)' % (adb_log.result))
                except:
                    logger.error('retrieve time from (%s) error' % (adb_log.result))
 
                logger.info('wheel taobao page fps: %s' % ( fps))
#                 baiduPage = self.d(className="android.webkit.WebView", packageName="org.chromium.chrome")
#                 if baiduPage.exists:
#                     self.assertEqual(baiduPage.info['contentDescription'], u'百度一下,你就知道')
                                
            closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="org.chromium.chrome")
            if closeButton.exists:
                logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
                closeButton.click()
        logger.info('Exit -- MUAT:BrowserTest:test_Fps')
        
    def test_Open16Tab(self):
        logger.info('Enter -- MUAT:ChromeTest:test_Open16Tab')
        
        #open chrome
        self.adb_tools.adb_shell("am start -n org.chromium.chrome/com.google.android.apps.chrome.Main")
        time.sleep(3)
        pc_max = self.d(resourceId='android:id/pc_max', className='android.widget.ImageView', packageName='org.chromium.chrome')
        pc_max.click()
        time.sleep(2)
        menuButton=self.d(resourceId='org.chromium.chrome:id/menu_button',packageName='org.chromium.chrome')
        menuButton.click()
        records=self.d(text=u"历史记录",packageName='org.chromium.chrome')
        records.click()
       
        for i in range(16):
            self.mouse.click(830,430,constants.MouseRightKey)
            self.mouse.click(890,460,constants.MouseLeftKey)
            time.sleep(1)
        str ='after open chrome 16 tab...\n' 
        getcpuinfo(str)
        #close chrome
        closebtn = self.d(resourceId='android:id/pc_close', className='android.widget.ImageView', packageName='org.chromium.chrome')
        closebtn.click()

        logger.info('Exit -- MUAT:ChromeTest:test_OpenChromeTab')
        
    def test_LanchTask(self):
        logger.info('Enter -- MUAT:ChromeTest:test_LanchTask')
        serial_number = None
        if self.param and self.param.parameters and self.param.parameters.serial_number:
            serial_number = self.param.parameters.serial_number
        #open chrome
        self.adb_tools.adb_shell("am start -n org.chromium.chrome/com.google.android.apps.chrome.Main")
        time.sleep(3)
        pc_max = self.d(resourceId='android:id/pc_max', className='android.widget.ImageView', packageName='org.chromium.chrome')
        self.assertTrue(pc_max.exists)
        pc_max.click()
        time.sleep(2)
        menuButton=self.d(resourceId='org.chromium.chrome:id/menu_button',packageName='org.chromium.chrome')
        menuButton.click()
        records=self.d(text=u"历史记录",packageName='org.chromium.chrome')
        records.click()
       
        for i in range(16):
            self.mouse.click(830,430,constants.MouseRightKey)
            self.mouse.click(890,460,constants.MouseLeftKey)
            time.sleep(1)
        str ='lanch taskmgr after open chrome 16 tab...\n' 
        getcpuinfo(str)
            
        wanted_re = re.compile(r'I.ActivityManager.*com.aliyun.mpc.taskmgr.*\+(.*)ms' )
        adb_log = AdbLog(mode=AdbLog.MODE_RE, wanted_re=wanted_re, logger=logger, serial_number=serial_number)
        adb_log.clear()
        adb_log.start()

        # start apk
        self.adb_tools.adb_shell('am start -n  com.aliyun.mpc.taskmgr/.TaskMgr')
        
        # check the log and get the data
        while True:
            if adb_log.result:
                break
            else:
                time.sleep(1)
        # store the result
        cost_time = 0
        try:
            if 's' in adb_log.result[0][0]:
                composit = adb_log.result[0][0].split('s')
                cost_time = int(composit[0]) * 1000 + int(composit[1])
            else:
                cost_time = int(adb_log.result[0][0])
        except:
            logger.error('retrieve cost time from (%s) error' % (adb_log.result))
        
        logger.info('start TaskMgr cost: %s' % (cost_time))
        # close apk
        self.adb_tools.adb_shell('am force-stop com.aliyun.mpc.taskmgr')
        #close chrome
        closebtn = self.d(resourceId='android:id/pc_close', className='android.widget.ImageView', packageName='org.chromium.chrome')
        closebtn.click()

        logger.info('Exit -- MUAT:ChromeTest:test_LanchTask')
        
    def test_LanchApplist(self):
        logger.info('Enter -- MUAT:ChromeTest:test_LanchApplist')
        serial_number = None
        if self.param and self.param.parameters and self.param.parameters.serial_number:
            serial_number = self.param.parameters.serial_number
        #open chrome
        self.adb_tools.adb_shell("am start -n org.chromium.chrome/com.google.android.apps.chrome.Main")
        time.sleep(3)
        pc_max = self.d(resourceId='android:id/pc_max', className='android.widget.ImageView', packageName='org.chromium.chrome')
        pc_max.click()
        time.sleep(2)
        menuButton=self.d(resourceId='org.chromium.chrome:id/menu_button',packageName='org.chromium.chrome')
        menuButton.click()
        records=self.d(text=u"历史记录",packageName='org.chromium.chrome')
        records.click()
        # 从历史记录中打开网页
        for i in range(16):
            self.mouse.click(830,430,constants.MouseRightKey)
            self.mouse.click(890,460,constants.MouseLeftKey)
            time.sleep(1)
        str ='lanch applist after open chrome 16 tab...\n' 
        getcpuinfo(str)
            
        # click blank region to disappear applist
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(1)

        # start adb log capture thread
        detect_re = re.compile(r'MPT click .(%s), (%s). at (.*)$' % (constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y))
        wanted_re = re.compile(r'MPT: sf post one frame at (.*)$')

        adb_log = AdbLog(mode=AdbLog.MODE_RE | AdbLog.MODE_NEED_DETECT, wanted_re=wanted_re, detect_re=detect_re, logger=logger, serial_number=serial_number)
        adb_log.clear()
        adb_log.start()

        # click app list
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        logger.debug('click applist point (%s,%s)' % (constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y))
        time.sleep(2)

        # check the log and get the data
        while True:
            if len(adb_log.result) == 2:
                break
            else:
                time.sleep(1)

        # store the result
        click_point_x = 0
        click_point_y = 0
        start_time = 0
        end_time = 0
        cost_time = 0
        try:
            click_point_x   = int(adb_log.result[0][0])
            click_point_y   = int(adb_log.result[0][1])
            start_time      = int(adb_log.result[0][2])
            end_time        = int(adb_log.result[1][0])
            if click_point_x == constants.MUAT_APP_LIST_POINT_X and click_point_y == constants.MUAT_APP_LIST_POINT_Y:
                cost_time = end_time - start_time
            else:
                logger.error('detect_re detect the wrong point: (%s)' % (adb_log.result[0]))
        except:
            logger.error('retrieve time from (%s) error' % (adb_log.result))

        logger.info('start applist cost: %s' % (cost_time))
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(1)
        #close chrome
        closebtn = self.d(resourceId='android:id/pc_close', className='android.widget.ImageView', packageName='org.chromium.chrome')
        closebtn.click()
        logger.info('Exit -- MUAT:ChromeTest:test_LanchApplist')
        
    def test_Open10AppTab(self):
        logger.info('Enter -- MUAT:ChromeTest:test_Open10AppTab')
        serial_number = None
        if self.param and self.param.parameters and self.param.parameters.serial_number:
            serial_number = self.param.parameters.serial_number
        
        #open youku
        self.adb_tools.adb_shell('am start -n com.youku.phone.x86/com.youku.phone.x86.ActivityWelcome')
        time.sleep(3)
        #open ttpod
        logger.info('open the ttpod application................')
        self.adb_tools.adb_shell("am start -n com.sds.android.ttpod/.EntryActivity")
        time.sleep(3)
        #open QQ
        logger.info('open QQ application.......................')
        self.adb_tools.adb_shell("am start -n com.tencent.mobileqq/.activity.SplashActivity")
        time.sleep(3)
        #open xiami
        logger.info('open xiami application.......................')
        self.adb_tools.adb_shell("am start -n fm.xiami.main/fm.xiami.bmamba.activity.StartMainActivity")
        time.sleep(3)
        #open qianniu
        logger.info('open qianniiu application.......................')
        self.adb_tools.adb_shell('am start -n com.taobao.qianniu/.ui.InitActivity')
        time.sleep(3)
        #open weibo
        logger.info('open weibo application.......................')
        self.adb_tools.adb_shell('am start -n com.sina.weibotab/.ui.ActivitySplash')
        time.sleep(3)
        #open wps_pro
        logger.info('open wps application.......................')
        self.adb_tools.adb_shell("am start -n com.kingsoft.moffice_pro/cn.wps.moffice.documentmanager.PreStartActivity")
        time.sleep(3)
        #open gaode map
        logger.info('open minimap application.......................')
        self.adb_tools.adb_shell("am start -n com.autonavi.minimap/.Splashy")
        time.sleep(3)
        #open wangxin
        logger.info('open mobileim application.......................')
        self.adb_tools.adb_shell("am start -n com.alibaba.mobileim/.SplashActivity")
        time.sleep(3)
        #open taobao
        logger.info('open taobaoHD application.......................')
        self.adb_tools.adb_shell("am start -n com.taobao.apad/.activity.MainActivity")
        time.sleep(3)
        #open chrome
        self.adb_tools.adb_shell("am start -n org.chromium.chrome/com.google.android.apps.chrome.Main")
        time.sleep(3)
        pc_max = self.d(resourceId='android:id/pc_max', className='android.widget.ImageView', packageName='org.chromium.chrome')
        self.assertTrue(pc_max.exists)
        pc_max.click()
        time.sleep(2)
        menuButton=self.d(resourceId='org.chromium.chrome:id/menu_button',packageName='org.chromium.chrome')
        menuButton.click()
        records=self.d(text=u"历史记录",packageName='org.chromium.chrome')
        records.click()
        for i in range(16):
            self.mouse.click(830,430,constants.MouseRightKey)
            self.mouse.click(890,460,constants.MouseLeftKey)
            time.sleep(1)
        str ='after 10Apps open chrome 16 tab...\n' 
        getcpuinfo(str)
        #记录打开applist的时间
         # click blank region to disappear applist
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(1)
        # start adb log capture thread
        detect_re = re.compile(r'MPT click .(%s), (%s). at (.*)$' % (constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y))
        wanted_re = re.compile(r'MPT: sf post one frame at (.*)$')

        adb_log = AdbLog(mode=AdbLog.MODE_RE | AdbLog.MODE_NEED_DETECT, wanted_re=wanted_re, detect_re=detect_re, logger=logger, serial_number=serial_number)
        adb_log.clear()
        adb_log.start()

        # click app list
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        logger.debug('click applist point (%s,%s)' % (constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y))
        time.sleep(2)

        # check the log and get the data
        while True:
            if len(adb_log.result) == 2:
                break
            else:
                time.sleep(1)

        # store the result
        click_point_x = 0
        click_point_y = 0
        start_time = 0
        end_time = 0
        cost_time = 0
        try:
            click_point_x   = int(adb_log.result[0][0])
            click_point_y   = int(adb_log.result[0][1])
            start_time      = int(adb_log.result[0][2])
            end_time        = int(adb_log.result[1][0])
            if click_point_x == constants.MUAT_APP_LIST_POINT_X and click_point_y == constants.MUAT_APP_LIST_POINT_Y:
                cost_time = end_time - start_time
            else:
                logger.error('detect_re detect the wrong point: (%s)' % (adb_log.result[0]))
        except:
            logger.error('retrieve time from (%s) error' % (adb_log.result))

        logger.info('after 10Apps start applist cost: %s' % (cost_time))
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        wanted_re = re.compile(r'I.ActivityManager.*com.aliyun.mpc.taskmgr.*\+(.*)ms' )
        adb_log = AdbLog(mode=AdbLog.MODE_RE, wanted_re=wanted_re, logger=logger, serial_number=serial_number)
        adb_log.clear()
        adb_log.start()
        
        #记录打开任务管理器的时间
        # start apk
        self.adb_tools.adb_shell('am start -n  com.aliyun.mpc.taskmgr/.TaskMgr')
        
        # check the log and get the data
        while True:
            if adb_log.result:
                break
            else:
                time.sleep(1)
        # store the result
        cost_time = 0
        try:
            if 's' in adb_log.result[0][0]:
                composit = adb_log.result[0][0].split('s')
                cost_time = int(composit[0]) * 1000 + int(composit[1])
            else:
                cost_time = int(adb_log.result[0][0])
        except:
            logger.error('retrieve cost time from (%s) error' % (adb_log.result))
        
        logger.info('after 10Apps start TaskMgr cost: %s' % (cost_time))
        # close apk
        self.adb_tools.adb_shell('am force-stop com.aliyun.mpc.taskmgr')
        
        #close youku
        logger.info('close the youku application................')
        self.adb_tools.adb_shell('am force-stop com.youku.phone.x86')
        time.sleep(2)
        #close ttpod
        logger.info('close the ttpod application................')
        self.adb_tools.adb_shell("am force-stop com.sds.android.ttpod")
        time.sleep(2)
        #close QQ
        logger.info('close QQ application.......................')
        self.adb_tools.adb_shell("am force-stop com.tencent.mobileqq")
        time.sleep(2)
        #close xiami
        logger.info('close xiami application.......................')
        self.adb_tools.adb_shell("am force-stop fm.xiami.main")
        time.sleep(2)
        #close qianniu
        logger.info('close qianniiu application.......................')
        self.adb_tools.adb_shell('am force-stop com.taobao.qianniu')
        time.sleep(2)
        #close weibo
        logger.info('close weibo application.......................')
        self.adb_tools.adb_shell('am force-stop com.sina.weibotab')
        time.sleep(2)
        #open wps_pro
        logger.info('close wps application.......................')
        self.adb_tools.adb_shell("am force-stop com.kingsoft.moffice_pro")
        time.sleep(2)
        #close gaode map
        logger.info('close minimap application.......................')
        self.adb_tools.adb_shell("am force-stop com.autonavi.minimap")
        time.sleep(2)
        #close wangxin
        logger.info('close mobileim application.......................')
        self.adb_tools.adb_shell("am force-stop com.alibaba.mobileim")
        time.sleep(2)
        #close taobao
        logger.info('close taobaoHD application.......................')
        self.adb_tools.adb_shell("am force-stop com.taobao.apad")
        time.sleep(2)
        #close chrome
        closebtn = self.d(resourceId='android:id/pc_close', className='android.widget.ImageView', packageName='org.chromium.chrome')
        closebtn.click()
        
        logger.info('Exit -- MUAT:ChromeTest:test_Open10AppTab')
        
        
        
        
        
        
        
        
        
        
        
コード例 #8
0
class MobileImTest(ParametrizedTestCase):

    def setUp(self):
        
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest('process monitor stop')

        self.d      = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.mouse = AdbMouse()
        self.adb_tools = AdbTools()

#         self.account.sleep()
#         self.account.wakeup()
        self.account.login()
        Button1=self.d(resourceId='com.yunpc.yunosloginui:id/avatar')
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if not Button1.exists:
                break
            else:
                time.sleep(1)
        self.adb_tools.adb_shell('am force-stop com.alibaba.mobileim')
        time.sleep(2)
        # self.adb_tools.adb_shell('am start -n com.alibaba.mobileim/com.alibaba.mobileim.ui.login.LoginActivity')
        self.adb_tools.adb_shell('am start -n com.alibaba.mobileim/.ui.tab.MainTabActivity')
#        /.ui.tab.MainTabActivity  /com.alibaba.mobileim.SplashActivity
        mobileimdialog = self.d(resourceId='android:id/pc_title', className='android.widget.TextView', packageName='com.alibaba.mobileim')
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if  mobileimdialog.exists:
                break
            else:
                time.sleep(1)
        if not mobileimdialog.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(mobileimdialog.exists)
        if mobileimdialog.exists:
            if self.d(resourceId="com.alibaba.mobileim:id/guide_image_one", className="android.widget.ImageView").exists:
                CustomViewPager = self.d(resourceId="com.alibaba.mobileim:id/container", className="com.alibaba.mobileim.fundamental.widget.CustomViewPager")
                if CustomViewPager.exsits:
                    #startX = CustomViewPager.info
                    logger.debug('CustomViewPager: (%s)' % (CustomViewPager.info['className']))
            else:
                #input wangxin login account:
                wx_account = self.d(resourceId="com.alibaba.mobileim:id/accountCompleteTextView", className="android.widget.EditText")
                if wx_account.exists and wx_account.info['text'] == constants.TEST_WX_USERNAME:
                    pass

                elif wx_account.exists and wx_account.info['text'] == u'淘宝帐号/手机号':
                    #self.assertEqual(wx_account.info['text'], u"淘宝帐号/手机号")
                    wx_account.clear_text()
                    time.sleep(2)
                    wx_account.set_text(constants.TEST_WX_USERNAME)
                    time.sleep(2)

                #input wangxin login password
                wx_password = self.d(resourceId="com.alibaba.mobileim:id/content", className="android.widget.EditText")
                if wx_password.exists:
                    # self.assertEqual(password.info['text'], u'密码')
                    wx_password.clear_text()
                    wx_password.set_text(constants.TEST_WX_PASSWD)
                    time.sleep(2)

                wx_loginbtn = self.d(resourceId="com.alibaba.mobileim:id/loginButton", className="android.widget.Button")
                if wx_loginbtn.exists:
                    self.assertEqual(wx_loginbtn.info['text'], u'登录')
                    wx_loginbtn.click()
                    #mobileimimg = self.d(resourceId='com.alibaba.mobileim:id/wxheadImage', className='android.widget.TextView', packageName='com.alibaba.mobileim')
                    start=time.time()
                    while time.time()-start<constants.Time_Out:
                        if self.d(resourceId='com.alibaba.mobileim:id/tab_me_text').exists:
                            break
                        else:
                            time.sleep(1)

                #whether update dialog appear, if click cancel button, if not run else operation
                if self.d(resourceId="com.alibaba.mobileim:id/pcenterPanel", className="android.widget.LinearLayout").exists:
                    update_cancelBtn = self.d(resourceId="com.alibaba.mobileim:id/button2", className="android.widget.Button")
                    if not update_cancelBtn.exists:
                        name = sys._getframe().f_code.co_name
                        screen_shot.ScreenShot(self,name)
                    self.assertTrue(update_cancelBtn.exists)
                    if update_cancelBtn.exists:
                        update_cancelBtn.click()
                        time.sleep(1)
  
    def test_SendMessage(self):
        logger.info('Enter -- MUAT:MobileImTest:test_SendMessage')
        tab_friends = self.d(resourceId="com.alibaba.mobileim:id/tab_friends_text", className="android.widget.ImageView")
        self.assertTrue(tab_friends.info["clickable"])
        if tab_friends.exists:
            tab_friends.click()
            time.sleep(1)
            FriendTag=self.d(resourceId='com.alibaba.mobileim:id/friends_layout',packageName='com.alibaba.mobileim')
            FriendTag.click()
            time.sleep(2)
            Friends=self.d(text='tb3489593',resourceId='com.alibaba.mobileim:id/select_name')
            self.assertTrue(Friends.exists)
            Friends.click()
            time.sleep(1)
            
            #进入发送消息对话框
            #check friend's ID
            chat_title = self.d(resourceId="com.alibaba.mobileim:id/chat_title", className="android.widget.TextView")
            self.assertEqual(chat_title.info['text'], constants.TEST_REMOTE_USERNAME)
            #send text message
            chat_inputtext = self.d(resourceId="com.alibaba.mobileim:id/chat_inputtext", className="android.widget.EditText")
            if not chat_inputtext.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(chat_inputtext.exists)
            if chat_inputtext.exists:
                chat_inputtext.click()
                chat_inputtext.clear_text()
                #切换输入法
#                 self.d.press(113,1)
  
                chat_inputtext.set_text("hello, nice to meet you ")
                time.sleep(1)
                if self.d(text="发送", className="android.widget.Button").exists:
                    self.d(text="发送", className="android.widget.Button").click()
                else:
                    logger.info(u"发送按钮不存在")
                    pass
            #send emotion image
            #进入表情选择界面
            reply_bar_expand = self.d(resourceId="com.alibaba.mobileim:id/reply_bar_expand", className="android.widget.CheckBox")
            if not reply_bar_expand.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(reply_bar_expand.exists)
            if reply_bar_expand.exists:
                reply_bar_expand.click()
                emotion = self.d(text=u"表情", className="android.widget.TextView")
                if not emotion.exists:
                    name = sys._getframe().f_code.co_name
                    screen_shot.ScreenShot(self,name)
                self.assertTrue(emotion.exists)
                if emotion.exists:
                    emotion.click()
                    time.sleep(1)
                    if self.d(text=u"阿里旺旺表情").exists:
                        self.d(text=u"阿里旺旺表情").click()
                        time.sleep(1)
                    # smily_scroller = self.d(resourceId="com.alibaba.mobileim:id/smily_scroller",className="android.widget.FrameLayout")
                    # if not smily_scroller.exists:
                    #     name = sys._getframe().f_code.co_name
                    #     screen_shot.ScreenShot(self,name)
                    # self.assertTrue(smily_scroller.exists)
                    # if smily_scroller.exists:
                    #     # 表情选取坐标起始值:Sx = 655 , Sy = 830 表情间距: Dx = 102, Dy = 55
                    #     Sx = 655
                    #     Sy = 830
                    #     Dx = 102
                    #     Dy = 55
                    #     # 表情页滑动起始和结束坐标点
                    #     startx = smily_scroller.info['visibleBounds']['left'] + 50
                    #     starty = smily_scroller.info['visibleBounds']['top'] + 80
                    #     endx = smily_scroller.info['visibleBounds']['left'] + 660
                    #     endy = starty
                    #
                    #     Nx = random.randint(0, 6)
                    #     Ny = random.randint(0, 2)
                    #     if Ny == 2 and Nx == 6:
                    #         Nx = Nx - 1
                    #     else:
                    #         pass
                    #
                    #     for i in range(random.randint(0, 4)):
                    #         self.d.drag(startx, starty, endx, endy, steps=10)
                    #         time.sleep(1)
                    #     self.d.click(Sx + Nx * Dx, Sy + Ny * Dy)
                    #
                        #select emotion
                        emotion_icon = self.d(resourceId='com.alibaba.mobileim:id/image', className='android.widget.ImageView')
                        self.assertTrue(emotion_icon.info['enabled'])
                        if emotion_icon.exists:
                            emotion_icon.click()
                            time.sleep(1)
                        if self.d(text="发送", className="android.widget.Button").exists:
                            self.d(text="发送", className="android.widget.Button").click()
                        else:
                            logger.info(u"发送按钮不存在")
                            pass
                    #淘公仔表情
                    if self.d(text="淘公仔表情", className="android.widget.RadioButton").exists:
                        self.d(text="淘公仔表情", className="android.widget.RadioButton").click()
                        smile_layout = self.d(resourceId="com.alibaba.mobileim:id/smile_layout", className="android.widget.LinearLayout")
                        if not smile_layout.exists:
                            name = sys._getframe().f_code.co_name
                            screen_shot.ScreenShot(self,name)
                        self.assertTrue(smile_layout.exists)
                        #logger.info("click the emotion.")
                        if smile_layout.exists:
                            time.sleep(1)
                            #获取第一个淘公仔的坐标点
                            x = smile_layout.info['visibleBounds']['left'] +80
                            y = smile_layout.info['visibleBounds']['top'] +40
                            self.d.click(x, y)
                            time.sleep(1)
            #返回主界面
            title_back = self.d(resourceId="com.alibaba.mobileim:id/title_back", className="android.widget.TextView")
            # self.assertTrue(title_back.info['clickable'])
            if title_back.exists:
                title_back.click()
                time.sleep(1)
                title_back.click()
                time.sleep(1)
 
        logger.info('Exit --  MUAT:MobileImTest:test_SendMessage')
  
    def test_SendtakePhoto(self):
        logger.info('Enter -- MUAT:MobileImTest:test_SendtakePhoto')
        #点击消息栏
        tab_message = self.d(resourceId="com.alibaba.mobileim:id/tab_message_text", className="android.widget.ImageView")
        # self.assertTrue(tab_message.info['enabled'])
        if tab_message.exists:
            tab_message.click()
            time.sleep(1)
            #查找历史消息找到wb-zhaoxinjian, 点击进入消息对话框
            friend = self.d(text=constants.TEST_REMOTE_USERNAME, resourceId="com.alibaba.mobileim:id/name", className="android.widget.TextView")
            if not friend.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(friend.exists)
            if friend.exists:
                friend.click()
                time.sleep(2)
            # else:
            #     #如果不存在则寻找另外的联系人
            #     pass
            #进入扩展选择界面,选择拍照发送
            reply_bar_expand = self.d(resourceId="com.alibaba.mobileim:id/reply_bar_expand", className="android.widget.CheckBox")
            if not reply_bar_expand.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(reply_bar_expand.exists)
            if reply_bar_expand.exists:
                reply_bar_expand.click()
                takepic = self.d(text=u"拍照", className="android.widget.TextView")
                if not takepic.exists:
                    name = sys._getframe().f_code.co_name
                    screen_shot.ScreenShot(self,name)
                self.assertTrue(takepic.exists)
                if takepic.exists:
                    takepic.click()
                    camera = self.d(resourceId="com.android.camera2:id/shutter_button", className="android.widget.ImageView", packageName="com.android.camera2")
                    start=time.time()
                    while time.time()-start<constants.Time_Out:
                        if  camera.exists:
                            break
                        else:
                            time.sleep(1)
                    #调用系统的相机拍摄照片
                    self.assertEqual(camera.info['contentDescription'], u'快门')
                    if camera.exists:
                        camera.click()
                        btn_done = self.d(resourceId="com.android.camera2:id/btn_done", className="android.widget.ImageView", packageName="com.android.camera2")
                        start=time.time()
                        while time.time()-start<constants.Time_Out:
                            if  btn_done.exists:
                                break
                            else:
                                time.sleep(1)
                        #确认完成拍照
                        self.assertEqual(btn_done.info['contentDescription'], u'完成')
                        if btn_done.exists:
                            btn_done.click()
                            btn_confirm = self.d(resourceId="com.alibaba.mobileim:id/confirm", className="android.widget.Button", packageName="com.alibaba.mobileim")
                            start=time.time()
                            while time.time()-start<constants.Time_Out:
                                if  btn_confirm.exists:
                                    break
                                else:
                                    time.sleep(1)
                            #点击确定按钮,发送照片
                            self.assertEqual(btn_confirm.info['text'], u'确定')
                            if btn_confirm.exists:
                                btn_confirm.click()
                                time.sleep(2)
            #返回主界面
            title_back = self.d(resourceId="com.alibaba.mobileim:id/title_back", className="android.widget.TextView")
            # self.assertTrue(title_back.info['clickable'])
            if title_back.exists:
                title_back.click()
                time.sleep(1)
                title_back.click()
                time.sleep(1)
  
  
        logger.info('Exit --  MUAT:MobileImTest:test_SendtakePhoto')
 
    def test_SendCard(self):
        logger.info('Enter -- MUAT:MobileImTest:test_SendCard')
        #点击消息栏
        tab_message = self.d(resourceId="com.alibaba.mobileim:id/tab_message_text", className="android.widget.ImageView")
        self.assertTrue(tab_message.info['enabled'])
        if tab_message.info['clickable']:
            tab_message.click()
            time.sleep(1)
            #查找历史消息找到wb-zhaoxinjian, 点击进入消息对话框
            friend = self.d(text=constants.TEST_REMOTE_USERNAME, resourceId="com.alibaba.mobileim:id/name", className="android.widget.TextView")
            if not friend.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(friend.exists)
            if friend.exists:
                friend.click()
                time.sleep(2)
            # else:
            #     #如果不存在则寻找另外的联系人
            #     pass
            #进入扩展选择界面,选择名片
            reply_bar_expand = self.d(resourceId="com.alibaba.mobileim:id/reply_bar_expand", className="android.widget.CheckBox")
            if not reply_bar_expand.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(reply_bar_expand.exists)
            if reply_bar_expand.exists:
                reply_bar_expand.click()
                card_btn = self.d(text=u"名片", className="android.widget.TextView")
                if not card_btn.exists:
                    name = sys._getframe().f_code.co_name
                    screen_shot.ScreenShot(self,name)
                self.assertTrue(card_btn.exists)
                if card_btn.exists:
                    card_btn.click()
                    time.sleep(3)
                    #进入选择好友界面,选择好友,并发送
                    wx_friends_btn = self.d(resourceId="com.alibaba.mobileim:id/wx_friends_button", className="android.widget.Button")
                    self.assertEqual(wx_friends_btn.info['text'], u'旺旺好友')
                    if wx_friends_btn.exists:
                        wx_friends_btn.click()
                        time.sleep(1)
                        #选择 景止、洗石、云渡
                        # self.d(text=u"景止").click()
                        self.d(text=u'旺信团队').click()
#                         time.sleep(1)
#                         self.d(text=u"洗石").click()
#                         time.sleep(1)
#                         self.d(text=u"云渡").click()
#                         time.sleep(1)
                        #点击确定按钮
                        startbtn = self.d(resourceId="com.alibaba.mobileim:id/start", className="android.widget.Button")
                        if not startbtn.exists:
                            name = sys._getframe().f_code.co_name
                            screen_shot.ScreenShot(self,name)
                        self.assertTrue(startbtn.exists)
                        if startbtn.exists:
                            startbtn.click()
                            time.sleep(1)
            #返回主界面
            # chat_back = self.d(resourceId="com.alibaba.mobileim:id/chat_back", className="android.widget.TextView")
            # self.assertTrue(chat_back.info['enabled'])
            # if chat_back.info['clickable']:
            #     chat_back.click()
            #     time.sleep(1)
            title_back = self.d(resourceId="com.alibaba.mobileim:id/title_back", className="android.widget.TextView")
            # self.assertTrue(title_back.info['clickable'])
            if title_back.exists:
                title_back.click()
                time.sleep(1)
                title_back.click()
                time.sleep(1)
 
        logger.info('Exit --  MUAT:MobileImTest:test_SendCard')
 
    def test_SendPicture(self):
        logger.info('Enter -- MUAT:MobileImTest:test_SendPicture')
        #点击消息栏
        tab_message = self.d(resourceId="com.alibaba.mobileim:id/tab_message_text", className="android.widget.ImageView")
        self.assertTrue(tab_message.info['enabled'])
        if tab_message.info['clickable']:
            tab_message.click()
            time.sleep(1)
            #查找历史消息找到wb-zhaoxinjian, 点击进入消息对话框
            friend = self.d(text=constants.TEST_REMOTE_USERNAME, resourceId="com.alibaba.mobileim:id/name", className="android.widget.TextView")
            if not friend.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(friend.exists)
            if friend.exists:
                friend.click()
                time.sleep(2)
            PlusButton = self.d(resourceId="com.alibaba.mobileim:id/reply_bar_expand", className="android.widget.CheckBox")
            if not PlusButton.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(PlusButton.exists)
            if PlusButton.exists:
                PlusButton.click()
                selectpic_btn = self.d(text=u"选择照片", className="android.widget.TextView")
                if not selectpic_btn.exists:
                    name = sys._getframe().f_code.co_name
                    screen_shot.ScreenShot(self,name)
                self.assertTrue(selectpic_btn.exists)
                if selectpic_btn.exists:
                    selectpic_btn.click()
                    time.sleep(1)
                    pic = self.d(resourceId="com.alibaba.mobileim:id/image_item", className="android.widget.ImageView")
                    if not pic.exists:
                        name = sys._getframe().f_code.co_name
                        screen_shot.ScreenShot(self,name)
                    self.assertTrue(pic.exists)
                    self.d(resourceId='com.alibaba.mobileim:id/image_check',packageName='com.alibaba.mobileim').click()
                        #点击完成, 发送图片
#                             self.d(resourceId="com.alibaba.mobileim:id/select_finish", className="android.widget.Button").click()
                    TitleBar=self.d(resourceId='android:id/pc_titlebar',packageName='com.alibaba.mobileim')
                    click_x=TitleBar.info['visibleBounds']['right']-30
                    click_y=TitleBar.info['visibleBounds']['bottom']+20
                    self.mouse.click(click_x, click_y, constants.MouseLeftKey)
                    
#                     select_finish = self.d(resourceId="com.alibaba.mobileim:id/finish", className="android.widget.Button")
#                     self.assertEqual(select_finish.info['text'], u'发送')
#                     select_finish.click()
                    time.sleep(2)
            #返回主界面
            title_back = self.d(resourceId="com.alibaba.mobileim:id/title_back", className="android.widget.TextView")
            # self.assertTrue(title_back.info['clickable'])
            if title_back.exists:
                title_back.click()
                time.sleep(1)
                title_back.click()
                time.sleep(1)
  
        logger.info('Exit --  MUAT:MobileImTest:test_SendPicture')
  
    def test_SendVoice(self):
        logger.info('Enter -- MUAT:MobileImTest:test_SendVoice')
  
        #点击消息栏
        tab_message = self.d(resourceId="com.alibaba.mobileim:id/tab_message_text", className="android.widget.ImageView")
        self.assertTrue(tab_message.info['enabled'])
        if tab_message.info['clickable']:
            tab_message.click()
            time.sleep(1)
            #查找历史消息找到wb-zhaoxinjian, 点击进入消息对话框
            friend = self.d(text=constants.TEST_REMOTE_USERNAME, resourceId="com.alibaba.mobileim:id/name", className="android.widget.TextView")
            if not friend.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(friend.exists)
            if friend.exists:
                friend.click()
                time.sleep(2)
            # else:
            #     #如果不存在则寻找另外的联系人
            #     pass
            #进入扩展选择界面,选择名片
            reply_bar_expand = self.d(resourceId="com.alibaba.mobileim:id/reply_bar_expand", className="android.widget.CheckBox")
            if not reply_bar_expand.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(reply_bar_expand.exists)
            if reply_bar_expand.exists:
                reply_bar_expand.click()
                voice_btn = self.d(text=u"语音消息", className="android.widget.TextView")
                if not voice_btn.exists:
                    name = sys._getframe().f_code.co_name
                    screen_shot.ScreenShot(self,name)
                self.assertTrue(voice_btn.exists)
                if voice_btn.exists:
                    voice_btn.click()
                    time.sleep(3)
                #长按,启动语音录音
                chat_record = self.d(resourceId="com.alibaba.mobileim:id/chat_record", className="android.widget.Button")
                self.assertEqual(chat_record.info['text'], u'请长按讲话')
                if chat_record.exists:
                    '''
                    还没有解决长按的方法,暂时用long_click()
                    '''
                    chat_record.long_click()
                    time.sleep(2)
        #返回主界面
            title_back = self.d(resourceId="com.alibaba.mobileim:id/title_back", className="android.widget.TextView")
            # self.assertTrue(title_back.info['clickable'])
            if title_back.exists:
                title_back.click()
                time.sleep(1)
                title_back.click()
                time.sleep(1)
  
        logger.info('Exit --  MUAT:MobileImTest:test_SendVoice')
 
    def test_ModifyInfo(self):
        logger.info('Enter -- MUAT:MobileImTest:test_ModifyInfo')
        meButton=self.d(resourceId='com.alibaba.mobileim:id/tab_me_text')
        if meButton.exists:
            meButton.click()
            time.sleep(2)
#                 moreButton=self.d(text=u'更多',packageName='com.alibaba.mobileim')
#                 if moreButton.exists:
#                     moreButton.click()
#                     time.sleep(2)
            if not self.d(text=u'设置', packageName='com.alibaba.mobileim').exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(self.d(text=u'设置', packageName='com.alibaba.mobileim').exists)
            profileButton = self.d(text=u'个人资料', packageName='com.alibaba.mobileim')
            #modify profile
            if profileButton.exists:
                profileButton.click()
                time.sleep(2)
                profileName=self.d(resourceId='com.alibaba.mobileim:id/profile_name')
                profileName.click()
                time.sleep(2)
                ModifyName=self.d(resourceId='com.alibaba.mobileim:id/modify_group_name',className='android.widget.EditText')
                cancelButton=self.d(resourceId='com.alibaba.mobileim:id/modify_cancel',className='android.widget.ImageView')
                cancelButton.click()
                #ModifyName.clear_text()
                #切换输入法
#                 self.d.press(113,1)
                ModifyName.set_text("who are you")
                time.sleep(2)
                okButton=self.d(text=u'完成',resourceId='com.alibaba.mobileim:id/title_button')
                if okButton.exists:
                    okButton.click()
                    time.sleep(2)
                    self.assertEqual(profileName.info['text'], "who are you")
                    profileName.click()
                    time.sleep(2)
                    cancelButton.click()
                    #切换输入法
#                     self.d.press(113,1)
                    ModifyName.set_text("tester_1")
                    time.sleep(2)
                    okButton.click()
                    self.assertEqual(profileName.info['text'], "tester_1")
                #modify male
                profileSex=self.d(resourceId='com.alibaba.mobileim:id/setting_profile_gender')
                if profileSex.exists:
                    if not profileSex.info['text'] == u'男':
                        profileSex.click()
                        time.sleep(2)
                        self.d(resourceId='com.alibaba.mobileim:id/profile_gender_male').click()
                        time.sleep(2)
                        self.assertEqual(profileSex.info['text'], u'男')
                    else:
                        profileSex.click()
                        time.sleep(2)
                        self.d(resourceId='com.alibaba.mobileim:id/profile_gender_female').click()
                        time.sleep(2)
                        self.assertEqual(profileSex.info['text'], u'女')
                #modify area
                profileAddress=self.d(resourceId='com.alibaba.mobileim:id/setting_profile_address')
                area_title=self.d(resourceId='com.alibaba.mobileim:id/title')
                bj1_x=area_title.info['visibleBounds']['right'] - 20
                bj1_y=area_title.info['visibleBounds']['bottom'] + 20
                bj2_x=bj1_x
                bj2_y=bj1_y + 44
                tj1_x=bj1_x
                tj1_y=bj2_y
                tj2_x=bj1_x
                tj2_y=bj2_y + 44
                if profileAddress.exists:
                    profileAddress.click()
                    time.sleep(2)
                    self.d.click(bj1_x,bj1_y)
                    time.sleep(2)
                    self.d.click(bj2_x,bj2_y)
                    time.sleep(2)
                    self.assertEqual(profileAddress.info['text'], u'北京 北京')
                    profileAddress.click()
                    time.sleep(2)
                    self.d.click(tj1_x,tj1_y)
                    time.sleep(2)
                    self.d.click(tj2_x,tj2_y)
                    time.sleep(2)
                    self.assertEqual(profileAddress.info['text'], u'天津 天津')
                    time.sleep(2)
                        
                #更换头像
                self.d(resourceId='com.alibaba.mobileim:id/title_back').click()
                profileHead=self.d(resourceId='com.alibaba.mobileim:id/people_head')
                if profileHead.exists:
                    profileHead.click()
                    TakePicture=self.d(text=u'拍照',resourceId='android:id/text1')
                    if TakePicture.exists:
                        TakePicture.click()
                        start=time.time()
                        while time.time()-start<constants.Time_Out:
                            if  self.d(resourceId='com.android.camera2:id/shutter_button').exists:
                                break
                            else:
                                time.sleep(1)
                        self.d(resourceId='com.android.camera2:id/shutter_button').click()
                        doneButton=self.d(resourceId='com.android.camera2:id/btn_done')
                        start=time.time()
                        while time.time()-start<constants.Time_Out:
                            if  doneButton.exists:
                                break
                            else:
                                time.sleep(1)
                        doneButton.click()
                        saveButton=self.d(resourceId='com.alibaba.mobileim:id/save')
                        start=time.time()
                        while time.time()-start<constants.Time_Out:
                            if  saveButton.exists:
                                break
                            else:
                                time.sleep(1)
                        saveButton.click()
                        time.sleep(2)
        logger.info('Exit -- MUAT:MobileImTest:test_ModifyInfo')
 
    def test_CheckInfo(self):
        logger.info('Enter -- MUAT:MobileImTest:test_CheckInfo')
  
        MobileimTitle=self.d(resourceId='android:id/pc_title')
        if not MobileimTitle.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(MobileimTitle.exists)
        if MobileimTitle.exists:
            MobileimTitle.click()
            logger.info('MobileimTitle is here')
            time.sleep(1)
  
        MessageButton=self.d(resourceId='com.alibaba.mobileim:id/tab_message_text')
        if not MessageButton.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(MessageButton.exists)
        if MessageButton.exists:
            MessageButton.click()
            logger.info('Message is here')
            time.sleep(1)
        FriendsButton=self.d(resourceId='com.alibaba.mobileim:id/tab_friends_text')
        if not FriendsButton.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(FriendsButton.exists)
        if FriendsButton.exists:
            FriendsButton.click()
            logger.info('Friends is here')
            SearchButton=self.d(resourceId='com.alibaba.mobileim:id/search_layout')
            if not SearchButton.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(SearchButton.exists)
            ShopButton=self.d(resourceId='com.alibaba.mobileim:id/shop_layout')
            if not ShopButton.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(ShopButton.exists)
            if ShopButton.exists:
                ShopButton.click()
                logger.info('Shop is here')
                time.sleep(1)
            GuyBtton=self.d(resourceId='com.alibaba.mobileim:id/friends_layout')
            self.assertTrue(GuyBtton.exists)
            if GuyBtton.exists:
                GuyBtton.click()
                logger.info('Guys is here')
                time.sleep(1)
            GruopButton=self.d(resourceId='com.alibaba.mobileim:id/tribe_layout')
            self.assertTrue(GruopButton.exists)
            if GruopButton.exists:
                GruopButton.click()
                logger.info('Gruop is here')
                time.sleep(1)
  
        CornerButton=self.d(resourceId='com.alibaba.mobileim:id/hangjia_iv')
        self.assertTrue(CornerButton.exists)
        if CornerButton.exists:
            CornerButton.click()
            logger.info('hangjia is here')
            CancelButton=self.d(text=u'取消',resourceId='com.alibaba.mobileim:id/button2')
            if CancelButton.exists:
                CancelButton.click()
                time.sleep(1)
            
#         MJX=self.d(resourceId='com.alibaba.mobileim:id/mjx_iv')
#         self.assertTrue(MJX.exists)
#         if MJX.exists:
#             MJX.click()
#             logger.info('MJX is here')
#             time.sleep(1)
#             self.d.press(0x42)
            
  
        MeButton=self.d(resourceId='com.alibaba.mobileim:id/tab_me_text')
        self.assertTrue(MeButton.exists)
        if MeButton.exists:
            MeButton.click()
            logger.info('Me is here')
            time.sleep(1)
  
        MaxBtton=self.d(resourceId='android:id/pc_max')
        if not MaxBtton.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(MaxBtton.exists)
        if MaxBtton.exists:
            MaxBtton.click()
            time.sleep(2)
            MaxBtton.click()
            time.sleep(2)
 
        # closeButton=self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.alibaba.mobileim")
        # if closeButton.exists:
        #     closeButton.click()
        #     time.sleep(3)
        logger.info('Exit -- MUAT:MobileImTest:test_CheckInfo')

#     def test_Drag(self):
#         logger.info('Enter -- MUAT:MobileImTest:test_Drag')
#         self.adb_tools.adb_shell('am start -n com.alibaba.mobileim/com.alibaba.mobileim.ui.login.LoginActivity')
#         time.sleep(5)
#         Button2=self.d(text=u'取消',resourceId='com.alibaba.mobileim:id/button2')
#         if Button2.exists:
#             Button2.click()
#         #登陆
#         LoginButton=self.d(resourceId='com.alibaba.mobileim:id/login')
#         if LoginButton.exists:
#             LoginButton.click()
#             LoginButton.click()
#             time.sleep(5)
#         #拖拉窗口
#         meButton=self.d(resourceId='com.alibaba.mobileim:id/tab_me_text')
#         start_x=meButton.info['visibleBounds']['right']
#         start_y=meButton.info['visibleBounds']['bottom']
#         end_x  =start_x + 100
#         end_x0 =start_x - 100
#         end_y  =start_y + 50
#         self.d.drag(start_x,start_y,end_x,end_y,steps=1)
#         self.d.drag(start_x,start_y,end_x0,end_y)
#         time.sleep(3)

        # closeButton=self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.alibaba.mobileim")
        # if closeButton.exists:
        #     closeButton.click()
        #     time.sleep(3)
        # logger.info('Exit -- MUAT:SettingsSystemTest:test_Drag')

    def tearDown(self):
        # tab_me test
        tab_me = self.d(resourceId="com.alibaba.mobileim:id/tab_me_text", className="android.widget.ImageView")
        # self.assertTrue(tab_me.info['clickable'])

#         if tab_me.exists:
#             tab_me.click()
#             time.sleep(1)
# 
#             myname = self.d(resourceId="com.alibaba.mobileim:id/title_text", className="android.widget.TextView")
#             self.assertEqual(myname.info['text'], 'tester_1')
# 
#             # setting button
#             setting_btn = self.d(resourceId="com.alibaba.mobileim:id/setting", className="android.widget.Button")
#             self.assertEqual(setting_btn.info['text'], u'设置')
# 
#             if setting_btn.exists:
#                 setting_btn.click()
#                 time.sleep(2)
# 
#             # account logout
#             logout_btn = self.d(resourceId='com.alibaba.mobileim:id/setting_logout')
#             self.assertEqual(logout_btn.info['text'], u'退出登录')
# 
#             if logout_btn.exists:
#                 logout_btn.click()
#                 time.sleep(1)
# 
#             exit_massege = self.d(resourceId="com.alibaba.mobileim:id/message", className="android.widget.TextView")
#             self.assertEqual(exit_massege.info['text'], u'退出后您将收不到新消息通知,是否确认退出?')
#             time.sleep(1)
#             if exit_massege.exists:
#                 self.d(resourceId="com.alibaba.mobileim:id/button1", className="android.widget.Button").click()
#                 time.sleep(2)
# 
#             accountClearButton = self.d(resourceId="com.alibaba.mobileim:id/accountClearButton", className="android.widget.TextView")
#             if not accountClearButton.exists:
#                 name = sys._getframe().f_code.co_name
#                 screen_shot.ScreenShot(self, name)
#                 time.sleep(3)
#             elif accountClearButton.exists:
#                 accountClearButton.click()
#                 time.sleep(1)

        closebtn = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.alibaba.mobileim")
        #self.assertTure(closebtn.exists)

        if closebtn.exists:
            logger.debug('click close button: (%s)' % (closebtn.info['packageName']))
            closebtn.click()
        #logger.info("EXIT -- MUAT:MobileImTest:close_mobileim")
        self.adb_tools.adb_shell('am force-stop com.alibaba.mobileim')
コード例 #9
0
class WPSTest(ParametrizedTestCase):
    def setUp(self):
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest('process monitor stop')

        self.d      = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.mouse = AdbMouse()
        self.adb_tools = AdbTools()
 
#         self.account.sleep()
#         self.account.wakeup()
#         self.account.login()
        Button1=self.d(resourceId='com.yunpc.yunosloginui:id/avatar')
        start=time.time()
        while time.time()-start < constants.Time_Out:
            if not Button1.exists:
                break
            else:
                time.sleep(1)
        closeButton=self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.kingsoft.moffice_pro")
        #self.adb_tools.adb_shell('adb shell am force-stop com.kingsoft.moffice_pro')
        if closeButton.exists:
            closeButton.click()
            time.sleep(1)

    def tearDown(self):
        closeButton=self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.kingsoft.moffice_pro")
        if closeButton.exists:
            closeButton.click()
            time.sleep(1)
            if closeButton.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertFalse(closeButton.exists)
            
        #self.adb_tools.adb_shell('adb shell am force-stop com.kingsoft.moffice_pro')
        time.sleep(1)
#         self.account.sleep()
    
             
    def test_OpenAndExit(self):
        logger.info('Enter -- MUAT:WPSTest:test_OpenAndExit')
        #self.adb_tools.adb_shell('am start -n com.kingsoft.moffice_pro/cn.wps.moffice.documentmanager.DocumentManager')
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        wps=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text='WPS Office')
        click_x = wps.info['visibleBounds']['left'] +5
        click_y = wps.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
#         click_x = WPSIcon.info['visibleBounds']['left'] +5
#         click_y = WPSIcon.info['visibleBounds']['top'] +5
#         self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        WPS_Title=self.d(text='WPS Office',resourceId='android:id/pc_title',packageName='com.kingsoft.moffice_pro')
        start = time.time()
        while time.time() - start < constants.Time_Out:
            if WPS_Title.exists:
                break
            else:
                time.sleep(1)
        if not WPS_Title.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(WPS_Title.exists)
        closeButton=self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.kingsoft.moffice_pro")
        if closeButton.exists:
            closeButton.click()
        logger.info('Exit -- MUAT:WPSTest:test_OpenAndExit')
              
    def test_OpenFile(self):
        logger.info('Enter -- MUAT:WPSTest:test_OpenFile')
        #self.adb_tools.adb_shell('am start -n com.kingsoft.moffice_pro/cn.wps.moffice.documentmanager.DocumentManager')
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        wps=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text='WPS Office')
        if wps.exists:
            click_x = wps.info['visibleBounds']['left'] +5
            click_y = wps.info['visibleBounds']['top'] +5
            self.mouse.click(click_x, click_y, constants.MouseLeftKey)
            WPS_Title=self.d(text='WPS Office',resourceId='android:id/pc_title',packageName='com.kingsoft.moffice_pro')
            start = time.time()
            while time.time() - start < constants.Time_Out:
                if WPS_Title.exists:
                    break
                else:
                    time.sleep(1)
            if not WPS_Title.exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(WPS_Title.exists)    
        profile_layout=self.d(resourceId='com.kingsoft.moffice_pro:id/left_nav_profile_layout')
        click_x=profile_layout.info['visibleBounds']['right'] - 10
        click_y=profile_layout.info['visibleBounds']['bottom'] + 10
        self.mouse.click(click_x,click_y,constants.MouseLeftKey)
        #DOC
        doc_file=self.d(text=u'文档' , resourceId='com.kingsoft.moffice_pro:id/text')
        if doc_file.exists:
            doc_file.click()
            start = time.time()
            backButton=self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_backBtn')
            while time.time() - start < constants.Time_Out:
                if backButton.exists:
                    break
                else:
                    time.sleep(1)
            if not self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_logo').exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_logo').exists)
            self.d.press(48)
            self.d.press(62)
            saveIcon=self.d(resourceId='com.kingsoft.moffice_pro:id/image_save')
            if saveIcon.exists:
                saveIcon.click()
                myfile=self.d(text=u'我的文档',resourceId='com.kingsoft.moffice_pro:id/fb_filename_text')
                if myfile.exists:
                    myfile.click()
                    saveButton=self.d(resourceId='com.kingsoft.moffice_pro:id/btn_save')
                    if saveButton.exists:
                        saveButton.click()
                        replaceButton=self.d(resourceId='com.kingsoft.moffice_pro:id/dialog_button_positive')
                        if replaceButton.exists:
                            replaceButton.click()
                        time.sleep(3)
                        if backButton.exists:
                            backButton.click()
                            time.sleep(1)
        #TXT
        txt_file=self.d(text=u'便笺',resourceId='com.kingsoft.moffice_pro:id/text')
        if txt_file.exists:
            txt_file.click()
            start = time.time()
            backButton=self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_backBtn')
            while time.time() - start < constants.Time_Out:
                if backButton.exists:
                    break
                else:
                    time.sleep(1)
            if not self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_logo').exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_logo').exists)
            self.d.press(48)
            self.d.press(62)
            saveIcon=self.d(resourceId='com.kingsoft.moffice_pro:id/image_save')
            if saveIcon.exists:
                saveIcon.click()
                myfile=self.d(text=u'我的文档',resourceId='com.kingsoft.moffice_pro:id/fb_filename_text')
                if myfile.exists:
                    myfile.click()
                    saveButton=self.d(resourceId='com.kingsoft.moffice_pro:id/btn_save')
                    if saveButton.exists:
                        saveButton.click()
                        replaceButton=self.d(resourceId='com.kingsoft.moffice_pro:id/dialog_button_positive')
                        if replaceButton.exists:
                            replaceButton.click()
                            replaceButton.click()
                        time.sleep(3)
                        if backButton.exists:
                            backButton.click()
                            time.sleep(1)
                               
        #XLS
        xls_file=self.d(text=u'表格',resourceId='com.kingsoft.moffice_pro:id/text')
        if xls_file.exists:
            xls_file.click()
            start = time.time()
            backButton=self.d(resourceId='com.kingsoft.moffice_pro:id/ss_titlebar_close')
            while time.time() - start < constants.Time_Out:
                if self.d(resourceId='com.kingsoft.moffice_pro:id/image_save').exists:
                    break
                else:
                    time.sleep(1)
            #time.sleep(1)
            if not self.d(resourceId='com.kingsoft.moffice_pro:id/ss_titlebar_logo').exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(self.d(resourceId='com.kingsoft.moffice_pro:id/ss_titlebar_logo').exists)
            self.d.press(48)
            self.d.press(62)
            self.d.press(66)
            saveIcon=self.d(resourceId='com.kingsoft.moffice_pro:id/image_save')
            if saveIcon.exists:
                saveIcon.click()
                myfile=self.d(text=u'我的文档',resourceId='com.kingsoft.moffice_pro:id/fb_filename_text')
                if myfile.exists:
                    myfile.click()
                    saveButton=self.d(resourceId='com.kingsoft.moffice_pro:id/btn_save')
                    if saveButton.exists:
                        saveButton.click()
                        replaceButton=self.d(resourceId='com.kingsoft.moffice_pro:id/dialog_button_positive')
                        if replaceButton.exists:
                            replaceButton.click()
                            time.sleep(3)
                        backButton=self.d(resourceId='com.kingsoft.moffice_pro:id/ss_titlebar_close')
                        if backButton.exists:
                            backButton.click()
                            time.sleep(1)
        #PPT
#         ppt_file=self.d(text=u'演示',resourceId='com.kingsoft.moffice_pro:id/text')
#         if ppt_file.exists:
#             ppt_file.click()
#             start = time.time()
#             #backButton=self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_backBtn')
#             saveIcon=self.d(resourceId='com.kingsoft.moffice_pro:id/image_save')
#             while time.time() - start < constants.Time_Out:
#                 if saveIcon.exists:
#                     break
#                 else:
#                     time.sleep(1)
#             #self.d.press(48)
#             wps_content = self.d(resourceId='com.kingsoft.moffice_pro:id/content')
#             write_x = wps_content.info['visibleBounds']['left']+700
#             write_y = wps_content.info['visibleBounds']['top']+300
#             self.mouse.doubleclick(write_x,write_y,constants.MouseLeftKey)
#             self.d.press(48)
#             self.d.press(62)
#             #saveIcon=self.d(resourceId='com.kingsoft.moffice_pro:id/image_save')
#             if saveIcon.exists:
#                 saveIcon.click()
#                 myfile=self.d(text=u'我的文档',resourceId='com.kingsoft.moffice_pro:id/fb_filename_text')
#                 if myfile.exists:
#                     myfile.click()
#                     saveButton=self.d(resourceId='com.kingsoft.moffice_pro:id/btn_save')
#                     if saveButton.exists:
#                         saveButton.click()
#                         replaceButton=self.d(resourceId='com.kingsoft.moffice_pro:id/dialog_button_positive')
#                         if replaceButton.exists:
#                             replaceButton.click()
#                             time.sleep(3)
#                             self.d(resourceId='com.kingsoft.moffice_pro:id/ppt_titlebar_close').click()
#                         backButton=self.d(resourceId='com.kingsoft.moffice_pro:id/ss_titlebar_close')
#                         if backButton.exists:
#                             backButton.click()
        
        closeButton=self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.kingsoft.moffice_pro")
        if closeButton.exists:
            closeButton.click()
        logger.info('Exit -- MUAT:WPSTest:test_OpenFile')
             
    def test_RecentFile(self):
        logger.info('Enter -- MUAT:WPSTest:test_RecentFile')
        #self.adb_tools.adb_shell('am start -n com.kingsoft.moffice_pro/cn.wps.moffice.documentmanager.DocumentManager')
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        wps=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text='WPS Office')
        click_x = wps.info['visibleBounds']['left'] +5
        click_y = wps.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
#         click_x = WPSIcon.info['visibleBounds']['left'] +5
#         click_y = WPSIcon.info['visibleBounds']['top'] +5
#         self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        WPS_Title=self.d(text='WPS Office',resourceId='android:id/pc_title',packageName='com.kingsoft.moffice_pro')
        start = time.time()
        while time.time() - start < constants.Time_Out:
            if WPS_Title.exists:
                break
            else:
                time.sleep(1)
        if not WPS_Title.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(WPS_Title.exists)
        profile_layout=self.d(resourceId='com.kingsoft.moffice_pro:id/left_nav_profile_layout')
        click_x=profile_layout.info['visibleBounds']['right'] - 10
        click_y=profile_layout.info['visibleBounds']['bottom'] + 58
        self.mouse.click(click_x,click_y,constants.MouseLeftKey)
        history_icon=self.d(resourceId='com.kingsoft.moffice_pro:id/history_record_item_icon')
        if not history_icon.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(history_icon.exists)
           
        closeButton=self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.kingsoft.moffice_pro")
        if closeButton.exists:
            closeButton.click()
        logger.info('Exit -- MUAT:WPSTest:test_RecentFile')
          
    def test_BackHome(self):
        logger.info('Enter -- MUAT:WPSTest:test_BackHome')
        #self.adb_tools.adb_shell('am start -n com.kingsoft.moffice_pro/cn.wps.moffice.documentmanager.DocumentManager')
        time.sleep(1)
        self.d.click(constants.MUAT_APP_LIST_EMPTY_X, constants.MUAT_APP_LIST_EMPTY_Y)
        time.sleep(0.2)
        self.d.click(constants.MUAT_APP_LIST_POINT_X, constants.MUAT_APP_LIST_POINT_Y)
        time.sleep(1)
        wps=self.d(resourceId='com.aliyun.lightdesk:id/gv_item_appname',text='WPS Office')
        click_x = wps.info['visibleBounds']['left'] +5
        click_y = wps.info['visibleBounds']['top'] +5
        self.mouse.click(click_x, click_y, constants.MouseLeftKey)
        
#         click_x = WPSIcon.info['visibleBounds']['left'] +5
#         click_y = WPSIcon.info['visibleBounds']['top'] +5
#         self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        WPS_Title=self.d(text='WPS Office',resourceId='android:id/pc_title',packageName='com.kingsoft.moffice_pro')
        start = time.time()
        while time.time() - start < constants.Time_Out:
            if WPS_Title.exists:
                break
            else:
                time.sleep(1)
        if not WPS_Title.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(WPS_Title.exists)
        profile_layout=self.d(resourceId='com.kingsoft.moffice_pro:id/left_nav_profile_layout')
        click_x=profile_layout.info['visibleBounds']['right'] - 10
        click_y=profile_layout.info['visibleBounds']['bottom'] + 10
        self.mouse.click(click_x,click_y,constants.MouseLeftKey)
        #DOC
        doc_file=self.d(text=u'文档' , resourceId='com.kingsoft.moffice_pro:id/text')
        if doc_file.exists:
            doc_file.click()
            start = time.time()
            backButton=self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_backBtn')
            while time.time() - start < constants.Time_Out:
                if backButton.exists:
                    break
                else:
                    time.sleep(1)
            WLogo=self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_logo',packageName='com.kingsoft.moffice_pro')
            if WLogo.exists:
                WLogo.click()
                time.sleep(1)
            if not self.d(text=u'新建',resourceId='com.kingsoft.moffice_pro:id/nav_item_title').exists:
                name = sys._getframe().f_code.co_name
                screen_shot.ScreenShot(self,name)
            self.assertTrue(self.d(text=u'新建',resourceId='com.kingsoft.moffice_pro:id/nav_item_title').exists)
            self.assertTrue(self.d(text=u'最近',resourceId='com.kingsoft.moffice_pro:id/nav_item_title').exists)
            self.assertTrue(self.d(text=u'星标',resourceId='com.kingsoft.moffice_pro:id/nav_item_title').exists)
            self.d(resourceId='android:id/pc_max').click()
            self.d.click(960,540)
            time.sleep(2)
            backButton=self.d(resourceId='com.kingsoft.moffice_pro:id/writer_maintoolbar_backBtn')
            if backButton.exists:
                backButton.click()
              
        closeButton=self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.kingsoft.moffice_pro")
        if closeButton.exists:
            closeButton.click()
        logger.info('Exit -- MUAT:WPSTest:test_BackHome')
            
コード例 #10
0
class PrintScreenTest(ParametrizedTestCase):
    def setUp(self):
        # check monitor running status
        if self.mon and not self.mon.running_status:
            self.skipTest('process monitor stop')

        self.d      = AutomationDevice().get_device()
        self.account = Account(self.d)
        self.mouse = AdbMouse()
        self.adb_tools = AdbTools()
        
        self.BaseImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "dependency", "BaseImage")
        self.FailureIamgePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "FailureImage")
        self.TmpImagePath = os.path.join(os.path.abspath(os.path.dirname("__file__")), "test-reports", "TmpImage")
        
        if not os.path.exists(self.TmpImagePath):
            os.mkdir(self.TmpImagePath)
        if not os.path.exists(os.path.join(self.TmpImagePath, "croped")):
            os.mkdir(os.path.join(self.TmpImagePath, "croped"))

#         self.account.sleep()
#         self.account.wakeup()
#         self.account.login()
        Button1=self.d(resourceId='com.yunpc.yunosloginui:id/avatar')
        start=time.time()
        while time.time()-start<constants.Time_Out:
            if not Button1.exists:
                break
            else:
                time.sleep(1)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.ali.screenshot")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            self.adb_tools.adb_shell('am force-stop com.ali.screenshot')
        
    def tearDown(self):
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.ali.screenshot")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            time.sleep(1)
        if closeButton.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self, name)
            self.adb_tools.adb_shell('am force-stop com.ali.screenshot')
            self.assertFalse(closeButton.exists)
            if os.path.exists(self.TmpImagePath):
                shutil.rmtree(self.TmpImagePath)
            
    def test_OpenAndExit(self):
        logger.info('Enter -- MUAT:PrintScreenTest:test_OpenAndExit')
        ScreenIcon = self.d(text=u"截屏", resourceId='com.aliyun.lightdesk:id/tag_name',className="android.widget.TextView")
        if not ScreenIcon.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(ScreenIcon.exists)
        click_x = ScreenIcon.info['visibleBounds']['left'] +5
        click_y = ScreenIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        time.sleep(1)
        ScreenTitle = self.d(resourceId="android:id/pc_titlebar", packageName="com.ali.screenshot")
        self.assertTrue(ScreenTitle.exists)
        closeButton = self.d(resourceId="android:id/pc_close", className="android.widget.ImageView", packageName="com.ali.screenshot")
        if closeButton.exists:
            logger.debug('click close button: (%s)' % (closeButton.info['packageName']))
            closeButton.click()
            time.sleep(1)
        logger.info('Exit -- MUAT:PrintScreenTest:test_OpenAndExit')
        
#     def test_StartByShortcut(self):
#         logger.info('Enter -- MUAT:PrintScreenTest:test_StartByShortcut')
    def test_FullScreenShot(self):
        logger.info('Enter -- MUAT:PrintScreenTest:test_FullScreenShot')
        ScreenIcon = self.d(text=u"截屏", resourceId='com.aliyun.lightdesk:id/tag_name',className="android.widget.TextView")
        if not ScreenIcon.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(ScreenIcon.exists)
        click_x = ScreenIcon.info['visibleBounds']['left'] +5
        click_y = ScreenIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        time.sleep(1)
        ScreenTitle = self.d(resourceId="android:id/pc_titlebar", packageName="com.ali.screenshot")
        self.assertTrue(ScreenTitle.exists)
        full_screenshot=self.d(resourceId='com.ali.screenshot:id/m_connect_win_button',packageName='com.ali.screenshot')
        if full_screenshot.exists:
            full_screenshot.click()
            time.sleep(2)
            self.mouse.click(1690,10,constants.MouseLeftKey)
            self.mouse.click(1690,90,constants.MouseLeftKey)
            time.sleep(1)
            FileManagePic=self.d(resourceId='com.yunpc.filemanager:id/paraList_imgHead',packageName='com.yunpc.filemanager')
            self.assertTrue(FileManagePic.exists)
            self.d(resourceId='android:id/pc_close',packageName='com.yunpc.filemanager').click()
        logger.info('Exit -- MUAT:PrintScreenTest:test_FullScreenShot')
        
    def test_AreaScreenShot(self):
        logger.info('Enter -- MUAT:PrintScreenTest:test_AreaScreenShot')
        ScreenIcon = self.d(text=u"截屏", resourceId='com.aliyun.lightdesk:id/tag_name',className="android.widget.TextView")
        if not ScreenIcon.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(ScreenIcon.exists)
        click_x = ScreenIcon.info['visibleBounds']['left'] +5
        click_y = ScreenIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        time.sleep(1)
        ScreenTitle = self.d(resourceId="android:id/pc_titlebar", packageName="com.ali.screenshot")
        self.assertTrue(ScreenTitle.exists)
        area_screenshot=self.d(resourceId='com.ali.screenshot:id/m_connect_rect_button',packageName='com.ali.screenshot')
        if area_screenshot.exists:
            area_screenshot.click()
            time.sleep(1)
            self.d.swipe(300,250,800,750,20)
            time.sleep(1)
            self.d(resourceId='com.ali.screenshot:id/s_crop_ok_button',packageName='com.ali.screenshot').click()
            time.sleep(1)
            self.mouse.click(1690,10,constants.MouseLeftKey)
            self.mouse.click(1690,90,constants.MouseLeftKey)
            time.sleep(1)
            self.assertTrue(self.d(resourceId='com.yunpc.filemanager:id/paraList_imgHead',packageName='com.yunpc.filemanager').exists)
            self.d(resourceId='android:id/pc_close',packageName='com.yunpc.filemanager').click()
        logger.info('Exit -- MUAT:PrintScreenTest:test_AreaScreenShot')
        
    def test_Cancle(self):
        logger.info('Enter -- MUAT:test_PrintScreen:test_Cancle')
        ScreenIcon = self.d(text=u"截屏", resourceId='com.aliyun.lightdesk:id/tag_name',className="android.widget.TextView")
        if not ScreenIcon.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(ScreenIcon.exists)
        click_x = ScreenIcon.info['visibleBounds']['left'] +5
        click_y = ScreenIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        time.sleep(1)
        ScreenTitle = self.d(resourceId="android:id/pc_titlebar", packageName="com.ali.screenshot")
        self.assertTrue(ScreenTitle.exists)
        area_screenshot=self.d(resourceId='com.ali.screenshot:id/m_connect_rect_button',packageName='com.ali.screenshot')
        if area_screenshot.exists:
            area_screenshot.click()
            time.sleep(1)
            self.d.swipe(300,250,800,750,20)
            time.sleep(1)
            self.d(resourceId='com.ali.screenshot:id/s_crop_cancel_button',packageName='com.ali.screenshot').click()
            time.sleep(1)
            self.mouse.click(1690,10,constants.MouseLeftKey)
            self.mouse.click(1670,90,constants.MouseLeftKey)
            self.assertFalse(self.d(resourceId='com.yunpc.filemanager:id/paraList_imgHead',packageName='com.yunpc.filemanager').exists)
            time.sleep(1)
        logger.info('Exit -- MUAT:PrintScreenTest:test_Cancle')
        
    def test_DragScreen(self):
        logger.info('Enter -- MUAT:test_PrintScreen:test_DragScreen') 
        ScreenIcon = self.d(text=u"截屏", resourceId='com.aliyun.lightdesk:id/tag_name',className="android.widget.TextView")
        if not ScreenIcon.exists:
            name = sys._getframe().f_code.co_name
            screen_shot.ScreenShot(self,name)
        self.assertTrue(ScreenIcon.exists)
        click_x = ScreenIcon.info['visibleBounds']['left'] +5
        click_y = ScreenIcon.info['visibleBounds']['top'] +5
        self.mouse.doubleclick(click_x, click_y, constants.MouseLeftKey)
        time.sleep(1)
        ScreenTitle = self.d(resourceId="android:id/pc_titlebar", packageName="com.ali.screenshot")
        self.assertTrue(ScreenTitle.exists)
        area_screenshot=self.d(resourceId='com.ali.screenshot:id/m_connect_rect_button',packageName='com.ali.screenshot')
        if area_screenshot.exists:
            area_screenshot.click()
            time.sleep(1)
            self.d.swipe(300,250,800,750,20)
            time.sleep(1)
            self.d.drag(500,400,900,700,10)
            time.sleep(1)
            self.assertTrue(self.d(resourceId='com.ali.screenshot:id/s_crop_ok_button',packageName='com.ali.screenshot').exists)
            self.d(resourceId='com.ali.screenshot:id/s_crop_ok_button',packageName='com.ali.screenshot').click()
            time.sleep(1)
            self.mouse.click(1690,10,constants.MouseLeftKey)
            self.mouse.click(1670,90,constants.MouseLeftKey)
            time.sleep(0.5)
            self.assertTrue(self.d(resourceId='com.yunpc.filemanager:id/paraList_imgHead',packageName='com.yunpc.filemanager').exists)
            time.sleep(1)
            self.d(resourceId='android:id/pc_close',packageName='com.yunpc.filemanager').click()
        
        logger.info('Exit -- MUAT:PrintScreenTest:test_DragScreen')