当前位置: 首页>>代码示例>>Python>>正文


Python Device.freeze_rotation方法代码示例

本文整理汇总了Python中uiautomator.Device.freeze_rotation方法的典型用法代码示例。如果您正苦于以下问题:Python Device.freeze_rotation方法的具体用法?Python Device.freeze_rotation怎么用?Python Device.freeze_rotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在uiautomator.Device的用法示例。


在下文中一共展示了Device.freeze_rotation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ModelInfo

# 需要导入模块: from uiautomator import Device [as 别名]
# 或者: from uiautomator.Device import freeze_rotation [as 别名]

#.........这里部分代码省略.........
        '''
        return self.mstrDevice.swipe(sx, sy, ex, ey, steps)
           
    def drage(self,sx, sy, ex, ey, steps=10):
        '''
            Description:
                
            param:
                sx, xy : start first x, y
                ex, ey : move to x, y
            return : Boolean
        '''
        return self.mstrDevice.drag(sx, sy, ex, ey, steps)
       
    #screen action of the device   
    def setOrientation(self,scrAct='natural', choiceDevice='mstr'):
        '''
            Description
                
            param
                d.orientation = 'l' or 'left'
                d.orientation = 'r' or 'right'
                d.orientation = 'n' or 'natural'
            return : None
        '''
        self.mstrDevice.orientation = scrAct
    
    def setFreezeRotation(self,condition=False,choiceDevice='mstr'):
        '''
            param:
                condition : False un-freeze rotation
            return : None
        '''
        self.mstrDevice.freeze_rotation(condition)
    
    
            
    def takeScreenShot(self, choiceDevice = 'mstr'):
        '''
            Description:
                take screenshot and save to local file 'home.png' can work until android 4.2
            param
                image name
        '''
        
    def dumpWindowHeirarchy(self,filename='./log/hierachy.xml'):
        return self.mstrDevice.dump(filename)
        
    def dumpWindowHeirarchyStream(self):
        return self.mstrDevice.dump()
        
    def notification(self):
        '''
            Open notification, can not work until android 4.3
            return : Boolean
        '''
        return self.mstrDevice.open.Notification()
    
    def quickSettings(self):
        '''
            open quick settins, can not work until android 4.3
            return : Boolean 
        '''
        return self.mstrDevice.open.quick_settings()
    def waitidle(self):
        '''
开发者ID:sqler21c,项目名称:Python,代码行数:70,代码来源:ModelInfo.py

示例2: Mobile

# 需要导入模块: from uiautomator import Device [as 别名]
# 或者: from uiautomator.Device import freeze_rotation [as 别名]

#.........这里部分代码省略.........
#Screen Actions of the device

    def get_screen_orientation(self):
        """
        Get the screen orientation.

        Possible result: natural, left, right, upsidedown

        See for more details: https://github.com/xiaocong/uiautomator#screen-actions-of-the-device
        """
        return self.device.orientation

    def set_screen_orientation(self, orientation):
        """
        Set the screen orientation.

        Input *orientation* : natural or n, left or l, right or r, upsidedown (support android version above 4.3)

        The keyword will unfreeze the screen rotation first.

        See for more details: https://github.com/xiaocong/uiautomator#screen-actions-of-the-device

        Example:

        | Set Screen Orientation | n | # Set orientation to natural |
        | Set Screen Orientation | natural | # Do the same thing  |
        """
        self.device.orientation = orientation

    def freeze_screen_rotation(self):
        """
        Freeze the screen auto rotation
        """
        self.device.freeze_rotation()

    def unfreeze_screen_rotation(self):
        """
        Un-Freeze the screen auto rotation
        """
        self.device.freeze_rotation(False)

    def screenshot(self, scale=None, quality=None):
        """
        Take a screenshot of device and log in the report with timestamp, scale for screenshot size and quality for screenshot quality
        default scale=1.0 quality=100
        """
        output_dir = BuiltIn().get_variable_value('${OUTPUTDIR}')
        ts = time.time()
        st = datetime.datetime.fromtimestamp(ts).strftime('%Y%m%d%H%M%S')
        screenshot_path = '%s%s%s.png' % (output_dir, os.sep, st)
        self.device.screenshot(screenshot_path, scale, quality)
        logger.info('\n<a href="%s">%s</a><br><img src="%s">' % (screenshot_path, st, screenshot_path), html=True)

#Watcher
#     def register_click_watcher(self, watcher_name, selectors, *condition_list):
#         """
#         The watcher click on the object which has the selectors when conditions match
#         """
#         print type(selectors)
#         watcher = self.device.watcher(watcher_name)
#         for condition in condition_list:
#             watcher.when(**condition)
#         watcher.click(**selectors)
#         self.device.watchers.run()
#         print 'register watcher:%s' % watcher_name
#         return
开发者ID:am01230123,项目名称:furry-ironman,代码行数:70,代码来源:Mobile.py

示例3: AdbDevice

# 需要导入模块: from uiautomator import Device [as 别名]
# 或者: from uiautomator.Device import freeze_rotation [as 别名]

#.........这里部分代码省略.........

    def isScreenOn(self):
        screenOnRE = re.compile('mScreenOnFully=(true|false)')
        m = screenOnRE.search(self.cmd.dumpsys(['window', 'policy']))
        if m is not None:
            return m.group(1) == 'true'

    def powerBtn(self):
        self.cmd.inputKeyevnt('POWER')

    def backBtn(self):
        self.cmd.inputKeyevnt('BACK')

    def homeBtn(self):
        self.cmd.inputKeyevnt('HOME')

    def menuBtn(self):
        self.cmd.inputKeyevnt('MENU')

    # def rotate(self, orient):
    #     if orient == 'auto':
    #         self.d.freeze_rotation(False)
    #     elif orient == '0':
    #         self.d.orientation = 'n'
    #     elif orient == '90':
    #         self.d.orientation = 'l'
    #     elif orient == '180':
    #         self.d.freeze_rotation(True)
    #         self._setScreenOrient(2)
    #     elif orient == '270':
    #         self.d.orientation = 'r'

    def rotate(self, orient):
        self.d.freeze_rotation(True)
        index = self.orientation.index(self.d.orientation)
        if orient == 'left':
            index -= 1
            if index < 0:
                self._setScreenOrient(len(self.orientation) - 1)
            else:
                self._setScreenOrient(index)
        elif orient == 'right':
            index += 1
            if index >= len(self.orientation):
                self._setScreenOrient(0)
            else:
                self._setScreenOrient(index)

    def volumeUp(self):
        self.cmd.inputKeyevnt('VOLUME_UP')

    def volumeDown(self):
        self.cmd.inputKeyevnt('VOLUME_DOWN')

    #     def _setAutoRotate(self, status):
    #         if status:
    #             self.cmd.shell(['content', 'insert', '--uri', 'content://settings/system', '--bind', 'name:s:accelerometer_rotation',
    #                             '--bind', 'value:i:1'])
    #             time.sleep(1)
    #             self.cmd.shell(['content', 'insert', '--uri', 'content://settings/system', '--bind', 'name:s:accelerometer_rotation',
    #                             '--bind', 'value:i:1'])
    #
    #         else:
    #             self.cmd.shell(['content', 'insert', '--uri', 'content://settings/system', '--bind', 'name:s:accelerometer_rotation',
    #                             '--bind', 'value:i:0'])
    #             time.sleep(1)
开发者ID:ChenYuTingJerry,项目名称:AutoSense_2,代码行数:70,代码来源:Adb.py

示例4: UiTestLib

# 需要导入模块: from uiautomator import Device [as 别名]
# 或者: from uiautomator.Device import freeze_rotation [as 别名]

#.........这里部分代码省略.........
        |  Result Should Be    | 0       |
        """
        print ("result is: %s\n", self._result)
        print ("ex is: %s\n", expected)
        if str(self._result) != expected:
            raise AssertionError("%s != %s" % (self._result, expected))

    def click_at_coordinates(self, x, y):
        """ Click at (x,y) coordinates.
        Example:
        | Action     | Argument   |  Argument  |
        | Click At Corrdinates | x | y |
        """
        return self.d.click(int(x), int(y))

    def long_click_at_coordinates(self, x, y):
        """
        # long click (x, y) on screen
        """
        return self.d.long_click(int(x), int(y))

    def swipe(self, sx, sy, ex, ey, steps=20):
        """
        Swipe from (sx,sy) to (ex,ey)
        """
        return self.d.swipe(int(sx), int(sy), int(ex), int(ex), int(steps))

    def drag(self, sx, sy, ex, ey, steps=20):
        """
        Drag from (sx,sy) to (ex,ey)
        """
        return self.d.drag(int(sx), int(sy), int(ex), int(ex), int(steps))

    def freeze_rotation(self, rotation=True):
        """
        Freeze rotation,
        *rotation*, True is default,
        """
        return self.d.freeze_rotation(rotation)

    def set_rotation(self, rotation):
        """
        # retrieve orientation,
        # it should be "natural" or "left" or "right" or "upsidedown"

        Example:
        | Action       | Argument   |
        | Set Rotation | nature      |
        | Set Rotation | left        |
        | Set Rotation | right       |
        | Set Rotation | upsidedown  |

        """
        orientation = self.d.orientation
        if rotation == "nature":
            self.d.orientation = "n"  # or "natural"
        elif rotation == "left":
            self.d.orientation = "l"  # or "left"
        elif rotation == "right":
            self.d.orientation = "r"  # or "right"
        elif rotation == "upsidedown":
            self.d.orientation = "upsidedown"  # or "upsidedown"
        else:
            self.d.rotation = "n"

    def take_screenshot(self, scale=None, quality=None):
开发者ID:huaping,项目名称:StabilityKPI,代码行数:70,代码来源:UiTestLib.py


注:本文中的uiautomator.Device.freeze_rotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。