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

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

Issue 7068005: Revert 86568 - 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
« no previous file with comments | « chrome/test/data/perf/frame_rate/head.js ('k') | chrome/test/ui/javascript_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
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(AUTOMATION_MSG_NAVIGATION_SUCCESS,
48 tab->NavigateToURL(net::FilePathToFileURL(test_path)));
49
50 // Start the test.
51 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start();")));
52
53 // Block until the test completes.
54 ASSERT_TRUE(WaitUntilJavaScriptCondition(
55 tab, L"", L"window.domAutomationController.send(!__running);",
56 TestTimeouts::huge_test_timeout_ms()));
57
58 // Read out the results.
59 std::wstring json;
60 ASSERT_TRUE(tab->ExecuteAndExtractString(
61 L"",
62 L"window.domAutomationController.send("
63 L"JSON.stringify(__calc_results()));",
64 &json));
65
66 std::map<std::string, std::string> results;
67 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results));
68
69 ASSERT_TRUE(results.find("mean") != results.end());
70 ASSERT_TRUE(results.find("sigma") != results.end());
71
72 std::string mean_and_error = results["mean"] + "," + results["sigma"];
73 PrintResultMeanAndError("fps" + suffix, "", "", mean_and_error,
74 "frames-per-second", false);
75 }
76 };
77
78 class FrameRateTest_Reference : public FrameRateTest {
79 public:
80 // Override the browser directory that is used by UITest::SetUp to cause it
81 // to use the reference build instead.
82 void SetUp() {
83 FilePath dir;
84 PathService::Get(chrome::DIR_TEST_TOOLS, &dir);
85 dir = dir.AppendASCII("reference_build");
86 #if defined(OS_WIN)
87 dir = dir.AppendASCII("chrome");
88 #elif defined(OS_LINUX)
89 dir = dir.AppendASCII("chrome_linux");
90 #elif defined(OS_MACOSX)
91 dir = dir.AppendASCII("chrome_mac");
92 #endif
93 browser_directory_ = dir;
94 FrameRateTest::SetUp();
95 }
96 };
97
98 TEST_F(FrameRateTest, Blank) {
99 RunTest("blank", "");
100 }
101
102 // TODO(darin): Need to update the reference build to a version that supports
103 // the webkitRequestAnimationFrame API.
104 #if 0
105 TEST_F(FrameRateTest_Reference, Blank) {
106 RunTest("blank", "_ref");
107 }
108 #endif
109
110 } // namespace
OLDNEW
« no previous file with comments | « chrome/test/data/perf/frame_rate/head.js ('k') | chrome/test/ui/javascript_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698