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

Unified Diff: telemetry/telemetry/internal/actions/key_event_unittest.py

Issue 2137243002: Revert of [telemetry] Add support for dispatching key events (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: telemetry/telemetry/internal/actions/key_event_unittest.py
diff --git a/telemetry/telemetry/internal/actions/key_event_unittest.py b/telemetry/telemetry/internal/actions/key_event_unittest.py
deleted file mode 100644
index b1b43d35ec7e4da3d7c28962e79b676f94fc0f3f..0000000000000000000000000000000000000000
--- a/telemetry/telemetry/internal/actions/key_event_unittest.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import time
-
-from telemetry.internal.actions import key_event
-from telemetry.testing import tab_test_case
-
-
-class KeyPressActionTest(tab_test_case.TabTestCase):
-
- @property
- def _scroll_position(self):
- return self._tab.EvaluateJavaScript(
- 'document.documentElement.scrollTop || document.body.scrollTop')
-
- @property
- def _window_height(self):
- return self._tab.EvaluateJavaScript('window.innerHeight')
-
- def _PressKey(self, key):
- action = key_event.KeyPressAction(key)
- action.WillRunAction(self._tab)
- action.RunAction(self._tab)
-
- def setUp(self):
- tab_test_case.TabTestCase.setUp(self)
- self.Navigate('blank.html')
-
- def testPressEndAndHome(self):
- # Make page taller than the window so it's scrollable.
- self._tab.ExecuteJavaScript(
- 'document.body.style.height = (3 * window.innerHeight + 1) + "px";')
-
- # Check that the browser is currently showing the top of the page and that
- # the page has non-trivial height.
- self.assertEquals(0, self._scroll_position)
- self.assertLess(50, self._window_height)
-
- self._PressKey('End')
-
- # Scroll happens *after* key press returns, so we need to wait a little.
- time.sleep(1)
-
- # We can only expect the bottom scroll position to be approximatly equal.
- self.assertAlmostEqual(2 * self._window_height, self._scroll_position,
- delta=20)
-
- self._PressKey('Home')
-
- # Scroll happens *after* key press returns, so we need to wait a little.
- time.sleep(1)
-
- self.assertEquals(self._scroll_position, 0)
-
- def testTextEntry(self):
- # Add an input box to the page.
- self._tab.ExecuteJavaScript(
- '(function() {'
- ' var elem = document.createElement("textarea");'
- ' document.body.appendChild(elem);'
- ' elem.focus();'
- '})();')
-
- # Simulate typing a sentence.
- for char in 'Hello, World!':
- self._PressKey(char)
-
- # Make changes to the sentence using special keys.
- for _ in xrange(6):
- self._PressKey('ArrowLeft')
- self._PressKey('Backspace')
- self._PressKey('Return')
-
- # Check that the contents of the textarea is correct.
- self.assertEquals('Hello,\nWorld!',
- self._tab.EvaluateJavaScript(
- 'document.querySelector("textarea").value'))
-
- def testPressUnknownKey(self):
- with self.assertRaises(ValueError):
- self._PressKey('UnknownKeyName')

Powered by Google App Engine
This is Rietveld 408576698