|
18 | 18 | @author: Diego Torres Milano |
19 | 19 | ''' |
20 | 20 |
|
21 | | -__version__ = '10.9.1' |
| 21 | +__version__ = '11.0.0' |
22 | 22 | __author__ = 'diego' |
23 | 23 |
|
24 | 24 | import sys |
|
38 | 38 | class ViewClientWrapper: |
39 | 39 | def __init__(self, serialno): |
40 | 40 | device, serialno = ViewClient.connectToDeviceOrExit(serialno=serialno) |
41 | | - self.viewClient = ViewClient(device, serialno) |
| 41 | + self.vc = ViewClient(device, serialno) |
| 42 | + self.device = device |
42 | 43 | if DEBUG: |
43 | 44 | print >> sys.stderr, "ViewClientWrapper: connected to", device, serialno |
44 | 45 |
|
45 | 46 | def dump(self): |
46 | 47 | """Dumps window hierarchy.""" |
47 | | - return self.viewClient.dump() |
| 48 | + return self.vc.dump() |
| 49 | + |
| 50 | + def touch(self, x, y): |
| 51 | + """Touches a point. |
| 52 | +
|
| 53 | + :param x: x |
| 54 | + :param y: y |
| 55 | + :return: |
| 56 | + """ |
| 57 | + return self.vc.touch(x, y) |
| 58 | + |
| 59 | + @staticmethod |
| 60 | + def long_touch_view(view): |
| 61 | + """Long-touches the view.""" |
| 62 | + return view.longTouch() |
| 63 | + |
| 64 | + @staticmethod |
| 65 | + def touch_view(view): |
| 66 | + """Touches the View""" |
| 67 | + return view.touch() |
| 68 | + |
| 69 | + @staticmethod |
| 70 | + def get_view_position_and_size(view): |
| 71 | + """ Gets the View position and size |
| 72 | + :param view: the View |
| 73 | + :return: the position and size |
| 74 | + """ |
| 75 | + return view.getPositionAndSize() |
| 76 | + |
| 77 | + def find_view_with_text(self, text): |
| 78 | + return self.vc.findViewWithText(text) |
| 79 | + |
| 80 | + def find_view_by_id(self, id): |
| 81 | + return self.vc.findViewById(id) |
48 | 82 |
|
49 | 83 | def start_activity(self, component): |
50 | 84 | """Starts Activity.""" |
51 | | - return self.viewClient.device.startActivity(component) |
| 85 | + return self.vc.device.startActivity(component) |
| 86 | + |
| 87 | + def get_top_activity_name(self): |
| 88 | + return self.device.getTopActivityName() |
| 89 | + |
| 90 | + def force_stop_package(self, package): |
| 91 | + self.device.shell('am force-stop %s' % package) |
52 | 92 |
|
53 | | - def long_touch_button(self, text): |
54 | | - """Long-touches the button.""" |
55 | | - self.viewClient.findViewWithTextOrRaise(text).longTouch() |
| 93 | + def get_windows(self): |
| 94 | + return self.device.getWindows() |
56 | 95 |
|
| 96 | + def is_keyboard_show(self): |
| 97 | + return self.device.isKeyboardShown() |
57 | 98 |
|
0 commit comments