star_view_browsertest.cc revision d0247b1b59f9c528cb6df88b4f2b9afaf80d181e
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.
4
5#include "chrome/browser/ui/views/location_bar/star_view.h"
6
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"
11
12namespace {
13
14typedef InProcessBrowserTest StarViewTest;
15
16// Verify that clicking the bookmark star a second time hides the bookmark
17// bubble.
18#if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)
19#define MAYBE_HideOnSecondClick DISABLED_HideOnSecondClick
20#else
21#define MAYBE_HideOnSecondClick HideOnSecondClick
22#endif
23IN_PROC_BROWSER_TEST_F(StarViewTest, MAYBE_HideOnSecondClick) {
24  BrowserView* browser_view = reinterpret_cast<BrowserView*>(
25      browser()->window());
26  views::ImageView* star_view =
27      browser_view->GetToolbarView()->location_bar()->star_view();
28
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);
33
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());
40
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());
50}
51
52}  // namespace
53