diff options
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.cc | 9 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 5 | ||||
-rw-r--r-- | chrome/common/notification_type.h | 5 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 31 |
5 files changed, 49 insertions, 3 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index f796af5..1aac1b1 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -918,8 +918,6 @@ void AutomationProvider::ExecuteBrowserCommand( IDC_SELECT_NEXT_TAB, IDC_SELECT_PREVIOUS_TAB, IDC_SHOW_BOOKMARK_MANAGER, - IDC_SHOW_DOWNLOADS, - IDC_SHOW_HISTORY, }; if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 24b770a..d4416c2 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -635,9 +635,16 @@ struct CommandNotification { const struct CommandNotification command_notifications[] = { {IDC_DUPLICATE_TAB, NotificationType::TAB_PARENTED}, {IDC_NEW_TAB, NotificationType::INITIAL_NEW_TAB_UI_LOAD}, + // Returns as soon as the restored tab is created. To further wait until // the content page is loaded, use WaitForTabToBeRestored. - {IDC_RESTORE_TAB, NotificationType::TAB_PARENTED} + {IDC_RESTORE_TAB, NotificationType::TAB_PARENTED}, + + // For the following commands, we need to wait for a new tab to be created, + // load to finish, and title to change. + {IDC_MANAGE_EXTENSIONS, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, + {IDC_SHOW_DOWNLOADS, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, + {IDC_SHOW_HISTORY, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, }; } // namespace diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index b783b2c..5068275 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1704,6 +1704,11 @@ bool TabContents::UpdateTitleForEntry(NavigationEntry* entry, // Lastly, set the title for the view. view_->SetPageTitle(final_title); + NotificationService::current()->Notify( + NotificationType::TAB_CONTENTS_TITLE_UPDATED, + Source<TabContents>(this), + NotificationService::NoDetails()); + return true; } diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h index e3e478c..7fc2703 100644 --- a/chrome/common/notification_type.h +++ b/chrome/common/notification_type.h @@ -316,6 +316,11 @@ class NotificationType { // the TabContents (the pointer is usable). No details are expected. TAB_CONTENTS_DISCONNECTED, + // This notification is sent after TabContents' title is updated. The source + // is a Source<TabContents> with a pointer to the TabContents. No details + // are expected. + TAB_CONTENTS_TITLE_UPDATED, + // This message is sent when a new InfoBar has been added to a TabContents. // The source is a Source<TabContents> with a pointer to the TabContents // the InfoBar was added to. The details is a Details<InfoBarDelegate> with diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index b3dce0f..9850d1f 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -435,6 +435,7 @@ TEST_F(AutomationProxyTest, NavigateToURLAsync) { TEST_F(AutomationProxyTest, AcceleratorNewTab) { scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(window.get()); int tab_count = -1; ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); @@ -445,6 +446,36 @@ TEST_F(AutomationProxyTest, AcceleratorNewTab) { ASSERT_TRUE(tab.get()); } +TEST_F(AutomationProxyTest, AcceleratorDownloads) { + scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(window.get()); + + ASSERT_TRUE(window->RunCommand(IDC_SHOW_DOWNLOADS)); + + // We expect the RunCommand above to wait until the title is updated. + EXPECT_EQ(L"Downloads", GetActiveTabTitle()); +} + +TEST_F(AutomationProxyTest, AcceleratorExtensions) { + scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(window.get()); + + ASSERT_TRUE(window->RunCommand(IDC_MANAGE_EXTENSIONS)); + + // We expect the RunCommand above to wait until the title is updated. + EXPECT_EQ(L"Extensions", GetActiveTabTitle()); +} + +TEST_F(AutomationProxyTest, AcceleratorHistory) { + scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(window.get()); + + ASSERT_TRUE(window->RunCommand(IDC_SHOW_HISTORY)); + + // We expect the RunCommand above to wait until the title is updated. + EXPECT_EQ(L"History", GetActiveTabTitle()); +} + class AutomationProxyTest4 : public UITest { protected: AutomationProxyTest4() : UITest() { |