| 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 |
| 7 from telemetry import scrolling_action | 7 from telemetry import scrolling_action |
| 8 from telemetry import tab_test_case | 8 from telemetry 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( |
| 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. | |
| 19 attributes=page_attributes) | 18 attributes=page_attributes) |
| 20 | 19 |
| 21 self._tab.Navigate(page.url) | 20 self._tab.Navigate(page.url) |
| 22 self._tab.WaitForDocumentReadyStateToBeComplete() | 21 self._tab.WaitForDocumentReadyStateToBeComplete() |
| 23 | 22 |
| 24 return page | 23 return page |
| 25 | 24 |
| 26 def testScrollingAction(self): | 25 def testScrollingAction(self): |
| 27 page = self.CreateAndNavigateToPageFromUnittestDataDir( | 26 page = self.CreateAndNavigateToPageFromUnittestDataDir( |
| 28 "blank.html", | 27 "blank.html", |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 __ScrollingAction_GetBoundingVisibleRect(document.body).top + | 81 __ScrollingAction_GetBoundingVisibleRect(document.body).top + |
| 83 __ScrollingAction_GetBoundingVisibleRect(document.body).height""")) | 82 __ScrollingAction_GetBoundingVisibleRect(document.body).height""")) |
| 84 rect_right = int(self._tab.EvaluateJavaScript(""" | 83 rect_right = int(self._tab.EvaluateJavaScript(""" |
| 85 __ScrollingAction_GetBoundingVisibleRect(document.body).left + | 84 __ScrollingAction_GetBoundingVisibleRect(document.body).left + |
| 86 __ScrollingAction_GetBoundingVisibleRect(document.body).width""")) | 85 __ScrollingAction_GetBoundingVisibleRect(document.body).width""")) |
| 87 viewport_width = int(self._tab.EvaluateJavaScript('window.innerWidth')) | 86 viewport_width = int(self._tab.EvaluateJavaScript('window.innerWidth')) |
| 88 viewport_height = int(self._tab.EvaluateJavaScript('window.innerHeight')) | 87 viewport_height = int(self._tab.EvaluateJavaScript('window.innerHeight')) |
| 89 | 88 |
| 90 self.assertTrue(rect_bottom <= viewport_height) | 89 self.assertTrue(rect_bottom <= viewport_height) |
| 91 self.assertTrue(rect_right <= viewport_width) | 90 self.assertTrue(rect_right <= viewport_width) |
| 91 |
| OLD | NEW |