| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 from datetime import datetime | 4 from datetime import datetime |
| 5 import glob | 5 import glob |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 | 9 |
| 10 import cloud_storage_test_base | 10 import cloud_storage_test_base |
| 11 import pixel_expectations | 11 import pixel_expectations |
| 12 | 12 |
| 13 from telemetry import test | 13 from telemetry import test |
| 14 from telemetry.core import bitmap | 14 from telemetry.core import bitmap |
| 15 from telemetry.page import cloud_storage |
| 15 from telemetry.page import page_test | 16 from telemetry.page import page_test |
| 16 | 17 |
| 17 test_data_dir = os.path.abspath(os.path.join( | 18 test_data_dir = os.path.abspath(os.path.join( |
| 18 os.path.dirname(__file__), '..', '..', 'data', 'gpu')) | 19 os.path.dirname(__file__), '..', '..', 'data', 'gpu')) |
| 19 | 20 |
| 20 default_reference_image_dir = os.path.join(test_data_dir, 'gpu_reference') | 21 default_reference_image_dir = os.path.join(test_data_dir, 'gpu_reference') |
| 21 | 22 |
| 22 test_harness_script = r""" | 23 test_harness_script = r""" |
| 23 var domAutomationController = {}; | 24 var domAutomationController = {}; |
| 24 | 25 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 screenshot): | 75 screenshot): |
| 75 # This is the new reference image; there's nothing to compare against. | 76 # This is the new reference image; there's nothing to compare against. |
| 76 ref_png = screenshot | 77 ref_png = screenshot |
| 77 else: | 78 else: |
| 78 # There was a preexisting reference image, so we might as well | 79 # There was a preexisting reference image, so we might as well |
| 79 # compare against it. | 80 # compare against it. |
| 80 ref_png = self._DownloadFromCloudStorage(image_name, page, tab) | 81 ref_png = self._DownloadFromCloudStorage(image_name, page, tab) |
| 81 elif self.options.download_refimg_from_cloud_storage: | 82 elif self.options.download_refimg_from_cloud_storage: |
| 82 # This bot doesn't have the ability to properly generate a | 83 # This bot doesn't have the ability to properly generate a |
| 83 # reference image, so download it from cloud storage. | 84 # reference image, so download it from cloud storage. |
| 84 ref_png = self._DownloadFromCloudStorage(image_name, page, tab) | 85 try: |
| 86 ref_png = self._DownloadFromCloudStorage(image_name, page, tab) |
| 87 except cloud_storage.NotFoundError as e: |
| 88 # There is no reference image yet in cloud storage. This |
| 89 # happens when the revision of the test is incremented or when |
| 90 # a new test is added, because the trybots are not allowed to |
| 91 # produce reference images, only the bots on the main |
| 92 # waterfalls. Report this as a failure so the developer has to |
| 93 # take action by explicitly suppressing the failure and |
| 94 # removing the suppression once the reference images have been |
| 95 # generated. Otherwise silent failures could happen for long |
| 96 # periods of time. |
| 97 raise page_test.Failure('Could not find image %s in cloud storage' % |
| 98 image_name) |
| 85 else: | 99 else: |
| 86 # Legacy path using on-disk results. | 100 # Legacy path using on-disk results. |
| 87 ref_png = self._GetReferenceImage(self.options.reference_dir, | 101 ref_png = self._GetReferenceImage(self.options.reference_dir, |
| 88 image_name, page.revision, screenshot) | 102 image_name, page.revision, screenshot) |
| 89 | 103 |
| 90 # Test new snapshot against existing reference image | 104 # Test new snapshot against existing reference image |
| 91 if not ref_png.IsEqual(screenshot, tolerance=2): | 105 if not ref_png.IsEqual(screenshot, tolerance=2): |
| 92 if self.options.test_machine_name: | 106 if self.options.test_machine_name: |
| 93 self._UploadErrorImagesToCloudStorage(image_name, screenshot, ref_png) | 107 self._UploadErrorImagesToCloudStorage(image_name, screenshot, ref_png) |
| 94 else: | 108 else: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 default=default_reference_image_dir) | 157 default=default_reference_image_dir) |
| 144 | 158 |
| 145 def CreatePageSet(self, options): | 159 def CreatePageSet(self, options): |
| 146 page_set = super(Pixel, self).CreatePageSet(options) | 160 page_set = super(Pixel, self).CreatePageSet(options) |
| 147 for page in page_set.pages: | 161 for page in page_set.pages: |
| 148 page.script_to_evaluate_on_commit = test_harness_script | 162 page.script_to_evaluate_on_commit = test_harness_script |
| 149 return page_set | 163 return page_set |
| 150 | 164 |
| 151 def CreateExpectations(self, page_set): | 165 def CreateExpectations(self, page_set): |
| 152 return pixel_expectations.PixelExpectations() | 166 return pixel_expectations.PixelExpectations() |
| OLD | NEW |