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

Side by Side Diff: chrome/test/ui/v8_benchmark_uitest.cc

Issue 6312154: Remove wstring from RVH's run Javascript command.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 PathService::Get(chrome::DIR_TEST_DATA, &test_dir); 60 PathService::Get(chrome::DIR_TEST_DATA, &test_dir);
61 return test_dir.AppendASCII("v8_benchmark"); 61 return test_dir.AppendASCII("v8_benchmark");
62 } 62 }
63 63
64 bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) { 64 bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) {
65 return WaitUntilCookieValue(tab, test_url, "__done", 65 return WaitUntilCookieValue(tab, test_url, "__done",
66 TestTimeouts::huge_test_timeout_ms(), "1"); 66 TestTimeouts::huge_test_timeout_ms(), "1");
67 } 67 }
68 68
69 bool GetScore(TabProxy* tab, std::string* score) { 69 bool GetScore(TabProxy* tab, std::string* score) {
70 std::wstring score_wide; 70 string16 score16;
71 bool succeeded = tab->ExecuteAndExtractString(L"", 71 bool succeeded = tab->ExecuteAndExtractString(string16(),
72 L"window.domAutomationController.send(automation.GetScore());", 72 ASCIIToUTF16("window.domAutomationController.send("
73 &score_wide); 73 "automation.GetScore());"),
74 &score16);
74 75
75 // Note that we don't use ASSERT_TRUE here (and in some other places) as it 76 // Note that we don't use ASSERT_TRUE here (and in some other places) as it
76 // doesn't work inside a function with a return type other than void. 77 // doesn't work inside a function with a return type other than void.
77 EXPECT_TRUE(succeeded); 78 EXPECT_TRUE(succeeded);
78 if (!succeeded) 79 if (!succeeded)
79 return false; 80 return false;
80 81
81 score->assign(WideToUTF8(score_wide)); 82 score->assign(UTF16ToUTF8(score16));
82 return true; 83 return true;
83 } 84 }
84 85
85 bool GetResults(TabProxy* tab, ResultsMap* results) { 86 bool GetResults(TabProxy* tab, ResultsMap* results) {
86 std::wstring json_wide; 87 string16 json16;
87 bool succeeded = tab->ExecuteAndExtractString(L"", 88 bool succeeded = tab->ExecuteAndExtractString(string16(),
88 L"window.domAutomationController.send(" 89 ASCIIToUTF16("window.domAutomationController.send("
89 L" JSON.stringify(automation.GetResults()));", 90 "JSON.stringify(automation.GetResults()));"),
90 &json_wide); 91 &json16);
91 92
92 EXPECT_TRUE(succeeded); 93 EXPECT_TRUE(succeeded);
93 if (!succeeded) 94 if (!succeeded)
94 return false; 95 return false;
95 96
96 std::string json = WideToUTF8(json_wide); 97 std::string json = UTF16ToUTF8(json16);
97 return JsonDictionaryToMap(json, results); 98 return JsonDictionaryToMap(json, results);
98 } 99 }
99 100
100 void PrintResults(TabProxy* tab) { 101 void PrintResults(TabProxy* tab) {
101 std::string score; 102 std::string score;
102 ASSERT_TRUE(GetScore(tab, &score)); 103 ASSERT_TRUE(GetScore(tab, &score));
103 104
104 ResultsMap results; 105 ResultsMap results;
105 ASSERT_TRUE(GetResults(tab, &results)); 106 ASSERT_TRUE(GetResults(tab, &results));
106 107
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 150 }
150 151
151 TEST_F(V8BenchmarkReferenceTest, Perf) { 152 TEST_F(V8BenchmarkReferenceTest, Perf) {
152 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunV8Benchmark)) 153 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunV8Benchmark))
153 return; 154 return;
154 155
155 RunTest(); 156 RunTest();
156 } 157 }
157 158
158 } // namespace 159 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698