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

Unified Diff: chrome/browser/ui/panels/test_panel_active_state_observer.cc

Issue 10689082: Fix flaky linux panel tests related to active state checks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove log msg Created 8 years, 5 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/browser/ui/panels/test_panel_active_state_observer.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/test_panel_active_state_observer.cc
diff --git a/chrome/browser/ui/panels/test_panel_active_state_observer.cc b/chrome/browser/ui/panels/test_panel_active_state_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3e53995977395e8e9889fa656cc5b7e344468fcf
--- /dev/null
+++ b/chrome/browser/ui/panels/test_panel_active_state_observer.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/panels/test_panel_active_state_observer.h"
+
+#include "chrome/browser/ui/panels/panel.h"
+#include "chrome/common/chrome_notification_types.h"
+
+PanelActiveStateObserver::PanelActiveStateObserver(
+ Panel* panel,
+ bool expect_active)
+ : panel_(panel),
+ expect_active_(expect_active),
+ seen_(false),
+ running_(false) {
+ registrar_.Add(this, chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS,
+ content::Source<Panel>(panel));
+}
+
+PanelActiveStateObserver::~PanelActiveStateObserver() {}
+
+void PanelActiveStateObserver::Wait() {
+ if (seen_ || AtExpectedState())
+ return;
+
+ running_ = true;
+ message_loop_runner_ = new ui_test_utils::MessageLoopRunner;
+ message_loop_runner_->Run();
+ EXPECT_TRUE(seen_);
+}
+
+bool PanelActiveStateObserver::AtExpectedState() {
+ return panel_->IsActive() == expect_active_;
+}
+
+void PanelActiveStateObserver::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ if (!running_)
+ return;
+
+ if (AtExpectedState()) {
+ seen_ = true;
+ message_loop_runner_->Quit();
+ running_ = false;
+ }
+}
« no previous file with comments | « chrome/browser/ui/panels/test_panel_active_state_observer.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698