Chromium Code Reviews| 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/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/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/test/automation/tab_proxy.h" | 14 #include "chrome/test/automation/tab_proxy.h" |
| 15 #include "chrome/test/ui/javascript_test_util.h" | 15 #include "chrome/test/ui/javascript_test_util.h" |
| 16 #include "chrome/test/ui/ui_perf_test.h" | 16 #include "chrome/test/ui/ui_perf_test.h" |
| 17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class FrameRateTest : public UIPerfTest { | 21 enum FrameRateTestFlags { |
| 22 kMakeBodyComposited = 1 << 0, | |
| 23 kDisableRaf = 1 << 1, | |
| 24 kDisableGpu = 1 << 2, | |
| 25 kReference = 1 << 3, | |
| 26 }; | |
| 27 | |
| 28 template<unsigned TestFlags> | |
|
Justin Novosad
2011/10/13 22:04:55
I chose to use a template arg here because the TES
| |
| 29 class FrameRateTest_ : public UIPerfTest { | |
| 22 public: | 30 public: |
| 23 FrameRateTest() { | 31 |
| 32 FrameRateTest_() { | |
| 24 show_window_ = true; | 33 show_window_ = true; |
| 25 dom_automation_enabled_ = true; | 34 dom_automation_enabled_ = true; |
| 26 // Since this is a performance test, try to use the host machine's GPU | 35 // Since this is a performance test, try to use the host machine's GPU |
| 27 // instead of falling back to software-rendering. | 36 // instead of falling back to software-rendering. |
| 28 force_use_osmesa_ = false; | 37 force_use_osmesa_ = false; |
| 29 disable_accelerated_compositing_ = false; | 38 disable_accelerated_compositing_ = false; |
| 30 } | 39 } |
| 31 | 40 |
| 32 virtual FilePath GetDataPath(const std::string& name) { | 41 virtual FilePath GetDataPath(const std::string& name) { |
| 33 // Make sure the test data is checked out. | 42 // Make sure the test data is checked out. |
| 34 FilePath test_path; | 43 FilePath test_path; |
| 35 PathService::Get(chrome::DIR_TEST_DATA, &test_path); | 44 PathService::Get(chrome::DIR_TEST_DATA, &test_path); |
| 36 test_path = test_path.Append(FILE_PATH_LITERAL("perf")); | 45 test_path = test_path.Append(FILE_PATH_LITERAL("perf")); |
| 37 test_path = test_path.Append(FILE_PATH_LITERAL("frame_rate")); | 46 test_path = test_path.Append(FILE_PATH_LITERAL("frame_rate")); |
| 38 test_path = test_path.Append(FILE_PATH_LITERAL("content")); | 47 test_path = test_path.Append(FILE_PATH_LITERAL("content")); |
| 39 test_path = test_path.AppendASCII(name); | 48 test_path = test_path.AppendASCII(name); |
| 40 return test_path; | 49 return test_path; |
| 41 } | 50 } |
| 42 | 51 |
| 43 virtual void SetUp() { | 52 virtual void SetUp() { |
| 44 // UI tests boot up render views starting from about:blank. This causes the | 53 if (TestFlags & kReference) { |
| 45 // renderer to start up thinking it cannot use the GPU. To work around that, | 54 UseReferenceBuild(); |
| 46 // and allow the frame rate test to use the GPU, we must pass | 55 } |
| 47 // kAllowWebUICompositing. | 56 |
| 48 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); | 57 if (TestFlags & kDisableGpu) { |
| 58 launch_arguments_.AppendSwitch(switches::kDisableAccelerated2dCanvas); | |
|
Justin Novosad
2011/10/13 22:04:55
because the switch dependencies may change over ti
| |
| 59 launch_arguments_.AppendSwitch(switches::kDisableAcceleratedCompositing); | |
| 60 launch_arguments_.AppendSwitch(switches::kDisableAcceleratedLayers); | |
| 61 launch_arguments_.AppendSwitch(switches::kDisableAcceleratedPlugins); | |
| 62 launch_arguments_.AppendSwitch(switches::kDisableAcceleratedVideo); | |
| 63 } else { | |
| 64 // UI tests boot up render views starting from about:blank. This causes | |
| 65 // the renderer to start up thinking it cannot use the GPU. To work | |
| 66 // around that, and allow the frame rate test to use the GPU, we must | |
| 67 // pass kAllowWebUICompositing. | |
| 68 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); | |
| 69 } | |
| 49 | 70 |
| 50 UIPerfTest::SetUp(); | 71 UIPerfTest::SetUp(); |
| 51 } | 72 } |
| 52 | 73 |
| 53 void RunTest(const std::string& name, | 74 void RunTest(const std::string& name, |
| 54 const std::string& suffix, | 75 const std::string& suffix) { |
| 55 bool make_body_composited) { | |
| 56 FilePath test_path = GetDataPath(name); | 76 FilePath test_path = GetDataPath(name); |
| 57 ASSERT_TRUE(file_util::DirectoryExists(test_path)) | 77 ASSERT_TRUE(file_util::DirectoryExists(test_path)) |
| 58 << "Missing test directory: " << test_path.value(); | 78 << "Missing test directory: " << test_path.value(); |
| 59 | 79 |
| 60 test_path = test_path.Append(FILE_PATH_LITERAL("test.html")); | 80 test_path = test_path.Append(FILE_PATH_LITERAL("test.html")); |
| 61 | 81 |
| 62 scoped_refptr<TabProxy> tab(GetActiveTab()); | 82 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 63 ASSERT_TRUE(tab.get()); | 83 ASSERT_TRUE(tab.get()); |
| 64 | 84 |
| 65 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 85 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 66 tab->NavigateToURL(net::FilePathToFileURL(test_path))); | 86 tab->NavigateToURL(net::FilePathToFileURL(test_path))); |
| 67 | 87 |
| 68 if (make_body_composited) { | 88 if (TestFlags & kMakeBodyComposited) { |
| 69 ASSERT_TRUE(tab->NavigateToURLAsync( | 89 ASSERT_TRUE(tab->NavigateToURLAsync( |
| 70 GURL("javascript:__make_body_composited();"))); | 90 GURL("javascript:__make_body_composited();"))); |
| 71 } | 91 } |
| 72 | 92 |
| 93 if (TestFlags & kDisableRaf) { | |
| 94 ASSERT_TRUE(tab->NavigateToURLAsync( | |
| 95 GURL("javascript:__init_raf(false);"))); | |
|
Justin Novosad
2011/10/13 22:04:55
I attempted to use the --disable-gpu-vsync switch
| |
| 96 } | |
| 97 | |
| 98 // Block until initialization completes. | |
| 99 ASSERT_TRUE(WaitUntilJavaScriptCondition( | |
| 100 tab, L"", L"window.domAutomationController.send(__initialized);", | |
| 101 TestTimeouts::large_test_timeout_ms())); | |
| 102 | |
| 73 // Start the tests. | 103 // Start the tests. |
| 74 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();"))); | 104 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();"))); |
| 75 | 105 |
| 76 // Block until the tests completes. | 106 // Block until the tests completes. |
| 77 ASSERT_TRUE(WaitUntilJavaScriptCondition( | 107 ASSERT_TRUE(WaitUntilJavaScriptCondition( |
| 78 tab, L"", L"window.domAutomationController.send(!__running_all);", | 108 tab, L"", L"window.domAutomationController.send(!__running_all);", |
| 79 TestTimeouts::large_test_timeout_ms())); | 109 TestTimeouts::large_test_timeout_ms())); |
| 80 | 110 |
| 81 // Read out the results. | 111 // Read out the results. |
| 82 std::wstring json; | 112 std::wstring json; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 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 } |
| 109 }; | 139 }; |
| 110 | 140 |
| 111 class FrameRateTest_Reference : public FrameRateTest { | 141 typedef FrameRateTest_<0> |
| 112 public: | 142 FrameRateTest; |
| 113 void SetUp() { | 143 typedef FrameRateTest_<kReference> |
| 114 UseReferenceBuild(); | 144 FrameRateTest_Reference; |
| 115 FrameRateTest::SetUp(); | 145 typedef FrameRateTest_<kMakeBodyComposited> |
| 116 } | 146 FrameRateTest_Comp; |
| 117 }; | 147 typedef FrameRateTest_<kReference | kMakeBodyComposited> |
| 148 FrameRateTest_Comp_Reference; | |
| 149 typedef FrameRateTest_<kDisableRaf> | |
| 150 FrameRateTest_NoRaf; | |
| 151 typedef FrameRateTest_<kReference | kDisableRaf> | |
| 152 FrameRateTest_NoRaf_Reference; | |
| 153 typedef FrameRateTest_<kDisableGpu> | |
| 154 FrameRateTest_NoGpu; | |
| 155 typedef FrameRateTest_<kReference | kDisableGpu> | |
| 156 FrameRateTest_NoGpu_Reference; | |
| 157 typedef FrameRateTest_<kDisableRaf | kDisableGpu> | |
| 158 FrameRateTest_NoRaf_NoGpu; | |
| 159 typedef FrameRateTest_<kReference | kDisableRaf | kDisableGpu> | |
| 160 FrameRateTest_NoRaf_NoGpu_Reference; | |
| 161 | |
| 118 | 162 |
| 119 #define FRAME_RATE_TEST(content) \ | 163 #define FRAME_RATE_TEST(content) \ |
| 120 TEST_F(FrameRateTest, content) { \ | 164 TEST_F(FrameRateTest, content) { \ |
| 121 RunTest(#content, "", false); \ | 165 RunTest(#content, ""); \ |
| 122 } \ | 166 } \ |
| 123 TEST_F(FrameRateTest_Reference, content) { \ | 167 TEST_F(FrameRateTest_Reference, content) { \ |
| 124 RunTest(#content, "_ref", false); \ | 168 RunTest(#content, "_ref"); \ |
| 125 } | 169 } |
| 126 | 170 |
| 127 | 171 |
| 128 // Tests that trigger compositing with a -webkit-translateZ(0) | 172 // Tests that trigger compositing with a -webkit-translateZ(0) |
| 129 #define FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(content) \ | 173 #define FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(content) \ |
| 130 TEST_F(FrameRateTest, content) { \ | 174 TEST_F(FrameRateTest, content) { \ |
| 131 RunTest(#content, "", false); \ | 175 RunTest(#content, ""); \ |
| 132 } \ | 176 } \ |
| 133 TEST_F(FrameRateTest, content ## _comp) { \ | 177 TEST_F(FrameRateTest_Comp, content ## _comp) { \ |
| 134 RunTest(#content, "_comp", true); \ | 178 RunTest(#content, "_comp"); \ |
| 135 } \ | 179 } \ |
| 136 TEST_F(FrameRateTest_Reference, content) { \ | 180 TEST_F(FrameRateTest_Reference, content) { \ |
| 137 RunTest(#content, "_ref", false); \ | 181 RunTest(#content, "_ref"); \ |
| 138 } \ | 182 } \ |
| 139 TEST_F(FrameRateTest_Reference, content ## _comp) { \ | 183 TEST_F(FrameRateTest_Comp_Reference, content ## _comp) { \ |
| 140 RunTest(#content, "_comp_ref", true); \ | 184 RunTest(#content, "_comp_ref"); \ |
| 141 } | 185 } |
| 142 | 186 |
| 187 // Tests for pages that have animated 2d canvas content. | |
| 188 // Tests run with and without RAF, and with and without GPU acceleration. | |
| 189 #define FRAME_RATE_TEST_ANIMATED_2D_CANVAS(content) \ | |
| 190 TEST_F(FrameRateTest, content) { \ | |
| 191 RunTest(#content, ""); \ | |
| 192 } \ | |
| 193 TEST_F(FrameRateTest_NoRaf, content) { \ | |
| 194 RunTest(#content, "_noraf"); \ | |
| 195 } \ | |
| 196 TEST_F(FrameRateTest_NoGpu, content) { \ | |
| 197 RunTest(#content, "_nogpu"); \ | |
| 198 } \ | |
| 199 TEST_F(FrameRateTest_NoRaf_NoGpu, content) { \ | |
| 200 RunTest(#content, "_noraf_nogpu"); \ | |
| 201 } \ | |
| 202 TEST_F(FrameRateTest_Reference, content) { \ | |
| 203 RunTest(#content, "_ref"); \ | |
| 204 } \ | |
| 205 TEST_F(FrameRateTest_NoRaf_Reference, content) { \ | |
| 206 RunTest(#content, "_noraf_ref"); \ | |
| 207 } \ | |
| 208 TEST_F(FrameRateTest_NoGpu_Reference, content) { \ | |
| 209 RunTest(#content, "_nogpu_ref"); \ | |
| 210 } \ | |
| 211 TEST_F(FrameRateTest_NoRaf_NoGpu_Reference, content) { \ | |
| 212 RunTest(#content, "_noraf_nogpu_ref"); \ | |
| 213 } \ | |
| 214 | |
| 143 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(blank); | 215 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(blank); |
| 144 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(googleblog); | 216 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(googleblog); |
| 145 | 217 |
| 218 // Canvas 2D tests | |
| 219 //FRAME_RATE_TEST_ANIMATED_2D_CANVAS( canvas2d_balls_drawImage ); | |
| 220 | |
| 146 } // namespace | 221 } // namespace |
| OLD | NEW |