diff options
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 35 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 18 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.cc | 40 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.h | 27 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 5 | ||||
-rw-r--r-- | chrome/browser/browser_encoding_uitest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/download/download_uitest.cc | 25 | ||||
-rw-r--r-- | chrome/browser/download/save_page_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/history/multipart_uitest.cc | 10 | ||||
-rw-r--r-- | chrome/common/notification_type.h | 6 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 7 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.cc | 13 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.h | 3 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 24 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.h | 17 |
15 files changed, 78 insertions, 158 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index bd341a6..93ad3d5 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -213,6 +213,11 @@ NotificationObserver* AutomationProvider::AddNavigationStatusListener( return observer; } +void AutomationProvider::RemoveNavigationStatusListener( + NotificationObserver* obs) { + notification_observer_list_.RemoveObserver(obs); +} + NotificationObserver* AutomationProvider::AddTabStripObserver( Browser* parent, IPC::Message* reply_message) { @@ -223,7 +228,7 @@ NotificationObserver* AutomationProvider::AddTabStripObserver( return observer; } -void AutomationProvider::RemoveObserver(NotificationObserver* obs) { +void AutomationProvider::RemoveTabStripObserver(NotificationObserver* obs) { notification_observer_list_.RemoveObserver(obs); } @@ -491,9 +496,6 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation, SetEnableExtensionAutomation) #endif - IPC_MESSAGE_HANDLER_DELAY_REPLY( - AutomationMsg_WaitForDownloadShelfVisibilityChange, - WaitForDownloadShelfVisibilityChange) IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount) IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll) @@ -597,7 +599,7 @@ void AutomationProvider::AppendTab(int handle, const GURL& url, if (append_tab_response < 0) { // The append tab failed. Remove the TabStripObserver if (observer) { - RemoveObserver(observer); + RemoveTabStripObserver(observer); delete observer; } @@ -1589,29 +1591,6 @@ void AutomationProvider::RemoveBookmark(int handle, *success = false; } -void AutomationProvider::WaitForDownloadShelfVisibilityChange( - int browser_handle, - bool visibility, - IPC::Message* reply_message) { - bool success = false; - if (browser_tracker_->ContainsHandle(browser_handle)) { - Browser* browser = browser_tracker_->GetResource(browser_handle); - if (browser->window()->IsDownloadShelfVisible() == visibility) { - success = true; - } else { - notification_observer_list_.AddObserver( - new DownloadShelfVisibilityObserver(this, - browser, - visibility, - reply_message)); - return; - } - } - AutomationMsg_WaitForDownloadShelfVisibilityChange::WriteReplyParams( - reply_message, success); - Send(reply_message); -} - // Sample json input: { "command": "GetHistoryInfo", // "search_text": "some text" } // Refer chrome/test/pyautolib/history_info.py for sample json output. diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index bf53b36..5662835 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -79,21 +79,22 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // complete, the completed_response object is sent; if the server requires // authentication, we instead send the auth_needed_response object. A pointer // to the added navigation observer is returned. This object should NOT be - // deleted and should be released by calling the RemoveObserver method. + // deleted and should be released by calling the corresponding + // RemoveNavigationStatusListener method. NotificationObserver* AddNavigationStatusListener( NavigationController* tab, IPC::Message* reply_message, int number_of_navigations, bool include_current_navigation); + void RemoveNavigationStatusListener(NotificationObserver* obs); + // Add an observer for the TabStrip. Currently only Tab append is observed. A // navigation listener is created on successful notification of tab append. A // pointer to the added navigation observer is returned. This object should - // NOT be deleted and should be released by calling the RemoveObserver method. + // NOT be deleted and should be released by calling the corresponding + // RemoveTabStripObserver method. NotificationObserver* AddTabStripObserver(Browser* parent, IPC::Message* reply_message); - - // Remove an observer. The |NotificationObserver| still needs to be deleted - // afterwards. - void RemoveObserver(NotificationObserver* obs); + void RemoveTabStripObserver(NotificationObserver* obs); // Get the index of a particular NavigationController object // in the given parent window. This method uses @@ -333,11 +334,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, int64 id, bool* success); - // Wait for the download shelf to appear or disappear. - void WaitForDownloadShelfVisibilityChange(int browser_handle, - bool visibility, - IPC::Message* reply_message); - // Get info about downloads. This includes only ones that have been // registered by the history system. // Uses the JSON interface for input/output. diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index c6343c0..3ca82e6 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -10,7 +10,6 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/automation/automation_provider.h" #include "chrome/browser/bookmarks/bookmark_model.h" -#include "chrome/browser/browser_window.h" #include "chrome/browser/dom_operation_notification_details.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_process_manager.h" @@ -160,7 +159,7 @@ NavigationNotificationObserver::~NavigationNotificationObserver() { reply_message_ = NULL; } - automation_->RemoveObserver(this); + automation_->RemoveNavigationStatusListener(this); } void NavigationNotificationObserver::Observe( @@ -235,7 +234,7 @@ void TabStripNotificationObserver::Observe(NotificationType type, ObserveTab(Source<NavigationController>(source).ptr()); // If verified, no need to observe anymore - automation_->RemoveObserver(this); + automation_->RemoveTabStripObserver(this); delete this; } else { NOTREACHED(); @@ -822,7 +821,7 @@ DocumentPrintedNotificationObserver::~DocumentPrintedNotificationObserver() { DCHECK(reply_message_ != NULL); AutomationMsg_PrintNow::WriteReplyParams(reply_message_, success_); automation_->Send(reply_message_); - automation_->RemoveObserver(this); + automation_->RemoveNavigationStatusListener(this); } void DocumentPrintedNotificationObserver::Observe( @@ -908,39 +907,6 @@ void LoginManagerObserver::Observe(NotificationType type, } #endif -DownloadShelfVisibilityObserver::DownloadShelfVisibilityObserver( - AutomationProvider* automation, - Browser* browser, - bool visibility, - IPC::Message* reply_message) - : automation_(automation), - visibility_(visibility), - reply_message_(reply_message) { - registrar_.Add(this, NotificationType::DOWNLOAD_SHELF_VISIBILITY_CHANGED, - Source<Browser>(browser)); -} - -DownloadShelfVisibilityObserver::~DownloadShelfVisibilityObserver() { -} - -void DownloadShelfVisibilityObserver::Observe( - NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - if (type == NotificationType::DOWNLOAD_SHELF_VISIBILITY_CHANGED) { - Browser* browser = Source<Browser>(source).ptr(); - if (browser->window()->IsDownloadShelfVisible() == visibility_) { - AutomationMsg_WaitForDownloadShelfVisibilityChange::WriteReplyParams( - reply_message_, true); - automation_->Send(reply_message_); - automation_->RemoveObserver(this); - delete this; - } - } else { - NOTREACHED(); - } -} - AutomationProviderBookmarkModelObserver::AutomationProviderBookmarkModelObserver( AutomationProvider* provider, IPC::Message* reply_message, diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index e6e434e..efb01e0 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -488,29 +488,6 @@ class LoginManagerObserver : public NotificationObserver { }; #endif -// Waits for the download shelf to appear or disappear -// (depending on |visibility|). -class DownloadShelfVisibilityObserver : public NotificationObserver { - public: - DownloadShelfVisibilityObserver(AutomationProvider* automation, - Browser* browser, - bool visiblity, - IPC::Message* reply_message); - ~DownloadShelfVisibilityObserver(); - - // NotificationObserver interface. - virtual void Observe(NotificationType type, const NotificationSource& source, - const NotificationDetails& details); - - private: - NotificationRegistrar registrar_; - AutomationProvider* automation_; - bool visibility_; - IPC::Message* reply_message_; - - DISALLOW_COPY_AND_ASSIGN(DownloadShelfVisibilityObserver); -}; - // Waits for the bookmark model to load. class AutomationProviderBookmarkModelObserver : BookmarkModelObserver { public: @@ -559,8 +536,8 @@ class AutomationProviderBookmarkModelObserver : BookmarkModelObserver { // When asked for pending downloads, the DownloadManager places // results in a DownloadManager::Observer. -class AutomationProviderDownloadManagerObserver - : public DownloadManager::Observer { +class AutomationProviderDownloadManagerObserver : + public DownloadManager::Observer { public: AutomationProviderDownloadManagerObserver() : DownloadManager::Observer() {} virtual ~AutomationProviderDownloadManagerObserver() {} diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 4770c59..60217ad 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -2626,11 +2626,6 @@ void Browser::UpdateTargetURL(TabContents* source, const GURL& url) { void Browser::UpdateDownloadShelfVisibility(bool visible) { if (GetStatusBubble()) GetStatusBubble()->UpdateDownloadShelfVisibility(visible); - - NotificationService::current()->Notify( - NotificationType::DOWNLOAD_SHELF_VISIBILITY_CHANGED, - Source<Browser>(this), - NotificationService::NoDetails()); } void Browser::ContentsZoomChange(bool zoom_in) { diff --git a/chrome/browser/browser_encoding_uitest.cc b/chrome/browser/browser_encoding_uitest.cc index df856c7..3c0531b 100644 --- a/chrome/browser/browser_encoding_uitest.cc +++ b/chrome/browser/browser_encoding_uitest.cc @@ -148,7 +148,7 @@ TEST_F(BrowserEncodingTest, TestOverrideEncoding) { SavePackage::SAVE_AS_COMPLETE_HTML)); scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); FilePath expected_file_name = FilePath().AppendASCII(kOverrideTestDir); expected_file_name = expected_file_name.AppendASCII(kExpectedFileName); CheckFile(full_file_name, expected_file_name, true); @@ -284,7 +284,7 @@ TEST_F(BrowserEncodingTest, TestEncodingAutoDetect) { kTestDatas[i].expected_result); EXPECT_TRUE(tab->SavePage(full_saved_file_name, temp_sub_resource_dir_, SavePackage::SAVE_AS_COMPLETE_HTML)); - EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); CheckFile(full_saved_file_name, expected_result_file_name, true); } } diff --git a/chrome/browser/download/download_uitest.cc b/chrome/browser/download/download_uitest.cc index 011a54c..b8171fa 100644 --- a/chrome/browser/download/download_uitest.cc +++ b/chrome/browser/download/download_uitest.cc @@ -112,7 +112,7 @@ class DownloadTest : public UITest { // TODO(tc): check download status text // Make sure the download shelf is showing. - EXPECT_TRUE(window->WaitForDownloadShelfVisibilityChange(true)); + EXPECT_TRUE(WaitForDownloadShelfVisible(window.get())); } FilePath filename; @@ -187,7 +187,7 @@ TEST_F(DownloadTest, FLAKY_DownloadMimeType) { scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); } // Access a file with a viewable mime-type, verify that a download @@ -213,7 +213,7 @@ TEST_F(DownloadTest, FLAKY_NoDownload) { scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - EXPECT_FALSE(browser->WaitForDownloadShelfVisibilityChange(true)); + EXPECT_FALSE(WaitForDownloadShelfVisible(browser.get())); } // Download a 0-size file with a content-disposition header, verify that the @@ -233,7 +233,7 @@ TEST_F(DownloadTest, FLAKY_ContentDisposition) { // Ensure the download shelf is visible on the window. scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); } // Test that the download shelf is per-window by starting a download in one @@ -254,7 +254,7 @@ TEST_F(DownloadTest, FLAKY_PerWindowShelf) { // Ensure the download shelf is visible on the window. scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); // Open a second tab ASSERT_TRUE(browser->AppendTab(GURL())); @@ -262,7 +262,7 @@ TEST_F(DownloadTest, FLAKY_PerWindowShelf) { // Hide shelf EXPECT_TRUE(browser->SetShelfVisible(false)); - EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(false)); + EXPECT_TRUE(WaitForDownloadShelfInvisible(browser.get())); // Go to first tab EXPECT_TRUE(browser->ActivateTab(0)); @@ -336,7 +336,7 @@ TEST_F(DownloadTest, FLAKY_IncognitoDownload) { ASSERT_TRUE(tab->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file))); // Verify that the download shelf is showing for the Incognito window. - EXPECT_TRUE(incognito->WaitForDownloadShelfVisibilityChange(true)); + EXPECT_TRUE(WaitForDownloadShelfVisible(incognito.get())); // Close the Incognito window and don't crash. ASSERT_TRUE(incognito->RunCommand(IDC_CLOSE_WINDOW)); @@ -385,9 +385,8 @@ TEST_F(DownloadTest, FLAKY_CloseNewTab1) { ASSERT_TRUE(tab_proxy->NavigateToURLAsyncWithDisposition( URLRequestMockHTTPJob::GetMockUrl(file), NEW_BACKGROUND_TAB)); - // When the download starts, we should still have one tab. - ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); EXPECT_EQ(1, GetTabCount()); CheckDownload(file); @@ -411,7 +410,7 @@ TEST_F(DownloadTest, FLAKY_DontCloseNewTab2) { FilePath file(FILE_PATH_LITERAL("download-test1.lib")); ASSERT_TRUE(tab_proxy->NavigateToURLAsync(GURL("javascript:openNew()"))); - ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); EXPECT_EQ(2, GetTabCount()); CheckDownload(file); @@ -438,7 +437,7 @@ TEST_F(DownloadTest, FLAKY_DontCloseNewTab3) { ASSERT_TRUE(tab_proxy->NavigateToURLAsync( URLRequestMockHTTPJob::GetMockUrl(file))); - ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); EXPECT_EQ(2, GetTabCount()); CheckDownload(file); @@ -462,7 +461,7 @@ TEST_F(DownloadTest, FLAKY_CloseNewTab2) { FilePath file(FILE_PATH_LITERAL("download-test1.lib")); ASSERT_TRUE(tab_proxy->NavigateToURLAsync(GURL("javascript:openNew()"))); - ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); EXPECT_EQ(1, GetTabCount()); CheckDownload(file); @@ -487,7 +486,7 @@ TEST_F(DownloadTest, FLAKY_CloseNewTab3) { ASSERT_TRUE(tab_proxy->NavigateToURLAsync( GURL("javascript:document.getElementById('form').submit()"))); - ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); EXPECT_EQ(1, GetTabCount()); CheckDownload(file); diff --git a/chrome/browser/download/save_page_uitest.cc b/chrome/browser/download/save_page_uitest.cc index c9de08b..07fd78c 100644 --- a/chrome/browser/download/save_page_uitest.cc +++ b/chrome/browser/download/save_page_uitest.cc @@ -84,7 +84,7 @@ TEST_F(SavePageTest, CleanFilenameFromPageTitle) { ASSERT_TRUE(browser.get()); automation()->SavePackageShouldPromptUser(false); EXPECT_TRUE(browser->RunCommandAsync(IDC_SAVE_PAGE)); - EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); + EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); automation()->SavePackageShouldPromptUser(true); CheckFile(full_file_name, file_name); diff --git a/chrome/browser/history/multipart_uitest.cc b/chrome/browser/history/multipart_uitest.cc index 9a50fe3c..7f8688f 100644 --- a/chrome/browser/history/multipart_uitest.cc +++ b/chrome/browser/history/multipart_uitest.cc @@ -15,16 +15,11 @@ namespace { class MultipartResponseUITest : public UITest { }; +#if defined(NDEBUG) // http://code.google.com/p/chromium/issues/detail?id=37746 // Running this test only for release builds as it fails in debug test // runs -#if defined(NDEBUG) -#define MAYBE_SingleVisit SingleVisit -#else -#define MAYBE_SingleVisit DISABLED_SingleVisit -#endif - -TEST_F(MultipartResponseUITest, MAYBE_SingleVisit) { +TEST_F(MultipartResponseUITest, SingleVisit) { // Make sure that visiting a multipart/x-mixed-replace site only // creates one entry in the visits table. const wchar_t kDocRoot[] = L"chrome/test/data"; @@ -61,5 +56,6 @@ TEST_F(MultipartResponseUITest, MAYBE_SingleVisit) { } db.Close(); } +#endif } // namespace diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h index 51573a7..d8b46b4 100644 --- a/chrome/common/notification_type.h +++ b/chrome/common/notification_type.h @@ -946,12 +946,6 @@ class NotificationType { // are a ChromeCookieDetails object. COOKIE_CHANGED, - // Downloads --------------------------------------------------------------- - - // Sent when the download shelf appears or disappears. The source is the - // Browser object. - DOWNLOAD_SHELF_VISIBILITY_CHANGED, - #if defined(OS_CHROMEOS) // Sent when a chromium os user logs in. LOGIN_USER_CHANGED, diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 9f96c5a..77f9d56 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -1396,11 +1396,4 @@ IPC_BEGIN_MESSAGES(Automation) IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_DeleteCookie, GURL, std::string, int, bool) - // Waits for the download shelf to appear or disappear (depending on - // |visibility|) and sets |success| to true on success. - IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_WaitForDownloadShelfVisibilityChange, - int /* browser handle */, - bool /* visibility */, - bool /* success */) - IPC_END_MESSAGES(Automation) diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index 6456cec..1b275d8 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -398,19 +398,6 @@ bool BrowserProxy::SetShelfVisible(bool is_visible) { is_visible)); } -bool BrowserProxy::WaitForDownloadShelfVisibilityChange(bool visibility) { - if (!is_valid()) - return false; - - bool result = false; - - if (!sender_->Send(new AutomationMsg_WaitForDownloadShelfVisibilityChange( - 0, handle_, visibility, &result))) - return false; - - return result; -} - bool BrowserProxy::SetIntPreference(const std::wstring& name, int value) { if (!is_valid()) return false; diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h index 198004a..d0bb4d0 100644 --- a/chrome/test/automation/browser_proxy.h +++ b/chrome/test/automation/browser_proxy.h @@ -178,9 +178,6 @@ class BrowserProxy : public AutomationResourceProxy { // Shows or hides the download shelf. bool SetShelfVisible(bool is_visible) WARN_UNUSED_RESULT; - // Waits for the download shelf to appear or disappear. - bool WaitForDownloadShelfVisibilityChange(bool visibility) WARN_UNUSED_RESULT; - // Sets the int value of the specified preference. bool SetIntPreference(const std::wstring& name, int value) WARN_UNUSED_RESULT; diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index a0e7f26..d956478 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -613,6 +613,30 @@ void UITestBase::NavigateToURLBlockUntilNavigationsComplete( url, number_of_navigations)) << url.spec(); } +bool UITestBase::WaitForDownloadShelfVisible(BrowserProxy* browser) { + return WaitForDownloadShelfVisibilityChange(browser, true); +} + +bool UITestBase::WaitForDownloadShelfInvisible(BrowserProxy* browser) { + return WaitForDownloadShelfVisibilityChange(browser, false); +} + +bool UITestBase::WaitForDownloadShelfVisibilityChange(BrowserProxy* browser, + bool wait_for_open) { + const int kCycles = 10; + for (int i = 0; i < kCycles; i++) { + // Give it a chance to catch up. + PlatformThread::Sleep(sleep_timeout_ms() / kCycles); + + bool visible = !wait_for_open; + if (!browser->IsShelfVisible(&visible)) + continue; + if (visible == wait_for_open) + return true; // Got the download shelf. + } + return false; +} + bool UITestBase::WaitForFindWindowVisibilityChange(BrowserProxy* browser, bool wait_for_open) { const int kCycles = 10; diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h index 3aadfac..9414808 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -191,6 +191,23 @@ class UITestBase { // assert that the tab count is valid at the end of the wait. void WaitUntilTabCount(int tab_count); + // Checks whether the download shelf is visible in the current browser, giving + // it a chance to appear (we don't know the exact timing) while finishing as + // soon as possible. + bool WaitForDownloadShelfVisible(BrowserProxy* browser); + + // Checks whether the download shelf is invisible in the current browser, + // giving it a chance to appear (we don't know the exact timing) while + // finishing as soon as possible. + bool WaitForDownloadShelfInvisible(BrowserProxy* browser); + + private: + // Waits for download shelf visibility or invisibility. + bool WaitForDownloadShelfVisibilityChange(BrowserProxy* browser, + bool wait_for_open); + + public: + // Waits until the Find window has become fully visible (if |wait_for_open| is // true) or fully hidden (if |wait_for_open| is false). This function can time // out (return false) if the window doesn't appear within a specific time. |