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/drag_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 import logging 5 import logging
5 import math 6 import math
6 import os
7 7
8 from telemetry import decorators 8 from telemetry import decorators
9 from telemetry.internal.actions import drag 9 from telemetry.internal.actions import drag
10 from telemetry.internal.actions import page_action 10 from telemetry.internal.actions import page_action
11 from telemetry.internal.actions import utils
11 from telemetry.testing import tab_test_case 12 from telemetry.testing import tab_test_case
12 13
13 14
14 class DragActionTest(tab_test_case.TabTestCase): 15 class DragActionTest(tab_test_case.TabTestCase):
15 def CheckWithinRange(self, value, expected, error_ratio): 16 def CheckWithinRange(self, value, expected, error_ratio):
16 error_range = abs(expected * error_ratio) 17 error_range = abs(expected * error_ratio)
17 return abs(value - expected) <= error_range 18 return abs(value - expected) <= error_range
18 19
19 @decorators.Disabled('chromeos') # crbug.com/483212 20 @decorators.Disabled('chromeos') # crbug.com/483212
20 def testDragAction(self): 21 def testDragAction(self):
21 self.Navigate('draggable.html') 22 self.Navigate('draggable.html')
22 23
23 with open(os.path.join(os.path.dirname(__file__), 24 utils.InjectJavaScript(self._tab, 'gesture_common.js')
24 'gesture_common.js')) as f:
25 js = f.read()
26 self._tab.ExecuteJavaScript(js)
27 25
28 div_width = self._tab.EvaluateJavaScript( 26 div_width = self._tab.EvaluateJavaScript(
29 '__GestureCommon_GetBoundingVisibleRect(document.body).width') 27 '__GestureCommon_GetBoundingVisibleRect(document.body).width')
30 div_height = self._tab.EvaluateJavaScript( 28 div_height = self._tab.EvaluateJavaScript(
31 '__GestureCommon_GetBoundingVisibleRect(document.body).height') 29 '__GestureCommon_GetBoundingVisibleRect(document.body).height')
32 30
33 i = drag.DragAction(left_start_ratio=0.5, top_start_ratio=0.5, 31 i = drag.DragAction(left_start_ratio=0.5, top_start_ratio=0.5,
34 left_end_ratio=0.25, top_end_ratio=0.25) 32 left_end_ratio=0.25, top_end_ratio=0.25)
35 try: 33 try:
36 i.WillRunAction(self._tab) 34 i.WillRunAction(self._tab)
(...skipping 25 matching lines...) Expand all
62 error_ratio = 0.1 60 error_ratio = 0.1
63 61
64 self.assertTrue( 62 self.assertTrue(
65 self.CheckWithinRange(div_position_x, expected_x, error_ratio), 63 self.CheckWithinRange(div_position_x, expected_x, error_ratio),
66 msg="Moved element's left coordinate: %d, expected: %d" % 64 msg="Moved element's left coordinate: %d, expected: %d" %
67 (div_position_x, expected_x)) 65 (div_position_x, expected_x))
68 self.assertTrue( 66 self.assertTrue(
69 self.CheckWithinRange(div_position_y, expected_y, error_ratio), 67 self.CheckWithinRange(div_position_y, expected_y, error_ratio),
70 msg="Moved element's top coordinate: %d, expected: %d" % 68 msg="Moved element's top coordinate: %d, expected: %d" %
71 (div_position_y, expected_y)) 69 (div_position_y, expected_y))
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/actions/drag.py ('k') | telemetry/telemetry/internal/actions/gesture_common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698