How to use setUserRotation method in fMBT

Best Python code snippet using fMBT_python

fmbtandroid.py

Source:fmbtandroid.py Github

copy

Full Screen

...939 abc (tuple of floats):940 new 3-axis accelerometer readings, one to three values.941 Returns True if successful, False if failed. Raises an exception942 if emulator cannot be connected to. Does not work with real hardware.943 Note: to rotate display with real hardware, see setUserRotation().944 Example:945 d.setAccelerometer((9.8, 0))946 d.setAccelerometer((0, 9.8))947 d.setAccelerometer((-9.6, 0.2, 0.8))948 """949 if self._conn:950 return self._conn.sendAcceleration(abc)951 else:952 return False953 def setAccelerometerRotation(self, value):954 """955 Enable or disable accelerometer-based screen rotation956 Parameters:957 value (boolean):958 True: enable accelerometer-based rotation959 False: disable accelerometer-based rotation.960 Returns True if successful, otherwise False.961 """962 if self._conn:963 return self._conn.sendAccelerometerRotation(value)964 else:965 return False966 def setAutoRotateScreenshot(self, value):967 """968 Enable or disable automatic screenshot rotation.969 Parameters:970 value (boolean):971 If True, rotate screenshot automatically to compensate972 current display rotation.973 refreshScreenshot()'s optional rotate parameter overrides this974 setting.975 See also autoRotateScreenshot(), displayRotation().976 """977 if value:978 self._autoRotateScreenshot = True979 else:980 self._autoRotateScreenshot = False981 def setConnection(self, connection):982 self._lastConnectionSettings = {}983 fmbtgti.GUITestInterface.setConnection(self, connection)984 if hasattr(self.connection(), "_serialNumber"):985 self.serialNumber = self.connection()._serialNumber986 def setDisplaySize(self, size=(None, None)):987 """988 Transform coordinates of synthesized events from screenshot989 resolution to given input area size. By default events are990 synthesized directly to screenshot coordinates.991 Parameters:992 size (pair of integers (width, height), optional):993 width and height of display in pixels. If not994 given, values from Android system properties995 "mDisplayWidth" and "mDisplayHeight" will be used.996 Returns None.997 """998 width, height = size999 if width == None or height == None:1000 w, h = self.existingConnection().recvScreenSize()1001 if w == h == 0:1002 w, h = self.existingConnection().recvDefaultViewportSize()1003 if width == None:1004 width = w1005 if height == None:1006 height = h1007 screenWidth, screenHeight = self.screenSize()1008 self.existingConnection().setScreenToDisplayCoords(1009 lambda x, y: (x * width / screenWidth,1010 y * height / screenHeight))1011 self.existingConnection().setDisplayToScreenCoords(1012 lambda x, y: (x * screenWidth / width,1013 y * screenHeight / height))1014 def setUiautomatorDump(self, uiautomatorDump):1015 """1016 Enable or disable using uiautomator on refreshView()1017 Parameters:1018 uiautomatorDump (boolean):1019 If True, uiautomator will be used on refreshView()1020 by default.1021 """1022 self._uiautomatorDump = uiautomatorDump1023 def setUserRotation(self, rotation):1024 """1025 Enable or disable accelerometer-based screen rotation1026 Parameters:1027 rotation (integer):1028 values 0, 1, 2 and 3 correspond to1029 ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270.1030 Returns True if successful, otherwise False.1031 Example:1032 # Disable accelerometer-based rotation for user rotation1033 # to take effect.1034 d.setAccelerometerRotation(False)1035 d.setUserRotation(fmbtandroid.ROTATION_90)1036 time.sleep(2)1037 d.setUserRotation(fmbtandroid.ROTATION_0)1038 time.sleep(2)1039 d.setAccelerometerRotation(True)1040 """1041 if rotation in ROTATIONS:1042 pass # already in correct scale1043 elif rotation in ROTATION_DEGS:1044 rotation = ROTATION_DEGS.index(rotation)1045 else:1046 raise ValueError('invalid rotation "%s"' % (rotation,))1047 if self._conn:1048 return self._conn.sendUserRotation(rotation)1049 else:1050 return False1051 def shell(self, shellCommand, timeout=None):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful