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

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

Issue 7038052: Add initial framework for performance tests that measure frame rate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <map>
6
7 #include "base/file_util.h"
8 #include "base/path_service.h"
9 #include "base/string_number_conversions.h"
10 #include "base/test/test_timeouts.h"
11 #include "base/utf_string_conversions.h"
12 #include "chrome/common/chrome_paths.h"
13 #include "chrome/test/automation/tab_proxy.h"
14 #include "chrome/test/ui/javascript_test_util.h"
15 #include "chrome/test/ui/ui_perf_test.h"
16 #include "net/base/net_util.h"
17
18 namespace {
19
20 class FrameRateTest : public UIPerfTest {
21 public:
22 FrameRateTest() {
23 show_window_ = true;
24 dom_automation_enabled_ = true;
25 }
26
27 virtual FilePath GetDataPath(const std::string& name) {
28 // Make sure the test data is checked out
brettw 2011/05/24 16:39:40 Ah HA! I found a comment missing a period.
29 FilePath test_path;
30 PathService::Get(chrome::DIR_TEST_DATA, &test_path);
31 test_path = test_path.Append(FILE_PATH_LITERAL("perf"));
32 test_path = test_path.Append(FILE_PATH_LITERAL("frame_rate"));
33 test_path = test_path.AppendASCII(name);
34 return test_path;
35 }
36
37 void RunTest(const std::string& name, const std::string& suffix) {
38 FilePath test_path = GetDataPath(name);
39 ASSERT_TRUE(file_util::DirectoryExists(test_path))
40 << "Missing test directory: " << test_path.value();
41
42 test_path = test_path.Append(FILE_PATH_LITERAL("test.html"));
43
44 scoped_refptr<TabProxy> tab(GetActiveTab());
45 ASSERT_TRUE(tab.get());
46
47 ASSERT_EQ(
48 AUTOMATION_MSG_NAVIGATION_SUCCESS,
brettw 2011/05/24 16:39:40 Why not put this on the previous line and then hav
49 tab->NavigateToURL(net::FilePathToFileURL(test_path)));
50
51 // Start the test.
52 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start();")));
53
54 // Block until the test completes.
55 ASSERT_TRUE(WaitUntilJavaScriptCondition(
56 tab, L"", L"window.domAutomationController.send(!__running);",
cmp 2011/05/21 02:22:19 Our perf tests have been flaky in domAutomationCon
57 TestTimeouts::huge_test_timeout_ms()));
58
59 // Read out the results.
60 std::wstring json;
61 ASSERT_TRUE(tab->ExecuteAndExtractString(
62 L"",
63 L"window.domAutomationController.send("
64 L"JSON.stringify(__calc_results()));",
65 &json));
66
67 std::map<std::string, std::string> results;
68 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results));
69
70 ASSERT_TRUE(results.find("mean") != results.end());
71 ASSERT_TRUE(results.find("sigma") != results.end());
72
73 std::string mean_and_error = results["mean"] + "," + results["sigma"];
74 PrintResultMeanAndError("fps" + suffix, "", "", mean_and_error,
75 "frames-per-second", true);
cmp 2011/05/21 02:22:19 I would not bother with setting important to true
76 }
77 };
78
79 class FrameRateTest_Reference : public FrameRateTest {
80 public:
81 // Override the browser directory that is used by UITest::SetUp to cause it
82 // to use the reference build instead.
83 void SetUp() {
84 FilePath dir;
85 PathService::Get(chrome::DIR_TEST_TOOLS, &dir);
86 dir = dir.AppendASCII("reference_build");
87 #if defined(OS_WIN)
88 dir = dir.AppendASCII("chrome");
89 #elif defined(OS_LINUX)
90 dir = dir.AppendASCII("chrome_linux");
91 #elif defined(OS_MACOSX)
92 dir = dir.AppendASCII("chrome_mac");
93 #endif
94 browser_directory_ = dir;
95 FrameRateTest::SetUp();
96 }
97 };
98
99 TEST_F(FrameRateTest, Blank) {
100 RunTest("blank", "");
101 }
102
103 // TODO(darin): Need to update the reference build to a version that supports
104 // the webkitRequestAnimationFrame API.
cmp 2011/05/21 02:22:19 We also need to update the reference build to pick
105 #if 0
106 TEST_F(FrameRateTest_Reference, Blank) {
107 RunTest("blank", "_ref");
108 }
109 #endif
110
111 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698