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

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

Issue 668753002: [Telemetry] Migrate bitmap.py from bitmaptools.cc to numpy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make GetBoundingBox just, like, WAY too fast Created 6 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 side-by-side diff with in-line comments
Download patch
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..7ab54ae51b178213ec2f8e2cc93cd32187b4b88c 100644
--- a/content/test/gpu/gpu_tests/cloud_storage_test_base.py
+++ b/content/test/gpu/gpu_tests/cloud_storage_test_base.py
@@ -5,6 +5,7 @@
"""Base classes for a test and validator which upload results
(reference images, error images) to cloud storage."""
+import cv2
import os
import re
import tempfile
@@ -33,18 +34,15 @@ 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],
- expectation["color"][2])
- if not actual_color.IsEqual(expected_color, expectation["tolerance"]):
- 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) + "]")
+ actual_color = screenshot.image[y][x]
+ expected_color = (expectation["color"][2], expectation["color"][1],
+ expectation["color"][0])
+ if not bitmap.ColorsAreEqual(actual_color, expected_color,
+ expectation["tolerance"]):
+ raise page_test.Failure(
+ 'Expected pixel at %s to be %s but got [%s, %s, %s]' %
+ (location, expectation["color"], actual_color[2], actual_color[1],
+ actual_color[0]))
class ValidatorBase(page_test.PageTest):
def __init__(self):
@@ -72,7 +70,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 +169,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

Powered by Google App Engine
This is Rietveld 408576698