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

Side by Side Diff: telemetry/telemetry/internal/actions/repeatable_scroll_unittest.py

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 from telemetry import decorators
6
7 from telemetry.internal.actions import page_action
5 from telemetry.internal.actions import repeatable_scroll 8 from telemetry.internal.actions import repeatable_scroll
9 from telemetry.internal.actions import utils
6 from telemetry.internal.browser import browser_info as browser_info_module 10 from telemetry.internal.browser import browser_info as browser_info_module
7 from telemetry.testing import tab_test_case 11 from telemetry.testing import tab_test_case
8 12
9 13
10 class RepeatableScrollActionTest(tab_test_case.TabTestCase): 14 class RepeatableScrollActionTest(tab_test_case.TabTestCase):
11 15
12 def setUp(self): 16 def setUp(self):
13 tab_test_case.TabTestCase.setUp(self) 17 tab_test_case.TabTestCase.setUp(self)
14 self.Navigate('blank.html') 18 self.Navigate('blank.html')
19 utils.InjectJavaScript(self._tab, 'gesture_common.js')
15 20
16 # Make page bigger than window so it's scrollable. 21 # Make page taller than window so it's scrollable.
17 self._tab.ExecuteJavaScript('document.body.style.height = ' 22 self._tab.ExecuteJavaScript('document.body.style.height ='
18 ' (3 * window.innerHeight + 1) + "px";') 23 '(3 * __GestureCommon_GetWindowHeight() + 1) + "px";')
19 24
20 self.assertEquals( 25 self.assertEquals(
21 self._tab.EvaluateJavaScript('document.documentElement.scrollTop ' 26 self._tab.EvaluateJavaScript('document.scrollingElement.scrollTop'), 0)
22 '|| document.body.scrollTop'), 0)
23 27
24 self._browser_info = browser_info_module.BrowserInfo(self._tab.browser) 28 self._browser_info = browser_info_module.BrowserInfo(self._tab.browser)
25 self._window_height = int( 29 self._window_height = int(self._tab.EvaluateJavaScript(
26 self._tab.EvaluateJavaScript('window.innerHeight')) 30 '__GestureCommon_GetWindowHeight()'))
27 31
28 def testRepeatableScrollActionNoRepeats(self): 32 def testRepeatableScrollActionNoRepeats(self):
29 if not self._browser_info.HasRepeatableSynthesizeScrollGesture(): 33 if not self._browser_info.HasRepeatableSynthesizeScrollGesture():
30 return 34 return
31 35
32 expected_scroll = (self._window_height / 2) - 1 36 expected_scroll = (self._window_height / 2) - 1
33 37
34 i = repeatable_scroll.RepeatableScrollAction(y_scroll_distance_ratio=0.5) 38 i = repeatable_scroll.RepeatableScrollAction(y_scroll_distance_ratio=0.5)
35 i.WillRunAction(self._tab) 39 i.WillRunAction(self._tab)
36 40
37 i.RunAction(self._tab) 41 i.RunAction(self._tab)
38 42
39 scroll_position = self._tab.EvaluateJavaScript( 43 scroll_position = self._tab.EvaluateJavaScript(
40 '(document.documentElement.scrollTop || document.body.scrollTop)') 44 'document.scrollingElement.scrollTop')
41 # We can only expect the final scroll position to be approximatly equal. 45 # We can only expect the final scroll position to be approximatly equal.
42 self.assertTrue(abs(scroll_position - expected_scroll) < 20, 46 self.assertTrue(abs(scroll_position - expected_scroll) < 20,
43 msg='scroll_position=%d;expected %d' % (scroll_position, 47 msg='scroll_position=%d;expected %d' % (scroll_position,
44 expected_scroll)) 48 expected_scroll))
45 49
46 def testRepeatableScrollActionTwoRepeats(self): 50 def testRepeatableScrollActionTwoRepeats(self):
47 if not self._browser_info.HasRepeatableSynthesizeScrollGesture(): 51 if not self._browser_info.HasRepeatableSynthesizeScrollGesture():
48 return 52 return
49 53
50 expected_scroll = ((self._window_height / 2) - 1) * 3 54 expected_scroll = ((self._window_height / 2) - 1) * 3
51 55
52 i = repeatable_scroll.RepeatableScrollAction(y_scroll_distance_ratio=0.5, 56 i = repeatable_scroll.RepeatableScrollAction(y_scroll_distance_ratio=0.5,
53 repeat_count=2, 57 repeat_count=2,
54 repeat_delay_ms=1) 58 repeat_delay_ms=1)
55 i.WillRunAction(self._tab) 59 i.WillRunAction(self._tab)
56 60
57 i.RunAction(self._tab) 61 i.RunAction(self._tab)
58 62
59 scroll_position = self._tab.EvaluateJavaScript( 63 scroll_position = self._tab.EvaluateJavaScript(
60 '(document.documentElement.scrollTop || document.body.scrollTop)') 64 'document.scrollingElement.scrollTop')
61 # We can only expect the final scroll position to be approximatly equal. 65 # We can only expect the final scroll position to be approximatly equal.
62 self.assertTrue(abs(scroll_position - expected_scroll) < 20, 66 self.assertTrue(abs(scroll_position - expected_scroll) < 20,
63 msg='scroll_position=%d;expected %d' % (scroll_position, 67 msg='scroll_position=%d;expected %d' % (scroll_position,
64 expected_scroll)) 68 expected_scroll))
69
70 # Regression test for crbug.com/627166
71 # TODO(ulan): enable for Android after catapult:#2475 is fixed.
72 @decorators.Disabled('all')
73 def testRepeatableScrollActionNoRepeatsZoomed(self):
74 if (not self._browser_info.HasRepeatableSynthesizeScrollGesture() or
75 not page_action.IsGestureSourceTypeSupported(self._tab, 'touch')):
76 return
77
78 self._tab.action_runner.PinchPage(scale_factor=0.1)
79
80 inner_height = self._tab.EvaluateJavaScript('window.innerHeight')
81 outer_height = self._tab.EvaluateJavaScript('window.outerHeight')
82
83 self.assertGreater(inner_height, outer_height)
84
85 i = repeatable_scroll.RepeatableScrollAction(y_scroll_distance_ratio=0.5)
86 i.WillRunAction(self._tab)
87 i.RunAction(self._tab)
88 # If scroll coordinates are computed incorrectly Chrome will crash with
89 # [FATAL:synthetic_gesture_target_base.cc(62)] Check failed:
90 # web_touch.touches[i].state != WebTouchPoint::StatePressed ||
91 # PointIsWithinContents(web_touch.touches[i].position.x,
92 # web_touch.touches[i].position.y). Touch coordinates are not within content
93 # bounds on TouchStart.
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/actions/repeatable_scroll.py ('k') | telemetry/telemetry/internal/actions/scroll.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698