Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: ui/views/corewm/tooltip_controller_unittest.cc

Issue 213833018: Aura tooltips do not move on mouse move in case of many neighboring views with the same label (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Write unit test for the case when a tooltip moves from one view to another with the same tooltip bu… Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/corewm/tooltip_controller_unittest.cc
diff --git a/ui/views/corewm/tooltip_controller_unittest.cc b/ui/views/corewm/tooltip_controller_unittest.cc
index 4764fc7115e675f398c0832b629b287897846388..9b60cb819891e9ad9eb62b85b011c77b9e6222f4 100644
--- a/ui/views/corewm/tooltip_controller_unittest.cc
+++ b/ui/views/corewm/tooltip_controller_unittest.cc
@@ -391,6 +391,42 @@ TEST_F(TooltipControllerTest, ReshowOnClickAfterEnterExit) {
EXPECT_EQ(v1_tt, helper_->GetTooltipText());
}
+TEST_F(TooltipControllerTest, TooltipPositionChangesOnTwoViewsWithSameLabel) {
+ // Owned by |view_|.
+ TooltipTestView* v1 = new TooltipTestView;
+ TooltipTestView* v2 = new TooltipTestView;
+ view_->AddChildView(v1);
+ view_->AddChildView(v2);
+ const base::string16 reference_string(base::ASCIIToUTF16(
+ "Identical Tooltip Text"));
+ v1->set_tooltip_text(reference_string);
+ v2->set_tooltip_text(reference_string);
+
+ gfx::Rect view_bounds(view_->GetLocalBounds());
+ view_bounds.set_height(view_bounds.height() / 2);
+ v1->SetBoundsRect(view_bounds);
+ view_bounds.set_y(view_bounds.height());
+ v2->SetBoundsRect(view_bounds);
+
+ gfx::Point center = v1->bounds().CenterPoint();
+ generator_->MoveMouseRelativeTo(GetWindow(), center);
+ helper_->FireTooltipTimer();
+ EXPECT_TRUE(helper_->IsTooltipVisible());
+ EXPECT_EQ(reference_string, helper_->GetTooltipText());
+ gfx::Point tooltip_bounds1 = helper_->GetTooltipPosition();
+
+ center = v2->bounds().CenterPoint();
+ generator_->MoveMouseRelativeTo(GetWindow(), center);
+ helper_->FireTooltipTimer();
+ EXPECT_TRUE(helper_->IsTooltipVisible());
+ EXPECT_EQ(reference_string, helper_->GetTooltipText());
+ gfx::Point tooltip_bounds2 = helper_->GetTooltipPosition();
+
+ EXPECT_NE(tooltip_bounds1, gfx::Point());
+ EXPECT_NE(tooltip_bounds2, gfx::Point());
+ EXPECT_NE(tooltip_bounds1, tooltip_bounds2);
+}
+
namespace {
// Returns the index of |window| in its parent's children.
@@ -679,6 +715,9 @@ class TestTooltip : public Tooltip {
virtual bool IsVisible() OVERRIDE {
return is_visible_;
}
+ virtual gfx::Point GetTooltipPosition() OVERRIDE {
+ return gfx::Point();
+ }
private:
bool is_visible_;

Powered by Google App Engine
This is Rietveld 408576698