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

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

Issue 10551002: TabContentsWrapper -> TabContents, part 56. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Not killing GetSelectedWebContents yet Created 8 years, 6 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/base/ui_test_utils.cc ('k') | chrome/test/perf/rendering/latency_tests.cc » ('j') | 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"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 message_queue.ClearQueue(); 159 message_queue.ClearQueue();
160 160
161 gfx::Rect new_bounds = GetNewTabContainerBounds(tab_container_size); 161 gfx::Rect new_bounds = GetNewTabContainerBounds(tab_container_size);
162 162
163 std::wostringstream js_call; 163 std::wostringstream js_call;
164 js_call << "preCallResizeInChromium("; 164 js_call << "preCallResizeInChromium(";
165 js_call << new_bounds.width() << ", " << new_bounds.height(); 165 js_call << new_bounds.width() << ", " << new_bounds.height();
166 js_call << ");"; 166 js_call << ");";
167 167
168 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 168 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
169 browser()->GetSelectedWebContents()->GetRenderViewHost(), 169 browser()->GetActiveWebContents()->GetRenderViewHost(),
170 L"", js_call.str())); 170 L"", js_call.str()));
171 171
172 std::string message; 172 std::string message;
173 ASSERT_TRUE(message_queue.WaitForMessage(&message)); 173 ASSERT_TRUE(message_queue.WaitForMessage(&message));
174 message_queue.ClearQueue(); 174 message_queue.ClearQueue();
175 browser()->window()->SetBounds(new_bounds); 175 browser()->window()->SetBounds(new_bounds);
176 176
177 // Wait for message from test page indicating the rendering is done. 177 // Wait for message from test page indicating the rendering is done.
178 while (message.compare("\"resized\"")) { 178 while (message.compare("\"resized\"")) {
179 ASSERT_TRUE(message_queue.WaitForMessage(&message)); 179 ASSERT_TRUE(message_queue.WaitForMessage(&message));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 << img_diff_path.value(); 366 << img_diff_path.value();
367 } 367 }
368 } 368 }
369 return rt; 369 return rt;
370 } 370 }
371 371
372 // Returns a gfx::Rect representing the bounds that the browser window should 372 // Returns a gfx::Rect representing the bounds that the browser window should
373 // have if the tab contents have the desired size. 373 // have if the tab contents have the desired size.
374 gfx::Rect GetNewTabContainerBounds(const gfx::Size& desired_size) { 374 gfx::Rect GetNewTabContainerBounds(const gfx::Size& desired_size) {
375 gfx::Rect container_rect; 375 gfx::Rect container_rect;
376 browser()->GetSelectedWebContents()->GetContainerBounds(&container_rect); 376 browser()->GetActiveWebContents()->GetContainerBounds(&container_rect);
377 // Size cannot be negative, so use a point. 377 // Size cannot be negative, so use a point.
378 gfx::Point correction( 378 gfx::Point correction(
379 desired_size.width() - container_rect.size().width(), 379 desired_size.width() - container_rect.size().width(),
380 desired_size.height() - container_rect.size().height()); 380 desired_size.height() - container_rect.size().height());
381 381
382 gfx::Rect window_rect = browser()->window()->GetRestoredBounds(); 382 gfx::Rect window_rect = browser()->window()->GetRestoredBounds();
383 gfx::Size new_size = window_rect.size(); 383 gfx::Size new_size = window_rect.size();
384 new_size.Enlarge(correction.x(), correction.y()); 384 new_size.Enlarge(correction.x(), correction.y());
385 window_rect.set_size(new_size); 385 window_rect.set_size(new_size);
386 return window_rect; 386 return window_rect;
387 } 387 }
388 388
389 // Take snapshot of the current tab, encode it as PNG, and save to a SkBitmap. 389 // Take snapshot of the current tab, encode it as PNG, and save to a SkBitmap.
390 bool TabSnapShotToImage(SkBitmap* bitmap) { 390 bool TabSnapShotToImage(SkBitmap* bitmap) {
391 CHECK(bitmap); 391 CHECK(bitmap);
392 std::vector<unsigned char> png; 392 std::vector<unsigned char> png;
393 393
394 gfx::Rect root_bounds = browser()->window()->GetBounds(); 394 gfx::Rect root_bounds = browser()->window()->GetBounds();
395 gfx::Rect tab_contents_bounds; 395 gfx::Rect tab_contents_bounds;
396 browser()->GetSelectedWebContents()->GetContainerBounds( 396 browser()->GetActiveWebContents()->GetContainerBounds(
397 &tab_contents_bounds); 397 &tab_contents_bounds);
398 398
399 gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), 399 gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(),
400 tab_contents_bounds.y() - root_bounds.y(), 400 tab_contents_bounds.y() - root_bounds.y(),
401 tab_contents_bounds.width(), 401 tab_contents_bounds.width(),
402 tab_contents_bounds.height()); 402 tab_contents_bounds.height());
403 403
404 gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); 404 gfx::NativeWindow native_window = browser()->window()->GetNativeWindow();
405 if (!browser::GrabWindowSnapshot(native_window, &png, snapshot_bounds)) { 405 if (!browser::GrabWindowSnapshot(native_window, &png, snapshot_bounds)) {
406 LOG(ERROR) << "browser::GrabWindowSnapShot() failed"; 406 LOG(ERROR) << "browser::GrabWindowSnapShot() failed";
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 IN_PROC_BROWSER_TEST_F(Canvas2DPixelTestSD, Canvas2DRedBoxSD) { 495 IN_PROC_BROWSER_TEST_F(Canvas2DPixelTestSD, Canvas2DRedBoxSD) {
496 // If test baseline needs to be updated after a given revision, update the 496 // If test baseline needs to be updated after a given revision, update the
497 // following number. If no revision requirement, then 0. 497 // following number. If no revision requirement, then 0.
498 const int64 ref_img_revision_update = 123489; 498 const int64 ref_img_revision_update = 123489;
499 499
500 gfx::Size container_size(400, 300); 500 gfx::Size container_size(400, 300);
501 FilePath url = 501 FilePath url =
502 test_data_dir().AppendASCII("pixel_canvas2d.html"); 502 test_data_dir().AppendASCII("pixel_canvas2d.html");
503 RunPixelTest(container_size, url, ref_img_revision_update); 503 RunPixelTest(container_size, url, ref_img_revision_update);
504 } 504 }
OLDNEW
« no previous file with comments | « chrome/test/base/ui_test_utils.cc ('k') | chrome/test/perf/rendering/latency_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698