Chromium Code Reviews| Index: chrome/test/base/javascript_browser_test.cc |
| diff --git a/chrome/test/base/javascript_browser_test.cc b/chrome/test/base/javascript_browser_test.cc |
| index 022956d460117900ac5cd1793b3c79df0c96a140..411fa5f9408654b45500a53faa3b6f4fd9fecd98 100644 |
| --- a/chrome/test/base/javascript_browser_test.cc |
| +++ b/chrome/test/base/javascript_browser_test.cc |
| @@ -4,12 +4,33 @@ |
| #include "chrome/test/base/javascript_browser_test.h" |
| +#include "base/logging.h" |
| #include "base/path_service.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/common/chrome_paths.h" |
| #include "content/public/browser/web_ui.h" |
| #include "ui/base/resource/resource_bundle.h" |
| +namespace { |
| + |
| +bool g_has_console_errors = false; |
| +bool g_has_console_info = false; |
|
mmenke
2016/06/03 16:05:51
Can we not use globals here, and get rid of set_ha
Dan Beam
2016/06/03 18:58:27
i can move the booleans wherever you'd like, PostT
|
| + |
| +bool LogHandler(int severity, |
| + const char* file, |
| + int line, |
| + size_t message_start, |
| + const std::string& str) { |
| + if (std::string("CONSOLE") == file) { |
| + g_has_console_info = true; |
| + if (severity == logging::LOG_ERROR) |
| + g_has_console_errors = true; |
| + } |
| + return false; |
| +} |
| + |
| +} // namespace |
| + |
| // static |
| const base::FilePath::CharType |
| JavaScriptBrowserTest::kA11yAuditLibraryJSPath[] = |
| @@ -42,6 +63,10 @@ JavaScriptBrowserTest::~JavaScriptBrowserTest() { |
| } |
| void JavaScriptBrowserTest::SetUpOnMainThread() { |
| + InProcessBrowserTest::SetUpOnMainThread(); |
| + |
| + logging::SetLogMessageHandler(&LogHandler); |
| + |
| base::FilePath test_data_directory; |
| ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory)); |
| test_data_directory = test_data_directory.Append(kWebUITestFolder); |
| @@ -61,6 +86,11 @@ void JavaScriptBrowserTest::SetUpOnMainThread() { |
| AddLibrary(base::FilePath(kWebUILibraryJS)); |
| } |
| +void JavaScriptBrowserTest::TearDownOnMainThread() { |
| + logging::SetLogMessageHandler(nullptr); |
| + InProcessBrowserTest::TearDownOnMainThread(); |
| +} |
| + |
| // TODO(dtseng): Make this return bool (success/failure) and remove ASSERt_TRUE |
| // calls. |
| void JavaScriptBrowserTest::BuildJavascriptLibraries( |
| @@ -121,3 +151,19 @@ base::string16 JavaScriptBrowserTest::BuildRunTestJSCall( |
| return content::WebUI::GetJavascriptCall(std::string("runTest"), |
| arguments.get()); |
| } |
| + |
| +bool JavaScriptBrowserTest::has_console_errors() const { |
| + return g_has_console_errors; |
| +} |
| + |
| +void JavaScriptBrowserTest::set_has_console_errors(bool has_console_errors) { |
| + g_has_console_errors = has_console_errors; |
| +} |
| + |
| +bool JavaScriptBrowserTest::has_console_info() const { |
| + return g_has_console_info; |
| +} |
| + |
| +void JavaScriptBrowserTest::set_has_console_info(bool has_console_info) { |
| + g_has_console_info = has_console_info; |
| +} |