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/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/test/trace_event_analyzer.h" | 14 #include "base/test/trace_event_analyzer.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/net/url_fixer_upper.h" | 16 #include "chrome/browser/net/url_fixer_upper.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_tabstrip.h" |
18 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
19 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
20 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" | 21 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" |
21 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/test/base/test_switches.h" | 24 #include "chrome/test/base/test_switches.h" |
24 #include "chrome/test/base/tracing.h" | 25 #include "chrome/test/base/tracing.h" |
25 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
26 #include "chrome/test/perf/browser_perf_test.h" | 27 #include "chrome/test/perf/browser_perf_test.h" |
27 #include "chrome/test/perf/perf_test.h" | 28 #include "chrome/test/perf/perf_test.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 ui_test_utils::RunThisRunLoop(&run_loop); | 204 ui_test_utils::RunThisRunLoop(&run_loop); |
204 } | 205 } |
205 | 206 |
206 // Take snapshot of the current tab, encode it as PNG, and save to a SkBitmap. | 207 // Take snapshot of the current tab, encode it as PNG, and save to a SkBitmap. |
207 bool TabSnapShotToImage(SkBitmap* bitmap) { | 208 bool TabSnapShotToImage(SkBitmap* bitmap) { |
208 CHECK(bitmap); | 209 CHECK(bitmap); |
209 std::vector<unsigned char> png; | 210 std::vector<unsigned char> png; |
210 | 211 |
211 gfx::Rect root_bounds = browser()->window()->GetBounds(); | 212 gfx::Rect root_bounds = browser()->window()->GetBounds(); |
212 gfx::Rect tab_contents_bounds; | 213 gfx::Rect tab_contents_bounds; |
213 browser()->GetActiveWebContents()->GetContainerBounds( | 214 chrome::GetActiveWebContents(browser())->GetContainerBounds( |
214 &tab_contents_bounds); | 215 &tab_contents_bounds); |
215 | 216 |
216 gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), | 217 gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), |
217 tab_contents_bounds.y() - root_bounds.y(), | 218 tab_contents_bounds.y() - root_bounds.y(), |
218 tab_contents_bounds.width(), | 219 tab_contents_bounds.width(), |
219 tab_contents_bounds.height()); | 220 tab_contents_bounds.height()); |
220 | 221 |
221 gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); | 222 gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); |
222 if (!browser::GrabWindowSnapshot(native_window, &png, snapshot_bounds)) { | 223 if (!browser::GrabWindowSnapshot(native_window, &png, snapshot_bounds)) { |
223 LOG(ERROR) << "browser::GrabWindowSnapShot() failed"; | 224 LOG(ERROR) << "browser::GrabWindowSnapShot() failed"; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 if (flags & kAllowExternalDNS) | 310 if (flags & kAllowExternalDNS) |
310 AllowExternalDNS(); | 311 AllowExternalDNS(); |
311 | 312 |
312 std::string json_events; | 313 std::string json_events; |
313 TraceEventVector events_sw, events_gpu; | 314 TraceEventVector events_sw, events_gpu; |
314 scoped_ptr<TraceAnalyzer> analyzer; | 315 scoped_ptr<TraceAnalyzer> analyzer; |
315 | 316 |
316 LOG(INFO) << gurl_.possibly_invalid_spec(); | 317 LOG(INFO) << gurl_.possibly_invalid_spec(); |
317 ui_test_utils::NavigateToURLWithDisposition( | 318 ui_test_utils::NavigateToURLWithDisposition( |
318 browser(), gurl_, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); | 319 browser(), gurl_, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
319 ui_test_utils::WaitForLoadStop(browser()->GetActiveWebContents()); | 320 ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser())); |
320 | 321 |
321 // Let the test spin up. | 322 // Let the test spin up. |
322 LOG(INFO) << "Spinning up test..."; | 323 LOG(INFO) << "Spinning up test..."; |
323 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); | 324 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); |
324 Wait(spinup_time_ms_); | 325 Wait(spinup_time_ms_); |
325 ASSERT_TRUE(tracing::EndTracing(&json_events)); | 326 ASSERT_TRUE(tracing::EndTracing(&json_events)); |
326 | 327 |
327 // Wait for a pixel color to change (if requested). | 328 // Wait for a pixel color to change (if requested). |
328 WaitForPixelColor(); | 329 WaitForPixelColor(); |
329 | 330 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 std::string mean_and_error = base::StringPrintf("%f,%f", mean_ms, | 371 std::string mean_and_error = base::StringPrintf("%f,%f", mean_ms, |
371 std_dev_ms); | 372 std_dev_ms); |
372 perf_test::PrintResultMeanAndError(test_name, "", trace_name, | 373 perf_test::PrintResultMeanAndError(test_name, "", trace_name, |
373 mean_and_error, "frame_time", true); | 374 mean_and_error, "frame_time", true); |
374 | 375 |
375 if (flags & kAllowExternalDNS) | 376 if (flags & kAllowExternalDNS) |
376 ResetAllowExternalDNS(); | 377 ResetAllowExternalDNS(); |
377 | 378 |
378 // Close the tab so that we can quit without timing out during the | 379 // Close the tab so that we can quit without timing out during the |
379 // wait-for-idle stage in browser_test framework. | 380 // wait-for-idle stage in browser_test framework. |
380 browser()->GetActiveWebContents()->Close(); | 381 chrome::GetActiveWebContents(browser())->Close(); |
381 } | 382 } |
382 | 383 |
383 private: | 384 private: |
384 // WaitPixel checks a color against the color at the given pixel coordinates | 385 // WaitPixel checks a color against the color at the given pixel coordinates |
385 // of an SkBitmap. | 386 // of an SkBitmap. |
386 class WaitPixel { | 387 class WaitPixel { |
387 enum Operator { | 388 enum Operator { |
388 EQUAL, | 389 EQUAL, |
389 NOT_EQUAL | 390 NOT_EQUAL |
390 }; | 391 }; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 | 552 |
552 IN_PROC_BROWSER_TEST_F(ThroughputTestSW, CanvasManyImagesSW) { | 553 IN_PROC_BROWSER_TEST_F(ThroughputTestSW, CanvasManyImagesSW) { |
553 RunCanvasBenchTest("many_images", kNone); | 554 RunCanvasBenchTest("many_images", kNone); |
554 } | 555 } |
555 | 556 |
556 IN_PROC_BROWSER_TEST_F(ThroughputTestGPU, CanvasManyImagesGPU) { | 557 IN_PROC_BROWSER_TEST_F(ThroughputTestGPU, CanvasManyImagesGPU) { |
557 RunCanvasBenchTest("many_images", kNone | kIsGpuCanvasTest); | 558 RunCanvasBenchTest("many_images", kNone | kIsGpuCanvasTest); |
558 } | 559 } |
559 | 560 |
560 } // namespace | 561 } // namespace |
OLD | NEW |