diff options
author | kbr <kbr@chromium.org> | 2016-02-06 02:07:48 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-06 10:09:20 +0000 |
commit | f0cfd18530b0e212c8586aa26f02e47aa984c921 (patch) | |
tree | 6b5b02842b0e566b8ec04376c67f0f1e251504d6 | |
parent | 368b922a73105f6af17f5a3d6729a67bab31bc1c (diff) | |
download | chromium_src-f0cfd18530b0e212c8586aa26f02e47aa984c921.zip chromium_src-f0cfd18530b0e212c8586aa26f02e47aa984c921.tar.gz chromium_src-f0cfd18530b0e212c8586aa26f02e47aa984c921.tar.bz2 |
Reenable and strengthen screenshot_sync test.
It looks like the mechanism this test uses may have been made reliable
since the time Issue 459820 was filed about it. A variant of the test
would have caught the regression just introduced in Issue 584381, so
reenable the test, and sample more pixels in the snapshot.
BUG=459820,584381
Review URL: https://codereview.chromium.org/1679593002
Cr-Commit-Position: refs/heads/master@{#374026}
-rw-r--r-- | content/test/data/gpu/screenshot_sync_canvas.html (renamed from content/test/data/gpu/screenshot_sync.html) | 4 | ||||
-rw-r--r-- | content/test/data/gpu/screenshot_sync_divs.html | 22 | ||||
-rw-r--r-- | content/test/gpu/gpu_tests/screenshot_sync.py | 49 | ||||
-rw-r--r-- | content/test/gpu/gpu_tests/screenshot_sync_expectations.py | 2 |
4 files changed, 59 insertions, 18 deletions
diff --git a/content/test/data/gpu/screenshot_sync.html b/content/test/data/gpu/screenshot_sync_canvas.html index 7f7b30e..ce00afb 100644 --- a/content/test/data/gpu/screenshot_sync.html +++ b/content/test/data/gpu/screenshot_sync_canvas.html @@ -1,13 +1,13 @@ <!DOCTYPE html> <html> <head> -<title>Synchronized screenshot test</title> +<title>Synchronized screenshot test with canvas</title> <style> html, body { margin: 0; } </style> </head> <body> - <canvas id="canvas" width="256" height="256"></canvas> + <canvas id="canvas" width="256" height="256" style="position: absolute; left; 0px; top: 0px;"></canvas> <div id="text"></div> <script> diff --git a/content/test/data/gpu/screenshot_sync_divs.html b/content/test/data/gpu/screenshot_sync_divs.html new file mode 100644 index 0000000..c6d91dc --- /dev/null +++ b/content/test/data/gpu/screenshot_sync_divs.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html> +<head> +<title>Synchronized screenshot test with divs</title> +<style> + html, body { margin: 0; } +</style> +</head> +<body> + <div id="backgrounddiv" style="position: absolute; left: 0px; top: 0px; width: 256px; height: 256px; will-change: transform; background-color: rgb(0, 255, 0);">.</div> + <div id="testdiv" style="position: absolute; left: 1px; top: 25px; width: 192px; height: 192px; will-change: transform; background-color: rgb(255, 0, 0);">.</div> + + <script> + function draw(r, g, b) { + document.getElementById('testdiv').style.background = + 'rgb(' + r + ', ' + g + ', ' + b + ')'; + document.getElementById('backgrounddiv').style.background = + 'rgb(' + r + ', ' + g + ', ' + b + ')'; + } + </script> + </body> +</html> diff --git a/content/test/gpu/gpu_tests/screenshot_sync.py b/content/test/gpu/gpu_tests/screenshot_sync.py index caa3853..cce1730 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 diff --git a/content/test/gpu/gpu_tests/screenshot_sync_expectations.py b/content/test/gpu/gpu_tests/screenshot_sync_expectations.py index 07ec586..44f8e06 100644 --- a/content/test/gpu/gpu_tests/screenshot_sync_expectations.py +++ b/content/test/gpu/gpu_tests/screenshot_sync_expectations.py @@ -11,4 +11,4 @@ class ScreenshotSyncExpectations(GpuTestExpectations): super(ScreenshotSyncExpectations, self).__init__(*args, **kwargs) def SetExpectations(self): - self.Skip('ScreenshotSync', ['win', 'mac', 'linux'], bug=459820) + pass |