Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: content/test/gpu/gpu_tests/maps.py

Issue 1413883003: Add a presubmit script and pylintrc for content/test/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address kbr's comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 import os 10 import os
12 11
13 import cloud_storage_test_base 12 from gpu_tests import cloud_storage_test_base
14 import gpu_test_base 13 from gpu_tests import gpu_test_base
15 import maps_expectations 14 from gpu_tests import maps_expectations
16 import path_util 15 from gpu_tests import path_util
17 16
18 from telemetry.core import util 17 from telemetry.core import util
19 from telemetry.page import page_test 18 from telemetry.page import page_test
20 from telemetry import story as story_module 19 from telemetry import story as story_module
21 from telemetry.story import story_set as story_set_module 20 from telemetry.story import story_set as story_set_module
22 21
23 class MapsValidator(cloud_storage_test_base.ValidatorBase): 22 class MapsValidator(cloud_storage_test_base.ValidatorBase):
23 def __init__(self):
24 super(MapsValidator, self).__init__()
25
24 def CustomizeBrowserOptions(self, options): 26 def CustomizeBrowserOptions(self, options):
25 # --test-type=gpu is used only to suppress the "Google API Keys are missing" 27 # --test-type=gpu is used only to suppress the "Google API Keys are missing"
26 # infobar, which causes flakiness in tests. 28 # infobar, which causes flakiness in tests.
27 options.AppendExtraBrowserArgs(['--enable-gpu-benchmarking', 29 options.AppendExtraBrowserArgs(['--enable-gpu-benchmarking',
28 '--test-type=gpu']) 30 '--test-type=gpu'])
29 31
30 def ValidateAndMeasurePage(self, page, tab, results): 32 def ValidateAndMeasurePage(self, page, tab, results):
31 # 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
32 # failing on the bots in it's absence. Remove once we can verify that it's 34 # failing on the bots in it's absence. Remove once we can verify that it's
33 # safe to do so. 35 # safe to do so.
34 MapsValidator.SpinWaitOnRAF(tab, 3) 36 MapsValidator.SpinWaitOnRAF(tab, 3)
35 37
36 if not tab.screenshot_supported: 38 if not tab.screenshot_supported:
37 raise page_test.Failure('Browser does not support screenshot capture') 39 raise page_test.Failure('Browser does not support screenshot capture')
38 screenshot = tab.Screenshot(5) 40 screenshot = tab.Screenshot(5)
39 if screenshot is None: 41 if screenshot is None:
40 raise page_test.Failure('Could not capture screenshot') 42 raise page_test.Failure('Could not capture screenshot')
41 43
42 dpr = tab.EvaluateJavaScript('window.devicePixelRatio') 44 dpr = tab.EvaluateJavaScript('window.devicePixelRatio')
43 expected = self._ReadPixelExpectations(page) 45 expected = self._ReadPixelExpectations(page)
44 self._ValidateScreenshotSamples( 46 self._ValidateScreenshotSamples(
45 page.display_name, screenshot, expected, dpr) 47 page.display_name, screenshot, expected, dpr)
46 48
47 @staticmethod 49 @staticmethod
48 def SpinWaitOnRAF(tab, iterations, timeout = 60): 50 def SpinWaitOnRAF(tab, iterations, timeout=60):
49 waitScript = r""" 51 waitScript = r"""
50 window.__spinWaitOnRAFDone = false; 52 window.__spinWaitOnRAFDone = false;
51 var iterationsLeft = %d; 53 var iterationsLeft = %d;
52 54
53 function spin() { 55 function spin() {
54 iterationsLeft--; 56 iterationsLeft--;
55 if (iterationsLeft == 0) { 57 if (iterationsLeft == 0) {
56 window.__spinWaitOnRAFDone = true; 58 window.__spinWaitOnRAFDone = true;
57 return; 59 return;
58 } 60 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 106
105 def CreateStorySet(self, options): 107 def CreateStorySet(self, options):
106 story_set_path = os.path.join( 108 story_set_path = os.path.join(
107 path_util.GetChromiumSrcDir(), 'content', 'test', 'gpu', 'page_sets') 109 path_util.GetChromiumSrcDir(), 'content', 'test', 'gpu', 'page_sets')
108 ps = story_set_module.StorySet( 110 ps = story_set_module.StorySet(
109 archive_data_file='data/maps.json', 111 archive_data_file='data/maps.json',
110 base_dir=story_set_path, 112 base_dir=story_set_path,
111 cloud_storage_bucket=story_module.PUBLIC_BUCKET) 113 cloud_storage_bucket=story_module.PUBLIC_BUCKET)
112 ps.AddStory(MapsPage(ps, ps.base_dir, self.GetExpectations())) 114 ps.AddStory(MapsPage(ps, ps.base_dir, self.GetExpectations()))
113 return ps 115 return ps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698