Example #1
0
 def _screenshot_uiauto(self):
     tmp_file = tempfile.mktemp(prefix='atx-tmp-', suffix='.jpg')
     self._uiauto.screenshot(tmp_file)
     try:
         return imutils.open_as_pillow(tmp_file)
     except IOError:
         raise IOError("Screenshot use uiautomator failed.")
     finally:
         base.remove_force(tmp_file)
Example #2
0
 def _screenshot_uiauto(self):
     tmp_file = tempfile.mktemp(prefix='atx-tmp-', suffix='.jpg')
     self._uiauto.screenshot(tmp_file)
     try:
         return imutils.open_as_pillow(tmp_file)
     except IOError:
         raise IOError("Screenshot use uiautomator failed.")
     finally:
         base.remove_force(tmp_file)
Example #3
0
 def _screenshot_uiauto(self):
     tmp_file = self._mktemp()
     self._uiauto.screenshot(tmp_file)
     try:
         return imutils.open_as_pillow(tmp_file)
     except IOError:
         raise IOError("Screenshot use uiautomator failed.")
     finally:
         base.remove_force(tmp_file)
Example #4
0
 def _screenshot_uiauto(self):
     tmp_file = self._mktemp()
     UiaDevice.screenshot(self, tmp_file)
     # self._uiauto.screenshot(tmp_file) # this will call Mixin.screenshot first, which may get too many loop
     try:
         return imutils.open_as_pillow(tmp_file)
     except IOError:
         raise IOError("Screenshot use uiautomator failed.")
     finally:
         base.remove_force(tmp_file)
Example #5
0
 def _screenshot_minicap(self):
     phone_tmp_file = '/data/local/tmp/_atx_screen-{}.jpg'.format(self._randid)
     local_tmp_file = self._mktemp()
     command = 'LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P {} -s > {}'.format(
         self._minicap_params(), phone_tmp_file)
     try:
         self.adb_shell(command)
         self.adb_cmd(['pull', phone_tmp_file, local_tmp_file])
         image = imutils.open_as_pillow(local_tmp_file)
         # Fix rotation not rotate right.
         (width, height) = image.size
         if self.screen_rotation in [1, 3] and width < height:
             image = image.rotate(90, Image.BILINEAR, expand=True)
         return image
     except IOError:
         raise IOError("Screenshot use minicap failed.")
     finally:
         self.adb_shell(['rm', phone_tmp_file])
         base.remove_force(local_tmp_file)