summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 21:49:45 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 21:49:45 +0000
commitc9deb2959225d40aaafdc8c5e93ccfff18fb6329 (patch)
tree654f7617372c92dd7bddb7e030dfba3b8772b5c1 /ash
parent1d7c7bc579fd500913b71828c23e57414fb21b4e (diff)
downloadchromium_src-c9deb2959225d40aaafdc8c5e93ccfff18fb6329.zip
chromium_src-c9deb2959225d40aaafdc8c5e93ccfff18fb6329.tar.gz
chromium_src-c9deb2959225d40aaafdc8c5e93ccfff18fb6329.tar.bz2
Revert 206150 "Remove tooltip bubble when mouse moves from launc..."
> Remove tooltip bubble when mouse moves from launcher item to it. > > Fix was easy (removing code!), unit test took a while. > > BUG=247884 > TEST=unittest > > Review URL: https://chromiumcodereview.appspot.com/16845003 TBR=skuhne@chromium.org Review URL: https://codereview.chromium.org/17009005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206165 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/launcher/launcher_tooltip_manager.cc34
-rw-r--r--ash/launcher/launcher_tooltip_manager.h4
-rw-r--r--ash/launcher/launcher_view_unittest.cc42
3 files changed, 16 insertions, 64 deletions
diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc
index 3fa02b4..3313790 100644
--- a/ash/launcher/launcher_tooltip_manager.cc
+++ b/ash/launcher/launcher_tooltip_manager.cc
@@ -226,7 +226,14 @@ void LauncherTooltipManager::ResetTimer() {
if (shelf_layout_manager_ && !shelf_layout_manager_->IsVisible())
return;
- CreateTimer(kTooltipAppearanceDelay);
+ base::OneShotTimer<LauncherTooltipManager>* new_timer =
+ new base::OneShotTimer<LauncherTooltipManager>();
+ new_timer->Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kTooltipAppearanceDelay),
+ this,
+ &LauncherTooltipManager::ShowInternal);
+ timer_.reset(new_timer);
}
void LauncherTooltipManager::StopTimer() {
@@ -240,13 +247,9 @@ bool LauncherTooltipManager::IsVisible() {
return widget_ && widget_->IsVisible();
}
-void LauncherTooltipManager::CreateZeroDelayTimerForTest() {
- CreateTimer(0);
-}
-
void LauncherTooltipManager::OnMouseEvent(ui::MouseEvent* event) {
- DCHECK(event);
DCHECK(event->target());
+ DCHECK(event);
if (!widget_ || !widget_->IsVisible())
return;
@@ -264,7 +267,13 @@ void LauncherTooltipManager::OnMouseEvent(ui::MouseEvent* event) {
target, launcher_view_->GetWidget()->GetNativeWindow(),
&location_in_launcher_view);
- if (launcher_view_->ShouldHideTooltip(location_in_launcher_view)) {
+ gfx::Point location_on_screen = event->location();
+ aura::Window::ConvertPointToTarget(
+ target, target->GetRootWindow(), &location_on_screen);
+ gfx::Rect bubble_rect = widget_->GetWindowBoundsInScreen();
+
+ if (launcher_view_->ShouldHideTooltip(location_in_launcher_view) &&
+ !bubble_rect.Contains(location_on_screen)) {
// Because this mouse event may arrive to |view_|, here we just schedule
// the closing event rather than directly calling Close().
CloseSoon();
@@ -358,16 +367,5 @@ void LauncherTooltipManager::CreateBubble(views::View* anchor,
native_view, views::corewm::ANIMATE_HIDE);
}
-void LauncherTooltipManager::CreateTimer(int delay_in_ms) {
- base::OneShotTimer<LauncherTooltipManager>* new_timer =
- new base::OneShotTimer<LauncherTooltipManager>();
- new_timer->Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(delay_in_ms),
- this,
- &LauncherTooltipManager::ShowInternal);
- timer_.reset(new base::OneShotTimer<LauncherTooltipManager>());
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/launcher/launcher_tooltip_manager.h b/ash/launcher/launcher_tooltip_manager.h
index a4cacd2..852c30cb 100644
--- a/ash/launcher/launcher_tooltip_manager.h
+++ b/ash/launcher/launcher_tooltip_manager.h
@@ -73,9 +73,6 @@ class ASH_EXPORT LauncherTooltipManager : public ui::EventHandler,
// Returns true if the tooltip is currently visible.
bool IsVisible();
- // Create an instant timer for test purposes.
- void CreateZeroDelayTimerForTest();
-
protected:
// ui::EventHandler overrides:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
@@ -98,7 +95,6 @@ protected:
void CloseSoon();
void ShowInternal();
void CreateBubble(views::View* anchor, const base::string16& text);
- void CreateTimer(int delay_in_ms);
LauncherTooltipBubble* view_;
views::Widget* widget_;
diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc
index 6ca05b0..3297f04 100644
--- a/ash/launcher/launcher_view_unittest.cc
+++ b/ash/launcher/launcher_view_unittest.cc
@@ -27,7 +27,6 @@
#include "grit/ash_resources.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/aura_test_base.h"
-#include "ui/aura/test/event_generator.h"
#include "ui/aura/window.h"
#include "ui/base/events/event.h"
#include "ui/base/events/event_constants.h"
@@ -920,47 +919,6 @@ TEST_F(LauncherViewTest, ShouldHideTooltipWithAppListWindowTest) {
app_list_button->GetMirroredBounds().CenterPoint()));
}
-// Test that by moving the mouse cursor off the button onto the bubble it closes
-// the bubble.
-TEST_F(LauncherViewTest, ShouldHideTooltipWhenHoveringOnTooltip) {
- internal::LauncherTooltipManager* tooltip_manager =
- launcher_view_->tooltip_manager();
- tooltip_manager->CreateZeroDelayTimerForTest();
- aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
-
- // Move the mouse off any item and check that no tooltip is shown.
- generator.MoveMouseTo(gfx::Point(0, 0));
- EXPECT_FALSE(tooltip_manager->IsVisible());
-
- // Move the mouse over the button and check that it is visible.
- views::View* app_list_button = launcher_view_->GetAppListButtonView();
- gfx::Rect bounds = app_list_button->GetBoundsInScreen();
- generator.MoveMouseTo(bounds.CenterPoint());
- // Wait for the timer to go off.
- RunAllPendingInMessageLoop();
- EXPECT_TRUE(tooltip_manager->IsVisible());
-
- // Move the mouse cursor slightly to the right of the item. The tooltip should
- // stay open.
- generator.MoveMouseBy(-(bounds.width() / 2 + 5), 0);
- // Make sure there is no delayed close.
- RunAllPendingInMessageLoop();
- EXPECT_TRUE(tooltip_manager->IsVisible());
-
- // Move back - it should still stay open.
- generator.MoveMouseBy(bounds.width() / 2 + 5, 0);
- // Make sure there is no delayed close.
- RunAllPendingInMessageLoop();
- EXPECT_TRUE(tooltip_manager->IsVisible());
-
- // Now move the mouse cursor slightly above the item - so that it is over the
- // tooltip bubble. Now it should disappear.
- generator.MoveMouseBy(0, -(bounds.height() / 2 + 5));
- // Wait until the delayed close kicked in.
- RunAllPendingInMessageLoop();
- EXPECT_FALSE(tooltip_manager->IsVisible());
-}
-
// Resizing launcher view while an add animation without fade-in is running,
// which happens when overflow happens. App list button should end up in its
// new ideal bounds.