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

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

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/BUILD.gn ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/ui_test_utils.h
diff --git a/chrome/test/base/ui_test_utils.h b/chrome/test/base/ui_test_utils.h
index 38ac0db71686916b457c353bb064adc34845b63f..25b537779615ceec062266bcd6615b0bd6b5324e 100644
--- a/chrome/test/base/ui_test_utils.h
+++ b/chrome/test/base/ui_test_utils.h
@@ -14,6 +14,8 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_list_observer.h"
#include "components/history/core/browser/history_service.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
@@ -287,6 +289,31 @@ class HistoryEnumerator {
DISALLOW_COPY_AND_ASSIGN(HistoryEnumerator);
};
+// Use in browser interactive uitests to wait until a browser is set to active.
+// To use create and call WaitForActivation().
+// TODO(warx): check if code base exists the requirement for deactivation sync,
+// this class can be modified to support that.
+class BrowserActivationWaiter : public chrome::BrowserListObserver {
+ public:
+ explicit BrowserActivationWaiter(Browser* browser);
+ ~BrowserActivationWaiter() override;
+
+ // Returns when the |browser_| which is supplied by the constructor becomes
+ // activated. If it is not activated, a message loop is used until the
+ // |browser_| is activated, otherwise this returns immediately.
+ void WaitForActivation();
+
+ private:
+ // chrome::BrowserListObserver override:
+ void OnBrowserSetLastActive(Browser* browser) override;
+
+ Browser* browser_;
+ bool observed_;
+ scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserActivationWaiter);
+};
+
} // namespace ui_test_utils
#endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_
« no previous file with comments | « chrome/test/BUILD.gn ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698