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 import decorators |
8 from telemetry.internal.actions import key_event | 8 from telemetry.internal.actions import key_event |
9 from telemetry.internal.actions import utils | 9 from telemetry.internal.actions import utils |
10 from telemetry.testing import tab_test_case | 10 from telemetry.testing import tab_test_case |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 def setUp(self): | 29 def setUp(self): |
30 tab_test_case.TabTestCase.setUp(self) | 30 tab_test_case.TabTestCase.setUp(self) |
31 self.Navigate('blank.html') | 31 self.Navigate('blank.html') |
32 utils.InjectJavaScript(self._tab, 'gesture_common.js') | 32 utils.InjectJavaScript(self._tab, 'gesture_common.js') |
33 | 33 |
34 # https://github.com/catapult-project/catapult/issues/3099 | 34 # https://github.com/catapult-project/catapult/issues/3099 |
35 @decorators.Disabled('android') | 35 @decorators.Disabled('android') |
36 def testPressEndAndHome(self): | 36 def testPressEndAndHome(self): |
37 # Make page taller than the window so it's scrollable. | 37 # Make page taller than the window so it's scrollable. |
38 self._tab.ExecuteJavaScript('document.body.style.height =' | 38 self._tab.ExecuteJavaScript('document.body.style.height ='\ |
39 '(3 * __GestureCommon_GetWindowHeight() + 1) + "px";') | 39 '(3 * __GestureCommon_GetWindowHeight() + 1) + "px";') |
40 | 40 |
41 # 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 |
42 # the page has non-trivial height. | 42 # the page has non-trivial height. |
43 self.assertEquals(0, self._scroll_position) | 43 self.assertEquals(0, self._scroll_position) |
44 self.assertLess(50, self._window_height) | 44 self.assertLess(50, self._window_height) |
45 | 45 |
46 self._PressKey('End') | 46 self._PressKey('End') |
47 | 47 |
48 # Scroll happens *after* key press returns, so we need to wait a little. | 48 # Scroll happens *after* key press returns, so we need to wait a little. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 # 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 |
82 # 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). |
83 self._tab.WaitForJavaScriptCondition( | 83 self._tab.WaitForJavaScriptCondition( |
84 'document.querySelector("textarea").value === "Hello,\\nWorld!"', | 84 'document.querySelector("textarea").value === "Hello,\\nWorld!"', |
85 timeout=1) | 85 timeout=1) |
86 | 86 |
87 def testPressUnknownKey(self): | 87 def testPressUnknownKey(self): |
88 with self.assertRaises(ValueError): | 88 with self.assertRaises(ValueError): |
89 self._PressKey('UnknownKeyName') | 89 self._PressKey('UnknownKeyName') |
OLD | NEW |