1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/location_bar/star_view.h"
7 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
8 #include "chrome/browser/ui/views/frame/browser_view.h"
9 #include "chrome/browser/ui/views/toolbar_view.h"
10 #include "chrome/test/base/in_process_browser_test.h"
14 typedef InProcessBrowserTest StarViewTest;
16 // Verify that clicking the bookmark star a second time hides the bookmark
18 #if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)
19 #define MAYBE_HideOnSecondClick DISABLED_HideOnSecondClick
21 #define MAYBE_HideOnSecondClick HideOnSecondClick
23 IN_PROC_BROWSER_TEST_F(StarViewTest, MAYBE_HideOnSecondClick) {
24 BrowserView* browser_view = reinterpret_cast<BrowserView*>(
26 views::ImageView* star_view =
27 browser_view->GetToolbarView()->location_bar()->star_view();
29 ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
30 ui::EF_LEFT_MOUSE_BUTTON);
31 ui::MouseEvent released_event(ui::ET_MOUSE_RELEASED, gfx::Point(),
32 gfx::Point(), ui::EF_LEFT_MOUSE_BUTTON);
34 // Verify that clicking once shows the bookmark bubble.
35 EXPECT_FALSE(BookmarkBubbleView::IsShowing());
36 star_view->OnMousePressed(pressed_event);
37 EXPECT_FALSE(BookmarkBubbleView::IsShowing());
38 star_view->OnMouseReleased(released_event);
39 EXPECT_TRUE(BookmarkBubbleView::IsShowing());
41 // Verify that clicking again doesn't reshow it.
42 star_view->OnMousePressed(pressed_event);
43 // Hide the bubble manually. In the browser this would normally happen during
44 // the event processing.
45 BookmarkBubbleView::Hide();
46 base::MessageLoop::current()->RunUntilIdle();
47 EXPECT_FALSE(BookmarkBubbleView::IsShowing());
48 star_view->OnMouseReleased(released_event);
49 EXPECT_FALSE(BookmarkBubbleView::IsShowing());