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

Side by Side Diff: chrome/browser/ui/webui/web_ui_browsertest.cc

Issue 8333013: Allow generator javascript test files to go anywhere in the source tree (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Nits. Created 9 years, 2 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/browser/ui/webui/web_ui_browsertest.h ('k') | chrome/chrome_tests.gypi » ('j') | 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) 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 #include "chrome/browser/ui/webui/web_ui_browsertest.h" 4 #include "chrome/browser/ui/webui/web_ui_browsertest.h"
5 5
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 logging::SetLogMessageHandler(NULL); 244 logging::SetLogMessageHandler(NULL);
245 } 245 }
246 246
247 void WebUIBrowserTest::SetUpInProcessBrowserTestFixture() { 247 void WebUIBrowserTest::SetUpInProcessBrowserTestFixture() {
248 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); 248 InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
249 TestChromeWebUIFactory::AddFactoryOverride(GURL(kDummyURL).host(), 249 TestChromeWebUIFactory::AddFactoryOverride(GURL(kDummyURL).host(),
250 mock_provider_.Pointer()); 250 mock_provider_.Pointer());
251 251
252 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_)); 252 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_));
253 test_data_directory_ = test_data_directory_.Append(kWebUITestFolder); 253 test_data_directory_ = test_data_directory_.Append(kWebUITestFolder);
254 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA,
255 &gen_test_data_directory_));
254 256
255 // TODO(dtseng): should this be part of every BrowserTest or just WebUI test. 257 // TODO(dtseng): should this be part of every BrowserTest or just WebUI test.
256 FilePath resources_pack_path; 258 FilePath resources_pack_path;
257 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); 259 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
258 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path); 260 ResourceBundle::AddDataPackToSharedInstance(resources_pack_path);
259 261
260 FilePath mockPath; 262 FilePath mockPath;
261 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &mockPath)); 263 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &mockPath));
262 mockPath = mockPath.AppendASCII("chrome"); 264 mockPath = mockPath.AppendASCII("chrome");
263 mockPath = mockPath.AppendASCII("third_party"); 265 mockPath = mockPath.AppendASCII("third_party");
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 std::vector<FilePath>::iterator user_libraries_iterator; 302 std::vector<FilePath>::iterator user_libraries_iterator;
301 for (user_libraries_iterator = user_libraries_.begin(); 303 for (user_libraries_iterator = user_libraries_.begin();
302 user_libraries_iterator != user_libraries_.end(); 304 user_libraries_iterator != user_libraries_.end();
303 ++user_libraries_iterator) { 305 ++user_libraries_iterator) {
304 std::string library_content; 306 std::string library_content;
305 if (user_libraries_iterator->IsAbsolute()) { 307 if (user_libraries_iterator->IsAbsolute()) {
306 ASSERT_TRUE(file_util::ReadFileToString(*user_libraries_iterator, 308 ASSERT_TRUE(file_util::ReadFileToString(*user_libraries_iterator,
307 &library_content)) 309 &library_content))
308 << user_libraries_iterator->value(); 310 << user_libraries_iterator->value();
309 } else { 311 } else {
310 ASSERT_TRUE(file_util::ReadFileToString( 312 bool ok = file_util::ReadFileToString(
311 test_data_directory_.Append(*user_libraries_iterator), 313 gen_test_data_directory_.Append(*user_libraries_iterator),
312 &library_content)) << user_libraries_iterator->value(); 314 &library_content);
315 if (!ok) {
316 ok = file_util::ReadFileToString(
317 test_data_directory_.Append(*user_libraries_iterator),
318 &library_content);
319 }
320 ASSERT_TRUE(ok) << user_libraries_iterator->value();
313 } 321 }
314 utf8_content.append(library_content); 322 utf8_content.append(library_content);
315 utf8_content.append(";\n"); 323 utf8_content.append(";\n");
316 } 324 }
317 content->append(UTF8ToUTF16(utf8_content)); 325 content->append(UTF8ToUTF16(utf8_content));
318 } 326 }
319 327
320 string16 WebUIBrowserTest::BuildRunTestJSCall( 328 string16 WebUIBrowserTest::BuildRunTestJSCall(
321 bool is_async, 329 bool is_async,
322 const std::string& function_name, 330 const std::string& function_name,
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 // testDone directly and expect pass result. 620 // testDone directly and expect pass result.
613 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { 621 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) {
614 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); 622 ASSERT_TRUE(RunJavascriptAsyncTest("testDone"));
615 } 623 }
616 624
617 // Test that calling testDone during RunJavascriptTest still completes when 625 // Test that calling testDone during RunJavascriptTest still completes when
618 // waiting for async result. 626 // waiting for async result.
619 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { 627 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) {
620 ASSERT_TRUE(RunJavascriptTest("testDone")); 628 ASSERT_TRUE(RunJavascriptTest("testDone"));
621 } 629 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/web_ui_browsertest.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698