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

Side by Side Diff: chrome/browser/gpu_pixel_browsertest.cc

Issue 8523022: Change snasphotting API to take in a bounds Rect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
17 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/test_launcher_utils.h" 21 #include "chrome/test/base/test_launcher_utils.h"
21 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/browser/gpu/gpu_data_manager.h" 23 #include "content/browser/gpu/gpu_data_manager.h"
23 #include "content/browser/gpu/gpu_process_host.h" 24 #include "content/browser/gpu/gpu_process_host.h"
24 #include "content/browser/renderer_host/render_view_host.h" 25 #include "content/browser/renderer_host/render_view_host.h"
25 #include "content/browser/tab_contents/tab_contents.h" 26 #include "content/browser/tab_contents/tab_contents.h"
26 #include "content/public/common/gpu_info.h" 27 #include "content/public/common/gpu_info.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 FilePath test_data_dir_; 249 FilePath test_data_dir_;
249 250
250 private: 251 private:
251 FilePath generated_img_dir_; 252 FilePath generated_img_dir_;
252 // The name of the test, with any special prefixes dropped. 253 // The name of the test, with any special prefixes dropped.
253 std::string test_name_; 254 std::string test_name_;
254 255
255 DISALLOW_COPY_AND_ASSIGN(GpuPixelBrowserTest); 256 DISALLOW_COPY_AND_ASSIGN(GpuPixelBrowserTest);
256 }; 257 };
257 258
258 // Currently fails (and times out) on linux due to a NOTIMPLEMENTED() statement. 259 #if defined(USE_AURA)
259 // (http://crbug.com/89964) 260 #define MAYBE_WEBGLTeapot DISABLED_WebGLTeapot
jonathan.backer 2011/11/11 14:41:20 nit: case is wrong s/WEB/Web
260 // Fails (and times out) on Windows/Mac due to pixel mismatch. 261 #else
261 // (http://crbug.com/95214) 262 #define MAYBE_WebGLTeapot WebGLTeapot
262 IN_PROC_BROWSER_TEST_F(GpuPixelBrowserTest, DISABLED_WebGLTeapot) { 263 #endif
264
265 IN_PROC_BROWSER_TEST_F(GpuPixelBrowserTest, MAYBE_WebGLTeapot) {
263 ui_test_utils::DOMMessageQueue message_queue; 266 ui_test_utils::DOMMessageQueue message_queue;
264 ui_test_utils::NavigateToURL( 267 ui_test_utils::NavigateToURL(
265 browser(), 268 browser(),
266 net::FilePathToFileURL(test_data_dir_.AppendASCII("webgl_teapot"). 269 net::FilePathToFileURL(test_data_dir_.AppendASCII("webgl_teapot").
267 AppendASCII("teapot.html"))); 270 AppendASCII("teapot.html")));
268 271
272 gfx::Size container_size(500, 500);
273 ResizeTabContainer(browser(), container_size);
274
269 // Wait for message from teapot page indicating the GL calls have been issued. 275 // Wait for message from teapot page indicating the GL calls have been issued.
270 ASSERT_TRUE(message_queue.WaitForMessage(NULL)); 276 ASSERT_TRUE(message_queue.WaitForMessage(NULL));
271 277
278 std::vector<unsigned char> screenshot_png;
279
280 gfx::Rect root_bounds = browser()->window()->GetBounds();
281 gfx::Rect tab_contents_bounds;
282 browser()->GetSelectedTabContents()->GetContainerBounds(&tab_contents_bounds);
283
284 gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(),
285 tab_contents_bounds.y() - root_bounds.y(),
286 tab_contents_bounds.width(),
287 tab_contents_bounds.height());
288
289 gfx::NativeWindow native_window = browser()->window()->GetNativeHandle();
290 gfx::Rect screenshot_size = browser::GrabWindowSnapshot(native_window,
291 &screenshot_png,
292 snapshot_bounds);
293 DCHECK(!screenshot_size.IsEmpty());
jonathan.backer 2011/11/11 14:41:20 ASSERT_TRUE
294 DCHECK(!screenshot_png.empty());
kkania 2011/11/11 17:06:31 ASSERT_TRUE here too. It's generally better to fai
295
272 SkBitmap bitmap; 296 SkBitmap bitmap;
273 gfx::Size container_size(500, 500); 297 bool success = gfx::PNGCodec::Decode(
274 ResizeTabContainer(browser(), container_size); 298 reinterpret_cast<unsigned char*>(&*screenshot_png.begin()),
275 ASSERT_TRUE(ui_test_utils::TakeRenderWidgetSnapshot( 299 screenshot_png.size(),
276 browser()->GetSelectedTabContents()->render_view_host(), 300 &bitmap);
277 container_size, &bitmap)); 301
302 DCHECK(success);
kkania 2011/11/11 17:06:31 ASSERT_TRUE
278 ASSERT_TRUE(CompareImages(bitmap, "")); 303 ASSERT_TRUE(CompareImages(bitmap, ""));
279 } 304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698