From c711fe71d939fe5f0f535e4ecefcd6b1f62d07b5 Mon Sep 17 00:00:00 2001 From: "yurys@chromium.org" Date: Mon, 25 Jul 2011 12:43:30 +0000 Subject: DevTools: use standard test utilities instead of custom ones where possible BUG=None TEST=WorkerDevToolsSanityTest.InspectSharedWorker Review URL: http://codereview.chromium.org/7492046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93878 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/debugger/devtools_sanity_unittest.cc | 37 ++++------------------ 1 file changed, 7 insertions(+), 30 deletions(-) (limited to 'chrome/browser/debugger/devtools_sanity_unittest.cc') diff --git a/chrome/browser/debugger/devtools_sanity_unittest.cc b/chrome/browser/debugger/devtools_sanity_unittest.cc index 6886cf8..d668cd2 100644 --- a/chrome/browser/debugger/devtools_sanity_unittest.cc +++ b/chrome/browser/debugger/devtools_sanity_unittest.cc @@ -5,6 +5,7 @@ #include "base/command_line.h" #include "base/path_service.h" #include "base/stringprintf.h" +#include "base/test/test_timeouts.h" #include "base/utf_string_conversions.h" #include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/extensions/extension_host.h" @@ -254,33 +255,6 @@ class DevToolsExtensionDebugTest : public DevToolsSanityTest, }; - -// Used to block until a navigation completes. -class LoadStopObserver : public NotificationObserver { - public: - explicit LoadStopObserver(const NotificationSource& source) : done_(false) { - registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); - ui_test_utils::RunMessageLoop(); - } - - private: - virtual void Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) { - if (type == content::NOTIFICATION_LOAD_STOP) { - if (done_) - return; - done_ = true; - MessageLoopForUI::current()->Quit(); - } - } - - NotificationRegistrar registrar_; - bool done_; - DISALLOW_COPY_AND_ASSIGN(LoadStopObserver); -}; - - class WorkerDevToolsSanityTest : public InProcessBrowserTest { public: WorkerDevToolsSanityTest() : window_(NULL) { @@ -318,12 +292,13 @@ class WorkerDevToolsSanityTest : public InProcessBrowserTest { if (found) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, new MessageLoop::QuitTask); - } else if (attempt < 30) { + } else if (attempt < TestTimeouts::action_timeout_ms() / + TestTimeouts::tiny_timeout_ms()) { MessageLoop::current()->PostDelayedTask( FROM_HERE, NewRunnableFunction( &OpenDevToolsWindowForFirstSharedWorkerOnIOThread, attempt + 1), - 100); + TestTimeouts::tiny_timeout_ms()); } else { FAIL() << "Shared worker not found."; } @@ -341,8 +316,10 @@ class WorkerDevToolsSanityTest : public InProcessBrowserTest { RenderViewHost* client_rvh = window_->GetRenderViewHost(); TabContents* client_contents = client_rvh->delegate()->GetAsTabContents(); if (client_contents->IsLoading()) { - LoadStopObserver( + ui_test_utils::WindowedNotificationObserver observer( + content::NOTIFICATION_LOAD_STOP, Source(&client_contents->controller())); + observer.Wait(); } } -- cgit v1.1