OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import os | 4 import os |
5 | 5 |
6 from telemetry.page import Page | 6 from telemetry.page import page as page_module |
7 from telemetry import scrolling_action | 7 from telemetry.page import scrolling_action |
8 from telemetry import tab_test_case | 8 from telemetry.test import tab_test_case |
9 | 9 |
10 class ScrollingActionTest(tab_test_case.TabTestCase): | 10 class ScrollingActionTest(tab_test_case.TabTestCase): |
11 def CreateAndNavigateToPageFromUnittestDataDir( | 11 def CreateAndNavigateToPageFromUnittestDataDir( |
12 self, filename, page_attributes): | 12 self, filename, page_attributes): |
13 unittest_data_dir = os.path.join(os.path.dirname(__file__), | 13 unittest_data_dir = os.path.join(os.path.dirname(__file__), |
14 '..', 'unittest_data') | 14 '..', '..', 'unittest_data') |
15 self._browser.SetHTTPServerDirectory(unittest_data_dir) | 15 self._browser.SetHTTPServerDirectory(unittest_data_dir) |
16 page = Page( | 16 page = page_module.Page( |
17 self._browser.http_server.UrlOf(filename), | 17 self._browser.http_server.UrlOf(filename), |
18 None, # In this test, we don't need a page set. | 18 None, # In this test, we don't need a page set. |
19 attributes=page_attributes) | 19 attributes=page_attributes) |
20 | 20 |
21 self._tab.Navigate(page.url) | 21 self._tab.Navigate(page.url) |
22 self._tab.WaitForDocumentReadyStateToBeComplete() | 22 self._tab.WaitForDocumentReadyStateToBeComplete() |
23 | 23 |
24 return page | 24 return page |
25 | 25 |
26 def testScrollingAction(self): | 26 def testScrollingAction(self): |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 __ScrollingAction_GetBoundingVisibleRect(document.body).top + | 82 __ScrollingAction_GetBoundingVisibleRect(document.body).top + |
83 __ScrollingAction_GetBoundingVisibleRect(document.body).height""")) | 83 __ScrollingAction_GetBoundingVisibleRect(document.body).height""")) |
84 rect_right = int(self._tab.EvaluateJavaScript(""" | 84 rect_right = int(self._tab.EvaluateJavaScript(""" |
85 __ScrollingAction_GetBoundingVisibleRect(document.body).left + | 85 __ScrollingAction_GetBoundingVisibleRect(document.body).left + |
86 __ScrollingAction_GetBoundingVisibleRect(document.body).width""")) | 86 __ScrollingAction_GetBoundingVisibleRect(document.body).width""")) |
87 viewport_width = int(self._tab.EvaluateJavaScript('window.innerWidth')) | 87 viewport_width = int(self._tab.EvaluateJavaScript('window.innerWidth')) |
88 viewport_height = int(self._tab.EvaluateJavaScript('window.innerHeight')) | 88 viewport_height = int(self._tab.EvaluateJavaScript('window.innerHeight')) |
89 | 89 |
90 self.assertTrue(rect_bottom <= viewport_height) | 90 self.assertTrue(rect_bottom <= viewport_height) |
91 self.assertTrue(rect_right <= viewport_width) | 91 self.assertTrue(rect_right <= viewport_width) |
OLD | NEW |