From 714786e1b9566ca76388497904d2ebdb7fd111f5 Mon Sep 17 00:00:00 2001 From: "viettrungluu@chromium.org" Date: Thu, 8 Apr 2010 16:07:16 +0000 Subject: Revert 43931 - [GTTF] Clean up browser tests: use more ui_test_utils functions to simplify the code expose more consistent and powerful utilities in ui_test_utils minor style improvements move some tests from DISABLED to FLAKY so we don't lose coverage remove redundant timeouts check more return values TEST=browser_tests BUG=none Review URL: http://codereview.chromium.org/1571002 TBR=phajdan.jr@chromium.org Review URL: http://codereview.chromium.org/1520026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43950 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/crash_recovery_browsertest.cc | 36 +++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'chrome/browser/crash_recovery_browsertest.cc') diff --git a/chrome/browser/crash_recovery_browsertest.cc b/chrome/browser/crash_recovery_browsertest.cc index 1ee4cc4..846ddfe 100644 --- a/chrome/browser/crash_recovery_browsertest.cc +++ b/chrome/browser/crash_recovery_browsertest.cc @@ -6,7 +6,8 @@ #include "chrome/browser/browser.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/notification_type.h" +#include "chrome/common/notification_registrar.h" +#include "chrome/common/notification_service.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/url_constants.h" #include "chrome/test/in_process_browser_test.h" @@ -16,11 +17,40 @@ namespace { +// Used to block until a navigation completes. +class RendererCrashObserver : public NotificationObserver { + public: + RendererCrashObserver() {} + + void WaitForRendererCrash() { + registrar_.Add(this, NotificationType::TAB_CONTENTS_DISCONNECTED, + NotificationService::AllSources()); + ui_test_utils::RunMessageLoop(); + } + + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + if (type == NotificationType::TAB_CONTENTS_DISCONNECTED) { + registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED, + NotificationService::AllSources()); + MessageLoopForUI::current()->Quit(); + } else { + NOTREACHED(); + } + } + + private: + NotificationRegistrar registrar_; + + DISALLOW_COPY_AND_ASSIGN(RendererCrashObserver); +}; + void SimulateRendererCrash(Browser* browser) { browser->OpenURL(GURL(chrome::kAboutCrashURL), GURL(), CURRENT_TAB, PageTransition::TYPED); - ui_test_utils::WaitForNotification( - NotificationType::TAB_CONTENTS_DISCONNECTED); + RendererCrashObserver crash_observer; + crash_observer.WaitForRendererCrash(); } } // namespace -- cgit v1.1