From 99a0e7ea2e8352630e5ef5bc39025b6e853fd767 Mon Sep 17 00:00:00 2001 From: "mmenke@chromium.org" Date: Thu, 3 May 2012 18:40:36 +0000 Subject: Revert 135167 - Simplify WindowedNotificationObserver now that WaitFor() is gone. It broke SafeBrowsingBlockingPageTest.MalwareRedirectInIFrameCanceled. Wouldn't surprise me if the bug is in the test, but don't have time to investigate it now. Sample failure: Note: Google Test filter = SafeBrowsingBlockingPageTest.MalwareRedirectInIFrameCanceled [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from SafeBrowsingBlockingPageTest, where TypeParam = [ RUN ] SafeBrowsingBlockingPageTest.MalwareRedirectInIFrameCanceled [27529:27529:0503/104834:550756638:WARNING:zygote_host_impl_linux.cc(154)] Running without the SUID sandbox! See http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on. chrome/test/base/ui_test_utils.cc:976: Failure Value of: seen_ Actual: false Expected: true [ FAILED ] SafeBrowsingBlockingPageTest.MalwareRedirectInIFrameCanceled, where TypeParam = and GetParam() = (1893 ms) [----------] 1 test from SafeBrowsingBlockingPageTest (1894 ms total) BUG=none TEST=none Review URL: http://codereview.chromium.org/10315004 TBR=bauerb@chromium.org Review URL: https://chromiumcodereview.appspot.com/10316023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135182 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/test/base/ui_test_utils.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to '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 ea8e8a2..272f4a0 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -10,7 +10,6 @@ #include -#include "base/auto_reset.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" @@ -961,28 +960,36 @@ WindowedNotificationObserver::WindowedNotificationObserver( int notification_type, const content::NotificationSource& source) : seen_(false), - running_(false) { - registrar_.Add(this, notification_type, source); + running_(false), + waiting_for_(source) { + registrar_.Add(this, notification_type, waiting_for_); } WindowedNotificationObserver::~WindowedNotificationObserver() {} void WindowedNotificationObserver::Wait() { - if (seen_) + if (seen_ || (waiting_for_ == content::NotificationService::AllSources() && + !sources_seen_.empty())) { return; + } - AutoReset auto_reset(&running_, true); + running_ = true; ui_test_utils::RunMessageLoop(); - EXPECT_TRUE(seen_); + running_ = false; } void WindowedNotificationObserver::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - seen_ = true; - if (running_) - MessageLoopForUI::current()->Quit(); + if (waiting_for_ == source || + (running_ && waiting_for_ == content::NotificationService::AllSources())) { + seen_ = true; + if (running_) + MessageLoopForUI::current()->Quit(); + } else { + sources_seen_.insert(source.map_key()); + } } WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver( -- cgit v1.1