OLD | NEW |
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 <map> | 5 #include <map> |
6 | 6 |
| 7 #include "base/debug/trace_event_test_utils.h" |
7 #include "base/file_util.h" | 8 #include "base/file_util.h" |
8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
9 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
10 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/test/automation/automation_proxy.h" |
| 16 #include "chrome/test/automation/browser_proxy.h" |
14 #include "chrome/test/automation/tab_proxy.h" | 17 #include "chrome/test/automation/tab_proxy.h" |
15 #include "chrome/test/ui/javascript_test_util.h" | 18 #include "chrome/test/ui/javascript_test_util.h" |
16 #include "chrome/test/ui/ui_perf_test.h" | 19 #include "chrome/test/ui/ui_perf_test.h" |
17 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
18 | 21 |
19 namespace { | 22 namespace { |
20 | 23 |
21 class FrameRateTest : public UIPerfTest { | 24 class FrameRateTest : public UIPerfTest { |
22 public: | 25 public: |
23 FrameRateTest() { | 26 FrameRateTest() { |
(...skipping 22 matching lines...) Expand all Loading... |
46 // and allow the frame rate test to use the GPU, we must pass | 49 // and allow the frame rate test to use the GPU, we must pass |
47 // kAllowWebUICompositing. | 50 // kAllowWebUICompositing. |
48 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); | 51 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); |
49 | 52 |
50 UIPerfTest::SetUp(); | 53 UIPerfTest::SetUp(); |
51 } | 54 } |
52 | 55 |
53 void RunTest(const std::string& name, | 56 void RunTest(const std::string& name, |
54 const std::string& suffix, | 57 const std::string& suffix, |
55 bool make_body_composited) { | 58 bool make_body_composited) { |
| 59 using namespace base::debug; |
| 60 using namespace base::debug::trace; |
| 61 |
56 FilePath test_path = GetDataPath(name); | 62 FilePath test_path = GetDataPath(name); |
57 ASSERT_TRUE(file_util::DirectoryExists(test_path)) | 63 ASSERT_TRUE(file_util::DirectoryExists(test_path)) |
58 << "Missing test directory: " << test_path.value(); | 64 << "Missing test directory: " << test_path.value(); |
59 | 65 |
60 test_path = test_path.Append(FILE_PATH_LITERAL("test.html")); | 66 test_path = test_path.Append(FILE_PATH_LITERAL("test.html")); |
61 | 67 |
62 scoped_refptr<TabProxy> tab(GetActiveTab()); | 68 scoped_refptr<TabProxy> tab(GetActiveTab()); |
63 ASSERT_TRUE(tab.get()); | 69 ASSERT_TRUE(tab.get()); |
64 | 70 |
65 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 71 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
66 tab->NavigateToURL(net::FilePathToFileURL(test_path))); | 72 tab->NavigateToURL(net::FilePathToFileURL(test_path))); |
67 | 73 |
68 if (make_body_composited) { | 74 if (make_body_composited) { |
69 ASSERT_TRUE(tab->NavigateToURLAsync( | 75 ASSERT_TRUE(tab->NavigateToURLAsync( |
70 GURL("javascript:__make_body_composited();"))); | 76 GURL("javascript:__make_body_composited();"))); |
71 } | 77 } |
72 | 78 |
| 79 // Create a browser proxy. |
| 80 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); |
| 81 |
| 82 // Start tracing category "test_frame_rate_tests". |
| 83 ASSERT_TRUE(browser->BeginTracing("test_frame_rate_tests")); |
| 84 |
73 // Start the tests. | 85 // Start the tests. |
74 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();"))); | 86 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();"))); |
75 | 87 |
76 // Block until the tests completes. | 88 // Block until the tests completes. |
77 ASSERT_TRUE(WaitUntilJavaScriptCondition( | 89 ASSERT_TRUE(WaitUntilJavaScriptCondition( |
78 tab, L"", L"window.domAutomationController.send(!__running_all);", | 90 tab, L"", L"window.domAutomationController.send(!__running_all);", |
79 TestTimeouts::large_test_timeout_ms())); | 91 TestTimeouts::large_test_timeout_ms())); |
80 | 92 |
| 93 // Stop tracing. |
| 94 std::string json_events; |
| 95 ASSERT_TRUE(browser->EndTracing(&json_events)); |
| 96 |
81 // Read out the results. | 97 // Read out the results. |
82 std::wstring json; | 98 std::wstring json; |
83 ASSERT_TRUE(tab->ExecuteAndExtractString( | 99 ASSERT_TRUE(tab->ExecuteAndExtractString( |
84 L"", | 100 L"", |
85 L"window.domAutomationController.send(" | 101 L"window.domAutomationController.send(" |
86 L"JSON.stringify(__calc_results_total()));", | 102 L"JSON.stringify(__calc_results_total()));", |
87 &json)); | 103 &json)); |
88 | 104 |
89 std::map<std::string, std::string> results; | 105 std::map<std::string, std::string> results; |
90 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results)); | 106 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results)); |
91 | 107 |
92 ASSERT_TRUE(results.find("mean") != results.end()); | 108 ASSERT_TRUE(results.find("mean") != results.end()); |
93 ASSERT_TRUE(results.find("sigma") != results.end()); | 109 ASSERT_TRUE(results.find("sigma") != results.end()); |
94 ASSERT_TRUE(results.find("gestures") != results.end()); | 110 ASSERT_TRUE(results.find("gestures") != results.end()); |
95 ASSERT_TRUE(results.find("means") != results.end()); | 111 ASSERT_TRUE(results.find("means") != results.end()); |
96 ASSERT_TRUE(results.find("sigmas") != results.end()); | 112 ASSERT_TRUE(results.find("sigmas") != results.end()); |
97 | 113 |
98 std::string trace_name = "fps" + suffix; | 114 // Check trace for GPU accleration. |
| 115 TraceAnalyzer analyzer(json_events); |
| 116 const TestTraceEvent* gpu_event = |
| 117 analyzer.FindEvent(Query(EVENT_NAME) == "SwapBuffers" && |
| 118 Query(EVENT_ARG, "is_GPU")); |
| 119 |
| 120 // Verify that sanity-check DoDeferredUpdate event exists. |
| 121 ASSERT_TRUE(analyzer.FindEvent(Query(EVENT_NAME) == "DoDeferredUpdate")); |
| 122 |
| 123 // If GPU acceleration is requested, set the appropriate suffix. _swfb means |
| 124 // software fallback (GPU acceleration requested but not available). |
| 125 std::string gpu_suffix = gpu_event ? "_gpu" : |
| 126 make_body_composited ? "_swfb" : ""; |
| 127 |
| 128 std::string trace_name = "fps" + suffix + gpu_suffix; |
99 printf("GESTURES %s: %s= [%s] [%s] [%s]\n", name.c_str(), | 129 printf("GESTURES %s: %s= [%s] [%s] [%s]\n", name.c_str(), |
100 trace_name.c_str(), | 130 trace_name.c_str(), |
101 results["gestures"].c_str(), | 131 results["gestures"].c_str(), |
102 results["means"].c_str(), | 132 results["means"].c_str(), |
103 results["sigmas"].c_str()); | 133 results["sigmas"].c_str()); |
104 | 134 |
105 std::string mean_and_error = results["mean"] + "," + results["sigma"]; | 135 std::string mean_and_error = results["mean"] + "," + results["sigma"]; |
106 PrintResultMeanAndError(name, "", trace_name, mean_and_error, | 136 PrintResultMeanAndError(name, "", trace_name, mean_and_error, |
107 "frames-per-second", true); | 137 "frames-per-second", true); |
108 } | 138 } |
(...skipping 28 matching lines...) Expand all Loading... |
137 RunTest(#content, "_ref", false); \ | 167 RunTest(#content, "_ref", false); \ |
138 } \ | 168 } \ |
139 TEST_F(FrameRateTest_Reference, content ## _comp) { \ | 169 TEST_F(FrameRateTest_Reference, content ## _comp) { \ |
140 RunTest(#content, "_comp_ref", true); \ | 170 RunTest(#content, "_comp_ref", true); \ |
141 } | 171 } |
142 | 172 |
143 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(blank); | 173 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(blank); |
144 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(googleblog); | 174 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(googleblog); |
145 | 175 |
146 } // namespace | 176 } // namespace |
OLD | NEW |