Skip to content

Commit

Permalink
Merge branch 'pr1070' into v1.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
yimelia committed Sep 7, 2022
2 parents 36057a1 + 01e6435 commit 9e80ebc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions airtest/core/android/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1647,12 +1647,13 @@ def get_device_info(self):
ret[k] = v
return ret

def get_display_of_all_screen(self, info):
def get_display_of_all_screen(self, info, package=None):
"""
Perform `adb shell dumpsys window windows` commands to get window display of application.
Args:
info: device screen properties
package: package name, default to the package of top activity
Returns:
None if adb command failed to run, otherwise return device screen properties(portrait mode)
Expand All @@ -1662,7 +1663,7 @@ def get_display_of_all_screen(self, info):
output = self.shell("dumpsys window windows")
windows = output.split("Window #")
offsetx, offsety, width, height = 0, 0, info['width'], info['height']
package = self._search_for_current_package(output)
package = self._search_for_current_package(output) if package is None else package
if package:
for w in windows:
if "package=%s" % package in w:
Expand Down
12 changes: 8 additions & 4 deletions airtest/core/android/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,19 +750,20 @@ def get_current_resolution(self):
w, h = h, w
return w, h

def get_render_resolution(self, refresh=False):
def get_render_resolution(self, refresh=False, package=None):
"""
Return render resolution after rotation
Args:
refresh: whether to force refresh render resolution
package: package name, default to the package of top activity
Returns:
offset_x, offset_y, offset_width and offset_height of the display
"""
if refresh or 'offset_x' not in self._display_info:
self.adjust_all_screen()
self.adjust_all_screen(package)
x, y, w, h = self._display_info.get('offset_x', 0), \
self._display_info.get('offset_y', 0), \
self._display_info.get('offset_width', 0), \
Expand Down Expand Up @@ -857,16 +858,19 @@ def _touch_point_by_orientation(self, tuple_xy):
)
return x, y

def adjust_all_screen(self):
def adjust_all_screen(self, package=None):
"""
Adjust the render resolution for all_screen device.
Args:
package: package name, default to the package of top activity
Return:
None
"""
info = self.display_info
ret = self.adb.get_display_of_all_screen(info)
ret = self.adb.get_display_of_all_screen(info, package)
if ret:
info.update(ret)
self._display_info = info
Expand Down

0 comments on commit 9e80ebc

Please sign in to comment.