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

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

Issue 9663033: Debug flaky gpu pixel tests by printing event trace on failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | « chrome/test/data/gpu/pixel_canvas2d.html ('k') | 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 "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_window.h" 12 #include "chrome/browser/ui/browser_window.h"
13 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" 13 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
14 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
15 #include "chrome/common/chrome_version_info.h" 15 #include "chrome/common/chrome_version_info.h"
16 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/test_launcher_utils.h" 17 #include "chrome/test/base/test_launcher_utils.h"
18 #include "chrome/test/base/tracing.h"
18 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/public/browser/render_view_host.h" 20 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "content/public/common/content_switches.h" 22 #include "content/public/common/content_switches.h"
22 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
23 #include "net/base/net_util.h" 24 #include "net/base/net_util.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "third_party/skia/include/core/SkColor.h" 27 #include "third_party/skia/include/core/SkColor.h"
27 #include "ui/gfx/codec/png_codec.h" 28 #include "ui/gfx/codec/png_codec.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 110 }
110 111
111 // If the existing ref image was saved from an revision older than the 112 // If the existing ref image was saved from an revision older than the
112 // ref_img_update_revision, refresh the ref image. 113 // ref_img_update_revision, refresh the ref image.
113 void RunPixelTest(const gfx::Size& tab_container_size, 114 void RunPixelTest(const gfx::Size& tab_container_size,
114 const FilePath& url, 115 const FilePath& url,
115 int64 ref_img_update_revision) { 116 int64 ref_img_update_revision) {
116 ref_img_revision_no_older_than_ = ref_img_update_revision; 117 ref_img_revision_no_older_than_ = ref_img_update_revision;
117 ObtainLocalRefImageFilePath(); 118 ObtainLocalRefImageFilePath();
118 119
120 #if defined(OS_WIN)
121 ASSERT_TRUE(tracing::BeginTracing("-test_*"));
122 #endif
123
119 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 124 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
120 125
121 ui_test_utils::DOMMessageQueue message_queue; 126 ui_test_utils::DOMMessageQueue message_queue;
122 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(url)); 127 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(url));
123 128
124 // Wait for notification that page is loaded. 129 // Wait for notification that page is loaded.
125 ASSERT_TRUE(message_queue.WaitForMessage(NULL)); 130 ASSERT_TRUE(message_queue.WaitForMessage(NULL));
126 message_queue.ClearQueue(); 131 message_queue.ClearQueue();
127 132
128 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 133 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
(...skipping 12 matching lines...) Expand all
141 } 146 }
142 147
143 bool ignore_bottom_corners = false; 148 bool ignore_bottom_corners = false;
144 #if defined(OS_MACOSX) 149 #if defined(OS_MACOSX)
145 // On Mac Lion, bottom corners have shadows with random pixels. 150 // On Mac Lion, bottom corners have shadows with random pixels.
146 ignore_bottom_corners = true; 151 ignore_bottom_corners = true;
147 #endif 152 #endif
148 153
149 SkBitmap bitmap; 154 SkBitmap bitmap;
150 ASSERT_TRUE(TabSnapShotToImage(&bitmap)); 155 ASSERT_TRUE(TabSnapShotToImage(&bitmap));
151 ASSERT_TRUE(CompareImages(bitmap, ignore_bottom_corners)); 156 bool is_image_same = CompareImages(bitmap, ignore_bottom_corners);
157 EXPECT_TRUE(is_image_same);
158
159 #if defined(OS_WIN)
160 std::string trace_events;
161 ASSERT_TRUE(tracing::EndTracing(&trace_events));
162 if (!is_image_same)
163 fprintf(stderr, "\n\nTRACE JSON:\n\n%s\n\n", trace_events.c_str());
Zhenyao Mo 2012/03/10 01:12:51 It's worth adding a comment that this is for tempo
jbates 2012/03/12 17:32:11 Done.
164 #endif
152 } 165 }
153 166
154 const FilePath& test_data_dir() const { 167 const FilePath& test_data_dir() const {
155 return test_data_dir_; 168 return test_data_dir_;
156 } 169 }
157 170
158 private: 171 private:
159 FilePath test_data_dir_; 172 FilePath test_data_dir_;
160 FilePath generated_img_dir_; 173 FilePath generated_img_dir_;
161 FilePath ref_img_dir_; 174 FilePath ref_img_dir_;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 IN_PROC_BROWSER_TEST_F(Canvas2DPixelTestSD, MAYBE_Canvas2DRedBoxSD) { 457 IN_PROC_BROWSER_TEST_F(Canvas2DPixelTestSD, MAYBE_Canvas2DRedBoxSD) {
445 // If test baseline needs to be updated after a given revision, update the 458 // If test baseline needs to be updated after a given revision, update the
446 // following number. If no revision requirement, then 0. 459 // following number. If no revision requirement, then 0.
447 const int64 ref_img_revision_update = 123489; 460 const int64 ref_img_revision_update = 123489;
448 461
449 gfx::Size container_size(400, 300); 462 gfx::Size container_size(400, 300);
450 FilePath url = 463 FilePath url =
451 test_data_dir().AppendASCII("pixel_canvas2d.html"); 464 test_data_dir().AppendASCII("pixel_canvas2d.html");
452 RunPixelTest(container_size, url, ref_img_revision_update); 465 RunPixelTest(container_size, url, ref_img_revision_update);
453 } 466 }
OLDNEW
« no previous file with comments | « chrome/test/data/gpu/pixel_canvas2d.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698