| 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 | 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()->GetSelectedWebContents()->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()->GetNativeHandle(); | 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"; |
| 407 return false; | 407 return false; |
| 408 } | 408 } |
| 409 | 409 |
| 410 if (!gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&*png.begin()), | 410 if (!gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&*png.begin()), |
| 411 png.size(), bitmap)) { | 411 png.size(), bitmap)) { |
| 412 LOG(ERROR) << "Decode PNG to a SkBitmap failed"; | 412 LOG(ERROR) << "Decode PNG to a SkBitmap failed"; |
| 413 return false; | 413 return false; |
| 414 } | 414 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |