From b34e8a7cb8483d53736032e33cc4de48e18cb3f7 Mon Sep 17 00:00:00 2001 From: tadashi0713 Date: Fri, 4 Jan 2019 19:51:25 +0900 Subject: [PATCH 1/7] Add press test --- test/unit/webdriver/touch_action_test.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/webdriver/touch_action_test.py b/test/unit/webdriver/touch_action_test.py index 0d752fd6..aac39ad0 100644 --- a/test/unit/webdriver/touch_action_test.py +++ b/test/unit/webdriver/touch_action_test.py @@ -37,6 +37,20 @@ def test_tap_x_y_json(self, touch_action): touch_action.tap(ElementStub(2), 3, 4) assert json == touch_action.json_wire_gestures + def test_press_json(self, touch_action): + json = [ + {'action': 'press', 'options': {'element': 3}} + ] + touch_action.press(ElementStub(3)) + assert json == touch_action.json_wire_gestures + + def test_press_x_y_json(self, touch_action): + json = [ + {'action': 'press', 'options': {'element': 4, 'x': 3, 'y': 4}} + ] + touch_action.press(ElementStub(4), 3, 4) + assert json == touch_action.json_wire_gestures + class DriverStub(object): def execute(self, _action, _params): From 88a68724b1de9a081f813ed9c7ad818ecbc5c2a8 Mon Sep 17 00:00:00 2001 From: tadashi0713 Date: Fri, 4 Jan 2019 20:01:01 +0900 Subject: [PATCH 2/7] Add test_long_press --- test/unit/webdriver/touch_action_test.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/webdriver/touch_action_test.py b/test/unit/webdriver/touch_action_test.py index aac39ad0..cce61164 100644 --- a/test/unit/webdriver/touch_action_test.py +++ b/test/unit/webdriver/touch_action_test.py @@ -51,6 +51,20 @@ def test_press_x_y_json(self, touch_action): touch_action.press(ElementStub(4), 3, 4) assert json == touch_action.json_wire_gestures + def test_long_press_json(self, touch_action): + json = [ + {'action': 'longPress', 'options': {'element': 5, 'duration': 2000}} + ] + touch_action.long_press(ElementStub(5), duration=2000) + assert json == touch_action.json_wire_gestures + + def test_long_press_x_y_json(self, touch_action): + json = [ + {'action': 'longPress', 'options': {'element': 6, 'x': 3, 'y': 4, 'duration': 1000}} + ] + touch_action.long_press(ElementStub(6), 3, 4) + assert json == touch_action.json_wire_gestures + class DriverStub(object): def execute(self, _action, _params): From 72444a4b180539c89b5ebc48b3c4746bdb51a58d Mon Sep 17 00:00:00 2001 From: tadashi0713 Date: Fri, 4 Jan 2019 20:07:27 +0900 Subject: [PATCH 3/7] Add test_wait --- test/unit/webdriver/touch_action_test.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/webdriver/touch_action_test.py b/test/unit/webdriver/touch_action_test.py index cce61164..2fc3c04e 100644 --- a/test/unit/webdriver/touch_action_test.py +++ b/test/unit/webdriver/touch_action_test.py @@ -65,6 +65,20 @@ def test_long_press_x_y_json(self, touch_action): touch_action.long_press(ElementStub(6), 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 + class DriverStub(object): def execute(self, _action, _params): From ad4afb01708aa174fce4336bcc9accb677b09fbe Mon Sep 17 00:00:00 2001 From: tadashi0713 Date: Fri, 4 Jan 2019 20:14:45 +0900 Subject: [PATCH 4/7] Add remaining tests --- test/unit/webdriver/touch_action_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/unit/webdriver/touch_action_test.py b/test/unit/webdriver/touch_action_test.py index 2fc3c04e..042ca47a 100644 --- a/test/unit/webdriver/touch_action_test.py +++ b/test/unit/webdriver/touch_action_test.py @@ -79,6 +79,25 @@ def test_wait_without_ms_json(self, touch_action): touch_action.wait() assert json == touch_action.json_wire_gestures + def test_move_to_json(self, touch_action): + json = [ + {'action': 'moveTo', 'options': {'element': 7, 'x': 3, 'y': 4}} + ] + touch_action.move_to(ElementStub(7), 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 = [] + touch_action.perform() + assert json == touch_action.json_wire_gestures + class DriverStub(object): def execute(self, _action, _params): From 2c2c517e24dfae4653afa7085c08b869079b3c3f Mon Sep 17 00:00:00 2001 From: tadashi0713 Date: Fri, 4 Jan 2019 20:26:23 +0900 Subject: [PATCH 5/7] Add tap --- test/unit/webdriver/touch_action_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/webdriver/touch_action_test.py b/test/unit/webdriver/touch_action_test.py index 042ca47a..26a1b6dc 100644 --- a/test/unit/webdriver/touch_action_test.py +++ b/test/unit/webdriver/touch_action_test.py @@ -88,14 +88,14 @@ def test_move_to_json(self, touch_action): def test_release_json(self, touch_action): json = [ - {'action': 'release', 'options': {}} + {'action': 'tap', 'options': {'count': 1, 'element': 8}}, {'action': 'release', 'options': {}} ] - touch_action.release() + touch_action.tap(ElementStub(8)).release() assert json == touch_action.json_wire_gestures def test_perform_json(self, touch_action): json = [] - touch_action.perform() + touch_action.tap(ElementStub(10)).perform() assert json == touch_action.json_wire_gestures From c62266749631eb8d562e375d878afb12b1433082 Mon Sep 17 00:00:00 2001 From: tadashi0713 Date: Fri, 4 Jan 2019 20:27:47 +0900 Subject: [PATCH 6/7] 10 -> 9 --- test/unit/webdriver/touch_action_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/webdriver/touch_action_test.py b/test/unit/webdriver/touch_action_test.py index 26a1b6dc..5d9f099f 100644 --- a/test/unit/webdriver/touch_action_test.py +++ b/test/unit/webdriver/touch_action_test.py @@ -95,7 +95,7 @@ def test_release_json(self, touch_action): def test_perform_json(self, touch_action): json = [] - touch_action.tap(ElementStub(10)).perform() + touch_action.tap(ElementStub(9)).perform() assert json == touch_action.json_wire_gestures From bcf213a3db18f263048a94ac36fd7f95e1db5fe5 Mon Sep 17 00:00:00 2001 From: tadashi0713 Date: Sat, 5 Jan 2019 15:27:37 +0900 Subject: [PATCH 7/7] Modify based on comment --- test/unit/webdriver/touch_action_test.py | 38 +++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/test/unit/webdriver/touch_action_test.py b/test/unit/webdriver/touch_action_test.py index 5d9f099f..4e37b63d 100644 --- a/test/unit/webdriver/touch_action_test.py +++ b/test/unit/webdriver/touch_action_test.py @@ -32,37 +32,37 @@ 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': 3}} + {'action': 'press', 'options': {'element': 1}} ] - touch_action.press(ElementStub(3)) + 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': 4, 'x': 3, 'y': 4}} + {'action': 'press', 'options': {'element': 1, 'x': 3, 'y': 4}} ] - touch_action.press(ElementStub(4), 3, 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': 5, 'duration': 2000}} + {'action': 'longPress', 'options': {'element': 1, 'duration': 2000}} ] - touch_action.long_press(ElementStub(5), 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': 6, 'x': 3, 'y': 4, 'duration': 1000}} + {'action': 'longPress', 'options': {'element': 1, 'x': 3, 'y': 4, 'duration': 1000}} ] - touch_action.long_press(ElementStub(6), 3, 4) + touch_action.long_press(ElementStub(1), 3, 4) assert json == touch_action.json_wire_gestures def test_wait_json(self, touch_action): @@ -81,22 +81,26 @@ def test_wait_without_ms_json(self, touch_action): def test_move_to_json(self, touch_action): json = [ - {'action': 'moveTo', 'options': {'element': 7, 'x': 3, 'y': 4}} + {'action': 'moveTo', 'options': {'element': 1, 'x': 3, 'y': 4}} ] - touch_action.move_to(ElementStub(7), 3, 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': 'tap', 'options': {'count': 1, 'element': 8}}, {'action': 'release', 'options': {}} + {'action': 'release', 'options': {}} ] - touch_action.tap(ElementStub(8)).release() + touch_action.release() assert json == touch_action.json_wire_gestures def test_perform_json(self, touch_action): - json = [] - touch_action.tap(ElementStub(9)).perform() - assert json == touch_action.json_wire_gestures + 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):