Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: chrome/test/perf/frame_rate/frame_rate_tests.cc

Issue 8052016: Adding support for animated pages in the FrameRate tests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/perf/frame_rate/head_animation.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/gfx/gl/gl_switches.h"
18 19
19 namespace { 20 //namespace must be named so that the PrintTo overload is externally visible
21 namespace FrameRateTestNamespace {
20 22
21 class FrameRateTest : public UIPerfTest { 23 enum FrameRateTestFlags {
24 kMakeBodyComposited = 1 << 0,
25 kDisableVsync = 1 << 1,
26 kDisableGpu = 1 << 2,
27 kReference = 1 << 3,
nduca 2011/10/19 19:25:49 kUseReferenceBuild
28 };
29
30 // Wrap flags into a class so that PrintTo can be overloaded
31 class FrameRateTestVariant {
nduca 2011/10/19 19:25:49 Would this be cleaner with FrameRateTestVariant ha
32 public:
33 explicit FrameRateTestVariant(unsigned flags) : flags_(flags){}
34 unsigned GetFlags() const {return flags_;}
35 private:
36 unsigned flags_;
37 };
38
39 void PrintTo(const FrameRateTestVariant& v, std::ostream* os) {
40 bool has_val = false;
41
42 #define PRINTFLAG( flag_name ) \
43 if (v.GetFlags() & flag_name) { \
44 if (has_val) { \
45 *os << " | "; \
46 } else { \
47 has_val = true; \
48 } \
49 *os << #flag_name; \
50 }
51
52 PRINTFLAG(kMakeBodyComposited)
53 PRINTFLAG(kDisableVsync)
54 PRINTFLAG(kDisableGpu)
55 // kReference flag deliberately omitted
56
57 if (!has_val) {
58 *os << "0";
59 }
60 }
61
62 class FrameRateTest :
63 public UIPerfTest,
64 public ::testing::WithParamInterface<FrameRateTestVariant> {
22 public: 65 public:
23 FrameRateTest() { 66 FrameRateTest() {
24 show_window_ = true; 67 show_window_ = true;
25 dom_automation_enabled_ = true; 68 dom_automation_enabled_ = true;
26 // Since this is a performance test, try to use the host machine's GPU 69 // Since this is a performance test, try to use the host machine's GPU
27 // instead of falling back to software-rendering. 70 // instead of falling back to software-rendering.
28 force_use_osmesa_ = false; 71 force_use_osmesa_ = false;
29 disable_accelerated_compositing_ = false; 72 disable_accelerated_compositing_ = false;
30 } 73 }
31 74
32 virtual FilePath GetDataPath(const std::string& name) { 75 virtual FilePath GetDataPath(const std::string& name) {
33 // Make sure the test data is checked out. 76 // Make sure the test data is checked out.
34 FilePath test_path; 77 FilePath test_path;
35 PathService::Get(chrome::DIR_TEST_DATA, &test_path); 78 PathService::Get(chrome::DIR_TEST_DATA, &test_path);
36 test_path = test_path.Append(FILE_PATH_LITERAL("perf")); 79 test_path = test_path.Append(FILE_PATH_LITERAL("perf"));
37 test_path = test_path.Append(FILE_PATH_LITERAL("frame_rate")); 80 test_path = test_path.Append(FILE_PATH_LITERAL("frame_rate"));
38 test_path = test_path.Append(FILE_PATH_LITERAL("content")); 81 test_path = test_path.Append(FILE_PATH_LITERAL("content"));
39 test_path = test_path.AppendASCII(name); 82 test_path = test_path.AppendASCII(name);
40 return test_path; 83 return test_path;
41 } 84 }
42 85
43 virtual void SetUp() { 86 virtual void SetUp() {
44 // UI tests boot up render views starting from about:blank. This causes the 87 if (GetParam().GetFlags() & kReference) {
45 // renderer to start up thinking it cannot use the GPU. To work around that, 88 UseReferenceBuild();
46 // and allow the frame rate test to use the GPU, we must pass 89 }
47 // kAllowWebUICompositing. 90
91 // UI tests boot up render views starting from about:blank. This causes
92 // the renderer to start up thinking it cannot use the GPU. To work
93 // around that, and allow the frame rate test to use the GPU, we must
94 // pass kAllowWebUICompositing.
48 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); 95 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing);
49 96
97 if (GetParam().GetFlags() & kDisableGpu) {
98 launch_arguments_.AppendSwitch(switches::kDisableAcceleratedCompositing);
99 launch_arguments_.AppendSwitch(switches::kDisableExperimentalWebGL);
100 }
101
102 if (GetParam().GetFlags() & kDisableVsync) {
103 launch_arguments_.AppendSwitch(switches::kDisableGpuVsync);
104 }
105
50 UIPerfTest::SetUp(); 106 UIPerfTest::SetUp();
51 } 107 }
52 108
53 void RunTest(const std::string& name, 109 void RunTest(const std::string& name) {
54 const std::string& suffix,
55 bool make_body_composited) {
56 FilePath test_path = GetDataPath(name); 110 FilePath test_path = GetDataPath(name);
57 ASSERT_TRUE(file_util::DirectoryExists(test_path)) 111 ASSERT_TRUE(file_util::DirectoryExists(test_path))
58 << "Missing test directory: " << test_path.value(); 112 << "Missing test directory: " << test_path.value();
59 113
60 test_path = test_path.Append(FILE_PATH_LITERAL("test.html")); 114 test_path = test_path.Append(FILE_PATH_LITERAL("test.html"));
61 115
62 scoped_refptr<TabProxy> tab(GetActiveTab()); 116 scoped_refptr<TabProxy> tab(GetActiveTab());
63 ASSERT_TRUE(tab.get()); 117 ASSERT_TRUE(tab.get());
64 118
65 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, 119 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
66 tab->NavigateToURL(net::FilePathToFileURL(test_path))); 120 tab->NavigateToURL(net::FilePathToFileURL(test_path)));
67 121
68 if (make_body_composited) { 122 if (GetParam().GetFlags() & kMakeBodyComposited) {
69 ASSERT_TRUE(tab->NavigateToURLAsync( 123 ASSERT_TRUE(tab->NavigateToURLAsync(
70 GURL("javascript:__make_body_composited();"))); 124 GURL("javascript:__make_body_composited();")));
71 } 125 }
72 126
127 // Block until initialization completes.
128 ASSERT_TRUE(WaitUntilJavaScriptCondition(
129 tab, L"", L"window.domAutomationController.send(__initialized);",
130 TestTimeouts::large_test_timeout_ms()));
131
73 // Start the tests. 132 // Start the tests.
74 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();"))); 133 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();")));
75 134
76 // Block until the tests completes. 135 // Block until the tests completes.
77 ASSERT_TRUE(WaitUntilJavaScriptCondition( 136 ASSERT_TRUE(WaitUntilJavaScriptCondition(
78 tab, L"", L"window.domAutomationController.send(!__running_all);", 137 tab, L"", L"window.domAutomationController.send(!__running_all);",
79 TestTimeouts::large_test_timeout_ms())); 138 TestTimeouts::large_test_timeout_ms()));
80 139
81 // Read out the results. 140 // Read out the results.
82 std::wstring json; 141 std::wstring json;
83 ASSERT_TRUE(tab->ExecuteAndExtractString( 142 ASSERT_TRUE(tab->ExecuteAndExtractString(
84 L"", 143 L"",
85 L"window.domAutomationController.send(" 144 L"window.domAutomationController.send("
86 L"JSON.stringify(__calc_results_total()));", 145 L"JSON.stringify(__calc_results_total()));",
87 &json)); 146 &json));
88 147
89 std::map<std::string, std::string> results; 148 std::map<std::string, std::string> results;
90 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results)); 149 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results));
91 150
92 ASSERT_TRUE(results.find("mean") != results.end()); 151 ASSERT_TRUE(results.find("mean") != results.end());
93 ASSERT_TRUE(results.find("sigma") != results.end()); 152 ASSERT_TRUE(results.find("sigma") != results.end());
94 ASSERT_TRUE(results.find("gestures") != results.end()); 153 ASSERT_TRUE(results.find("gestures") != results.end());
95 ASSERT_TRUE(results.find("means") != results.end()); 154 ASSERT_TRUE(results.find("means") != results.end());
96 ASSERT_TRUE(results.find("sigmas") != results.end()); 155 ASSERT_TRUE(results.find("sigmas") != results.end());
97 156
98 std::string trace_name = "fps" + suffix; 157 std::string trace_name = "fps";
nduca 2011/10/19 19:25:49 can't you do suffix = (GetParam().GetFlags() & kRe
99 printf("GESTURES %s: %s= [%s] [%s] [%s]\n", name.c_str(), 158 printf("GESTURES %s: %s= [%s] [%s] [%s]\n", name.c_str(),
100 trace_name.c_str(), 159 trace_name.c_str(),
101 results["gestures"].c_str(), 160 results["gestures"].c_str(),
102 results["means"].c_str(), 161 results["means"].c_str(),
103 results["sigmas"].c_str()); 162 results["sigmas"].c_str());
104 163
105 std::string mean_and_error = results["mean"] + "," + results["sigma"]; 164 std::string mean_and_error = results["mean"] + "," + results["sigma"];
106 PrintResultMeanAndError(name, "", trace_name, mean_and_error, 165 PrintResultMeanAndError(name, "", trace_name, mean_and_error,
107 "frames-per-second", true); 166 "frames-per-second", true);
108 } 167 }
109 }; 168 };
110 169
111 class FrameRateTest_Reference : public FrameRateTest { 170 FrameRateTestVariant kTestVariant_Plain(0);
112 public: 171 FrameRateTestVariant kTestVariant_Comp(kMakeBodyComposited);
113 void SetUp() { 172 FrameRateTestVariant kTestVariant_Reference(kReference);
114 UseReferenceBuild(); 173 FrameRateTestVariant kTestVariant_Comp_Reference(kMakeBodyComposited
115 FrameRateTest::SetUp(); 174 | kReference);
116 } 175 FrameRateTestVariant kTestVariant_NoVsync(kDisableVsync);
117 }; 176 FrameRateTestVariant kTestVariant_NoGpu(kDisableGpu);
118 177 FrameRateTestVariant kTestVariant_NoVsync_Reference(kDisableVsync
119 #define FRAME_RATE_TEST(content) \ 178 | kReference);
120 TEST_F(FrameRateTest, content) { \
121 RunTest(#content, "", false); \
122 } \
123 TEST_F(FrameRateTest_Reference, content) { \
124 RunTest(#content, "_ref", false); \
125 }
126
127 179
128 // Tests that trigger compositing with a -webkit-translateZ(0) 180 // Tests that trigger compositing with a -webkit-translateZ(0)
129 #define FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(content) \ 181 #define FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(content) \
130 TEST_F(FrameRateTest, content) { \ 182 TEST_P(FrameRateTest, content) { \
131 RunTest(#content, "", false); \ 183 RunTest(#content); \
132 } \
133 TEST_F(FrameRateTest, content ## _comp) { \
134 RunTest(#content, "_comp", true); \
135 } \
136 TEST_F(FrameRateTest_Reference, content) { \
137 RunTest(#content, "_ref", false); \
138 } \
139 TEST_F(FrameRateTest_Reference, content ## _comp) { \
140 RunTest(#content, "_comp_ref", true); \
141 } 184 }
142 185
143 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(blank); 186 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(blank);
144 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(googleblog); 187 FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(googleblog);
145 188
189 INSTANTIATE_TEST_CASE_P(, FrameRateTest, ::testing::Values(
190 kTestVariant_Plain,
191 kTestVariant_Comp));
192 INSTANTIATE_TEST_CASE_P(Reference, FrameRateTest, ::testing::Values(
193 kTestVariant_Reference,
194 kTestVariant_Comp_Reference));
195
196 // Must use a different class name to avoid test instantiation conflicts
197 // with FrameRateTest (used above). An alias is good enough.
198 typedef FrameRateTest FrameRateCanvasTest;
199
200 #define FRAME_RATE_TEST_ANIMATED_2D_CANVAS(content) \
201 TEST_P(FrameRateCanvasTest, content) { \
202 RunTest(#content); \
203 } \
204
205 INSTANTIATE_TEST_CASE_P(, FrameRateCanvasTest, ::testing::Values(
206 kTestVariant_Plain,
207 kTestVariant_NoVsync,
208 kTestVariant_NoGpu));
209 INSTANTIATE_TEST_CASE_P(Reference, FrameRateCanvasTest, ::testing::Values(
210 kTestVariant_Reference,
211 kTestVariant_NoVsync_Reference));
212
146 } // namespace 213 } // namespace
OLDNEW
« no previous file with comments | « chrome/test/data/perf/frame_rate/head_animation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698