diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 16:40:57 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 16:40:57 +0000 |
commit | 4d0cd7ce8c91a2c0157ecf9e0a5153712ff43d10 (patch) | |
tree | eff001f3129de849da6e8658d45072c2ccf494f6 /chrome/browser/views/bookmark_bar_view.cc | |
parent | 50f2f629605750f033ef3c766498e42783a785f6 (diff) | |
download | chromium_src-4d0cd7ce8c91a2c0157ecf9e0a5153712ff43d10.zip chromium_src-4d0cd7ce8c91a2c0157ecf9e0a5153712ff43d10.tar.gz chromium_src-4d0cd7ce8c91a2c0157ecf9e0a5153712ff43d10.tar.bz2 |
A set of tests to exercise chrome menus as well as parts of bookmark
bar view. These are disabled until we straighten out the buildbot that
is always logged in.
BUG=1318922
TEST=this is just a bunch of tests.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/bookmark_bar_view.cc')
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.cc | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index e9dbb11..6579a0f 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -235,7 +235,13 @@ class BookmarkButton : public ChromeViews::TextButton { url_(url), profile_(profile) { show_animation_.reset(new SlideAnimation(this)); - show_animation_->Show(); + if (BookmarkBarView::testing_) { + // For some reason during testing the events generated by animating + // throw off the test. So, don't animate while testing. + show_animation_->Reset(1); + } else { + show_animation_->Show(); + } } bool GetTooltipText(int x, int y, std::wstring* tooltip) { @@ -507,6 +513,8 @@ class BookmarkNodeMenuController : public ChromeViews::MenuDelegate, menu_.Cancel(); } + MenuItemView* menu() { return &menu_; } + private: // Menu::Delegate method. Does the appropriate operation based on chosen // menu item. @@ -750,6 +758,12 @@ class MenuRunner : public ChromeViews::MenuDelegate, menu_.Cancel(); } + MenuItemView* menu() { return &menu_; } + + MenuItemView* context_menu() { + return context_menu_.get() ? context_menu_->menu() : NULL; + } + private: // Creates an entry in menu for each child node of parent starting at // start_child_index, recursively invoking this for any star groups. @@ -980,6 +994,9 @@ class ButtonSeparatorView : public ChromeViews::View { // static const int BookmarkBarView::kMaxButtonWidth = 150; +// static +bool BookmarkBarView::testing_ = false; + // Returns the bitmap to use for starred groups. static const SkBitmap& GetGroupIcon() { if (!kFolderIcon) { @@ -1444,24 +1461,38 @@ bool BookmarkBarView::IsAlwaysShown() { } bool BookmarkBarView::IsNewTabPage() { - DCHECK(browser_); - - if (browser_->GetSelectedTabContents()) { - return browser_->GetSelectedTabContents()->IsBookmarkBarAlwaysVisible(); - } - - return false; + return (browser_ && browser_->GetSelectedTabContents() && + browser_->GetSelectedTabContents()->IsBookmarkBarAlwaysVisible()); } void BookmarkBarView::AnimationProgressed(const Animation* animation) { - browser_->ToolbarSizeChanged(NULL, true); + if (browser_) + browser_->ToolbarSizeChanged(NULL, true); } void BookmarkBarView::AnimationEnded(const Animation* animation) { - browser_->ToolbarSizeChanged(NULL, false); + if (browser_) + browser_->ToolbarSizeChanged(NULL, false); SchedulePaint(); } +ChromeViews::TextButton* BookmarkBarView::GetBookmarkButton(int index) { + DCHECK(index >= 0 && index < GetBookmarkButtonCount()); + return static_cast<ChromeViews::TextButton*>(GetChildViewAt(index)); +} + +ChromeViews::MenuItemView* BookmarkBarView::GetMenu() { + return menu_runner_.get() ? menu_runner_->menu() : NULL; +} + +ChromeViews::MenuItemView* BookmarkBarView::GetContextMenu() { + return menu_runner_.get() ? menu_runner_->context_menu() : NULL; +} + +ChromeViews::MenuItemView* BookmarkBarView::GetDropMenu() { + return drop_menu_runner_.get() ? drop_menu_runner_->menu() : NULL; +} + void BookmarkBarView::Init() { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -1525,11 +1556,6 @@ int BookmarkBarView::GetBookmarkButtonCount() { return GetChildViewCount() - 4; } -ChromeViews::TextButton* BookmarkBarView::GetBookmarkButton(int index) { - DCHECK(index >= 0 && index < GetBookmarkButtonCount()); - return static_cast<ChromeViews::TextButton*>(GetChildViewAt(index)); -} - void BookmarkBarView::Loaded(BookmarkBarModel* model) { BookmarkBarNode* node = model_->GetBookmarkBarNode(); DCHECK(node && model_->other_node()); @@ -1722,8 +1748,7 @@ void BookmarkBarView::RunMenu(ChromeViews::View* view, CPoint screen_loc(x, 0); View::ConvertPointToScreen(this, &screen_loc); menu_runner_.reset(new MenuRunner(this, node, start_index)); - HWND parent_hwnd = reinterpret_cast<HWND>( - browser_->window()->GetPlatformID()); + HWND parent_hwnd = GetViewContainer()->GetHWND(); menu_runner_->RunMenuAt(parent_hwnd, gfx::Rect(screen_loc.x, screen_loc.y, view->GetWidth(), height), @@ -1914,6 +1939,12 @@ void BookmarkBarView::StopShowFolderDropMenuTimer() { } void BookmarkBarView::StartShowFolderDropMenuTimer(BookmarkBarNode* node) { + if (testing_) { + // So that tests can run as fast as possible disable the delay during + // testing. + ShowDropFolderForNode(node); + return; + } DCHECK(!show_folder_drop_menu_task_); show_folder_drop_menu_task_ = new ShowFolderDropMenuTask(this, node); static DWORD delay = 0; |