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

Unified Diff: telemetry/telemetry/core/android_action_runner_unittest.py

Issue 2822573002: Fix android_action_runner.InputSwipe and InputText (Closed)
Patch Set: nit. Created 3 years, 8 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
« no previous file with comments | « telemetry/telemetry/core/android_action_runner.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/core/android_action_runner_unittest.py
diff --git a/telemetry/telemetry/core/android_action_runner_unittest.py b/telemetry/telemetry/core/android_action_runner_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..795738318da3117e02e200c7a05f911a33059f1d
--- /dev/null
+++ b/telemetry/telemetry/core/android_action_runner_unittest.py
@@ -0,0 +1,76 @@
+# Copyright 2017 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.
+
+from telemetry import decorators
+from telemetry.internal.actions import action_runner as action_runner_module
+from telemetry.testing import tab_test_case
+
+
+class AndroidActionRunnerInteractionTest(tab_test_case.TabTestCase):
+ @decorators.Enabled('android')
+ def testSmoothScrollBy(self):
+ self.Navigate('page_with_swipeables.html')
+ action_runner = action_runner_module.ActionRunner(self._tab,
+ skip_waits=True)
+ self.assertEquals(action_runner.EvaluateJavaScript('window.scrollY'), 0)
+ self.assertEquals(action_runner.EvaluateJavaScript('window.scrollX'), 0)
+
+ platform = action_runner.tab.browser.platform
+ app_ui = action_runner.tab.browser.GetAppUi()
+ view = app_ui.WaitForUiNode(resource_id='compositor_view_holder')
+ scroll_start1 = 0.5 * (view.bounds.center + view.bounds.bottom_right)
+ platform.android_action_runner.SmoothScrollBy(
+ scroll_start1.x, scroll_start1.y, 'down', 300)
+ self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') > 0)
+
+ scroll_start2 = 0.5 * (view.bounds.center + view.bounds.top_left)
+ platform.android_action_runner.SmoothScrollBy(
+ scroll_start2.x, scroll_start2.y, 'up', 500)
+ self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') == 0)
+
+ @decorators.Enabled('android')
+ def testInputSwipe(self):
+ self.Navigate('page_with_swipeables.html')
+ action_runner = action_runner_module.ActionRunner(self._tab,
+ skip_waits=True)
+ self.assertEquals(action_runner.EvaluateJavaScript('window.scrollY'), 0)
+ self.assertEquals(action_runner.EvaluateJavaScript('window.scrollX'), 0)
+
+ platform = action_runner.tab.browser.platform
+ app_ui = action_runner.tab.browser.GetAppUi()
+ view = app_ui.WaitForUiNode(resource_id='compositor_view_holder')
+ scroll_start1 = 0.5 * (view.bounds.center + view.bounds.bottom_right)
+ scroll_end1 = scroll_start1.y - 300
+ platform.android_action_runner.InputSwipe(
+ scroll_start1.x, scroll_start1.y, scroll_start1.x, scroll_end1, 300)
+ self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') > 0)
+
+ scroll_start2 = 0.5 * (view.bounds.center + view.bounds.top_left)
+ scroll_end2 = scroll_start2.y + 500
+ platform.android_action_runner.InputSwipe(
+ scroll_start2.x, scroll_start2.y, scroll_start2.x, scroll_end2, 500)
+ self.assertTrue(action_runner.EvaluateJavaScript('window.scrollY') == 0)
+
+ @decorators.Enabled('android')
+ def testInputText(self):
+ self.Navigate('blank.html')
+ self._tab.ExecuteJavaScript(
+ '(function() {'
+ ' var elem = document.createElement("textarea");'
+ ' document.body.appendChild(elem);'
+ ' elem.focus();'
+ '})();')
+
+ action_runner = action_runner_module.ActionRunner(self._tab,
+ skip_waits=True)
+ platform = action_runner.tab.browser.platform
+ platform.android_action_runner.InputText('Input spaces')
+ platform.android_action_runner.InputText(', even multiple spaces')
+
+ # Check that the contents of the textarea is correct. It might take some
+ # time until keystrokes are handled on Android.
+ self._tab.WaitForJavaScriptCondition(
+ ('document.querySelector("textarea").value === '
+ '"Input spaces, even multiple spaces"'),
+ timeout=5)
« no previous file with comments | « telemetry/telemetry/core/android_action_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698