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

Unified Diff: content/test/gpu/gpu_tests/screenshot_sync.py

Issue 1679593002: Reenable and strengthen screenshot_sync test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed vmiura's review feedback. Sample more potentially broken pixels. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/test/gpu/gpu_tests/screenshot_sync.py
diff --git a/content/test/gpu/gpu_tests/screenshot_sync.py b/content/test/gpu/gpu_tests/screenshot_sync.py
index caa38532119b10674f379ee5ac87956996343374..cce1730660368ca0fef202dfe2b9fe03532e1177 100644
--- a/content/test/gpu/gpu_tests/screenshot_sync.py
+++ b/content/test/gpu/gpu_tests/screenshot_sync.py
@@ -11,6 +11,7 @@ from gpu_tests import screenshot_sync_expectations
from telemetry.page import page_test
from telemetry.story import story_set as story_set_module
from telemetry.util import image_util
+from telemetry.util import rgba_color
data_path = os.path.join(
path_util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu')
@@ -26,31 +27,42 @@ class ScreenshotSyncValidator(gpu_test_base.ValidatorBase):
if not tab.screenshot_supported:
raise page_test.Failure('Browser does not support screenshot capture')
- def CheckColorMatch(canvasRGB, screenshotRGB):
- for i in range(0, 3):
- if abs(canvasRGB[i] - screenshotRGB[i]) > 1:
- raise page_test.Failure('Color mismatch in component #%d: %d vs %d' %
- (i, canvasRGB[i], screenshotRGB[i]))
+ def CheckColorMatchAtLocation(expectedRGB, screenshot, x, y):
+ pixel_value = image_util.GetPixelColor(screenshot, x, y)
+ if not expectedRGB.IsEqual(pixel_value):
+ error_message = ('Color mismatch at (%d, %d): expected (%d, %d, %d), ' +
+ 'got (%d, %d, %d)') % (
+ x, y, expectedRGB.r, expectedRGB.g, expectedRGB.b,
+ pixel_value.r, pixel_value.g, pixel_value.b)
+ raise page_test.Failure(error_message)
def CheckScreenshot():
- canvasRGB = []
- for _ in range(0, 3):
- canvasRGB.append(random.randint(0, 255))
- tab.EvaluateJavaScript("window.draw(%d, %d, %d);" % tuple(canvasRGB))
+ canvasRGB = rgba_color.RgbaColor(random.randint(0, 255),
+ random.randint(0, 255),
+ random.randint(0, 255),
+ 255)
+ tab.EvaluateJavaScript("window.draw(%d, %d, %d);" % (
+ canvasRGB.r, canvasRGB.g, canvasRGB.b))
screenshot = tab.Screenshot(5)
- CheckColorMatch(canvasRGB, image_util.Pixels(screenshot))
+ start_x = 10
+ start_y = 0
+ outer_size = 256
+ skip = 10
+ for y in range(start_y, outer_size, skip):
+ for x in range(start_x, outer_size, skip):
+ CheckColorMatchAtLocation(canvasRGB, screenshot, x, y)
- repetitions = 50
+ repetitions = 20
for _ in range(0, repetitions):
CheckScreenshot()
class ScreenshotSyncPage(gpu_test_base.PageBase):
- def __init__(self, story_set, base_dir, expectations):
+ def __init__(self, story_set, base_dir, url, name, expectations):
super(ScreenshotSyncPage, self).__init__(
- url='file://screenshot_sync.html',
+ url=url,
page_set=story_set,
base_dir=base_dir,
- name='ScreenshotSync',
+ name=name,
expectations=expectations)
@@ -68,5 +80,12 @@ class ScreenshotSyncProcess(gpu_test_base.TestBase):
def CreateStorySet(self, options):
ps = story_set_module.StorySet(base_dir=data_path, serving_dirs=[''])
- ps.AddStory(ScreenshotSyncPage(ps, ps.base_dir, self.GetExpectations()))
+ ps.AddStory(ScreenshotSyncPage(ps, ps.base_dir,
+ 'file://screenshot_sync_canvas.html',
+ 'ScreenshotSync.WithCanvas',
+ self.GetExpectations()))
+ ps.AddStory(ScreenshotSyncPage(ps, ps.base_dir,
+ 'file://screenshot_sync_divs.html',
+ 'ScreenshotSync.WithDivs',
+ self.GetExpectations()))
return ps
« no previous file with comments | « content/test/data/gpu/screenshot_sync_divs.html ('k') | content/test/gpu/gpu_tests/screenshot_sync_expectations.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698