summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/panels/test_panel_notification_observer.cc
diff options
context:
space:
mode:
authorjennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-14 00:57:29 +0000
committerjennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-14 00:57:29 +0000
commit5a03f0349795162f76ba2f330e66f32cace8e85a (patch)
tree26f2f0d55844a05b747e1d16cfbd5bcc79f7b0d4 /chrome/browser/ui/panels/test_panel_notification_observer.cc
parentc0c948b50e294ae7c4650aa87a97c0813a68c66b (diff)
downloadchromium_src-5a03f0349795162f76ba2f330e66f32cace8e85a.zip
chromium_src-5a03f0349795162f76ba2f330e66f32cace8e85a.tar.gz
chromium_src-5a03f0349795162f76ba2f330e66f32cace8e85a.tar.bz2
Improve panel tests by properly waiting for expected conditions.
Pulled logic from PanelActiveStateObserver into a base class for reuse. Updated ActivatePanelOrTabbedWindow to apply to browserless panels. Fixed DetachedPanelBrowserTest.DrawAttentionResetOnActivate to actually create detached panels. Added guard in Panel::SetPanelBounds() to check if there is no change. Native layer doesn't always check (anymore). TBR=thakis BUG=140971,145428,145740,147536,147643 TEST=tests adjusted Review URL: https://codereview.chromium.org/10914242 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/panels/test_panel_notification_observer.cc')
-rw-r--r--chrome/browser/ui/panels/test_panel_notification_observer.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/chrome/browser/ui/panels/test_panel_notification_observer.cc b/chrome/browser/ui/panels/test_panel_notification_observer.cc
new file mode 100644
index 0000000..efd6793
--- /dev/null
+++ b/chrome/browser/ui/panels/test_panel_notification_observer.cc
@@ -0,0 +1,44 @@
+// 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_notification_observer.h"
+
+#include "chrome/common/chrome_notification_types.h"
+#include "content/public/browser/notification_source.h"
+#include "content/public/test/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TestPanelNotificationObserver::TestPanelNotificationObserver(
+ int notification,
+ const content::NotificationSource& source)
+ : seen_(false),
+ running_(false) {
+ registrar_.Add(this, notification, source);
+}
+
+TestPanelNotificationObserver::~TestPanelNotificationObserver() {}
+
+void TestPanelNotificationObserver::Wait() {
+ if (seen_ || AtExpectedState())
+ return;
+
+ running_ = true;
+ message_loop_runner_ = new content::MessageLoopRunner;
+ message_loop_runner_->Run();
+ EXPECT_TRUE(seen_);
+}
+
+void TestPanelNotificationObserver::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ if (!running_)
+ return;
+
+ if (AtExpectedState()) {
+ seen_ = true;
+ message_loop_runner_->Quit();
+ running_ = false;
+ }
+}