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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 PathService::Get(chrome::DIR_TEST_DATA, &test_dir); | 59 PathService::Get(chrome::DIR_TEST_DATA, &test_dir); |
60 return test_dir.AppendASCII("sunspider"); | 60 return test_dir.AppendASCII("sunspider"); |
61 } | 61 } |
62 | 62 |
63 bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) { | 63 bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) { |
64 return WaitUntilCookieValue(tab, test_url, "__done", | 64 return WaitUntilCookieValue(tab, test_url, "__done", |
65 TestTimeouts::huge_test_timeout_ms(), "1"); | 65 TestTimeouts::huge_test_timeout_ms(), "1"); |
66 } | 66 } |
67 | 67 |
68 bool GetTotal(TabProxy* tab, std::string* total) { | 68 bool GetTotal(TabProxy* tab, std::string* total) { |
69 std::wstring total_wide; | 69 string16 total16; |
70 bool succeeded = tab->ExecuteAndExtractString(L"", | 70 bool succeeded = tab->ExecuteAndExtractString(string16(), |
71 L"window.domAutomationController.send(automation.GetTotal());", | 71 ASCIIToUTF16("window.domAutomationController.send(" |
72 &total_wide); | 72 "automation.GetTotal());"), |
| 73 &total16); |
73 | 74 |
74 // Note that we don't use ASSERT_TRUE here (and in some other places) as it | 75 // Note that we don't use ASSERT_TRUE here (and in some other places) as it |
75 // doesn't work inside a function with a return type other than void. | 76 // doesn't work inside a function with a return type other than void. |
76 EXPECT_TRUE(succeeded); | 77 EXPECT_TRUE(succeeded); |
77 if (!succeeded) | 78 if (!succeeded) |
78 return false; | 79 return false; |
79 | 80 |
80 total->assign(WideToUTF8(total_wide)); | 81 total->assign(UTF16ToUTF8(total16)); |
81 return true; | 82 return true; |
82 } | 83 } |
83 | 84 |
84 bool GetResults(TabProxy* tab, ResultsMap* results) { | 85 bool GetResults(TabProxy* tab, ResultsMap* results) { |
85 std::wstring json_wide; | 86 string16 json16; |
86 bool succeeded = tab->ExecuteAndExtractString(L"", | 87 bool succeeded = tab->ExecuteAndExtractString(string16(), |
87 L"window.domAutomationController.send(" | 88 ASCIIToUTF16("window.domAutomationController.send(" |
88 L" JSON.stringify(automation.GetResults()));", | 89 "JSON.stringify(automation.GetResults()));"), |
89 &json_wide); | 90 &json16); |
90 | 91 |
91 EXPECT_TRUE(succeeded); | 92 EXPECT_TRUE(succeeded); |
92 if (!succeeded) | 93 if (!succeeded) |
93 return false; | 94 return false; |
94 | 95 |
95 std::string json = WideToUTF8(json_wide); | 96 std::string json = UTF16ToUTF8(json16); |
96 return JsonDictionaryToMap(json, results); | 97 return JsonDictionaryToMap(json, results); |
97 } | 98 } |
98 | 99 |
99 void PrintResults(TabProxy* tab) { | 100 void PrintResults(TabProxy* tab) { |
100 std::string total; | 101 std::string total; |
101 ASSERT_TRUE(GetTotal(tab, &total)); | 102 ASSERT_TRUE(GetTotal(tab, &total)); |
102 | 103 |
103 ResultsMap results; | 104 ResultsMap results; |
104 ASSERT_TRUE(GetResults(tab, &results)); | 105 ASSERT_TRUE(GetResults(tab, &results)); |
105 | 106 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 148 } |
148 | 149 |
149 TEST_F(SunSpiderReferenceTest, Perf) { | 150 TEST_F(SunSpiderReferenceTest, Perf) { |
150 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunSunSpider)) | 151 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunSunSpider)) |
151 return; | 152 return; |
152 | 153 |
153 RunTest(); | 154 RunTest(); |
154 } | 155 } |
155 | 156 |
156 } // namespace | 157 } // namespace |
OLD | NEW |