Chromium Code Reviews| Index: content/public/test/content_browser_test_utils.cc |
| diff --git a/content/public/test/content_browser_test_utils.cc b/content/public/test/content_browser_test_utils.cc |
| index daa8e09267aec581b1ada59ffba88c66473c0475..93edd9804bcadd382882a449365b7aa9749ea16a 100644 |
| --- a/content/public/test/content_browser_test_utils.cc |
| +++ b/content/public/test/content_browser_test_utils.cc |
| @@ -8,6 +8,8 @@ |
| #include "base/files/file_path.h" |
| #include "base/path_service.h" |
| #include "base/run_loop.h" |
| +#include "base/strings/pattern.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "content/public/browser/navigation_controller.h" |
| #include "content/public/browser/notification_source.h" |
| #include "content/public/browser/web_contents.h" |
| @@ -127,5 +129,33 @@ void ShellAddedObserver::ShellCreated(Shell* shell) { |
| runner_->QuitClosure().Run(); |
| } |
| +ConsoleObserverDelegate::ConsoleObserverDelegate(WebContents* web_contents, |
| + const std::string& filter) |
| + : web_contents_(web_contents), |
| + filter_(filter), |
| + message_(""), |
|
Charlie Reis
2016/05/24 22:54:16
nit: I think this is unnecessary, right?
meacer
2016/05/31 23:57:54
Copypasta :)
|
| + message_loop_runner_(new MessageLoopRunner) {} |
| + |
| +ConsoleObserverDelegate::~ConsoleObserverDelegate() {} |
| + |
| +void ConsoleObserverDelegate::Wait() { |
| + message_loop_runner_->Run(); |
| +} |
| + |
| +bool ConsoleObserverDelegate::AddMessageToConsole( |
| + WebContents* source, |
| + int32_t level, |
| + const base::string16& message, |
| + int32_t line_no, |
| + const base::string16& source_id) { |
| + DCHECK(source == web_contents_); |
| + |
| + std::string ascii_message = base::UTF16ToASCII(message); |
| + if (base::MatchPattern(ascii_message, filter_)) { |
| + message_ = ascii_message; |
| + message_loop_runner_->Quit(); |
| + } |
| + return false; |
| +} |
| } // namespace content |