| Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
|
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
|
| index abafb25727564a90159834dcef9f2f7dbd60dbf2..73843e4348828b8cc4225a6756bfc6bba0ab81ab 100644
|
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
|
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
|
| @@ -1584,3 +1584,107 @@ class BookmarkBarViewTest19 : public BookmarkBarViewEventTestBase {
|
| };
|
|
|
| VIEW_TEST(BookmarkBarViewTest19, BookmarkBarViewTest19_SiblingMenu)
|
| +
|
| +#if !(defined(OS_WIN) && defined(USE_AURA))
|
| +
|
| +// Verify that when clicking a mouse button outside a context menu,
|
| +// the context menu is dismissed *and* the underlying view receives
|
| +// the the mouse event (due to event reposting).
|
| +class BookmarkBarViewTest20 : public BookmarkBarViewEventTestBase {
|
| + public:
|
| + BookmarkBarViewTest20() : test_view_(new TestViewForMenuExit) {}
|
| +
|
| + protected:
|
| + virtual void DoTestOnMessageLoop() OVERRIDE {
|
| + // Add |test_view_| next to |bb_view_|.
|
| + views::View* parent = bb_view_->parent();
|
| + views::View* container_view = new ContainerViewForMenuExit;
|
| + container_view->AddChildView(bb_view_.get());
|
| + container_view->AddChildView(test_view_);
|
| + parent->AddChildView(container_view);
|
| + parent->Layout();
|
| +
|
| + ASSERT_EQ(test_view_->press_count(), 0);
|
| +
|
| + // Move the mouse to the Test View and press the left mouse button.
|
| + ui_test_utils::MoveMouseToCenterAndPress(
|
| + test_view_, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
|
| + CreateEventTask(this, &BookmarkBarViewTest20::Step1));
|
| + }
|
| +
|
| + private:
|
| + void Step1() {
|
| + ASSERT_EQ(test_view_->press_count(), 1);
|
| + ASSERT_TRUE(bb_view_->GetMenu() == NULL);
|
| +
|
| + // Move the mouse to the first folder on the bookmark bar and press the
|
| + // left mouse button.
|
| + views::TextButton* button = GetBookmarkButton(0);
|
| + ui_test_utils::MoveMouseToCenterAndPress(
|
| + button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
|
| + CreateEventTask(this, &BookmarkBarViewTest20::Step2));
|
| + }
|
| +
|
| + void Step2() {
|
| + ASSERT_EQ(test_view_->press_count(), 1);
|
| + views::MenuItemView* menu = bb_view_->GetMenu();
|
| + ASSERT_TRUE(menu != NULL);
|
| + ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
|
| +
|
| + // Move the mouse to the Test View and press the left mouse button.
|
| + // The context menu will consume the event and exit. Thereafter,
|
| + // the event is reposted and delivered to the Test View which
|
| + // increases its press-count.
|
| + ui_test_utils::MoveMouseToCenterAndPress(
|
| + test_view_, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP,
|
| + CreateEventTask(this, &BookmarkBarViewTest20::Step3));
|
| + }
|
| +
|
| + void Step3() {
|
| + ASSERT_EQ(test_view_->press_count(), 2);
|
| + ASSERT_TRUE(bb_view_->GetMenu() == NULL);
|
| + Done();
|
| + }
|
| +
|
| + class ContainerViewForMenuExit : public views::View {
|
| + public:
|
| + ContainerViewForMenuExit() {
|
| + }
|
| +
|
| + virtual void Layout() OVERRIDE {
|
| + DCHECK_EQ(2, child_count());
|
| + views::View* bb_view = child_at(0);
|
| + views::View* test_view = child_at(1);
|
| + const int width = bb_view->width();
|
| + const int height = bb_view->height();
|
| + bb_view->SetBounds(0,0, width - 22, height);
|
| + test_view->SetBounds(width - 20, 0, 20, height);
|
| + }
|
| +
|
| + private:
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ContainerViewForMenuExit);
|
| + };
|
| +
|
| + class TestViewForMenuExit : public views::View {
|
| + public:
|
| + TestViewForMenuExit() : press_count_(0) {
|
| + }
|
| + virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE {
|
| + ++press_count_;
|
| + return true;
|
| + }
|
| + int press_count() const { return press_count_; }
|
| +
|
| + private:
|
| + int press_count_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TestViewForMenuExit);
|
| + };
|
| +
|
| + TestViewForMenuExit* test_view_;
|
| +};
|
| +
|
| +VIEW_TEST(BookmarkBarViewTest20, ContextMenuExitTest)
|
| +
|
| +#endif // !(defined(OS_WIN) && defined(USE_AURA))
|
|
|