Skip to content

Add touch action unittest #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions test/unit/webdriver/touch_action_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,76 @@ def test_tap_json(self, touch_action):

def test_tap_x_y_json(self, touch_action):
json = [
{'action': 'tap', 'options': {'x': 3, 'y': 4, 'count': 1, 'element': 2}}
{'action': 'tap', 'options': {'x': 3, 'y': 4, 'count': 1, 'element': 1}}
]
touch_action.tap(ElementStub(2), 3, 4)
touch_action.tap(ElementStub(1), 3, 4)
assert json == touch_action.json_wire_gestures

def test_press_json(self, touch_action):
json = [
{'action': 'press', 'options': {'element': 1}}
]
touch_action.press(ElementStub(1))
assert json == touch_action.json_wire_gestures

def test_press_x_y_json(self, touch_action):
json = [
{'action': 'press', 'options': {'element': 1, 'x': 3, 'y': 4}}
]
touch_action.press(ElementStub(1), 3, 4)
assert json == touch_action.json_wire_gestures

def test_long_press_json(self, touch_action):
json = [
{'action': 'longPress', 'options': {'element': 1, 'duration': 2000}}
]
touch_action.long_press(ElementStub(1), duration=2000)
assert json == touch_action.json_wire_gestures

def test_long_press_x_y_json(self, touch_action):
json = [
{'action': 'longPress', 'options': {'element': 1, 'x': 3, 'y': 4, 'duration': 1000}}
]
touch_action.long_press(ElementStub(1), 3, 4)
assert json == touch_action.json_wire_gestures

def test_wait_json(self, touch_action):
json = [
{'action': 'wait', 'options': {'ms': 10}}
]
touch_action.wait(10)
assert json == touch_action.json_wire_gestures

def test_wait_without_ms_json(self, touch_action):
json = [
{'action': 'wait', 'options': {'ms': 0}}
]
touch_action.wait()
assert json == touch_action.json_wire_gestures

def test_move_to_json(self, touch_action):
json = [
{'action': 'moveTo', 'options': {'element': 1, 'x': 3, 'y': 4}}
]
touch_action.move_to(ElementStub(1), 3, 4)
assert json == touch_action.json_wire_gestures

def test_release_json(self, touch_action):
json = [
{'action': 'release', 'options': {}}
]
touch_action.release()
assert json == touch_action.json_wire_gestures

def test_perform_json(self, touch_action):
json_tap = [
{'action': 'tap', 'options': {'element': 1, 'count': 1}}
]
touch_action.tap(ElementStub(1))
assert json_tap == touch_action.json_wire_gestures
touch_action.perform()
assert [] == touch_action.json_wire_gestures


class DriverStub(object):
def execute(self, _action, _params):
Expand Down