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

Unified Diff: chrome/browser/ui/blocked_content/popup_blocker_browsertest.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 | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
diff --git a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
index 82d529dafa174913b6acdd93217dcf7e56ced83b..108fb3be5912c508aea1ae0e550711a8e69c16ba 100644
--- a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
+++ b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
@@ -20,7 +20,6 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -104,38 +103,6 @@ class CloseObserver : public content::WebContentsObserver {
DISALLOW_COPY_AND_ASSIGN(CloseObserver);
};
-class BrowserActivationObserver : public chrome::BrowserListObserver {
- public:
- BrowserActivationObserver()
- : browser_(chrome::FindLastActive()), observed_(false) {
- BrowserList::AddObserver(this);
- }
- ~BrowserActivationObserver() override { BrowserList::RemoveObserver(this); }
-
- void WaitForActivation() {
- if (observed_)
- return;
- message_loop_runner_ = new content::MessageLoopRunner;
- message_loop_runner_->Run();
- }
-
- private:
- // chrome::BrowserListObserver:
- void OnBrowserSetLastActive(Browser* browser) override {
- if (browser == browser_)
- return;
- observed_ = true;
- if (message_loop_runner_.get() && message_loop_runner_->loop_running())
- message_loop_runner_->Quit();
- }
-
- Browser* browser_;
- bool observed_;
- scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
-
- DISALLOW_COPY_AND_ASSIGN(BrowserActivationObserver);
-};
-
class PopupBlockerBrowserTest : public InProcessBrowserTest {
public:
PopupBlockerBrowserTest() {}
@@ -550,11 +517,9 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ModalPopUnder) {
app_modal::JavaScriptAppModalDialog* js_dialog =
static_cast<app_modal::JavaScriptAppModalDialog*>(dialog);
- BrowserActivationObserver activation_observer;
+ ui_test_utils::BrowserActivationWaiter waiter(popup_browser);
js_dialog->native_dialog()->AcceptAppModalDialog();
-
- if (popup_browser != chrome::FindLastActive())
- activation_observer.WaitForActivation();
+ waiter.WaitForActivation();
ASSERT_EQ(popup_browser, chrome::FindLastActive());
}
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698