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

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

Issue 11065050: The center of a rect is x+width/2, y+height/2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | « no previous file | ui/aura/gestures/gesture_recognizer_unittest.cc » ('j') | ui/gfx/rect_unittest.cc » ('J')
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/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 #include "ash/shell.h" 6 #include "ash/shell.h"
7 #include "ash/test/ash_test_base.h" 7 #include "ash/test/ash_test_base.h"
8 #include "ash/tooltips/tooltip_controller.h" 8 #include "ash/tooltips/tooltip_controller.h"
9 #include "ash/wm/cursor_manager.h" 9 #include "ash/wm/cursor_manager.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 AddViewToWidgetAndResize(widget.get(), view2); 187 AddViewToWidgetAndResize(widget.get(), view2);
188 188
189 aura::Window* window = widget->GetNativeView(); 189 aura::Window* window = widget->GetNativeView();
190 190
191 // Fire tooltip timer so tooltip becomes visible. 191 // Fire tooltip timer so tooltip becomes visible.
192 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 192 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
193 generator.MoveMouseRelativeTo(window, 193 generator.MoveMouseRelativeTo(window,
194 view1->bounds().CenterPoint()); 194 view1->bounds().CenterPoint());
195 FireTooltipTimer(); 195 FireTooltipTimer();
196 EXPECT_TRUE(IsTooltipVisible()); 196 EXPECT_TRUE(IsTooltipVisible());
197 for (int i = 0; i < 50; i++) { 197 for (int i = 0; i < 49; ++i) {
198 generator.MoveMouseBy(1, 0); 198 generator.MoveMouseBy(1, 0);
199 EXPECT_TRUE(IsTooltipVisible()); 199 EXPECT_TRUE(IsTooltipVisible());
200 EXPECT_EQ(window, 200 EXPECT_EQ(window,
201 Shell::GetPrimaryRootWindow()->GetEventHandlerForPoint( 201 Shell::GetPrimaryRootWindow()->GetEventHandlerForPoint(
202 generator.current_location())); 202 generator.current_location()));
203 string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); 203 string16 expected_tooltip = ASCIIToUTF16("Tooltip Text");
204 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); 204 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window));
205 EXPECT_EQ(expected_tooltip, GetTooltipText()); 205 EXPECT_EQ(expected_tooltip, GetTooltipText());
206 EXPECT_EQ(window, GetTooltipWindow()); 206 EXPECT_EQ(window, GetTooltipWindow());
207 } 207 }
208 for (int i = 0; i < 50; i++) { 208 for (int i = 0; i < 49; ++i) {
209 generator.MoveMouseBy(1, 0); 209 generator.MoveMouseBy(1, 0);
210 EXPECT_FALSE(IsTooltipVisible()); 210 EXPECT_FALSE(IsTooltipVisible());
211 EXPECT_EQ(window, 211 EXPECT_EQ(window,
212 Shell::GetPrimaryRootWindow()->GetEventHandlerForPoint( 212 Shell::GetPrimaryRootWindow()->GetEventHandlerForPoint(
213 generator.current_location())); 213 generator.current_location()));
214 string16 expected_tooltip; // = "" 214 string16 expected_tooltip; // = ""
215 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); 215 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window));
216 EXPECT_EQ(expected_tooltip, GetTooltipText()); 216 EXPECT_EQ(expected_tooltip, GetTooltipText());
217 EXPECT_EQ(window, GetTooltipWindow()); 217 EXPECT_EQ(window, GetTooltipWindow());
218 } 218 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 EXPECT_TRUE(IsTooltipVisible()); 390 EXPECT_TRUE(IsTooltipVisible());
391 EXPECT_TRUE(IsTooltipShownTimerRunning()); 391 EXPECT_TRUE(IsTooltipShownTimerRunning());
392 392
393 generator.PressKey(ui::VKEY_1, 0); 393 generator.PressKey(ui::VKEY_1, 0);
394 EXPECT_FALSE(IsTooltipVisible()); 394 EXPECT_FALSE(IsTooltipVisible());
395 EXPECT_FALSE(IsTooltipTimerRunning()); 395 EXPECT_FALSE(IsTooltipTimerRunning());
396 EXPECT_FALSE(IsTooltipShownTimerRunning()); 396 EXPECT_FALSE(IsTooltipShownTimerRunning());
397 397
398 // Moving the mouse inside |view1| should not change the state of the tooltip 398 // Moving the mouse inside |view1| should not change the state of the tooltip
399 // or the timers. 399 // or the timers.
400 for (int i = 0; i < 50; i++) { 400 for (int i = 0; i < 49; i++) {
401 generator.MoveMouseBy(1, 0); 401 generator.MoveMouseBy(1, 0);
402 EXPECT_FALSE(IsTooltipVisible()); 402 EXPECT_FALSE(IsTooltipVisible());
403 EXPECT_FALSE(IsTooltipTimerRunning()); 403 EXPECT_FALSE(IsTooltipTimerRunning());
404 EXPECT_FALSE(IsTooltipShownTimerRunning()); 404 EXPECT_FALSE(IsTooltipShownTimerRunning());
405 EXPECT_EQ(window, 405 EXPECT_EQ(window,
406 Shell::GetPrimaryRootWindow()->GetEventHandlerForPoint( 406 Shell::GetPrimaryRootWindow()->GetEventHandlerForPoint(
407 generator.current_location())); 407 generator.current_location()));
408 string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 1"); 408 string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 1");
409 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); 409 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window));
410 EXPECT_EQ(expected_tooltip, GetTooltipText()); 410 EXPECT_EQ(expected_tooltip, GetTooltipText());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 EXPECT_TRUE(IsTooltipVisible()); 445 EXPECT_TRUE(IsTooltipVisible());
446 EXPECT_TRUE(IsTooltipShownTimerRunning()); 446 EXPECT_TRUE(IsTooltipShownTimerRunning());
447 447
448 FireTooltipShownTimer(); 448 FireTooltipShownTimer();
449 EXPECT_FALSE(IsTooltipVisible()); 449 EXPECT_FALSE(IsTooltipVisible());
450 EXPECT_FALSE(IsTooltipTimerRunning()); 450 EXPECT_FALSE(IsTooltipTimerRunning());
451 EXPECT_FALSE(IsTooltipShownTimerRunning()); 451 EXPECT_FALSE(IsTooltipShownTimerRunning());
452 452
453 // Moving the mouse inside |view1| should not change the state of the tooltip 453 // Moving the mouse inside |view1| should not change the state of the tooltip
454 // or the timers. 454 // or the timers.
455 for (int i = 0; i < 50; i++) { 455 for (int i = 0; i < 49; ++i) {
456 generator.MoveMouseBy(1, 0); 456 generator.MoveMouseBy(1, 0);
457 EXPECT_FALSE(IsTooltipVisible()); 457 EXPECT_FALSE(IsTooltipVisible());
458 EXPECT_FALSE(IsTooltipTimerRunning()); 458 EXPECT_FALSE(IsTooltipTimerRunning());
459 EXPECT_FALSE(IsTooltipShownTimerRunning()); 459 EXPECT_FALSE(IsTooltipShownTimerRunning());
460 EXPECT_EQ(window, 460 EXPECT_EQ(window,
461 Shell::GetPrimaryRootWindow()->GetEventHandlerForPoint( 461 Shell::GetPrimaryRootWindow()->GetEventHandlerForPoint(
462 generator.current_location())); 462 generator.current_location()));
463 string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 1"); 463 string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 1");
464 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); 464 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window));
465 EXPECT_EQ(expected_tooltip, GetTooltipText()); 465 EXPECT_EQ(expected_tooltip, GetTooltipText());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // be able to show tooltips on the primary display. 512 // be able to show tooltips on the primary display.
513 aura::test::EventGenerator generator1(root_windows[0]); 513 aura::test::EventGenerator generator1(root_windows[0]);
514 generator1.MoveMouseRelativeTo(widget1->GetNativeView(), 514 generator1.MoveMouseRelativeTo(widget1->GetNativeView(),
515 view1->bounds().CenterPoint()); 515 view1->bounds().CenterPoint());
516 FireTooltipTimer(); 516 FireTooltipTimer();
517 EXPECT_TRUE(IsTooltipVisible()); 517 EXPECT_TRUE(IsTooltipVisible());
518 } 518 }
519 519
520 } // namespace test 520 } // namespace test
521 } // namespace ash 521 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/aura/gestures/gesture_recognizer_unittest.cc » ('j') | ui/gfx/rect_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698