Chromium Code Reviews| Index: chrome/browser/ui/webui/web_ui_browsertest.cc |
| diff --git a/chrome/browser/ui/webui/web_ui_browsertest.cc b/chrome/browser/ui/webui/web_ui_browsertest.cc |
| index 9ae134fa44e323ad8c6da57dc2beda7e92d1b0fc..3504a35edb87ea1699c1eb1b0f4fba6396d88ce3 100644 |
| --- a/chrome/browser/ui/webui/web_ui_browsertest.cc |
| +++ b/chrome/browser/ui/webui/web_ui_browsertest.cc |
| @@ -45,7 +45,10 @@ using content::WebUIMessageHandler; |
| namespace { |
| -const FilePath::CharType kMockJS[] = FILE_PATH_LITERAL("mock4js.js"); |
| +const FilePath::CharType kA11yAuditLibraryJSPath[] = FILE_PATH_LITERAL( |
| + "third_party/accessibility-developer-tools/gen/axs_testing.js"); |
| +const FilePath::CharType kMockJSPath[] = |
| + FILE_PATH_LITERAL("chrome/third_party/mock4js/mock4js.js"); |
| const FilePath::CharType kWebUILibraryJS[] = FILE_PATH_LITERAL("test_api.js"); |
| const FilePath::CharType kWebUITestFolder[] = FILE_PATH_LITERAL("webui"); |
| base::LazyInstance<std::vector<std::string> > error_messages_ = |
| @@ -74,6 +77,17 @@ void WebUIBrowserTest::AddLibrary(const FilePath& library_path) { |
| user_libraries_.push_back(library_path); |
| } |
| +// Add a helper JS library to the given WebUIBrowserTest from a path relative to |
| +// base::DIR_SOURCE_ROOT. |
| +// static |
| +void AddLibraryFromSourceRoot(WebUIBrowserTest* browser_test, |
| + const FilePath& path) { |
| + FilePath filePath; |
| + ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &filePath)); |
|
Paweł Hajdan Jr.
2013/01/07 17:33:51
nit: I'd prefer to make this helper return bool, h
aboxhall
2013/01/07 18:20:04
I think I'll leave it as-is for now; this function
|
| + filePath = filePath.Append(path); |
| + browser_test->AddLibrary(filePath); |
| +} |
| + |
| bool WebUIBrowserTest::RunJavascriptFunction(const std::string& function_name) { |
| ConstValueVector empty_args; |
| return RunJavascriptFunction(function_name, empty_args); |
| @@ -329,13 +343,8 @@ void WebUIBrowserTest::SetUpInProcessBrowserTestFixture() { |
| ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| resources_pack_path, ui::SCALE_FACTOR_NONE); |
| - FilePath mockPath; |
| - ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &mockPath)); |
| - mockPath = mockPath.AppendASCII("chrome"); |
| - mockPath = mockPath.AppendASCII("third_party"); |
| - mockPath = mockPath.AppendASCII("mock4js"); |
| - mockPath = mockPath.Append(kMockJS); |
| - AddLibrary(mockPath); |
| + AddLibraryFromSourceRoot(this, FilePath(kA11yAuditLibraryJSPath)); |
| + AddLibraryFromSourceRoot(this, FilePath(kMockJSPath)); |
| AddLibrary(FilePath(kWebUILibraryJS)); |
| } |