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_path.h" | 6 #include "base/file_path.h" |
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_util.h" | 9 #include "base/string_util.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 PathService::Get(chrome::DIR_TEST_DATA, &test_dir); | 58 PathService::Get(chrome::DIR_TEST_DATA, &test_dir); |
59 return test_dir.AppendASCII("dromaeo"); | 59 return test_dir.AppendASCII("dromaeo"); |
60 } | 60 } |
61 | 61 |
62 bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) { | 62 bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) { |
63 return WaitUntilCookieValue(tab, test_url, "__done", | 63 return WaitUntilCookieValue(tab, test_url, "__done", |
64 TestTimeouts::huge_test_timeout_ms(), "1"); | 64 TestTimeouts::huge_test_timeout_ms(), "1"); |
65 } | 65 } |
66 | 66 |
67 bool GetScore(TabProxy* tab, std::string* score) { | 67 bool GetScore(TabProxy* tab, std::string* score) { |
68 std::wstring score_wide; | 68 string16 score16; |
69 bool succeeded = tab->ExecuteAndExtractString(L"", | 69 bool succeeded = tab->ExecuteAndExtractString(string16(), |
70 L"window.domAutomationController.send(automation.GetScore());", | 70 ASCIIToUTF16("window.domAutomationController.send(" |
71 &score_wide); | 71 "automation.GetScore());"), |
| 72 &score16); |
72 | 73 |
73 // Note that we don't use ASSERT_TRUE here (and in some other places) as it | 74 // Note that we don't use ASSERT_TRUE here (and in some other places) as it |
74 // doesn't work inside a function with a return type other than void. | 75 // doesn't work inside a function with a return type other than void. |
75 EXPECT_TRUE(succeeded); | 76 EXPECT_TRUE(succeeded); |
76 if (!succeeded) | 77 if (!succeeded) |
77 return false; | 78 return false; |
78 | 79 |
79 score->assign(WideToUTF8(score_wide)); | 80 score->assign(UTF16ToUTF8(score16)); |
80 return true; | 81 return true; |
81 } | 82 } |
82 | 83 |
83 bool GetResults(TabProxy* tab, ResultsMap* results) { | 84 bool GetResults(TabProxy* tab, ResultsMap* results) { |
84 std::wstring json_wide; | 85 string16 json16; |
85 bool succeeded = tab->ExecuteAndExtractString(L"", | 86 bool succeeded = tab->ExecuteAndExtractString(string16(), |
86 L"window.domAutomationController.send(" | 87 ASCIIToUTF16("window.domAutomationController.send(" |
87 L" JSON.stringify(automation.GetResults()));", | 88 "JSON.stringify(automation.GetResults()));"), |
88 &json_wide); | 89 &json16); |
89 | 90 |
90 EXPECT_TRUE(succeeded); | 91 EXPECT_TRUE(succeeded); |
91 if (!succeeded) | 92 if (!succeeded) |
92 return false; | 93 return false; |
93 | 94 |
94 std::string json = WideToUTF8(json_wide); | 95 std::string json = UTF16ToUTF8(json16); |
95 return JsonDictionaryToMap(json, results); | 96 return JsonDictionaryToMap(json, results); |
96 } | 97 } |
97 | 98 |
98 void PrintResults(TabProxy* tab) { | 99 void PrintResults(TabProxy* tab) { |
99 std::string score; | 100 std::string score; |
100 ASSERT_TRUE(GetScore(tab, &score)); | 101 ASSERT_TRUE(GetScore(tab, &score)); |
101 | 102 |
102 ResultsMap results; | 103 ResultsMap results; |
103 ASSERT_TRUE(GetResults(tab, &results)); | 104 ASSERT_TRUE(GetResults(tab, &results)); |
104 | 105 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 169 |
169 TEST_F(DromaeoReferenceTest, JSLibPerf) { | 170 TEST_F(DromaeoReferenceTest, JSLibPerf) { |
170 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunDromaeo)) | 171 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunDromaeo)) |
171 return; | 172 return; |
172 | 173 |
173 RunTest(FILE_PATH_LITERAL("jslib")); | 174 RunTest(FILE_PATH_LITERAL("jslib")); |
174 } | 175 } |
175 | 176 |
176 | 177 |
177 } // namespace | 178 } // namespace |
OLD | NEW |