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

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 2441543004: Refactor BrowserActivationWaiter as test support and move PopupBlockerBrowserTest to interactive_ui… (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/ui_test_utils.cc
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index 326f443216ccf5be919feaec0295c59f1afc7b50..5c994f273b6988e5171f840ee372ed43fa7302ff 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -540,4 +540,32 @@ void WaitForHistoryToLoad(history::HistoryService* history_service) {
}
}
+BrowserActivationWaiter::BrowserActivationWaiter(Browser* browser)
+ : browser_(browser), observed_(false) {
+ if (chrome::FindLastActive() == browser_) {
+ observed_ = true;
+ return;
+ }
+ BrowserList::AddObserver(this);
+}
+
+BrowserActivationWaiter::~BrowserActivationWaiter() {}
+
+void BrowserActivationWaiter::WaitForActivation() {
+ if (observed_)
+ return;
+ message_loop_runner_ = new content::MessageLoopRunner;
+ message_loop_runner_->Run();
+}
+
+void BrowserActivationWaiter::OnBrowserSetLastActive(Browser* browser) {
+ if (browser != browser_)
+ return;
+
+ observed_ = true;
+ BrowserList::RemoveObserver(this);
+ if (message_loop_runner_.get() && message_loop_runner_->loop_running())
+ message_loop_runner_->Quit();
+}
+
} // namespace ui_test_utils
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698