Chromium Code Reviews| Index: content/test/gpu/gpu_tests/cloud_storage_test_base.py |
| diff --git a/content/test/gpu/gpu_tests/cloud_storage_test_base.py b/content/test/gpu/gpu_tests/cloud_storage_test_base.py |
| index 9343a602f562b8047264fe8e97167aec143dcbca..4ad1d2e98595578cee48f42e3eef846e66d9a370 100644 |
| --- a/content/test/gpu/gpu_tests/cloud_storage_test_base.py |
| +++ b/content/test/gpu/gpu_tests/cloud_storage_test_base.py |
| @@ -9,6 +9,8 @@ import os |
| import re |
| import tempfile |
| +import cv2 |
|
tonyg
2014/10/21 16:12:56
Nit: alphabetize
mthiesse
2014/10/22 15:33:09
Done.
|
| + |
| from telemetry import benchmark |
| from telemetry.core import bitmap |
| from telemetry.page import page_test |
| @@ -33,18 +35,17 @@ def _CompareScreenshotSamples(screenshot, expectations, device_pixel_ratio): |
| 'Expected pixel location [%d, %d] is out of range on [%d, %d] image' % |
| (x, y, screenshot.width, screenshot.height)) |
| - actual_color = screenshot.GetPixelColor(x, y) |
| - expected_color = bitmap.RgbaColor( |
| - expectation["color"][0], |
| - expectation["color"][1], |
| + actual_color = screenshot.image[y][x] |
| + expected_color = (expectation["color"][0], expectation["color"][1], |
| expectation["color"][2]) |
|
slamm
2014/10/21 23:21:58
Nit. Follow style-guide for indentation.
https://
mthiesse
2014/10/22 15:33:09
Done.
|
| - if not actual_color.IsEqual(expected_color, expectation["tolerance"]): |
| + if not bitmap.ColorsAreEqual(actual_color, expected_color, |
| + expectation["tolerance"]): |
|
slamm
2014/10/21 23:21:58
Fix indentation (same issue as line 39).
mthiesse
2014/10/22 15:33:09
Done.
|
| raise page_test.Failure('Expected pixel at ' + str(location) + |
| ' to be ' + |
| str(expectation["color"]) + " but got [" + |
| - str(actual_color.r) + ", " + |
| - str(actual_color.g) + ", " + |
| - str(actual_color.b) + "]") |
| + str(actual_color[2]) + ", " + |
| + str(actual_color[1]) + ", " + |
| + str(actual_color[0]) + "]") |
|
slamm
2014/10/21 23:21:58
Nit that precedes you. Use '%' formatting:
raise
mthiesse
2014/10/22 15:33:09
Done.
|
| class ValidatorBase(page_test.PageTest): |
| def __init__(self): |
| @@ -72,7 +73,7 @@ class ValidatorBase(page_test.PageTest): |
| output_dir = os.path.dirname(image_path) |
| if not os.path.exists(output_dir): |
| os.makedirs(output_dir) |
| - png_image.WritePngFile(image_path) |
| + cv2.imwrite(image_path, png_image.image) |
| def _WriteErrorImages(self, img_dir, img_name, screenshot, ref_png): |
| full_image_name = img_name + '_' + str(self.options.build_revision) |
| @@ -171,7 +172,7 @@ class ValidatorBase(page_test.PageTest): |
| cloud_storage.Get(self.options.refimg_cloud_storage_bucket, |
| self._FormatReferenceImageName(img_name, page, tab), |
| temp_file) |
| - return bitmap.Bitmap.FromPngFile(temp_file) |
| + return bitmap.Bitmap.FromImageFile(temp_file) |
| def _UploadErrorImagesToCloudStorage(self, image_name, screenshot, ref_img): |
| """For a failing run, uploads the failing image, reference image (if |