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

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

Issue 53064: - Launch DOM checker in the subdirectory 'dom_checker/', as specified by the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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/dom_checker/expected_failures-http.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/json_value_serializer.h" 13 #include "chrome/common/json_value_serializer.h"
14 #include "chrome/test/automation/tab_proxy.h" 14 #include "chrome/test/automation/tab_proxy.h"
15 #include "chrome/test/ui/ui_test.h" 15 #include "chrome/test/ui/ui_test.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "net/base/net_util.h" 17 #include "net/base/net_util.h"
18 18
19 namespace { 19 namespace {
20 20
21 static const FilePath::CharType kBaseUrl[] = 21 static const FilePath::CharType kBaseUrl[] =
22 FILE_PATH_LITERAL("http://localhost:8000/"); 22 FILE_PATH_LITERAL("http://localhost:8000/");
23 23
24 static const FilePath::CharType kTestDirectory[] =
25 FILE_PATH_LITERAL("dom_checker/");
26
24 static const FilePath::CharType kStartFile[] = 27 static const FilePath::CharType kStartFile[] =
25 FILE_PATH_LITERAL("dom_checker.html"); 28 FILE_PATH_LITERAL("dom_checker.html");
26 29
27 const wchar_t kRunDomCheckerTest[] = L"run-dom-checker-test"; 30 const wchar_t kRunDomCheckerTest[] = L"run-dom-checker-test";
28 31
29 class DomCheckerTest : public UITest { 32 class DomCheckerTest : public UITest {
30 public: 33 public:
31 typedef std::list<std::string> ResultsList; 34 typedef std::list<std::string> ResultsList;
32 typedef std::set<std::string> ResultsSet; 35 typedef std::set<std::string> ResultsSet;
33 36
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 test_count); 140 test_count);
138 } 141 }
139 142
140 bool GetTestsFailed(TabProxy* tab, ResultsSet* tests_failed) { 143 bool GetTestsFailed(TabProxy* tab, ResultsSet* tests_failed) {
141 std::wstring json_wide; 144 std::wstring json_wide;
142 bool succeeded = tab->ExecuteAndExtractString(L"", 145 bool succeeded = tab->ExecuteAndExtractString(L"",
143 L"window.domAutomationController.send(" 146 L"window.domAutomationController.send("
144 L" JSON.stringify(automation.GetFailures()));", 147 L" JSON.stringify(automation.GetFailures()));",
145 &json_wide); 148 &json_wide);
146 149
150 // Note that we don't use ASSERT_TRUE here (and in some other places) as it
151 // doesn't work inside a function with a return type other than void.
147 EXPECT_TRUE(succeeded); 152 EXPECT_TRUE(succeeded);
148 if (!succeeded) 153 if (!succeeded)
149 return false; 154 return false;
150 155
151 std::string json = WideToUTF8(json_wide); 156 std::string json = WideToUTF8(json_wide);
152 JSONStringValueSerializer deserializer(json); 157 JSONStringValueSerializer deserializer(json);
153 scoped_ptr<Value> value(deserializer.Deserialize(NULL)); 158 scoped_ptr<Value> value(deserializer.Deserialize(NULL));
154 159
155 EXPECT_TRUE(value.get()); 160 EXPECT_TRUE(value.get());
156 if (!value.get()) 161 if (!value.get())
(...skipping 19 matching lines...) Expand all
176 } 181 }
177 } 182 }
178 183
179 return true; 184 return true;
180 } 185 }
181 186
182 void RunDomChecker(bool use_http, int* test_count, ResultsSet* tests_failed) { 187 void RunDomChecker(bool use_http, int* test_count, ResultsSet* tests_failed) {
183 GURL test_url; 188 GURL test_url;
184 FilePath::StringType start_file(kStartFile); 189 FilePath::StringType start_file(kStartFile);
185 if (use_http) { 190 if (use_http) {
191 FilePath::StringType test_directory(kTestDirectory);
186 FilePath::StringType url_string(kBaseUrl); 192 FilePath::StringType url_string(kBaseUrl);
193 url_string.append(test_directory);
187 url_string.append(start_file); 194 url_string.append(start_file);
188 test_url = GURL(url_string); 195 test_url = GURL(url_string);
189 } else { 196 } else {
190 FilePath test_path = GetDomCheckerDir(); 197 FilePath test_path = GetDomCheckerDir();
191 test_path = test_path.Append(start_file); 198 test_path = test_path.Append(start_file);
192 test_url = net::FilePathToFileURL(test_path); 199 test_url = net::FilePathToFileURL(test_path);
193 } 200 }
194 201
195 scoped_ptr<TabProxy> tab(GetActiveTab()); 202 scoped_ptr<TabProxy> tab(GetActiveTab());
196 tab->NavigateToURL(test_url); 203 tab->NavigateToURL(test_url);
197 204
198 // Wait for the test to finish. 205 // Wait for the test to finish.
199 ASSERT_TRUE(WaitUntilTestCompletes(tab.get())); 206 ASSERT_TRUE(WaitUntilTestCompletes(tab.get()));
200 207
201 // Get the test results. 208 // Get the test results.
202 ASSERT_TRUE(GetTestCount(tab.get(), test_count)); 209 ASSERT_TRUE(GetTestCount(tab.get(), test_count));
203 ASSERT_TRUE(GetTestsFailed(tab.get(), tests_failed)); 210 ASSERT_TRUE(GetTestsFailed(tab.get(), tests_failed));
204 ASSERT_GT(*test_count, 0); 211 ASSERT_GT(*test_count, 0);
205 } 212 }
206 213
207 DISALLOW_COPY_AND_ASSIGN(DomCheckerTest); 214 DISALLOW_COPY_AND_ASSIGN(DomCheckerTest);
208 }; 215 };
209 216
210 } // namespace 217 } // namespace
211 218
212 TEST_F(DomCheckerTest, File) { 219 TEST_F(DomCheckerTest, DISABLED_File) {
213 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunDomCheckerTest)) 220 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunDomCheckerTest))
214 return; 221 return;
215 222
216 ResultsList new_passes, new_failures; 223 ResultsList new_passes, new_failures;
217 RunTest(false, &new_passes, &new_failures); 224 RunTest(false, &new_passes, &new_failures);
218 PrintResults(new_passes, new_failures); 225 PrintResults(new_passes, new_failures);
219 } 226 }
220 227
221 TEST_F(DomCheckerTest, Http) { 228 TEST_F(DomCheckerTest, DISABLED_Http) {
222 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunDomCheckerTest)) 229 if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunDomCheckerTest))
223 return; 230 return;
224 231
225 ResultsList new_passes, new_failures; 232 ResultsList new_passes, new_failures;
226 RunTest(true, &new_passes, &new_failures); 233 RunTest(true, &new_passes, &new_failures);
227 PrintResults(new_passes, new_failures); 234 PrintResults(new_passes, new_failures);
228 } 235 }
OLDNEW
« no previous file with comments | « chrome/test/data/dom_checker/expected_failures-http.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698