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

Side by Side Diff: ash/tooltips/tooltip_controller_unittest.cc

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase at r285842 Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/test/ash_test_base.cc ('k') | ash/wm/app_list_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shell.h" 5 #include "ash/shell.h"
6 #include "ash/test/ash_test_base.h" 6 #include "ash/test/ash_test_base.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/aura/env.h" 8 #include "ui/aura/env.h"
9 #include "ui/aura/test/event_generator.h"
10 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
11 #include "ui/aura/window_event_dispatcher.h" 10 #include "ui/aura/window_event_dispatcher.h"
12 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/events/test/event_generator.h"
13 #include "ui/gfx/font.h" 13 #include "ui/gfx/font.h"
14 #include "ui/gfx/point.h" 14 #include "ui/gfx/point.h"
15 #include "ui/views/corewm/tooltip_controller.h" 15 #include "ui/views/corewm/tooltip_controller.h"
16 #include "ui/views/corewm/tooltip_controller_test_helper.h" 16 #include "ui/views/corewm/tooltip_controller_test_helper.h"
17 #include "ui/views/view.h" 17 #include "ui/views/view.h"
18 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
19 #include "ui/wm/public/tooltip_client.h" 19 #include "ui/wm/public/tooltip_client.h"
20 20
21 using views::corewm::TooltipController; 21 using views::corewm::TooltipController;
22 using views::corewm::test::TooltipTestView; 22 using views::corewm::test::TooltipTestView;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 TEST_F(TooltipControllerTest, HideTooltipWhenCursorHidden) { 100 TEST_F(TooltipControllerTest, HideTooltipWhenCursorHidden) {
101 scoped_ptr<views::Widget> widget(CreateNewWidgetOn(0)); 101 scoped_ptr<views::Widget> widget(CreateNewWidgetOn(0));
102 TooltipTestView* view = new TooltipTestView; 102 TooltipTestView* view = new TooltipTestView;
103 AddViewToWidgetAndResize(widget.get(), view); 103 AddViewToWidgetAndResize(widget.get(), view);
104 view->set_tooltip_text(base::ASCIIToUTF16("Tooltip Text")); 104 view->set_tooltip_text(base::ASCIIToUTF16("Tooltip Text"));
105 EXPECT_EQ(base::string16(), helper_->GetTooltipText()); 105 EXPECT_EQ(base::string16(), helper_->GetTooltipText());
106 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); 106 EXPECT_EQ(NULL, helper_->GetTooltipWindow());
107 107
108 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 108 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
109 generator.MoveMouseRelativeTo(widget->GetNativeView(), 109 generator.MoveMouseRelativeTo(widget->GetNativeView(),
110 view->bounds().CenterPoint()); 110 view->bounds().CenterPoint());
111 base::string16 expected_tooltip = base::ASCIIToUTF16("Tooltip Text"); 111 base::string16 expected_tooltip = base::ASCIIToUTF16("Tooltip Text");
112 112
113 // Fire tooltip timer so tooltip becomes visible. 113 // Fire tooltip timer so tooltip becomes visible.
114 helper_->FireTooltipTimer(); 114 helper_->FireTooltipTimer();
115 EXPECT_TRUE(helper_->IsTooltipVisible()); 115 EXPECT_TRUE(helper_->IsTooltipVisible());
116 116
117 // Hide the cursor and check again. 117 // Hide the cursor and check again.
118 ash::Shell::GetInstance()->cursor_manager()->DisableMouseEvents(); 118 ash::Shell::GetInstance()->cursor_manager()->DisableMouseEvents();
(...skipping 22 matching lines...) Expand all
141 EXPECT_EQ(widget1->GetNativeView()->GetRootWindow(), root_windows[0]); 141 EXPECT_EQ(widget1->GetNativeView()->GetRootWindow(), root_windows[0]);
142 142
143 scoped_ptr<views::Widget> widget2(CreateNewWidgetWithBoundsOn( 143 scoped_ptr<views::Widget> widget2(CreateNewWidgetWithBoundsOn(
144 1, gfx::Rect(1200, 10, 100, 100))); 144 1, gfx::Rect(1200, 10, 100, 100)));
145 TooltipTestView* view2 = new TooltipTestView; 145 TooltipTestView* view2 = new TooltipTestView;
146 AddViewToWidgetAndResize(widget2.get(), view2); 146 AddViewToWidgetAndResize(widget2.get(), view2);
147 view2->set_tooltip_text(base::ASCIIToUTF16("Tooltip Text for view 2")); 147 view2->set_tooltip_text(base::ASCIIToUTF16("Tooltip Text for view 2"));
148 EXPECT_EQ(widget2->GetNativeView()->GetRootWindow(), root_windows[1]); 148 EXPECT_EQ(widget2->GetNativeView()->GetRootWindow(), root_windows[1]);
149 149
150 // Show tooltip on second display. 150 // Show tooltip on second display.
151 aura::test::EventGenerator generator(root_windows[1]); 151 ui::test::EventGenerator generator(root_windows[1]);
152 generator.MoveMouseRelativeTo(widget2->GetNativeView(), 152 generator.MoveMouseRelativeTo(widget2->GetNativeView(),
153 view2->bounds().CenterPoint()); 153 view2->bounds().CenterPoint());
154 helper_->FireTooltipTimer(); 154 helper_->FireTooltipTimer();
155 EXPECT_TRUE(helper_->IsTooltipVisible()); 155 EXPECT_TRUE(helper_->IsTooltipVisible());
156 156
157 // Get rid of secondary display. This destroy's the tooltip's aura window. If 157 // Get rid of secondary display. This destroy's the tooltip's aura window. If
158 // we have handled this case, we will not crash in the following statement. 158 // we have handled this case, we will not crash in the following statement.
159 UpdateDisplay("1000x600"); 159 UpdateDisplay("1000x600");
160 #if !defined(OS_WIN) 160 #if !defined(OS_WIN)
161 // TODO(cpu): Detangle the window destruction notification. Currently 161 // TODO(cpu): Detangle the window destruction notification. Currently
162 // the TooltipController::OnWindowDestroyed is not being called then the 162 // the TooltipController::OnWindowDestroyed is not being called then the
163 // display is torn down so the tooltip is is still there. 163 // display is torn down so the tooltip is is still there.
164 EXPECT_FALSE(helper_->IsTooltipVisible()); 164 EXPECT_FALSE(helper_->IsTooltipVisible());
165 #endif 165 #endif
166 EXPECT_EQ(widget2->GetNativeView()->GetRootWindow(), root_windows[0]); 166 EXPECT_EQ(widget2->GetNativeView()->GetRootWindow(), root_windows[0]);
167 167
168 // The tooltip should create a new aura window for itself, so we should still 168 // The tooltip should create a new aura window for itself, so we should still
169 // be able to show tooltips on the primary display. 169 // be able to show tooltips on the primary display.
170 aura::test::EventGenerator generator1(root_windows[0]); 170 ui::test::EventGenerator generator1(root_windows[0]);
171 generator1.MoveMouseRelativeTo(widget1->GetNativeView(), 171 generator1.MoveMouseRelativeTo(widget1->GetNativeView(),
172 view1->bounds().CenterPoint()); 172 view1->bounds().CenterPoint());
173 helper_->FireTooltipTimer(); 173 helper_->FireTooltipTimer();
174 EXPECT_TRUE(helper_->IsTooltipVisible()); 174 EXPECT_TRUE(helper_->IsTooltipVisible());
175 } 175 }
176 176
177 } // namespace test 177 } // namespace test
178 } // namespace ash 178 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/ash_test_base.cc ('k') | ash/wm/app_list_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698