Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: telemetry/telemetry/core/android_action_runner_unittest.py

Issue 2822573002: Fix android_action_runner.InputSwipe and InputText (Closed)
Patch Set: More fixes. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 from telemetry import decorators
rnephew (Reviews Here) 2017/04/26 01:01:26 nit: line between copyright and imports.
ssid 2017/04/26 01:12:46 Done.
5 from telemetry.internal.actions import action_runner as action_runner_module
6 from telemetry.testing import tab_test_case
7
8
9 class AndroidActionRunnerInteractionTest(tab_test_case.TabTestCase):
10 @decorators.Enabled('android')
11 def testSmoothScrollBy(self):
12 self.Navigate('page_with_swipeables.html')
13 action_runner = action_runner_module.ActionRunner(self._tab,
14 skip_waits=True)
15 self.assertEquals(action_runner.EvaluateJavaScript('window.scrollY'), 0)
16 self.assertEquals(action_runner.EvaluateJavaScript('window.scrollX'), 0)
17
18 platform = action_runner.tab.browser.platform
19 app_ui = action_runner.tab.browser.GetAppUi()
20 view = app_ui.WaitForUiNode(resource_id='compositor_view_holder')
21 scroll_start1 = 0.5 * (view.bounds.center + view.bounds.bottom_right)
22 platform.android_action_runner.SmoothScrollBy(
23 scroll_start1.x, scroll_start1.y, 'down', 300)
24 self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') > 0)
25
26 scroll_start2 = 0.5 * (view.bounds.center + view.bounds.top_left)
27 platform.android_action_runner.SmoothScrollBy(
28 scroll_start2.x, scroll_start2.y, 'up', 500)
29 self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') == 0)
30
31 @decorators.Enabled('android')
32 def testInputSwipe(self):
33 self.Navigate('page_with_swipeables.html')
34 action_runner = action_runner_module.ActionRunner(self._tab,
35 skip_waits=True)
36 self.assertEquals(action_runner.EvaluateJavaScript('window.scrollY'), 0)
37 self.assertEquals(action_runner.EvaluateJavaScript('window.scrollX'), 0)
38
39 platform = action_runner.tab.browser.platform
40 app_ui = action_runner.tab.browser.GetAppUi()
41 view = app_ui.WaitForUiNode(resource_id='compositor_view_holder')
42 scroll_start1 = 0.5 * (view.bounds.center + view.bounds.bottom_right)
43 scroll_end1 = scroll_start1.y - 300
44 platform.android_action_runner.InputSwipe(
45 scroll_start1.x, scroll_start1.y, scroll_start1.x, scroll_end1, 300)
46 self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') > 0)
47
48 scroll_start2 = 0.5 * (view.bounds.center + view.bounds.top_left)
49 scroll_end2 = scroll_start2.y + 500
50 platform.android_action_runner.InputSwipe(
51 scroll_start2.x, scroll_start2.y, scroll_start2.x, scroll_end2, 500)
52 self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') == 0)
53
54 @decorators.Enabled('android')
55 def testInputText(self):
56 self.Navigate('blank.html')
57 self._tab.ExecuteJavaScript(
58 '(function() {'
59 ' var elem = document.createElement("textarea");'
60 ' document.body.appendChild(elem);'
61 ' elem.focus();'
62 '})();')
63
64 action_runner = action_runner_module.ActionRunner(self._tab,
65 skip_waits=True)
66 platform = action_runner.tab.browser.platform
67 platform.android_action_runner.InputText('with spaces')
68 action_runner.PressKey('Home') # |That is boring.
rnephew (Reviews Here) 2017/04/26 01:01:26 Is this part realistic? Are Home and End keys real
ssid 2017/04/26 01:12:46 Actually not realistic. I was just trying to repli
69 platform.android_action_runner.InputText('Input ')
70 action_runner.PressKey('End') # This is boring|.
71 platform.android_action_runner.InputText(', even multiple spaces')
72
73 # Check that the contents of the textarea is correct. It might take some
74 # time until keystrokes are handled on Android.
75 self._tab.WaitForJavaScriptCondition(
76 ('document.querySelector("textarea").value === '
77 '"Input with spaces, even multiple spaces"'),
78 timeout=5)
79
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698