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

Side by Side Diff: chrome/test/gpu/gpu_pixel_browsertest.cc

Issue 10829432: Add key pixel check option in GpuPixelBrowserTest. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/stringprintf.h"
11 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
13 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" 15 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
15 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/chrome_version_info.h" 17 #include "chrome/common/chrome_version_info.h"
17 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/test_launcher_utils.h" 19 #include "chrome/test/base/test_launcher_utils.h"
19 #include "chrome/test/base/tracing.h" 20 #include "chrome/test/base/tracing.h"
20 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
21 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
24 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
25 #include "content/test/gpu/test_switches.h" 26 #include "content/test/gpu/test_switches.h"
26 #include "googleurl/src/gurl.h" 27 #include "googleurl/src/gurl.h"
27 #include "net/base/net_util.h" 28 #include "net/base/net_util.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 #include "third_party/skia/include/core/SkBitmap.h" 30 #include "third_party/skia/include/core/SkBitmap.h"
30 #include "third_party/skia/include/core/SkColor.h" 31 #include "third_party/skia/include/core/SkColor.h"
31 #include "ui/compositor/compositor_setup.h" 32 #include "ui/compositor/compositor_setup.h"
32 #include "ui/gfx/codec/png_codec.h" 33 #include "ui/gfx/codec/png_codec.h"
33 #include "ui/gfx/size.h" 34 #include "ui/gfx/size.h"
34 #include "ui/gl/gl_switches.h" 35 #include "ui/gl/gl_switches.h"
35 36
36 namespace { 37 namespace {
37 38
39 enum ReferenceImageOption {
40 kReferenceImageLocal,
41 kReferenceImageCheckedIn,
42 kReferenceImageNone // Only check a few key pixels.
43 };
44
45 struct ReferencePixel {
46 int x, y;
47 unsigned char r, g, b;
48 };
49
38 // Command line flag for overriding the default location for putting generated 50 // Command line flag for overriding the default location for putting generated
39 // test images that do not match references. 51 // test images that do not match references.
40 const char kGeneratedDir[] = "generated-dir"; 52 const char kGeneratedDir[] = "generated-dir";
41 // Command line flag for overriding the default location for reference images. 53 // Command line flag for overriding the default location for reference images.
42 const char kReferenceDir[] = "reference-dir"; 54 const char kReferenceDir[] = "reference-dir";
43 55
44 // Corner shadow size. 56 // Corner shadow size.
45 const int kCornerDecorationSize = 15; 57 const int kCornerDecorationSize = 15;
46 // Side shadow size. 58 // Side shadow size.
47 const int kSideDecorationSize = 2; 59 const int kSideDecorationSize = 2;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 97
86 } // namespace 98 } // namespace
87 99
88 // Test fixture for GPU image comparison tests. 100 // Test fixture for GPU image comparison tests.
89 // TODO(kkania): Document how to add to/modify these tests. 101 // TODO(kkania): Document how to add to/modify these tests.
90 class GpuPixelBrowserTest : public InProcessBrowserTest { 102 class GpuPixelBrowserTest : public InProcessBrowserTest {
91 public: 103 public:
92 GpuPixelBrowserTest() 104 GpuPixelBrowserTest()
93 : ref_img_revision_(0), 105 : ref_img_revision_(0),
94 ref_img_revision_no_older_than_(0), 106 ref_img_revision_no_older_than_(0),
95 use_checked_in_ref_imgs_(false) { 107 ref_img_option_(kReferenceImageNone) {
96 } 108 }
97 109
98 virtual void SetUpCommandLine(CommandLine* command_line) { 110 virtual void SetUpCommandLine(CommandLine* command_line) {
99 command_line->AppendSwitchASCII(switches::kTestGLLib, 111 command_line->AppendSwitchASCII(switches::kTestGLLib,
100 "libllvmpipe.so"); 112 "libllvmpipe.so");
101 } 113 }
102 114
103 virtual void SetUpInProcessBrowserTestFixture() { 115 virtual void SetUpInProcessBrowserTestFixture() {
104 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); 116 InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
105 117
118 CommandLine* command_line = CommandLine::ForCurrentProcess();
119 if (command_line->HasSwitch(switches::kUseGpuInTests))
120 ref_img_option_ = kReferenceImageLocal;
121
106 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); 122 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
107 test_data_dir_ = test_data_dir_.AppendASCII("gpu"); 123 test_data_dir_ = test_data_dir_.AppendASCII("gpu");
108 124
109 CommandLine* command_line = CommandLine::ForCurrentProcess();
110 if (command_line->HasSwitch(kGeneratedDir)) 125 if (command_line->HasSwitch(kGeneratedDir))
111 generated_img_dir_ = command_line->GetSwitchValuePath(kGeneratedDir); 126 generated_img_dir_ = command_line->GetSwitchValuePath(kGeneratedDir);
112 else 127 else
113 generated_img_dir_ = test_data_dir_.AppendASCII("generated"); 128 generated_img_dir_ = test_data_dir_.AppendASCII("generated");
114 if (command_line->HasSwitch(kReferenceDir))
115 ref_img_dir_ = command_line->GetSwitchValuePath(kReferenceDir);
116 else if (!command_line->HasSwitch(switches::kUseGpuInTests))
117 ref_img_dir_ = test_data_dir_.AppendASCII("llvmpipe_reference");
118 else
119 ref_img_dir_ = test_data_dir_.AppendASCII("gpu_reference");
120 129
121 // Only use checked in ref images when using a software rasterizer as 130 switch (ref_img_option_) {
122 // all machines should generate the same output with a software rasterizer. 131 case kReferenceImageLocal:
123 use_checked_in_ref_imgs_ = !command_line->HasSwitch( 132 if (command_line->HasSwitch(kReferenceDir))
124 switches::kUseGpuInTests); 133 ref_img_dir_ = command_line->GetSwitchValuePath(kReferenceDir);
134 else
135 ref_img_dir_ = test_data_dir_.AppendASCII("gpu_reference");
136 break;
137 case kReferenceImageCheckedIn:
138 ref_img_dir_ = test_data_dir_.AppendASCII("llvmpipe_reference");
139 break;
140 default:
141 break;
142 }
125 143
126 test_name_ = testing::UnitTest::GetInstance()->current_test_info()->name(); 144 test_name_ = testing::UnitTest::GetInstance()->current_test_info()->name();
127 const char* test_status_prefixes[] = {"DISABLED_", "FLAKY_", "FAILS_"}; 145 const char* test_status_prefixes[] = {"DISABLED_", "FLAKY_", "FAILS_"};
128 for (size_t i = 0; i < arraysize(test_status_prefixes); ++i) { 146 for (size_t i = 0; i < arraysize(test_status_prefixes); ++i) {
129 ReplaceFirstSubstringAfterOffset( 147 ReplaceFirstSubstringAfterOffset(
130 &test_name_, 0, test_status_prefixes[i], ""); 148 &test_name_, 0, test_status_prefixes[i], "");
131 } 149 }
132 150
133 ui::DisableTestCompositor(); 151 ui::DisableTestCompositor();
134 } 152 }
135 153
136 // If the existing ref image was saved from an revision older than the 154 // If the existing ref image was saved from an revision older than the
137 // ref_img_update_revision, refresh the ref image. 155 // ref_img_update_revision, refresh the ref image.
138 void RunPixelTest(const gfx::Size& tab_container_size, 156 void RunPixelTest(const gfx::Size& tab_container_size,
139 const FilePath& url, 157 const FilePath& url,
140 int64 ref_img_update_revision) { 158 int64 ref_img_update_revision,
141 if (!use_checked_in_ref_imgs_) { 159 const ReferencePixel* ref_pixels,
160 size_t ref_pixel_count) {
161 if (ref_img_option_ == kReferenceImageLocal) {
142 ref_img_revision_no_older_than_ = ref_img_update_revision; 162 ref_img_revision_no_older_than_ = ref_img_update_revision;
143 ObtainLocalRefImageRevision(); 163 ObtainLocalRefImageRevision();
144 } 164 }
145 165
146 #if defined(OS_WIN) 166 #if defined(OS_WIN)
147 ASSERT_TRUE(tracing::BeginTracing("-test_*")); 167 ASSERT_TRUE(tracing::BeginTracing("-test_*"));
148 #endif 168 #endif
149 169
150 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 170 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
151 171
(...skipping 27 matching lines...) Expand all
179 } 199 }
180 200
181 bool ignore_bottom_corners = false; 201 bool ignore_bottom_corners = false;
182 #if defined(OS_MACOSX) 202 #if defined(OS_MACOSX)
183 // On Mac Lion, bottom corners have shadows with random pixels. 203 // On Mac Lion, bottom corners have shadows with random pixels.
184 ignore_bottom_corners = true; 204 ignore_bottom_corners = true;
185 #endif 205 #endif
186 206
187 SkBitmap bitmap; 207 SkBitmap bitmap;
188 ASSERT_TRUE(TabSnapShotToImage(&bitmap)); 208 ASSERT_TRUE(TabSnapShotToImage(&bitmap));
189 bool is_image_same = CompareImages(bitmap, ignore_bottom_corners); 209 bool same_pixels = true;
190 EXPECT_TRUE(is_image_same); 210 if (ref_img_option_ == kReferenceImageNone && ref_pixels && ref_pixel_count)
211 same_pixels = ComparePixels(bitmap, ref_pixels, ref_pixel_count);
212 else
213 same_pixels = CompareImages(bitmap, ignore_bottom_corners);
214 EXPECT_TRUE(same_pixels);
191 215
192 #if defined(OS_WIN) 216 #if defined(OS_WIN)
193 // For debugging the flaky test, this prints out a trace of what happened on 217 // For debugging the flaky test, this prints out a trace of what happened on
194 // failure. 218 // failure.
195 std::string trace_events; 219 std::string trace_events;
196 ASSERT_TRUE(tracing::EndTracing(&trace_events)); 220 ASSERT_TRUE(tracing::EndTracing(&trace_events));
197 if (!is_image_same) 221 if (!same_pixels)
198 fprintf(stderr, "\n\nTRACE JSON:\n\n%s\n\n", trace_events.c_str()); 222 fprintf(stderr, "\n\nTRACE JSON:\n\n%s\n\n", trace_events.c_str());
199 #endif 223 #endif
200 } 224 }
201 225
202 const FilePath& test_data_dir() const { 226 const FilePath& test_data_dir() const {
203 return test_data_dir_; 227 return test_data_dir_;
204 } 228 }
205 229
206 private: 230 private:
207 FilePath test_data_dir_; 231 FilePath test_data_dir_;
208 FilePath generated_img_dir_; 232 FilePath generated_img_dir_;
209 FilePath ref_img_dir_; 233 FilePath ref_img_dir_;
210 int64 ref_img_revision_; 234 int64 ref_img_revision_;
211 // The name of the test, with any special prefixes dropped. 235 // The name of the test, with any special prefixes dropped.
212 std::string test_name_; 236 std::string test_name_;
213 237
214 // Any local ref image generated from older revision is ignored. 238 // Any local ref image generated from older revision is ignored.
215 int64 ref_img_revision_no_older_than_; 239 int64 ref_img_revision_no_older_than_;
216 240
217 // If true, the test will use checked in reference images. 241 // Whether use locally generated ref images, or checked in ref images, or
218 bool use_checked_in_ref_imgs_; 242 // simply check a few key pixels.
243 ReferenceImageOption ref_img_option_;
219 244
220 // Compares the generated bitmap with the appropriate reference image on disk. 245 // Compares the generated bitmap with the appropriate reference image on disk.
221 // Returns true iff the images were the same. 246 // Returns true iff the images were the same.
222 // 247 //
223 // If no valid reference image exists, save the generated bitmap to the disk. 248 // If no valid reference image exists, save the generated bitmap to the disk.
224 // The image format is: 249 // The image format is:
225 // <test_name>_<revision>.png 250 // <test_name>_<revision>.png
226 // E.g., 251 // E.g.,
227 // WebGLTeapot_19762.png 252 // WebGLTeapot_19762.png
228 // The number is the chromium revision that generated the image. 253 // The number is the chromium revision that generated the image.
229 // 254 //
230 // On failure or on ref image generation, the image and diff image will be 255 // On failure or on ref image generation, the image and diff image will be
231 // written to disk. The formats are: 256 // written to disk. The formats are:
232 // FAIL_<ref_image_name>, DIFF_<ref_image_name> 257 // FAIL_<ref_image_name>, DIFF_<ref_image_name>
233 // E.g., 258 // E.g.,
234 // FAIL_WebGLTeapot_19762.png, DIFF_WebGLTeapot_19762.png 259 // FAIL_WebGLTeapot_19762.png, DIFF_WebGLTeapot_19762.png
235 bool CompareImages(const SkBitmap& gen_bmp, bool skip_bottom_corners) { 260 bool CompareImages(const SkBitmap& gen_bmp, bool skip_bottom_corners) {
236 SkBitmap ref_bmp_on_disk; 261 SkBitmap ref_bmp_on_disk;
237 262
238 FilePath img_path = ref_img_dir_.AppendASCII(test_name_ + ".png"); 263 FilePath img_path = ref_img_dir_.AppendASCII(test_name_ + ".png");
239 bool found_ref_img = ReadPNGFile(img_path, &ref_bmp_on_disk); 264 bool found_ref_img = ReadPNGFile(img_path, &ref_bmp_on_disk);
240 265
241 if (!found_ref_img && use_checked_in_ref_imgs_) { 266 if (!found_ref_img && ref_img_option_ == kReferenceImageCheckedIn) {
242 LOG(ERROR) << "Couldn't find reference image: " 267 LOG(ERROR) << "Couldn't find reference image: "
243 << img_path.value(); 268 << img_path.value();
244 // No image to compare to, exit early. 269 // No image to compare to, exit early.
245 return false; 270 return false;
246 } 271 }
247 272
248 const SkBitmap* ref_bmp; 273 const SkBitmap* ref_bmp;
249 bool save_gen = false; 274 bool save_gen = false;
250 bool save_diff = true; 275 bool save_diff = true;
251 bool rt = true; 276 bool rt = true;
252 277
253 if ((ref_img_revision_ <= 0 && !use_checked_in_ref_imgs_) || 278 if ((ref_img_revision_ <= 0 && ref_img_option_ == kReferenceImageLocal) ||
254 !found_ref_img) { 279 !found_ref_img) {
255 chrome::VersionInfo chrome_version_info; 280 chrome::VersionInfo chrome_version_info;
256 FilePath rev_path = ref_img_dir_.AppendASCII( 281 FilePath rev_path = ref_img_dir_.AppendASCII(
257 test_name_ + "_" + chrome_version_info.LastChange() + ".rev"); 282 test_name_ + "_" + chrome_version_info.LastChange() + ".rev");
258 if (!WritePNGFile(gen_bmp, img_path)) { 283 if (!WritePNGFile(gen_bmp, img_path)) {
259 LOG(ERROR) << "Can't save generated image to: " 284 LOG(ERROR) << "Can't save generated image to: "
260 << img_path.value() 285 << img_path.value()
261 << " as future reference."; 286 << " as future reference.";
262 rt = false; 287 rt = false;
263 } else { 288 } else {
(...skipping 27 matching lines...) Expand all
291 } 316 }
292 317
293 SkBitmap diff_bmp; 318 SkBitmap diff_bmp;
294 if (ref_bmp->width() != gen_bmp.width() || 319 if (ref_bmp->width() != gen_bmp.width() ||
295 ref_bmp->height() != gen_bmp.height()) { 320 ref_bmp->height() != gen_bmp.height()) {
296 LOG(ERROR) 321 LOG(ERROR)
297 << "Dimensions do not match (Expected) vs (Actual):" 322 << "Dimensions do not match (Expected) vs (Actual):"
298 << "(" << ref_bmp->width() << "x" << ref_bmp->height() 323 << "(" << ref_bmp->width() << "x" << ref_bmp->height()
299 << ") vs. " 324 << ") vs. "
300 << "(" << gen_bmp.width() << "x" << gen_bmp.height() << ")"; 325 << "(" << gen_bmp.width() << "x" << gen_bmp.height() << ")";
301 if (!use_checked_in_ref_imgs_) 326 if (ref_img_option_ == kReferenceImageLocal)
302 save_gen = true; 327 save_gen = true;
303 rt = false; 328 rt = false;
304 } else { 329 } else {
305 // Compare pixels and create a simple diff image. 330 // Compare pixels and create a simple diff image.
306 int diff_pixels_count = 0; 331 int diff_pixels_count = 0;
307 diff_bmp.setConfig(SkBitmap::kARGB_8888_Config, 332 diff_bmp.setConfig(SkBitmap::kARGB_8888_Config,
308 gen_bmp.width(), gen_bmp.height()); 333 gen_bmp.width(), gen_bmp.height());
309 diff_bmp.allocPixels(); 334 diff_bmp.allocPixels();
310 diff_bmp.eraseColor(SK_ColorWHITE); 335 diff_bmp.eraseColor(SK_ColorWHITE);
311 SkAutoLockPixels lock_bmp(gen_bmp); 336 SkAutoLockPixels lock_bmp(gen_bmp);
(...skipping 14 matching lines...) Expand all
326 if ((*gen_bmp.getAddr32(x, y) & kAlphaMask) != 351 if ((*gen_bmp.getAddr32(x, y) & kAlphaMask) !=
327 (*ref_bmp->getAddr32(x, y) & kAlphaMask)) { 352 (*ref_bmp->getAddr32(x, y) & kAlphaMask)) {
328 ++diff_pixels_count; 353 ++diff_pixels_count;
329 *diff_bmp.getAddr32(x, y) = 192 << 16; // red 354 *diff_bmp.getAddr32(x, y) = 192 << 16; // red
330 } 355 }
331 } 356 }
332 } 357 }
333 if (diff_pixels_count > 0) { 358 if (diff_pixels_count > 0) {
334 LOG(ERROR) << diff_pixels_count 359 LOG(ERROR) << diff_pixels_count
335 << " pixels do not match."; 360 << " pixels do not match.";
336 if (!use_checked_in_ref_imgs_) { 361 if (ref_img_option_ == kReferenceImageLocal) {
337 save_gen = true; 362 save_gen = true;
338 save_diff = true; 363 save_diff = true;
339 } 364 }
340 rt = false; 365 rt = false;
341 } 366 }
342 } 367 }
343 368
344 std::string ref_img_filename = img_path.BaseName().MaybeAsASCII(); 369 std::string ref_img_filename = img_path.BaseName().MaybeAsASCII();
345 if (save_gen) { 370 if (save_gen) {
346 FilePath img_fail_path = generated_img_dir_.AppendASCII( 371 FilePath img_fail_path = generated_img_dir_.AppendASCII(
(...skipping 13 matching lines...) Expand all
360 LOG(ERROR) << "Can't save generated diff image to: " 385 LOG(ERROR) << "Can't save generated diff image to: "
361 << img_diff_path.value(); 386 << img_diff_path.value();
362 } else { 387 } else {
363 LOG(INFO) << "Saved difference image to: " 388 LOG(INFO) << "Saved difference image to: "
364 << img_diff_path.value(); 389 << img_diff_path.value();
365 } 390 }
366 } 391 }
367 return rt; 392 return rt;
368 } 393 }
369 394
395 bool ComparePixels(const SkBitmap& gen_bmp,
396 const ReferencePixel* ref_pixels,
397 size_t ref_pixel_count) {
398 SkAutoLockPixels lock_bmp(gen_bmp);
399
400 for (size_t i = 0; i < ref_pixel_count; ++i) {
401 int x = ref_pixels[i].x;
402 int y = ref_pixels[i].y;
403 unsigned char r = ref_pixels[i].r;
404 unsigned char g = ref_pixels[i].g;
405 unsigned char b = ref_pixels[i].b;
406
407 DCHECK(x >= 0 && x < gen_bmp.width() && y >= 0 && y < gen_bmp.height());
408
409 unsigned char* rgba = reinterpret_cast<unsigned char*>(
410 gen_bmp.getAddr32(x, y));
411 DCHECK(rgba);
412 if (rgba[0] != b || rgba[1] != g || rgba[2] != r) {
413 std::string error_message = base::StringPrintf(
414 "pixel(%d,%d) expects [%u,%u,%u], but gets [%u,%u,%u] instead",
415 x, y, r, g, b, rgba[0], rgba[1], rgba[2]);
416 LOG(ERROR) << error_message.c_str();
417 return false;
418 }
419 }
420 return true;
421 }
422
370 // Returns a gfx::Rect representing the bounds that the browser window should 423 // Returns a gfx::Rect representing the bounds that the browser window should
371 // have if the tab contents have the desired size. 424 // have if the tab contents have the desired size.
372 gfx::Rect GetNewTabContainerBounds(const gfx::Size& desired_size) { 425 gfx::Rect GetNewTabContainerBounds(const gfx::Size& desired_size) {
373 gfx::Rect container_rect; 426 gfx::Rect container_rect;
374 chrome::GetActiveWebContents(browser())->GetContainerBounds(&container_rect) ; 427 chrome::GetActiveWebContents(browser())->GetContainerBounds(&container_rect) ;
375 // Size cannot be negative, so use a point. 428 // Size cannot be negative, so use a point.
376 gfx::Point correction( 429 gfx::Point correction(
377 desired_size.width() - container_rect.size().width(), 430 desired_size.width() - container_rect.size().width(),
378 desired_size.height() - container_rect.size().height()); 431 desired_size.height() - container_rect.size().height());
379 432
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 #define MAYBE_CSS3DBlueBox FLAKY_CSS3DBlueBox 515 #define MAYBE_CSS3DBlueBox FLAKY_CSS3DBlueBox
463 #else 516 #else
464 #define MAYBE_CSS3DBlueBox CSS3DBlueBox 517 #define MAYBE_CSS3DBlueBox CSS3DBlueBox
465 #endif 518 #endif
466 519
467 IN_PROC_BROWSER_TEST_F(GpuPixelBrowserTest, MAYBE_WebGLGreenTriangle) { 520 IN_PROC_BROWSER_TEST_F(GpuPixelBrowserTest, MAYBE_WebGLGreenTriangle) {
468 // If test baseline needs to be updated after a given revision, update the 521 // If test baseline needs to be updated after a given revision, update the
469 // following number. If no revision requirement, then 0. 522 // following number. If no revision requirement, then 0.
470 const int64 ref_img_revision_update = 123489; 523 const int64 ref_img_revision_update = 123489;
471 524
525 const ReferencePixel ref_pixels[] = {
526 // x, y, r, g, b
527 {50, 100, 0, 0, 0},
528 {100, 100, 0, 255, 0},
529 {150, 100, 0, 0, 0},
530 {50, 150, 0, 255, 0},
531 {100, 150, 0, 255, 0},
532 {150, 150, 0, 255, 0}
533 };
534 const size_t ref_pixel_count = sizeof(ref_pixels) / sizeof(ReferencePixel);
535
472 gfx::Size container_size(400, 300); 536 gfx::Size container_size(400, 300);
473 FilePath url = 537 FilePath url =
474 test_data_dir().AppendASCII("pixel_webgl.html"); 538 test_data_dir().AppendASCII("pixel_webgl.html");
475 RunPixelTest(container_size, url, ref_img_revision_update); 539 RunPixelTest(container_size, url, ref_img_revision_update,
540 ref_pixels, ref_pixel_count);
476 } 541 }
477 542
478 IN_PROC_BROWSER_TEST_F(GpuPixelBrowserTest, MAYBE_CSS3DBlueBox) { 543 IN_PROC_BROWSER_TEST_F(GpuPixelBrowserTest, MAYBE_CSS3DBlueBox) {
479 // If test baseline needs to be updated after a given revision, update the 544 // If test baseline needs to be updated after a given revision, update the
480 // following number. If no revision requirement, then 0. 545 // following number. If no revision requirement, then 0.
481 const int64 ref_img_revision_update = 123489; 546 const int64 ref_img_revision_update = 123489;
482 547
548 const ReferencePixel ref_pixels[] = {
549 // x, y, r, g, b
550 {70, 50, 0, 0, 255},
551 {150, 50, 0, 0, 0},
552 {70, 90, 0, 0, 255},
553 {150, 90, 0, 0, 255},
554 {70, 125, 0, 0, 255},
555 {150, 125, 0, 0, 0}
556 };
557 const size_t ref_pixel_count = sizeof(ref_pixels) / sizeof(ReferencePixel);
558
483 gfx::Size container_size(400, 300); 559 gfx::Size container_size(400, 300);
484 FilePath url = 560 FilePath url =
485 test_data_dir().AppendASCII("pixel_css3d.html"); 561 test_data_dir().AppendASCII("pixel_css3d.html");
486 RunPixelTest(container_size, url, ref_img_revision_update); 562 RunPixelTest(container_size, url, ref_img_revision_update,
563 ref_pixels, ref_pixel_count);
487 } 564 }
488 565
489 IN_PROC_BROWSER_TEST_F(GpuPixelBrowserTest, Canvas2DRedBoxHD) { 566 IN_PROC_BROWSER_TEST_F(GpuPixelBrowserTest, Canvas2DRedBoxHD) {
490 // If test baseline needs to be updated after a given revision, update the 567 // If test baseline needs to be updated after a given revision, update the
491 // following number. If no revision requirement, then 0. 568 // following number. If no revision requirement, then 0.
492 const int64 ref_img_revision_update = 123489; 569 const int64 ref_img_revision_update = 123489;
493 570
571 const ReferencePixel ref_pixels[] = {
572 // x, y, r, g, b
573 {40, 100, 0, 0, 0},
574 {60, 100, 127, 0, 0},
575 {140, 100, 127, 0, 0},
576 {160, 100, 0, 0, 0}
577 };
578 const size_t ref_pixel_count = sizeof(ref_pixels) / sizeof(ReferencePixel);
579
494 gfx::Size container_size(400, 300); 580 gfx::Size container_size(400, 300);
495 FilePath url = 581 FilePath url =
496 test_data_dir().AppendASCII("pixel_canvas2d.html"); 582 test_data_dir().AppendASCII("pixel_canvas2d.html");
497 RunPixelTest(container_size, url, ref_img_revision_update); 583 RunPixelTest(container_size, url, ref_img_revision_update,
584 ref_pixels, ref_pixel_count);
498 } 585 }
499 586
500 class Canvas2DPixelTestSD : public GpuPixelBrowserTest { 587 class Canvas2DPixelTestSD : public GpuPixelBrowserTest {
501 public: 588 public:
502 virtual void SetUpCommandLine(CommandLine* command_line) { 589 virtual void SetUpCommandLine(CommandLine* command_line) {
503 GpuPixelBrowserTest::SetUpCommandLine(command_line); 590 GpuPixelBrowserTest::SetUpCommandLine(command_line);
504 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 591 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
505 } 592 }
506 }; 593 };
507 594
508 IN_PROC_BROWSER_TEST_F(Canvas2DPixelTestSD, Canvas2DRedBoxSD) { 595 IN_PROC_BROWSER_TEST_F(Canvas2DPixelTestSD, Canvas2DRedBoxSD) {
509 // If test baseline needs to be updated after a given revision, update the 596 // If test baseline needs to be updated after a given revision, update the
510 // following number. If no revision requirement, then 0. 597 // following number. If no revision requirement, then 0.
511 const int64 ref_img_revision_update = 123489; 598 const int64 ref_img_revision_update = 123489;
512 599
600 const ReferencePixel ref_pixels[] = {
601 // x, y, r, g, b
602 {40, 100, 0, 0, 0},
603 {60, 100, 127, 0, 0},
604 {140, 100, 127, 0, 0},
605 {160, 100, 0, 0, 0}
606 };
607 const size_t ref_pixel_count = sizeof(ref_pixels) / sizeof(ReferencePixel);
608
513 gfx::Size container_size(400, 300); 609 gfx::Size container_size(400, 300);
514 FilePath url = 610 FilePath url =
515 test_data_dir().AppendASCII("pixel_canvas2d.html"); 611 test_data_dir().AppendASCII("pixel_canvas2d.html");
516 RunPixelTest(container_size, url, ref_img_revision_update); 612 RunPixelTest(container_size, url, ref_img_revision_update,
613 ref_pixels, ref_pixel_count);
517 } 614 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698