diff options
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browser_window.h | 18 | ||||
-rw-r--r-- | chrome/browser/browser_window_cocoa.h | 1 | ||||
-rw-r--r-- | chrome/browser/browser_window_cocoa.mm | 4 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 33 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 6 | ||||
-rw-r--r-- | chrome/test/test_browser_window.h | 1 |
7 files changed, 49 insertions, 18 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 4d82ab1..5ec7ffd 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1838,7 +1838,9 @@ void AutomationProvider::GetBookmarkBarVisitility(const IPC::Message& message, if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); if (browser) { - BookmarkBarView* bookmark_bar = browser->window()->GetBookmarkBarView(); + BrowserWindowTesting* testing = + browser->window()->GetBrowserWindowTesting(); + BookmarkBarView* bookmark_bar = testing->GetBookmarkBarView(); if (bookmark_bar) { animating = bookmark_bar->IsAnimating(); visible = browser->window()->IsBookmarkBarVisible(); diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index aec7107..c2b4f07 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -9,6 +9,7 @@ class BookmarkBarView; class Browser; class BrowserList; class BrowserView; +class BrowserWindowTesting; class GoButton; class LocationBarView; class HtmlDialogContentsDelegate; @@ -54,6 +55,10 @@ class BrowserWindow { // returns an HWND. DO NOT USE IN CROSS PLATFORM CODE. virtual void* GetNativeHandle() = 0; + // Returns a pointer to the testing interface to the Browser window, or NULL + // if there is none. + virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0; + // TODO(beng): REMOVE (obtain via BrowserFrame). // Return the TabStrip associated with the frame. virtual TabStrip* GetTabStrip() const = 0; @@ -95,9 +100,6 @@ class BrowserWindow { // Returns the go button. virtual GoButton* GetGoButton() const = 0; - // Returns the Bookmark Bar view. - virtual BookmarkBarView* GetBookmarkBarView() = 0; - // Updates the toolbar with the state for the specified |contents|. virtual void UpdateToolbar(TabContents* contents, bool should_restore_state) = 0; @@ -147,4 +149,14 @@ class BrowserWindow { virtual void DestroyBrowser() = 0; }; +// A BrowserWindow utility interface used for accessing elements of the browser +// UI used only by UI test automation. +class BrowserWindowTesting { +public: +#if defined(OS_WIN) + // Returns the Bookmark Bar view. + virtual BookmarkBarView* GetBookmarkBarView() = 0; +#endif +}; + #endif // CHROME_BROWSER_BROWSER_WINDOW_H__ diff --git a/chrome/browser/browser_window_cocoa.h b/chrome/browser/browser_window_cocoa.h index 74847bd..62b4811 100644 --- a/chrome/browser/browser_window_cocoa.h +++ b/chrome/browser/browser_window_cocoa.h @@ -27,6 +27,7 @@ class BrowserWindowCocoa : public BrowserWindow { virtual void Activate(); virtual void FlashFrame(); virtual void* GetNativeHandle(); + virtual BrowserWindowTesting* GetBrowserWindowTesting(); virtual TabStrip* GetTabStrip() const; virtual StatusBubble* GetStatusBubble(); virtual void SelectedTabToolbarSizeChanged(bool is_animating); diff --git a/chrome/browser/browser_window_cocoa.mm b/chrome/browser/browser_window_cocoa.mm index d3061d9..b3d9365 100644 --- a/chrome/browser/browser_window_cocoa.mm +++ b/chrome/browser/browser_window_cocoa.mm @@ -47,6 +47,10 @@ void* BrowserWindowCocoa::GetNativeHandle() { return [controller_ window]; } +BrowserWindowTesting* BrowserWindowCocoa::GetBrowserWindowTesting() { + return NULL; +} + TabStrip* BrowserWindowCocoa::GetTabStrip() const { return NULL; } diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 8214a14..da7adae 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -419,6 +419,10 @@ void* BrowserView::GetNativeHandle() { return GetWidget()->GetHWND(); } +BrowserWindowTesting* BrowserView::GetBrowserWindowTesting() { + return this; +} + TabStrip* BrowserView::GetTabStrip() const { return tabstrip_; } @@ -485,19 +489,6 @@ GoButton* BrowserView::GetGoButton() const { return toolbar_->GetGoButton(); } -BookmarkBarView* BrowserView::GetBookmarkBarView() { - TabContents* current_tab = browser_->GetSelectedTabContents(); - if (!bookmark_bar_view_.get()) { - bookmark_bar_view_.reset(new BookmarkBarView(current_tab->profile(), - browser_.get())); - bookmark_bar_view_->SetParentOwned(false); - } else { - bookmark_bar_view_->SetProfile(current_tab->profile()); - } - bookmark_bar_view_->SetPageNavigator(current_tab); - return bookmark_bar_view_.get(); -} - BrowserView* BrowserView::GetBrowserView() const { return NULL; } @@ -621,6 +612,22 @@ void BrowserView::ShowHTMLDialog(HtmlDialogContentsDelegate* delegate, } /////////////////////////////////////////////////////////////////////////////// +// BrowserView, BrowserWindowTesting implementation: + +BookmarkBarView* BrowserView::GetBookmarkBarView() { + TabContents* current_tab = browser_->GetSelectedTabContents(); + if (!bookmark_bar_view_.get()) { + bookmark_bar_view_.reset(new BookmarkBarView(current_tab->profile(), + browser_.get())); + bookmark_bar_view_->SetParentOwned(false); + } else { + bookmark_bar_view_->SetProfile(current_tab->profile()); + } + bookmark_bar_view_->SetPageNavigator(current_tab); + return bookmark_bar_view_.get(); +} + +/////////////////////////////////////////////////////////////////////////////// // BrowserView, NotificationObserver implementation: void BrowserView::Observe(NotificationType type, diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 172a1db..d2df248 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -34,6 +34,7 @@ class TabContentsContainerView; // including the TabStrip, toolbars, download shelves, the content area etc. // class BrowserView : public BrowserWindow, + public BrowserWindowTesting, public NotificationObserver, public TabStripModelObserver, public views::WindowDelegate, @@ -153,6 +154,7 @@ class BrowserView : public BrowserWindow, virtual void Activate(); virtual void FlashFrame(); virtual void* GetNativeHandle(); + virtual BrowserWindowTesting* GetBrowserWindowTesting(); virtual TabStrip* GetTabStrip() const; virtual StatusBubble* GetStatusBubble(); virtual void SelectedTabToolbarSizeChanged(bool is_animating); @@ -163,7 +165,6 @@ class BrowserView : public BrowserWindow, virtual ToolbarStarToggle* GetStarButton() const; virtual LocationBarView* GetLocationBarView() const; virtual GoButton* GetGoButton() const; - virtual BookmarkBarView* GetBookmarkBarView(); virtual BrowserView* GetBrowserView() const; virtual void UpdateToolbar(TabContents* contents, bool should_restore_state); virtual void FocusToolbar(); @@ -180,6 +181,9 @@ class BrowserView : public BrowserWindow, virtual void ShowHTMLDialog(HtmlDialogContentsDelegate* delegate, void* parent_window); + // Overridden from BrowserWindowTesting: + virtual BookmarkBarView* GetBookmarkBarView(); + // Overridden from NotificationObserver: virtual void Observe(NotificationType type, const NotificationSource& source, diff --git a/chrome/test/test_browser_window.h b/chrome/test/test_browser_window.h index ce4250a..920490b 100644 --- a/chrome/test/test_browser_window.h +++ b/chrome/test/test_browser_window.h @@ -26,6 +26,7 @@ class TestBrowserWindow : public BrowserWindow { virtual void Activate() {} virtual void FlashFrame() {} virtual void* GetNativeHandle() { return NULL; } + virtual BrowserWindowTesting* GetBrowserWindowTesting() { return NULL; } virtual TabStrip* GetTabStrip() const { return const_cast<TabStrip*>(&tab_strip_); } |