| 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 logging | 4 import logging |
| 5 import os | 5 import os |
| 6 import time |
| 6 | 7 |
| 7 from telemetry.core import util | 8 from telemetry.core import util |
| 8 from telemetry.core import exceptions | 9 from telemetry.core import exceptions |
| 9 from telemetry.unittest import tab_test_case | 10 from telemetry.unittest import tab_test_case |
| 10 | 11 |
| 11 | 12 |
| 12 def _IsDocumentVisible(tab): | 13 def _IsDocumentVisible(tab): |
| 13 state = tab.EvaluateJavaScript('document.webkitVisibilityState') | 14 state = tab.EvaluateJavaScript('document.webkitVisibilityState') |
| 14 # TODO(dtu): Remove when crbug.com/166243 is fixed. | 15 # TODO(dtu): Remove when crbug.com/166243 is fixed. |
| 15 tab.Disconnect() | 16 tab.Disconnect() |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 return | 65 return |
| 65 | 66 |
| 66 unittest_data_dir = os.path.join(os.path.dirname(__file__), | 67 unittest_data_dir = os.path.join(os.path.dirname(__file__), |
| 67 '..', '..', 'unittest_data') | 68 '..', '..', 'unittest_data') |
| 68 self._browser.SetHTTPServerDirectories(unittest_data_dir) | 69 self._browser.SetHTTPServerDirectories(unittest_data_dir) |
| 69 self._tab.Navigate( | 70 self._tab.Navigate( |
| 70 self._browser.http_server.UrlOf('green_rect.html')) | 71 self._browser.http_server.UrlOf('green_rect.html')) |
| 71 self._tab.WaitForDocumentReadyStateToBeComplete() | 72 self._tab.WaitForDocumentReadyStateToBeComplete() |
| 72 pixel_ratio = self._tab.EvaluateJavaScript('window.devicePixelRatio || 1') | 73 pixel_ratio = self._tab.EvaluateJavaScript('window.devicePixelRatio || 1') |
| 73 | 74 |
| 75 # TODO(bajones): Sleep for a bit to counter BUG 260878. |
| 76 time.sleep(0.5) |
| 74 screenshot = self._tab.Screenshot(5) | 77 screenshot = self._tab.Screenshot(5) |
| 75 assert screenshot | 78 assert screenshot |
| 76 screenshot.GetPixelColor(0 * pixel_ratio, 0 * pixel_ratio).AssertIsRGB( | 79 screenshot.GetPixelColor(0 * pixel_ratio, 0 * pixel_ratio).AssertIsRGB( |
| 77 0, 255, 0, tolerance=2) | 80 0, 255, 0, tolerance=2) |
| 78 screenshot.GetPixelColor(31 * pixel_ratio, 31 * pixel_ratio).AssertIsRGB( | 81 screenshot.GetPixelColor(31 * pixel_ratio, 31 * pixel_ratio).AssertIsRGB( |
| 79 0, 255, 0, tolerance=2) | 82 0, 255, 0, tolerance=2) |
| 80 screenshot.GetPixelColor(32 * pixel_ratio, 32 * pixel_ratio).AssertIsRGB( | 83 screenshot.GetPixelColor(32 * pixel_ratio, 32 * pixel_ratio).AssertIsRGB( |
| 81 255, 255, 255, tolerance=2) | 84 255, 255, 255, tolerance=2) |
| OLD | NEW |