| 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/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/test/trace_event_analyzer.h" | 13 #include "base/test/trace_event_analyzer.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/net/url_fixer_upper.h" | 15 #include "chrome/browser/net/url_fixer_upper.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 19 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" | 19 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" |
| 20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/test/base/test_switches.h" | 22 #include "chrome/test/base/test_switches.h" |
| 23 #include "chrome/test/base/tracing.h" | 23 #include "chrome/test/base/tracing.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "chrome/test/perf/browser_perf_test.h" | 25 #include "chrome/test/perf/browser_perf_test.h" |
| 26 #include "chrome/test/perf/perf_test.h" | 26 #include "chrome/test/perf/perf_test.h" |
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 ui_test_utils::RunMessageLoop(); | 200 ui_test_utils::RunMessageLoop(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Take snapshot of the current tab, encode it as PNG, and save to a SkBitmap. | 203 // Take snapshot of the current tab, encode it as PNG, and save to a SkBitmap. |
| 204 bool TabSnapShotToImage(SkBitmap* bitmap) { | 204 bool TabSnapShotToImage(SkBitmap* bitmap) { |
| 205 CHECK(bitmap); | 205 CHECK(bitmap); |
| 206 std::vector<unsigned char> png; | 206 std::vector<unsigned char> png; |
| 207 | 207 |
| 208 gfx::Rect root_bounds = browser()->window()->GetBounds(); | 208 gfx::Rect root_bounds = browser()->window()->GetBounds(); |
| 209 gfx::Rect tab_contents_bounds; | 209 gfx::Rect tab_contents_bounds; |
| 210 browser()->GetSelectedWebContents()->GetContainerBounds( | 210 browser()->GetActiveWebContents()->GetContainerBounds( |
| 211 &tab_contents_bounds); | 211 &tab_contents_bounds); |
| 212 | 212 |
| 213 gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), | 213 gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), |
| 214 tab_contents_bounds.y() - root_bounds.y(), | 214 tab_contents_bounds.y() - root_bounds.y(), |
| 215 tab_contents_bounds.width(), | 215 tab_contents_bounds.width(), |
| 216 tab_contents_bounds.height()); | 216 tab_contents_bounds.height()); |
| 217 | 217 |
| 218 gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); | 218 gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); |
| 219 if (!browser::GrabWindowSnapshot(native_window, &png, snapshot_bounds)) { | 219 if (!browser::GrabWindowSnapshot(native_window, &png, snapshot_bounds)) { |
| 220 LOG(ERROR) << "browser::GrabWindowSnapShot() failed"; | 220 LOG(ERROR) << "browser::GrabWindowSnapShot() failed"; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 if (flags & kAllowExternalDNS) | 306 if (flags & kAllowExternalDNS) |
| 307 AllowExternalDNS(); | 307 AllowExternalDNS(); |
| 308 | 308 |
| 309 std::string json_events; | 309 std::string json_events; |
| 310 TraceEventVector events_sw, events_gpu; | 310 TraceEventVector events_sw, events_gpu; |
| 311 scoped_ptr<TraceAnalyzer> analyzer; | 311 scoped_ptr<TraceAnalyzer> analyzer; |
| 312 | 312 |
| 313 LOG(INFO) << gurl_.possibly_invalid_spec(); | 313 LOG(INFO) << gurl_.possibly_invalid_spec(); |
| 314 ui_test_utils::NavigateToURLWithDisposition( | 314 ui_test_utils::NavigateToURLWithDisposition( |
| 315 browser(), gurl_, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); | 315 browser(), gurl_, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
| 316 ui_test_utils::WaitForLoadStop(browser()->GetSelectedWebContents()); | 316 ui_test_utils::WaitForLoadStop(browser()->GetActiveWebContents()); |
| 317 | 317 |
| 318 // Let the test spin up. | 318 // Let the test spin up. |
| 319 LOG(INFO) << "Spinning up test..."; | 319 LOG(INFO) << "Spinning up test..."; |
| 320 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); | 320 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); |
| 321 Wait(spinup_time_ms_); | 321 Wait(spinup_time_ms_); |
| 322 ASSERT_TRUE(tracing::EndTracing(&json_events)); | 322 ASSERT_TRUE(tracing::EndTracing(&json_events)); |
| 323 | 323 |
| 324 // Wait for a pixel color to change (if requested). | 324 // Wait for a pixel color to change (if requested). |
| 325 WaitForPixelColor(); | 325 WaitForPixelColor(); |
| 326 | 326 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 544 |
| 545 IN_PROC_BROWSER_TEST_F(ThroughputTestSW, CanvasManyImagesSW) { | 545 IN_PROC_BROWSER_TEST_F(ThroughputTestSW, CanvasManyImagesSW) { |
| 546 RunCanvasBenchTest("many_images", kNone); | 546 RunCanvasBenchTest("many_images", kNone); |
| 547 } | 547 } |
| 548 | 548 |
| 549 IN_PROC_BROWSER_TEST_F(ThroughputTestGPU, CanvasManyImagesGPU) { | 549 IN_PROC_BROWSER_TEST_F(ThroughputTestGPU, CanvasManyImagesGPU) { |
| 550 RunCanvasBenchTest("many_images", kNone | kIsGpuCanvasTest); | 550 RunCanvasBenchTest("many_images", kNone | kIsGpuCanvasTest); |
| 551 } | 551 } |
| 552 | 552 |
| 553 } // namespace | 553 } // namespace |
| OLD | NEW |