| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Runs a Google Maps pixel test. | 5 """Runs a Google Maps pixel test. |
| 6 Performs several common navigation actions on the map (pan, zoom, rotate) then | 6 Performs several common navigation actions on the map (pan, zoom, rotate) then |
| 7 captures a screenshot and compares selected pixels against expected values""" | 7 captures a screenshot and compares selected pixels against expected values""" |
| 8 | 8 |
| 9 import json | 9 import json |
| 10 import optparse | 10 import optparse |
| 11 import os | 11 import os |
| 12 | 12 |
| 13 import cloud_storage_test_base | 13 import cloud_storage_test_base |
| 14 import maps_expectations | 14 import maps_expectations |
| 15 | 15 |
| 16 from telemetry import test | 16 from telemetry import test |
| 17 from telemetry.core import bitmap | 17 from telemetry.core import bitmap |
| 18 from telemetry.core import util | 18 from telemetry.core import util |
| 19 from telemetry.page import page |
| 20 from telemetry.page import page_set |
| 19 from telemetry.page import page_test | 21 from telemetry.page import page_test |
| 20 from telemetry.page import page_set | 22 # pylint: disable=W0401,W0614 |
| 23 from telemetry.page.actions.all_page_actions import * |
| 21 | 24 |
| 22 class _MapsValidator(cloud_storage_test_base.ValidatorBase): | 25 class _MapsValidator(cloud_storage_test_base.ValidatorBase): |
| 23 def __init__(self): | 26 def __init__(self): |
| 24 super(_MapsValidator, self).__init__('ValidatePage') | 27 super(_MapsValidator, self).__init__('ValidatePage') |
| 25 | 28 |
| 26 def CustomizeBrowserOptions(self, options): | 29 def CustomizeBrowserOptions(self, options): |
| 27 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | 30 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
| 28 | 31 |
| 29 def ValidatePage(self, page, tab, results): | 32 def ValidatePage(self, page, tab, results): |
| 30 # TODO: This should not be necessary, but it's not clear if the test is | 33 # TODO: This should not be necessary, but it's not clear if the test is |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 68 |
| 66 tab.ExecuteJavaScript(waitScript) | 69 tab.ExecuteJavaScript(waitScript) |
| 67 util.WaitFor(IsWaitComplete, timeout) | 70 util.WaitFor(IsWaitComplete, timeout) |
| 68 | 71 |
| 69 def _ReadPixelExpectations(self, page): | 72 def _ReadPixelExpectations(self, page): |
| 70 expectations_path = os.path.join(page._base_dir, page.pixel_expectations) | 73 expectations_path = os.path.join(page._base_dir, page.pixel_expectations) |
| 71 with open(expectations_path, 'r') as f: | 74 with open(expectations_path, 'r') as f: |
| 72 json_contents = json.load(f) | 75 json_contents = json.load(f) |
| 73 return json_contents | 76 return json_contents |
| 74 | 77 |
| 78 |
| 79 class MapsPage(page.Page): |
| 80 def __init__(self, page_set, base_dir): |
| 81 super(MapsPage, self).__init__( |
| 82 url='http://localhost:10020/tracker.html', |
| 83 page_set=page_set, |
| 84 base_dir=base_dir) |
| 85 self.name = 'Maps.maps_001' |
| 86 self.script_to_evaluate_on_commit = 'window.screen = null;' |
| 87 self.pixel_expectations = 'data/maps_001_expectations.json' |
| 88 |
| 89 def RunNavigateSteps(self, action_runner): |
| 90 action_runner.RunAction(NavigateAction()) |
| 91 action_runner.RunAction(WaitAction({'javascript': 'window.testDone'})) |
| 92 |
| 93 |
| 75 class Maps(cloud_storage_test_base.TestBase): | 94 class Maps(cloud_storage_test_base.TestBase): |
| 76 """Google Maps pixel tests.""" | 95 """Google Maps pixel tests.""" |
| 77 test = _MapsValidator | 96 test = _MapsValidator |
| 78 | 97 |
| 79 def CreateExpectations(self, page_set): | 98 def CreateExpectations(self, page_set): |
| 80 return maps_expectations.MapsExpectations() | 99 return maps_expectations.MapsExpectations() |
| 81 | 100 |
| 82 def CreatePageSet(self, options): | 101 def CreatePageSet(self, options): |
| 83 page_set_path = os.path.join( | 102 page_set_path = os.path.join( |
| 84 util.GetChromiumSrcDir(), 'content', 'test', 'gpu', 'page_sets') | 103 util.GetChromiumSrcDir(), 'content', 'test', 'gpu', 'page_sets') |
| 85 page_set_dict = { | 104 ps = page_set.PageSet(archive_data_file='data/maps.json', |
| 86 'archive_data_file': 'data/maps.json', | 105 make_javascript_deterministic=False, |
| 87 'make_javascript_deterministic': False, | 106 file_path=page_set_path) |
| 88 'pages': [ | 107 ps.AddPage(MapsPage(ps, ps.base_dir)) |
| 89 { | 108 return ps |
| 90 'name': 'Maps.maps_001', | |
| 91 'url': 'http://localhost:10020/tracker.html', | |
| 92 # TODO: Hack to prevent maps from scaling due to window size. | |
| 93 # Remove when the maps team provides a better way of overriding this | |
| 94 # behavior | |
| 95 'script_to_evaluate_on_commit': 'window.screen = null;', | |
| 96 'navigate_steps': [ | |
| 97 { 'action': 'navigate' }, | |
| 98 { 'action': 'wait', 'javascript': 'window.testDone' } | |
| 99 ], | |
| 100 'pixel_expectations': 'data/maps_001_expectations.json' | |
| 101 } | |
| 102 ] | |
| 103 } | |
| 104 | |
| 105 return page_set.PageSet.FromDict(page_set_dict, page_set_path) | |
| OLD | NEW |