OLD | NEW |
---|---|
(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 | |
5 from telemetry import decorators | |
6 from telemetry.internal.actions import action_runner as action_runner_module | |
7 from telemetry.testing import tab_test_case | |
8 | |
9 | |
10 class AndroidActionRunnerInteractionTest(tab_test_case.TabTestCase): | |
11 @decorators.Enabled('android') | |
12 def testSmoothScrollBy(self): | |
13 self.Navigate('page_with_swipeables.html') | |
14 action_runner = action_runner_module.ActionRunner(self._tab, | |
15 skip_waits=True) | |
16 self.assertEquals(action_runner.EvaluateJavaScript('window.scrollY'), 0) | |
17 self.assertEquals(action_runner.EvaluateJavaScript('window.scrollX'), 0) | |
18 | |
19 platform = action_runner.tab.browser.platform | |
20 app_ui = action_runner.tab.browser.GetAppUi() | |
21 view = app_ui.WaitForUiNode(resource_id='compositor_view_holder') | |
22 scroll_start1 = 0.5 * (view.bounds.center + view.bounds.bottom_right) | |
23 platform.android_action_runner.SmoothScrollBy( | |
24 scroll_start1.x, scroll_start1.y, 'down', 300) | |
25 self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') > 0) | |
26 | |
27 scroll_start2 = 0.5 * (view.bounds.center + view.bounds.top_left) | |
28 platform.android_action_runner.SmoothScrollBy( | |
29 scroll_start2.x, scroll_start2.y, 'up', 500) | |
30 self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') == 0) | |
31 | |
32 @decorators.Enabled('android') | |
33 def testInputSwipe(self): | |
34 self.Navigate('page_with_swipeables.html') | |
35 action_runner = action_runner_module.ActionRunner(self._tab, | |
36 skip_waits=True) | |
37 self.assertEquals(action_runner.EvaluateJavaScript('window.scrollY'), 0) | |
38 self.assertEquals(action_runner.EvaluateJavaScript('window.scrollX'), 0) | |
39 | |
40 platform = action_runner.tab.browser.platform | |
41 app_ui = action_runner.tab.browser.GetAppUi() | |
42 view = app_ui.WaitForUiNode(resource_id='compositor_view_holder') | |
43 scroll_start1 = 0.5 * (view.bounds.center + view.bounds.bottom_right) | |
44 scroll_end1 = scroll_start1.y - 300 | |
45 platform.android_action_runner.InputSwipe( | |
46 scroll_start1.x, scroll_start1.y, scroll_start1.x, scroll_end1, 300) | |
47 self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') > 0) | |
48 | |
49 scroll_start2 = 0.5 * (view.bounds.center + view.bounds.top_left) | |
50 scroll_end2 = scroll_start2.y + 500 | |
51 platform.android_action_runner.InputSwipe( | |
52 scroll_start2.x, scroll_start2.y, scroll_start2.x, scroll_end2, 500) | |
53 self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') == 0) | |
54 | |
55 @decorators.Enabled('android') | |
56 def testInputText(self): | |
57 self.Navigate('blank.html') | |
58 self._tab.ExecuteJavaScript( | |
59 '(function() {' | |
60 ' var elem = document.createElement("textarea");' | |
61 ' document.body.appendChild(elem);' | |
62 ' elem.focus();' | |
63 '})();') | |
64 | |
65 action_runner = action_runner_module.ActionRunner(self._tab, | |
66 skip_waits=True) | |
67 platform = action_runner.tab.browser.platform | |
68 platform.android_action_runner.InputText('Input spaces') | |
69 platform.android_action_runner.InputText(', even multiple spaces') | |
70 | |
71 # Check that the contents of the textarea is correct. It might take some | |
72 # time until keystrokes are handled on Android. | |
73 self._tab.WaitForJavaScriptCondition( | |
74 ('document.querySelector("textarea").value === ' | |
75 '"Input spaces, even multiple spaces"'), | |
76 timeout=5) | |
77 | |
nednguyen
2017/04/26 14:59:56
nits: remove this blank line
ssid
2017/04/26 17:24:26
Done.
| |
OLD | NEW |