Chromium Code Reviews| 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 os | 10 import os |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 # safe to do so. | 36 # safe to do so. |
| 37 MapsValidator.SpinWaitOnRAF(tab, 3) | 37 MapsValidator.SpinWaitOnRAF(tab, 3) |
| 38 | 38 |
| 39 if not tab.screenshot_supported: | 39 if not tab.screenshot_supported: |
| 40 raise page_test.Failure('Browser does not support screenshot capture') | 40 raise page_test.Failure('Browser does not support screenshot capture') |
| 41 screenshot = tab.Screenshot(5) | 41 screenshot = tab.Screenshot(5) |
| 42 if screenshot is None: | 42 if screenshot is None: |
| 43 raise page_test.Failure('Could not capture screenshot') | 43 raise page_test.Failure('Could not capture screenshot') |
| 44 | 44 |
| 45 dpr = tab.EvaluateJavaScript('window.devicePixelRatio') | 45 dpr = tab.EvaluateJavaScript('window.devicePixelRatio') |
| 46 print 'Maps\' devicePixelRatio is ' + str(dpr) | |
| 47 # Even though the Maps test uses a fixed devicePixelRatio so that | |
| 48 # it fetches all of the map tiles at the same resolution, on two | |
| 49 # different devices with the same devicePixelRatio (a Retina | |
| 50 # MacBook Pro and a Nexus 9), different scale factors of the final | |
| 51 # screenshot are observed. Hack around this by specifying a scale | |
| 52 # factor for these bots in the test expectations. This relies on | |
| 53 # the test-machine-name argument being specified on the command | |
| 54 # line. | |
| 46 expected = self._ReadPixelExpectations(page) | 55 expected = self._ReadPixelExpectations(page) |
| 47 self._ValidateScreenshotSamples( | 56 self._ValidateScreenshotSamples( |
| 48 page.display_name, screenshot, expected, dpr) | 57 page.display_name, screenshot, expected, dpr) |
| 49 | 58 |
| 50 @staticmethod | 59 @staticmethod |
| 51 def SpinWaitOnRAF(tab, iterations, timeout=60): | 60 def SpinWaitOnRAF(tab, iterations, timeout=60): |
| 52 waitScript = r""" | 61 waitScript = r""" |
| 53 window.__spinWaitOnRAFDone = false; | 62 window.__spinWaitOnRAFDone = false; |
| 54 var iterationsLeft = %d; | 63 var iterationsLeft = %d; |
| 55 | 64 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 70 tab.ExecuteJavaScript(waitScript) | 79 tab.ExecuteJavaScript(waitScript) |
| 71 util.WaitFor(IsWaitComplete, timeout) | 80 util.WaitFor(IsWaitComplete, timeout) |
| 72 | 81 |
| 73 def _ReadPixelExpectations(self, page): | 82 def _ReadPixelExpectations(self, page): |
| 74 expectations_path = os.path.join(page._base_dir, page.pixel_expectations) | 83 expectations_path = os.path.join(page._base_dir, page.pixel_expectations) |
| 75 with open(expectations_path, 'r') as f: | 84 with open(expectations_path, 'r') as f: |
| 76 json_contents = json.load(f) | 85 json_contents = json.load(f) |
| 77 return json_contents | 86 return json_contents |
| 78 | 87 |
| 79 | 88 |
| 89 # Note: the WPR for this test was recorded from the smoothness.maps | |
| 90 # benchmark's similar page. The Maps team gave us a build of their | |
| 91 # test. The only modification to the test was to config.js, where the | |
| 92 # width and height query args were set to 800 by 600. The WPR was | |
| 93 # recorded with: | |
| 94 # | |
| 95 # tools/perf/record_wpr smoothness_maps --browser=system --upload | |
| 96 # | |
| 97 # Then the maps_???.wpr.sha1 and maps.json were copied from | |
|
aiolos (Not reviewing)
2016/05/27 17:35:51
I'd suggest adding this comment to the pageset.
Ken Russell (switch to Gerrit)
2016/05/27 18:23:49
Done.
| |
| 98 # tools/perf/page_sets/data into content/test/gpu/page_sets/data. The | |
| 99 # same sha1 file and json file need to be copied into both of these | |
| 100 # directories in any CL which updates the recording. | |
| 80 class MapsPage(gpu_test_base.PageBase): | 101 class MapsPage(gpu_test_base.PageBase): |
| 81 def __init__(self, story_set, base_dir, expectations): | 102 def __init__(self, story_set, base_dir, expectations): |
| 82 super(MapsPage, self).__init__( | 103 super(MapsPage, self).__init__( |
| 83 url='http://localhost:10020/tracker.html', | 104 url='http://localhost:8000/performance.html', |
| 84 page_set=story_set, | 105 page_set=story_set, |
| 85 base_dir=base_dir, | 106 base_dir=base_dir, |
| 86 name='Maps.maps_002', | 107 name='Maps.maps_004', |
| 87 make_javascript_deterministic=False, | 108 make_javascript_deterministic=False, |
| 88 expectations=expectations) | 109 expectations=expectations) |
| 89 self.pixel_expectations = 'data/maps_002_expectations.json' | 110 self.pixel_expectations = 'data/maps_004_expectations.json' |
| 90 | 111 |
| 91 def RunNavigateSteps(self, action_runner): | 112 def RunNavigateSteps(self, action_runner): |
| 92 super(MapsPage, self).RunNavigateSteps(action_runner) | 113 super(MapsPage, self).RunNavigateSteps(action_runner) |
| 93 action_runner.WaitForJavaScriptCondition( | 114 action_runner.WaitForJavaScriptCondition( |
| 94 'window.testDone', timeout_in_seconds=180) | 115 'window.testDone', timeout_in_seconds=180) |
| 95 | 116 |
| 96 | 117 |
| 97 class Maps(cloud_storage_test_base.TestBase): | 118 class Maps(cloud_storage_test_base.TestBase): |
| 98 """Google Maps pixel tests.""" | 119 """Google Maps pixel tests.""" |
| 99 test = MapsValidator | 120 test = MapsValidator |
| 100 | 121 |
| 101 @classmethod | 122 @classmethod |
| 102 def Name(cls): | 123 def Name(cls): |
| 103 return 'maps' | 124 return 'maps' |
| 104 | 125 |
| 105 def _CreateExpectations(self): | 126 def _CreateExpectations(self): |
| 106 return maps_expectations.MapsExpectations() | 127 return maps_expectations.MapsExpectations() |
| 107 | 128 |
| 108 def CreateStorySet(self, options): | 129 def CreateStorySet(self, options): |
| 109 story_set_path = os.path.join( | 130 story_set_path = os.path.join( |
| 110 path_util.GetChromiumSrcDir(), 'content', 'test', 'gpu', 'page_sets') | 131 path_util.GetChromiumSrcDir(), 'content', 'test', 'gpu', 'page_sets') |
| 111 ps = story_set_module.StorySet( | 132 ps = story_set_module.StorySet( |
| 112 archive_data_file='data/maps.json', | 133 archive_data_file='data/maps.json', |
| 113 base_dir=story_set_path, | 134 base_dir=story_set_path, |
| 114 cloud_storage_bucket=story_module.PUBLIC_BUCKET) | 135 cloud_storage_bucket=story_module.PUBLIC_BUCKET) |
| 115 ps.AddStory(MapsPage(ps, ps.base_dir, self.GetExpectations())) | 136 ps.AddStory(MapsPage(ps, ps.base_dir, self.GetExpectations())) |
| 116 return ps | 137 return ps |
| OLD | NEW |