diff options
author | simon.hong81@gmail.com <simon.hong81@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-04 17:05:40 +0000 |
---|---|---|
committer | simon.hong81@gmail.com <simon.hong81@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-04 17:05:40 +0000 |
commit | 84be8c1b5550ed9af31fafbbc647e4633c4a18c1 (patch) | |
tree | 42f5b4e391f7065ecceb008810df51bacd907a25 /ash/launcher | |
parent | 87db77a8d9edbad179c889200b6701a6b133e515 (diff) | |
download | chromium_src-84be8c1b5550ed9af31fafbbc647e4633c4a18c1.zip chromium_src-84be8c1b5550ed9af31fafbbc647e4633c4a18c1.tar.gz chromium_src-84be8c1b5550ed9af31fafbbc647e4633c4a18c1.tar.bz2 |
[ash] Hide tooltip when mouse button is pressed
Hiding tooltip when mouse button is pressed was done in launcher view.
It looks more better when tooltip manager handles.
R=skuhne@chromium.org
BUG=NONE
TEST=ash_unittests
Review URL: https://chromiumcodereview.appspot.com/23536012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221208 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/launcher')
-rw-r--r-- | ash/launcher/launcher_tooltip_manager.cc | 6 | ||||
-rw-r--r-- | ash/launcher/launcher_tooltip_manager_unittest.cc | 37 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 5 |
3 files changed, 42 insertions, 6 deletions
diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc index 2d92e0f..901330a 100644 --- a/ash/launcher/launcher_tooltip_manager.cc +++ b/ash/launcher/launcher_tooltip_manager.cc @@ -256,6 +256,12 @@ void LauncherTooltipManager::OnMouseEvent(ui::MouseEvent* event) { DCHECK(view_); DCHECK(launcher_view_); + // Pressing the mouse button anywhere should close the tooltip. + if (event->type() == ui::ET_MOUSE_PRESSED) { + CloseSoon(); + return; + } + aura::Window* target = static_cast<aura::Window*>(event->target()); if (widget_->GetNativeWindow()->GetRootWindow() != target->GetRootWindow()) { CloseSoon(); diff --git a/ash/launcher/launcher_tooltip_manager_unittest.cc b/ash/launcher/launcher_tooltip_manager_unittest.cc index 5df58a6..d222e7a 100644 --- a/ash/launcher/launcher_tooltip_manager_unittest.cc +++ b/ash/launcher/launcher_tooltip_manager_unittest.cc @@ -217,7 +217,7 @@ TEST_F(LauncherTooltipManagerTest, ShouldHideForEvents) { EXPECT_FALSE(TooltipIsVisible()); } -TEST_F(LauncherTooltipManagerTest, HideForMouseEvent) { +TEST_F(LauncherTooltipManagerTest, HideForMouseMoveEvent) { ShowImmediately(); ASSERT_TRUE(TooltipIsVisible()); @@ -245,5 +245,40 @@ TEST_F(LauncherTooltipManagerTest, HideForMouseEvent) { EXPECT_FALSE(TooltipIsVisible()); } +//Checks that tooltip is hidden when mouse is pressed in anywhere. +TEST_F(LauncherTooltipManagerTest, HideForMouseClickEvent) { + ShowImmediately(); + ASSERT_TRUE(TooltipIsVisible()); + + aura::RootWindow* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); + ui::EventHandler* event_handler = GetEventHandler(); + + gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); + ASSERT_FALSE(tooltip_rect.IsEmpty()); + + // Should hide if the mouse is pressed in the tooltip. + ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(), + tooltip_rect.CenterPoint(), ui::EF_NONE); + + SetEventTarget(root_window, &mouse_event); + event_handler->OnMouseEvent(&mouse_event); + EXPECT_FALSE(mouse_event.handled()); + RunAllPendingInMessageLoop(); + EXPECT_FALSE(TooltipIsVisible()); + + // Should hide if the mouse is pressed outside of the tooltip. + ShowImmediately(); + ASSERT_TRUE(TooltipIsVisible()); + + ui::LocatedEvent::TestApi test_api(&mouse_event); + test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); + + SetEventTarget(root_window, &mouse_event); + event_handler->OnMouseEvent(&mouse_event); + EXPECT_FALSE(mouse_event.handled()); + RunAllPendingInMessageLoop(); + EXPECT_FALSE(TooltipIsVisible()); +} + } // namespace test } // namespace ash diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index 893edcc..ce43c60 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -1517,7 +1517,6 @@ void LauncherView::PointerPressedOnButton(views::View* view, if (drag_view_) return; - tooltip_->Close(); int index = view_model_->GetIndexOfView(view); if (index == -1) return; @@ -1605,8 +1604,6 @@ void LauncherView::ButtonPressed(views::Button* sender, if (dragging()) return; - tooltip_->Close(); - if (sender == overflow_button_) { ToggleOverflowBubble(); return; @@ -1697,8 +1694,6 @@ void LauncherView::ShowContextMenuForView(views::View* source, view_index = -1; } - tooltip_->Close(); - if (view_index == -1) { Shell::GetInstance()->ShowContextMenu(point, source_type); return; |