| 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 17 matching lines...) Expand all Loading... |
| 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 |
| 80 class MapsPage(gpu_test_base.PageBase): | 89 class MapsPage(gpu_test_base.PageBase): |
| 81 def __init__(self, story_set, base_dir, expectations): | 90 def __init__(self, story_set, base_dir, expectations): |
| 82 super(MapsPage, self).__init__( | 91 super(MapsPage, self).__init__( |
| 83 url='http://localhost:10020/tracker.html', | 92 url='http://localhost:8000/performance.html', |
| 84 page_set=story_set, | 93 page_set=story_set, |
| 85 base_dir=base_dir, | 94 base_dir=base_dir, |
| 86 name='Maps.maps_002', | 95 name='Maps.maps_004', |
| 87 make_javascript_deterministic=False, | 96 make_javascript_deterministic=False, |
| 88 expectations=expectations) | 97 expectations=expectations) |
| 89 self.pixel_expectations = 'data/maps_002_expectations.json' | 98 self.pixel_expectations = 'data/maps_004_expectations.json' |
| 90 | 99 |
| 91 def RunNavigateSteps(self, action_runner): | 100 def RunNavigateSteps(self, action_runner): |
| 92 super(MapsPage, self).RunNavigateSteps(action_runner) | 101 super(MapsPage, self).RunNavigateSteps(action_runner) |
| 93 action_runner.WaitForJavaScriptCondition( | 102 action_runner.WaitForJavaScriptCondition( |
| 94 'window.testDone', timeout_in_seconds=180) | 103 'window.testDone', timeout_in_seconds=180) |
| 95 | 104 |
| 96 | 105 |
| 97 class Maps(cloud_storage_test_base.TestBase): | 106 class Maps(cloud_storage_test_base.TestBase): |
| 98 """Google Maps pixel tests.""" | 107 """Google Maps pixel tests. |
| 108 |
| 109 Note: the WPR for this test was recorded from the smoothness.maps |
| 110 benchmark's similar page. The Maps team gave us a build of their |
| 111 test. The only modification to the test was to config.js, where the |
| 112 width and height query args were set to 800 by 600. The WPR was |
| 113 recorded with: |
| 114 |
| 115 tools/perf/record_wpr smoothness_maps --browser=system --upload |
| 116 |
| 117 Then the maps_???.wpr.sha1 and maps.json were copied from |
| 118 tools/perf/page_sets/data into content/test/gpu/page_sets/data. The |
| 119 same sha1 file and json file need to be copied into both of these |
| 120 directories in any CL which updates the recording.""" |
| 99 test = MapsValidator | 121 test = MapsValidator |
| 100 | 122 |
| 101 @classmethod | 123 @classmethod |
| 102 def Name(cls): | 124 def Name(cls): |
| 103 return 'maps' | 125 return 'maps' |
| 104 | 126 |
| 105 def _CreateExpectations(self): | 127 def _CreateExpectations(self): |
| 106 return maps_expectations.MapsExpectations() | 128 return maps_expectations.MapsExpectations() |
| 107 | 129 |
| 108 def CreateStorySet(self, options): | 130 def CreateStorySet(self, options): |
| 109 story_set_path = os.path.join( | 131 story_set_path = os.path.join( |
| 110 path_util.GetChromiumSrcDir(), 'content', 'test', 'gpu', 'page_sets') | 132 path_util.GetChromiumSrcDir(), 'content', 'test', 'gpu', 'page_sets') |
| 111 ps = story_set_module.StorySet( | 133 ps = story_set_module.StorySet( |
| 112 archive_data_file='data/maps.json', | 134 archive_data_file='data/maps.json', |
| 113 base_dir=story_set_path, | 135 base_dir=story_set_path, |
| 114 cloud_storage_bucket=story_module.PUBLIC_BUCKET) | 136 cloud_storage_bucket=story_module.PUBLIC_BUCKET) |
| 115 ps.AddStory(MapsPage(ps, ps.base_dir, self.GetExpectations())) | 137 ps.AddStory(MapsPage(ps, ps.base_dir, self.GetExpectations())) |
| 116 return ps | 138 return ps |
| OLD | NEW |