summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/automation_provider.cc24
-rw-r--r--chrome/browser/automation/automation_provider.h3
-rw-r--r--chrome/browser/browser_window.h5
-rw-r--r--chrome/browser/find_in_page_controller_uitest.cc5
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc6
-rw-r--r--chrome/browser/views/bookmark_bar_view.h5
-rw-r--r--chrome/browser/views/frame/browser_view.cc14
-rw-r--r--chrome/browser/views/frame/browser_view.h1
-rw-r--r--chrome/browser/views/frame/browser_view2.cc13
-rw-r--r--chrome/browser/views/frame/browser_view2.h1
-rw-r--r--chrome/browser/vista_frame.cc13
-rw-r--r--chrome/browser/vista_frame.h1
-rw-r--r--chrome/browser/xp_frame.cc13
-rw-r--r--chrome/browser/xp_frame.h1
-rw-r--r--chrome/test/automation/automation_messages_internal.h8
-rw-r--r--chrome/test/automation/browser_proxy.cc25
-rw-r--r--chrome/test/automation/browser_proxy.h8
-rw-r--r--chrome/test/ui/ui_test.cc17
-rw-r--r--chrome/test/ui/ui_test.h6
19 files changed, 160 insertions, 9 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 5158c80..b831a71 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/save_package.h"
#include "chrome/browser/ssl_blocking_page.h"
#include "chrome/browser/web_contents.h"
+#include "chrome/browser/views/bookmark_bar_view.h"
#include "chrome/browser/views/location_bar_view.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/automation/automation_messages.h"
@@ -755,6 +756,8 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
GetFindWindowVisibility)
IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowLocationRequest,
HandleFindWindowLocationRequest)
+ IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibilityRequest,
+ GetBookmarkBarVisitility)
IPC_END_MESSAGE_MAP()
}
@@ -1720,6 +1723,27 @@ void AutomationProvider::HandleFindWindowLocationRequest(
x, y));
}
+void AutomationProvider::GetBookmarkBarVisitility(const IPC::Message& message,
+ int handle) {
+ bool visible = false;
+ bool animating = false;
+
+ void* iter = NULL;
+ if (browser_tracker_->ContainsHandle(handle)) {
+ Browser* browser = browser_tracker_->GetResource(handle);
+ if (browser) {
+ BookmarkBarView* bookmark_bar = browser->window()->GetBookmarkBarView();
+ if (bookmark_bar) {
+ animating = bookmark_bar->IsAnimating();
+ visible = browser->window()->IsBookmarkBarVisible();
+ }
+ }
+ }
+
+ Send(new AutomationMsg_BookmarkBarVisibilityResponse(message.routing_id(),
+ visible, animating));
+}
+
void AutomationProvider::HandleInspectElementRequest(
const IPC::Message& message, int handle, int x, int y) {
WebContents* web_contents = GetWebContentsForHandle(handle, NULL);
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index 370eeb3..674565c 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -208,6 +208,9 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
// Responds to requests to find the location of the Find window.
void HandleFindWindowLocationRequest(const IPC::Message& message, int handle);
+ // Get the visibility state of the Bookmark bar.
+ void GetBookmarkBarVisitility(const IPC::Message& message, int handle);
+
// Responds to InspectElement request
void HandleInspectElementRequest(const IPC::Message& message,
int handle,
diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h
index 43957c0..271d0cc 100644
--- a/chrome/browser/browser_window.h
+++ b/chrome/browser/browser_window.h
@@ -179,11 +179,14 @@ class BrowserWindow {
const gfx::Rect& bounds,
int show_command);
+ // Returns whether the bookmark bar is visible or not.
+ virtual bool IsBookmarkBarVisible() const = 0;
+
protected:
friend class BrowserList;
friend class BrowserView;
virtual void DestroyBrowser() = 0;
};
-#endif // #ifndef CHROME_BROWSER_BROWSER_WINDOW_H__
+#endif // CHROME_BROWSER_BROWSER_WINDOW_H__
diff --git a/chrome/browser/find_in_page_controller_uitest.cc b/chrome/browser/find_in_page_controller_uitest.cc
index e40d09c..0fd4012 100644
--- a/chrome/browser/find_in_page_controller_uitest.cc
+++ b/chrome/browser/find_in_page_controller_uitest.cc
@@ -122,7 +122,7 @@ TEST_F(FindInPageControllerTest, FindEnoughMatches_Issue1341577) {
// The find window should not change its location just because we open and close
// a new tab.
-TEST_F(FindInPageControllerTest, DISABLED_FindMovesOnTabClose_Issue1343052) {
+TEST_F(FindInPageControllerTest, FindMovesOnTabClose_Issue1343052) {
TestServer server(L"chrome/test/data");
GURL url = server.TestServerPageW(kFramePage);
@@ -134,6 +134,7 @@ TEST_F(FindInPageControllerTest, DISABLED_FindMovesOnTabClose_Issue1343052) {
// Toggle the bookmark bar state.
browser->ApplyAccelerator(IDC_SHOW_BOOKMARKS_BAR);
+ EXPECT_TRUE(WaitForBookmarkBarVisibilityChange(browser.get(), true));
// Open the Find window and wait for it to animate.
EXPECT_TRUE(tabA->OpenFindInPage());
@@ -159,7 +160,7 @@ TEST_F(FindInPageControllerTest, DISABLED_FindMovesOnTabClose_Issue1343052) {
// Now reset the bookmarks bar state and try the same again.
browser->ApplyAccelerator(IDC_SHOW_BOOKMARKS_BAR);
- Sleep(kWaitForActionMsec);
+ EXPECT_TRUE(WaitForBookmarkBarVisibilityChange(browser.get(), false));
// Bookmark bar has moved, reset our coordinates.
EXPECT_TRUE(tabA->GetFindWindowLocation(&x, &y));
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index fb9d579..191aa04 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -265,7 +265,7 @@ class BookmarkButton : public ChromeViews::TextButton {
Profile* profile_;
scoped_ptr<SlideAnimation> show_animation_;
- DISALLOW_EVIL_CONSTRUCTORS(BookmarkButton);
+ DISALLOW_COPY_AND_ASSIGN(BookmarkButton);
};
// DropInfo -------------------------------------------------------------------
@@ -545,7 +545,7 @@ class MenuRunner : public ChromeViews::MenuDelegate,
scoped_ptr<BookmarkBarContextMenuController> context_menu_;
- DISALLOW_EVIL_CONSTRUCTORS(MenuRunner);
+ DISALLOW_COPY_AND_ASSIGN(MenuRunner);
};
// ButtonSeparatorView --------------------------------------------------------
@@ -585,7 +585,7 @@ class ButtonSeparatorView : public ChromeViews::View {
}
private:
- DISALLOW_EVIL_CONSTRUCTORS(ButtonSeparatorView);
+ DISALLOW_COPY_AND_ASSIGN(ButtonSeparatorView);
};
} // namespace
diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h
index d48780c..d9bd48b 100644
--- a/chrome/browser/views/bookmark_bar_view.h
+++ b/chrome/browser/views/bookmark_bar_view.h
@@ -135,6 +135,9 @@ class BookmarkBarView : public ChromeViews::View,
// True if we're supposed to draw the bookmarks bar in the new tab style.
bool IsNewTabPage();
+ // Whether or not we are animating.
+ bool IsAnimating() { return size_animation_->IsAnimating(); }
+
// SlideAnimationDelegate implementation.
void AnimationProgressed(const Animation* animation);
void AnimationEnded(const Animation* animation);
@@ -194,7 +197,7 @@ class BookmarkBarView : public ChromeViews::View,
BookmarkBarView* view_;
BookmarkBarNode* node_;
- DISALLOW_EVIL_CONSTRUCTORS(ShowFolderDropMenuTask);
+ DISALLOW_COPY_AND_ASSIGN(ShowFolderDropMenuTask);
};
// Creates recent bookmark button and when visible button as well as
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index ab02f4c..b35958c 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -188,6 +188,20 @@ void BrowserView::DestroyBrowser() {
frame_->DestroyBrowser();
}
+bool BrowserView::IsBookmarkBarVisible() const {
+ BookmarkBarView* bookmark_bar_view = frame_->GetBookmarkBarView();
+ if (!bookmark_bar_view)
+ return false;
+
+ if (bookmark_bar_view->IsNewTabPage() || bookmark_bar_view->IsAnimating())
+ return true;
+
+ CSize sz;
+ bookmark_bar_view->GetPreferredSize(&sz);
+ // 1 is the minimum in GetPreferredSize for the bookmark bar.
+ return sz.cy > 1;
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView, ChromeViews::ClientView overrides:
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index e8ffc03..5d48fc7 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -69,6 +69,7 @@ class BrowserView : public BrowserWindow,
virtual void ProfileChanged(Profile* profile);
virtual void FocusToolbar();
virtual void DestroyBrowser();
+ virtual bool IsBookmarkBarVisible() const;
/*
// Overridden from ChromeViews::ClientView:
diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc
index db3eedf..64c210d 100644
--- a/chrome/browser/views/frame/browser_view2.cc
+++ b/chrome/browser/views/frame/browser_view2.cc
@@ -440,6 +440,19 @@ void BrowserView2::FocusToolbar() {
void BrowserView2::DestroyBrowser() {
}
+bool BrowserView2::IsBookmarkBarVisible() const {
+ if (!bookmark_bar_view_.get())
+ return false;
+
+ if (bookmark_bar_view_->IsNewTabPage() || bookmark_bar_view_->IsAnimating())
+ return true;
+
+ CSize sz;
+ bookmark_bar_view_->GetPreferredSize(&sz);
+ // 1 is the minimum in GetPreferredSize for the bookmark bar.
+ return sz.cy > 1;
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView2, NotificationObserver implementation:
diff --git a/chrome/browser/views/frame/browser_view2.h b/chrome/browser/views/frame/browser_view2.h
index 40b4a4c..3f6d276 100644
--- a/chrome/browser/views/frame/browser_view2.h
+++ b/chrome/browser/views/frame/browser_view2.h
@@ -162,6 +162,7 @@ class BrowserView2 : public BrowserWindow,
virtual void UpdateToolbar(TabContents* contents, bool should_restore_state);
virtual void FocusToolbar();
virtual void DestroyBrowser();
+ virtual bool IsBookmarkBarVisible() const;
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/vista_frame.cc b/chrome/browser/vista_frame.cc
index b1b0ebb3..779ada5 100644
--- a/chrome/browser/vista_frame.cc
+++ b/chrome/browser/vista_frame.cc
@@ -649,6 +649,19 @@ void VistaFrame::ProfileChanged(Profile* profile) {
void VistaFrame::FocusToolbar() {
}
+bool VistaFrame::IsBookmarkBarVisible() const {
+ if (!bookmark_bar_view_.get())
+ return false;
+
+ if (bookmark_bar_view_->IsNewTabPage() || bookmark_bar_view_->IsAnimating())
+ return true;
+
+ CSize sz;
+ bookmark_bar_view_->GetPreferredSize(&sz);
+ // 1 is the minimum in GetPreferredSize for the bookmark bar.
+ return sz.cy > 1;
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// Events
diff --git a/chrome/browser/vista_frame.h b/chrome/browser/vista_frame.h
index 22656af..d913b6e 100644
--- a/chrome/browser/vista_frame.h
+++ b/chrome/browser/vista_frame.h
@@ -184,6 +184,7 @@ class VistaFrame : public BrowserWindow,
virtual void UpdateToolbar(TabContents* contents, bool should_restore_state);
virtual void ProfileChanged(Profile* profile);
virtual void FocusToolbar();
+ virtual bool IsBookmarkBarVisible() const;
////////////////////////////////////////////////////////////////////////////////
// ChromeViews::ViewContainer
diff --git a/chrome/browser/xp_frame.cc b/chrome/browser/xp_frame.cc
index fee785b..908f699 100644
--- a/chrome/browser/xp_frame.cc
+++ b/chrome/browser/xp_frame.cc
@@ -1890,6 +1890,19 @@ void XPFrame::FocusToolbar() {
browser_view_->FocusToolbar();
}
+bool XPFrame::IsBookmarkBarVisible() const {
+ if (!bookmark_bar_view_.get())
+ return false;
+
+ if (bookmark_bar_view_->IsNewTabPage() || bookmark_bar_view_->IsAnimating())
+ return true;
+
+ CSize sz;
+ bookmark_bar_view_->GetPreferredSize(&sz);
+ // 1 is the minimum in GetPreferredSize for the bookmark bar.
+ return sz.cy > 1;
+}
+
void XPFrame::MoveToFront(bool should_activate) {
int flags = SWP_NOMOVE | SWP_NOSIZE;
if (!should_activate) {
diff --git a/chrome/browser/xp_frame.h b/chrome/browser/xp_frame.h
index f7960b7..622a65f 100644
--- a/chrome/browser/xp_frame.h
+++ b/chrome/browser/xp_frame.h
@@ -93,6 +93,7 @@ class XPFrame : public BrowserWindow,
virtual void UpdateToolbar(TabContents* contents, bool should_restore_state);
virtual void ProfileChanged(Profile* profile);
virtual void FocusToolbar();
+ virtual bool IsBookmarkBarVisible() const;
//
// CWindowImpl event management magic. See atlcrack.h
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 57a4f3e..aed439e 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -752,5 +752,13 @@ IPC_BEGIN_MESSAGES(Automation, 0)
IPC_MESSAGE_ROUTED2(AutomationMsg_FindWindowLocationResponse,
int, /* x */
int /* y */)
+
+ // Is the Bookmark bar visible? The response will indicate whether it is
+ // visible or not and whether it is being animated into (or out of its place).
+ IPC_MESSAGE_ROUTED1(AutomationMsg_BookmarkBarVisibilityRequest,
+ int /* browser_handle */)
+ IPC_MESSAGE_ROUTED2(AutomationMsg_BookmarkBarVisibilityResponse,
+ bool, /* is_visible */
+ bool /* still_animating */)
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc
index 88c447d..425c6b5 100644
--- a/chrome/test/automation/browser_proxy.cc
+++ b/chrome/test/automation/browser_proxy.cc
@@ -347,3 +347,28 @@ bool BrowserProxy::RunCommand(int browser_command) const {
return false;
}
+bool BrowserProxy::GetBookmarkBarVisibility(bool* is_visible,
+ bool* is_animating) {
+ if (!is_valid())
+ return false;
+
+ if (!is_visible || !is_animating) {
+ NOTREACHED();
+ return false;
+ }
+
+ IPC::Message* response = NULL;
+ bool succeeded = sender_->SendAndWaitForResponse(
+ new AutomationMsg_BookmarkBarVisibilityRequest(0, handle_),
+ &response,
+ AutomationMsg_BookmarkBarVisibilityResponse::ID);
+
+ if (!succeeded)
+ return false;
+
+ void* iter = NULL;
+ response->ReadBool(&iter, is_visible);
+ response->ReadBool(&iter, is_animating);
+ delete response;
+ return true;
+}
diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h
index fdb7dc9..133a93d2 100644
--- a/chrome/test/automation/browser_proxy.h
+++ b/chrome/test/automation/browser_proxy.h
@@ -5,8 +5,8 @@
#ifndef CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_
#define CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_
-#include <string>
#include <windows.h>
+#include <string>
#include "chrome/test/automation/automation_handle_tracker.h"
class GURL;
@@ -139,8 +139,12 @@ class BrowserProxy : public AutomationResourceProxy {
// executed, false otherwise.
bool RunCommand(int browser_command) const;
+ // Returns whether the Bookmark bar is visible and whether we are animating
+ // it into position. Returns false on failure.
+ bool GetBookmarkBarVisibility(bool* is_visible, bool* is_animating);
+
private:
- DISALLOW_EVIL_CONSTRUCTORS(BrowserProxy);
+ DISALLOW_COPY_AND_ASSIGN(BrowserProxy);
};
#endif // CHROME_TEST_AUTOMATION_BROWSER_PROXY_H_
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index d2d619f..d6949e5d 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -376,6 +376,23 @@ bool UITest::WaitForFindWindowFullyVisible(TabProxy* tab) {
return false;
}
+bool UITest::WaitForBookmarkBarVisibilityChange(BrowserProxy* browser,
+ bool wait_for_open) {
+ const int kCycles = 20;
+ for (int i = 0; i < kCycles; i++) {
+ bool visible = false;
+ bool animating = true;
+ if (!browser->GetBookmarkBarVisibility(&visible, &animating))
+ return false; // Some error.
+ if (visible == wait_for_open && !animating)
+ return true; // Bookmark bar visibility change complete.
+
+ // Give it a chance to catch up.
+ Sleep(kWaitForActionMaxMsec / kCycles);
+ }
+ return false;
+}
+
GURL UITest::GetActiveTabURL() {
scoped_ptr<TabProxy> tab_proxy(GetActiveTab());
if (!tab_proxy.get())
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 20c8b1b..fe080a0 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -127,6 +127,12 @@ class UITest : public testing::Test {
// if the window doesn't appear within a specific time.
bool WaitForFindWindowFullyVisible(TabProxy* tab);
+ // Waits until the Bookmark bar has stopped animating and become fully visible
+ // (if |wait_for_open| is true) or fully hidden (if |wait_for_open| is false).
+ // This function can time out (in which case it returns false).
+ bool WaitForBookmarkBarVisibilityChange(BrowserProxy* browser,
+ bool wait_for_open);
+
// Closes the specified browser. Returns true if the browser was closed.
// This call is blocking. |application_closed| is set to true if this was
// the last browser window (and therefore as a result of it closing the