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

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

Issue 2962433002: color: Run GPU pixel tests with ColorCorrectRendering feature (Closed)
Patch Set: Update tests that fail w/new flag Created 3 years, 5 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
« no previous file with comments | « content/test/gpu/gpu_tests/pixel_test_pages.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 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 import os 5 import os
6 import random 6 import random
7 import sys 7 import sys
8 8
9 from gpu_tests import color_profile_manager
9 from gpu_tests import gpu_integration_test 10 from gpu_tests import gpu_integration_test
10 from gpu_tests import path_util 11 from gpu_tests import path_util
11 from gpu_tests import screenshot_sync_expectations 12 from gpu_tests import screenshot_sync_expectations
12 13
13 from telemetry.util import image_util 14 from telemetry.util import image_util
14 from telemetry.util import rgba_color 15 from telemetry.util import rgba_color
15 16
16 data_path = os.path.join( 17 data_path = os.path.join(
17 path_util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') 18 path_util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu')
18 19
19 class ScreenshotSyncIntegrationTest(gpu_integration_test.GpuIntegrationTest): 20 class ScreenshotSyncIntegrationTest(gpu_integration_test.GpuIntegrationTest):
20 """Tests that screenshots are properly synchronized with the frame on 21 """Tests that screenshots are properly synchronized with the frame on
21 which they were requested. 22 which they were requested.
22 """ 23 """
23 24
24 @classmethod 25 @classmethod
25 def Name(cls): 26 def Name(cls):
26 """The name by which this test is invoked on the command line.""" 27 """The name by which this test is invoked on the command line."""
27 return 'screenshot_sync' 28 return 'screenshot_sync'
28 29
29 @classmethod 30 @classmethod
30 def SetUpProcess(cls): 31 def SetUpProcess(cls):
32 color_profile_manager.ForceUntilExitSRGB()
31 super(cls, ScreenshotSyncIntegrationTest).SetUpProcess() 33 super(cls, ScreenshotSyncIntegrationTest).SetUpProcess()
32 cls.CustomizeBrowserArgs(cls._AddDefaultArgs([])) 34 cls.CustomizeBrowserArgs(cls._AddDefaultArgs([]))
33 cls.StartBrowser() 35 cls.StartBrowser()
34 cls.SetStaticServerDirs([data_path]) 36 cls.SetStaticServerDirs([data_path])
35 37
36 @staticmethod 38 @staticmethod
37 def _AddDefaultArgs(browser_args): 39 def _AddDefaultArgs(browser_args):
38 # --test-type=gpu is used to suppress the "Google API Keys are 40 # --test-type=gpu is used to suppress the "Google API Keys are
39 # missing" infobar, which causes flakiness in tests. 41 # missing" infobar, which causes flakiness in tests.
40 return ['--test-type=gpu'] + browser_args 42 return [
43 '--force-color-profile=srgb',
44 '--enable-features=ColorCorrectRendering',
45 '--test-type=gpu'] + browser_args
41 46
42 @classmethod 47 @classmethod
43 def _CreateExpectations(cls): 48 def _CreateExpectations(cls):
44 return screenshot_sync_expectations.ScreenshotSyncExpectations() 49 return screenshot_sync_expectations.ScreenshotSyncExpectations()
45 50
46 @classmethod 51 @classmethod
47 def GenerateGpuTests(cls, options): 52 def GenerateGpuTests(cls, options):
48 yield('ScreenshotSync_SWRasterWithCanvas', 53 yield('ScreenshotSync_SWRasterWithCanvas',
49 'screenshot_sync_canvas.html', 54 'screenshot_sync_canvas.html',
50 ('--disable-gpu-rasterization')) 55 ('--disable-gpu-rasterization'))
(...skipping 10 matching lines...) Expand all
61 def _Navigate(self, test_path): 66 def _Navigate(self, test_path):
62 url = self.UrlOfStaticFilePath(test_path) 67 url = self.UrlOfStaticFilePath(test_path)
63 # It's crucial to use the action_runner, rather than the tab's 68 # It's crucial to use the action_runner, rather than the tab's
64 # Navigate method directly. It waits for the document ready state 69 # Navigate method directly. It waits for the document ready state
65 # to become interactive or better, avoiding critical race 70 # to become interactive or better, avoiding critical race
66 # conditions. 71 # conditions.
67 self.tab.action_runner.Navigate(url) 72 self.tab.action_runner.Navigate(url)
68 73
69 def _CheckColorMatchAtLocation(self, expectedRGB, screenshot, x, y): 74 def _CheckColorMatchAtLocation(self, expectedRGB, screenshot, x, y):
70 pixel_value = image_util.GetPixelColor(screenshot, x, y) 75 pixel_value = image_util.GetPixelColor(screenshot, x, y)
71 if not expectedRGB.IsEqual(pixel_value): 76 # Allow for off-by-one errors due to color conversion.
77 tolerance = 1
78 if not expectedRGB.IsEqual(pixel_value, tolerance):
72 error_message = ('Color mismatch at (%d, %d): expected (%d, %d, %d), ' + 79 error_message = ('Color mismatch at (%d, %d): expected (%d, %d, %d), ' +
73 'got (%d, %d, %d)') % ( 80 'got (%d, %d, %d)') % (
74 x, y, expectedRGB.r, expectedRGB.g, expectedRGB.b, 81 x, y, expectedRGB.r, expectedRGB.g, expectedRGB.b,
75 pixel_value.r, pixel_value.g, pixel_value.b) 82 pixel_value.r, pixel_value.g, pixel_value.b)
76 self.fail(error_message) 83 self.fail(error_message)
77 84
78 def _CheckScreenshot(self): 85 def _CheckScreenshot(self):
79 canvasRGB = rgba_color.RgbaColor(random.randint(0, 255), 86 canvasRGB = rgba_color.RgbaColor(random.randint(0, 255),
80 random.randint(0, 255), 87 random.randint(0, 255),
81 random.randint(0, 255), 88 random.randint(0, 255),
(...skipping 15 matching lines...) Expand all
97 browser_arg = args[0] 104 browser_arg = args[0]
98 self.RestartBrowserIfNecessaryWithArgs(self._AddDefaultArgs([browser_arg])) 105 self.RestartBrowserIfNecessaryWithArgs(self._AddDefaultArgs([browser_arg]))
99 self._Navigate(test_path) 106 self._Navigate(test_path)
100 repetitions = 20 107 repetitions = 20
101 for _ in range(0, repetitions): 108 for _ in range(0, repetitions):
102 self._CheckScreenshot() 109 self._CheckScreenshot()
103 110
104 def load_tests(loader, tests, pattern): 111 def load_tests(loader, tests, pattern):
105 del loader, tests, pattern # Unused. 112 del loader, tests, pattern # Unused.
106 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__]) 113 return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__])
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_tests/pixel_test_pages.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698