Skip to content

Commit 9733c60

Browse files
tadashi0713KazuCocoa
authored andcommitted
Add touch action unittest (#306)
* Add press test * Add test_long_press * Add test_wait * Add remaining tests * Add tap * 10 -> 9 * Modify based on comment
1 parent 261ff54 commit 9733c60

File tree

1 file changed

+67
-2
lines changed

1 file changed

+67
-2
lines changed

test/unit/webdriver/touch_action_test.py

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,76 @@ def test_tap_json(self, touch_action):
3232

3333
def test_tap_x_y_json(self, touch_action):
3434
json = [
35-
{'action': 'tap', 'options': {'x': 3, 'y': 4, 'count': 1, 'element': 2}}
35+
{'action': 'tap', 'options': {'x': 3, 'y': 4, 'count': 1, 'element': 1}}
3636
]
37-
touch_action.tap(ElementStub(2), 3, 4)
37+
touch_action.tap(ElementStub(1), 3, 4)
3838
assert json == touch_action.json_wire_gestures
3939

40+
def test_press_json(self, touch_action):
41+
json = [
42+
{'action': 'press', 'options': {'element': 1}}
43+
]
44+
touch_action.press(ElementStub(1))
45+
assert json == touch_action.json_wire_gestures
46+
47+
def test_press_x_y_json(self, touch_action):
48+
json = [
49+
{'action': 'press', 'options': {'element': 1, 'x': 3, 'y': 4}}
50+
]
51+
touch_action.press(ElementStub(1), 3, 4)
52+
assert json == touch_action.json_wire_gestures
53+
54+
def test_long_press_json(self, touch_action):
55+
json = [
56+
{'action': 'longPress', 'options': {'element': 1, 'duration': 2000}}
57+
]
58+
touch_action.long_press(ElementStub(1), duration=2000)
59+
assert json == touch_action.json_wire_gestures
60+
61+
def test_long_press_x_y_json(self, touch_action):
62+
json = [
63+
{'action': 'longPress', 'options': {'element': 1, 'x': 3, 'y': 4, 'duration': 1000}}
64+
]
65+
touch_action.long_press(ElementStub(1), 3, 4)
66+
assert json == touch_action.json_wire_gestures
67+
68+
def test_wait_json(self, touch_action):
69+
json = [
70+
{'action': 'wait', 'options': {'ms': 10}}
71+
]
72+
touch_action.wait(10)
73+
assert json == touch_action.json_wire_gestures
74+
75+
def test_wait_without_ms_json(self, touch_action):
76+
json = [
77+
{'action': 'wait', 'options': {'ms': 0}}
78+
]
79+
touch_action.wait()
80+
assert json == touch_action.json_wire_gestures
81+
82+
def test_move_to_json(self, touch_action):
83+
json = [
84+
{'action': 'moveTo', 'options': {'element': 1, 'x': 3, 'y': 4}}
85+
]
86+
touch_action.move_to(ElementStub(1), 3, 4)
87+
assert json == touch_action.json_wire_gestures
88+
89+
def test_release_json(self, touch_action):
90+
json = [
91+
{'action': 'release', 'options': {}}
92+
]
93+
touch_action.release()
94+
assert json == touch_action.json_wire_gestures
95+
96+
def test_perform_json(self, touch_action):
97+
json_tap = [
98+
{'action': 'tap', 'options': {'element': 1, 'count': 1}}
99+
]
100+
touch_action.tap(ElementStub(1))
101+
assert json_tap == touch_action.json_wire_gestures
102+
touch_action.perform()
103+
assert [] == touch_action.json_wire_gestures
104+
40105

41106
class DriverStub(object):
42107
def execute(self, _action, _params):

0 commit comments

Comments
 (0)