OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import time | 5 import time |
6 | 6 |
| 7 from telemetry import decorators |
7 from telemetry.internal.actions import key_event | 8 from telemetry.internal.actions import key_event |
8 from telemetry.internal.actions import utils | 9 from telemetry.internal.actions import utils |
9 from telemetry.testing import tab_test_case | 10 from telemetry.testing import tab_test_case |
10 | 11 |
11 | 12 |
12 class KeyPressActionTest(tab_test_case.TabTestCase): | 13 class KeyPressActionTest(tab_test_case.TabTestCase): |
13 | 14 |
14 @property | 15 @property |
15 def _scroll_position(self): | 16 def _scroll_position(self): |
16 return self._tab.EvaluateJavaScript( | 17 return self._tab.EvaluateJavaScript( |
17 'document.documentElement.scrollTop || document.body.scrollTop') | 18 'document.documentElement.scrollTop || document.body.scrollTop') |
18 | 19 |
19 @property | 20 @property |
20 def _window_height(self): | 21 def _window_height(self): |
21 return self._tab.EvaluateJavaScript('__GestureCommon_GetWindowHeight()') | 22 return self._tab.EvaluateJavaScript('__GestureCommon_GetWindowHeight()') |
22 | 23 |
23 def _PressKey(self, key): | 24 def _PressKey(self, key): |
24 action = key_event.KeyPressAction(key) | 25 action = key_event.KeyPressAction(key) |
25 action.WillRunAction(self._tab) | 26 action.WillRunAction(self._tab) |
26 action.RunAction(self._tab) | 27 action.RunAction(self._tab) |
27 | 28 |
28 def setUp(self): | 29 def setUp(self): |
29 tab_test_case.TabTestCase.setUp(self) | 30 tab_test_case.TabTestCase.setUp(self) |
30 self.Navigate('blank.html') | 31 self.Navigate('blank.html') |
31 utils.InjectJavaScript(self._tab, 'gesture_common.js') | 32 utils.InjectJavaScript(self._tab, 'gesture_common.js') |
32 | 33 |
| 34 # https://github.com/catapult-project/catapult/issues/3099 |
| 35 @decorators.Disabled('android') |
33 def testPressEndAndHome(self): | 36 def testPressEndAndHome(self): |
34 # Make page taller than the window so it's scrollable. | 37 # Make page taller than the window so it's scrollable. |
35 self._tab.ExecuteJavaScript('document.body.style.height =' | 38 self._tab.ExecuteJavaScript('document.body.style.height =' |
36 '(3 * __GestureCommon_GetWindowHeight() + 1) + "px";') | 39 '(3 * __GestureCommon_GetWindowHeight() + 1) + "px";') |
37 | 40 |
38 # Check that the browser is currently showing the top of the page and that | 41 # Check that the browser is currently showing the top of the page and that |
39 # the page has non-trivial height. | 42 # the page has non-trivial height. |
40 self.assertEquals(0, self._scroll_position) | 43 self.assertEquals(0, self._scroll_position) |
41 self.assertLess(50, self._window_height) | 44 self.assertLess(50, self._window_height) |
42 | 45 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 80 |
78 # Check that the contents of the textarea is correct. It might take a second | 81 # Check that the contents of the textarea is correct. It might take a second |
79 # until all keystrokes have been handled by the browser (crbug.com/630017). | 82 # until all keystrokes have been handled by the browser (crbug.com/630017). |
80 self._tab.WaitForJavaScriptExpression( | 83 self._tab.WaitForJavaScriptExpression( |
81 'document.querySelector("textarea").value === "Hello,\\nWorld!"', | 84 'document.querySelector("textarea").value === "Hello,\\nWorld!"', |
82 timeout=1) | 85 timeout=1) |
83 | 86 |
84 def testPressUnknownKey(self): | 87 def testPressUnknownKey(self): |
85 with self.assertRaises(ValueError): | 88 with self.assertRaises(ValueError): |
86 self._PressKey('UnknownKeyName') | 89 self._PressKey('UnknownKeyName') |
OLD | NEW |