OLD | NEW |
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/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
22 #include "grit/ui_resources.h" | 22 #include "grit/ui_resources.h" |
23 #include "ui/aura/test/aura_test_base.h" | 23 #include "ui/aura/test/aura_test_base.h" |
24 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
25 #include "ui/base/events/event.h" | 25 #include "ui/base/events/event.h" |
26 #include "ui/base/events/event_constants.h" | 26 #include "ui/base/events/event_constants.h" |
27 #include "ui/compositor/layer.h" | 27 #include "ui/compositor/layer.h" |
28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
29 #include "ui/views/widget/widget_delegate.h" | 29 #include "ui/views/widget/widget_delegate.h" |
30 | 30 |
| 31 namespace { |
| 32 const int kExpectedAppIndex = 2; |
| 33 } |
| 34 |
31 namespace ash { | 35 namespace ash { |
32 namespace test { | 36 namespace test { |
33 | 37 |
34 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
35 // LauncherIconObserver tests. | 39 // LauncherIconObserver tests. |
36 | 40 |
37 class TestLauncherIconObserver : public LauncherIconObserver { | 41 class TestLauncherIconObserver : public LauncherIconObserver { |
38 public: | 42 public: |
39 explicit TestLauncherIconObserver(Launcher* launcher) | 43 explicit TestLauncherIconObserver(Launcher* launcher) |
40 : launcher_(launcher), | 44 : launcher_(launcher), |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 return test_api_->GetButton(index); | 250 return test_api_->GetButton(index); |
247 } | 251 } |
248 | 252 |
249 LauncherItem GetItemByID(LauncherID id) { | 253 LauncherItem GetItemByID(LauncherID id) { |
250 LauncherItems::const_iterator items = model_->ItemByID(id); | 254 LauncherItems::const_iterator items = model_->ItemByID(id); |
251 return *items; | 255 return *items; |
252 } | 256 } |
253 | 257 |
254 void CheckModelIDs( | 258 void CheckModelIDs( |
255 const std::vector<std::pair<LauncherID, views::View*> >& id_map) { | 259 const std::vector<std::pair<LauncherID, views::View*> >& id_map) { |
256 ASSERT_EQ(static_cast<int>(id_map.size()), test_api_->GetButtonCount()); | 260 size_t map_index = 0; |
257 ASSERT_EQ(id_map.size(), model_->items().size()); | 261 for (size_t model_index = 0; |
258 for (size_t i = 0; i < id_map.size(); ++i) { | 262 model_index < model_->items().size(); |
259 EXPECT_EQ(id_map[i].first, model_->items()[i].id); | 263 ++model_index) { |
260 EXPECT_EQ(id_map[i].second, test_api_->GetButton(i)); | 264 ash::LauncherItem item = model_->items()[model_index]; |
| 265 // if (item.type == ash::TYPE_APP_LIST) |
| 266 // continue; |
| 267 ash::LauncherID id = item.id; |
| 268 EXPECT_EQ(id_map[map_index].first, id); |
| 269 EXPECT_EQ(id_map[map_index].second, GetButtonByID(id)); |
| 270 ++map_index; |
261 } | 271 } |
| 272 ASSERT_EQ(map_index, id_map.size()); |
262 } | 273 } |
263 | 274 |
264 views::View* SimulateDrag(internal::LauncherButtonHost::Pointer pointer, | 275 views::View* SimulateDrag(internal::LauncherButtonHost::Pointer pointer, |
265 int button_index, | 276 int button_index, |
266 int destination_index) { | 277 int destination_index) { |
| 278 // Add kExpectedAppIndex to each button index to allow default icons. |
267 internal::LauncherButtonHost* button_host = launcher_view_.get(); | 279 internal::LauncherButtonHost* button_host = launcher_view_.get(); |
268 | 280 |
269 // Mouse down. | 281 // Mouse down. |
270 views::View* button = test_api_->GetButton(button_index); | 282 views::View* button = |
| 283 test_api_->GetButton(kExpectedAppIndex + button_index); |
271 ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, | 284 ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, |
272 button->bounds().origin(), | 285 button->bounds().origin(), |
273 button->bounds().origin(), 0); | 286 button->bounds().origin(), 0); |
274 button_host->PointerPressedOnButton(button, pointer, click_event); | 287 button_host->PointerPressedOnButton(button, pointer, click_event); |
275 | 288 |
276 // Drag. | 289 // Drag. |
277 views::View* destination = test_api_->GetButton(destination_index); | 290 views::View* destination = |
| 291 test_api_->GetButton(kExpectedAppIndex + destination_index); |
278 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, | 292 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, |
279 destination->bounds().origin(), | 293 destination->bounds().origin(), |
280 destination->bounds().origin(), 0); | 294 destination->bounds().origin(), 0); |
281 button_host->PointerDraggedOnButton(button, pointer, drag_event); | 295 button_host->PointerDraggedOnButton(button, pointer, drag_event); |
282 return button; | 296 return button; |
283 } | 297 } |
284 | 298 |
285 void SetupForDragTest( | 299 void SetupForDragTest( |
286 std::vector<std::pair<LauncherID, views::View*> >* id_map) { | 300 std::vector<std::pair<LauncherID, views::View*> >* id_map) { |
287 // Initialize |id_map| with the automatically-created launcher buttons. | 301 // Initialize |id_map| with the automatically-created launcher buttons. |
288 for (size_t i = 0; i < model_->items().size(); ++i) { | 302 for (size_t i = 0; i < model_->items().size(); ++i) { |
289 id_map->push_back(std::make_pair(model_->items()[i].id, | 303 internal::LauncherButton* button = test_api_->GetButton(i); |
290 test_api_->GetButton(i))); | 304 // if (!button) |
| 305 // continue; |
| 306 |
| 307 id_map->push_back(std::make_pair(model_->items()[i].id, button)); |
291 } | 308 } |
292 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(*id_map)); | 309 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(*id_map)); |
293 | 310 |
294 // Add 5 app launcher buttons for testing. | 311 // Add 5 app launcher buttons for testing. |
295 for (int i = 1; i <= 5; ++i) { | 312 for (int i = 0; i < 5; ++i) { |
296 LauncherID id = AddAppShortcut(); | 313 LauncherID id = AddAppShortcut(); |
297 id_map->insert(id_map->begin() + i, | 314 id_map->push_back(std::make_pair(id, GetButtonByID(id))); |
298 std::make_pair(id, test_api_->GetButton(i))); | |
299 } | 315 } |
300 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(*id_map)); | 316 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(*id_map)); |
301 } | 317 } |
302 | 318 |
303 views::View* GetTooltipAnchorView() { | 319 views::View* GetTooltipAnchorView() { |
304 return launcher_view_->tooltip_manager()->anchor_; | 320 return launcher_view_->tooltip_manager()->anchor_; |
305 } | 321 } |
306 | 322 |
307 void ShowTooltip() { | 323 void ShowTooltip() { |
308 launcher_view_->tooltip_manager()->ShowInternal(); | 324 launcher_view_->tooltip_manager()->ShowInternal(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 ++added_count; | 435 ++added_count; |
420 } | 436 } |
421 | 437 |
422 // LauncherView should be big enough to hold at least 3 new buttons. | 438 // LauncherView should be big enough to hold at least 3 new buttons. |
423 ASSERT_GE(added_count, 3); | 439 ASSERT_GE(added_count, 3); |
424 | 440 |
425 // Wait for the last animation to finish. | 441 // Wait for the last animation to finish. |
426 test_api_->RunMessageLoopUntilAnimationsDone(); | 442 test_api_->RunMessageLoopUntilAnimationsDone(); |
427 | 443 |
428 // Verifies non-overflow buttons are visible. | 444 // Verifies non-overflow buttons are visible. |
429 for (int i = 0; i <= test_api_->GetLastVisibleIndex(); ++i) { | 445 for (int i = 1; i <= test_api_->GetLastVisibleIndex(); ++i) { |
430 internal::LauncherButton* button = test_api_->GetButton(i); | 446 internal::LauncherButton* button = test_api_->GetButton(i); |
431 EXPECT_TRUE(button->visible()) << "button index=" << i; | 447 EXPECT_TRUE(button->visible()) << "button index=" << i; |
432 EXPECT_EQ(1.0f, button->layer()->opacity()) << "button index=" << i; | 448 EXPECT_EQ(1.0f, button->layer()->opacity()) << "button index=" << i; |
433 } | 449 } |
434 } | 450 } |
435 | 451 |
436 // Check that model changes are handled correctly while a launcher icon is being | 452 // Check that model changes are handled correctly while a launcher icon is being |
437 // dragged. | 453 // dragged. |
438 TEST_F(LauncherViewTest, ModelChangesWhileDragging) { | 454 TEST_F(LauncherViewTest, ModelChangesWhileDragging) { |
439 internal::LauncherButtonHost* button_host = launcher_view_.get(); | 455 internal::LauncherButtonHost* button_host = launcher_view_.get(); |
440 | 456 |
441 std::vector<std::pair<LauncherID, views::View*> > id_map; | 457 std::vector<std::pair<LauncherID, views::View*> > id_map; |
442 SetupForDragTest(&id_map); | 458 SetupForDragTest(&id_map); |
443 | 459 |
444 // Dragging changes model order. | 460 // Dragging changes model order. |
445 views::View* dragged_button = SimulateDrag( | 461 views::View* dragged_button = SimulateDrag( |
446 internal::LauncherButtonHost::MOUSE, 1, 3); | 462 internal::LauncherButtonHost::MOUSE, 0, 2); |
447 std::rotate(id_map.begin() + 1, id_map.begin() + 2, id_map.begin() + 4); | 463 std::rotate(id_map.begin() + kExpectedAppIndex, |
| 464 id_map.begin() + kExpectedAppIndex + 1, |
| 465 id_map.begin() + kExpectedAppIndex + 3); |
448 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 466 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
449 | 467 |
450 // Cancelling the drag operation restores previous order. | 468 // Cancelling the drag operation restores previous order. |
451 button_host->PointerReleasedOnButton(dragged_button, | 469 button_host->PointerReleasedOnButton(dragged_button, |
452 internal::LauncherButtonHost::MOUSE, | 470 internal::LauncherButtonHost::MOUSE, |
453 true); | 471 true); |
454 std::rotate(id_map.begin() + 1, id_map.begin() + 3, id_map.begin() + 4); | 472 std::rotate(id_map.begin() + kExpectedAppIndex, |
| 473 id_map.begin() + kExpectedAppIndex + 2, |
| 474 id_map.begin() + kExpectedAppIndex + 3); |
455 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 475 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
456 | 476 |
457 // Deleting an item keeps the remaining intact. | 477 // Deleting an item keeps the remaining intact. |
458 dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 1, 3); | 478 dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 0, 2); |
459 model_->RemoveItemAt(3); | 479 model_->RemoveItemAt(kExpectedAppIndex + 1); |
460 id_map.erase(id_map.begin() + 3); | 480 id_map.erase(id_map.begin() + kExpectedAppIndex + 1); |
461 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 481 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
462 button_host->PointerReleasedOnButton(dragged_button, | 482 button_host->PointerReleasedOnButton(dragged_button, |
463 internal::LauncherButtonHost::MOUSE, | 483 internal::LauncherButtonHost::MOUSE, |
464 false); | 484 false); |
465 | 485 |
466 // Adding a launcher item cancels the drag and respects the order. | 486 // Adding a launcher item cancels the drag and respects the order. |
467 dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 1, 3); | 487 dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 0, 2); |
468 LauncherID new_id = AddAppShortcut(); | 488 LauncherID new_id = AddAppShortcut(); |
469 id_map.insert(id_map.begin() + 5, | 489 id_map.push_back(std::make_pair(new_id, GetButtonByID(new_id))); |
470 std::make_pair(new_id, test_api_->GetButton(5))); | |
471 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 490 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
472 button_host->PointerReleasedOnButton(dragged_button, | 491 button_host->PointerReleasedOnButton(dragged_button, |
473 internal::LauncherButtonHost::MOUSE, | 492 internal::LauncherButtonHost::MOUSE, |
474 false); | 493 false); |
475 } | 494 } |
476 | 495 |
477 // Check that 2nd drag from the other pointer would be ignored. | 496 // Check that 2nd drag from the other pointer would be ignored. |
478 TEST_F(LauncherViewTest, SimultaneousDrag) { | 497 TEST_F(LauncherViewTest, SimultaneousDrag) { |
479 internal::LauncherButtonHost* button_host = launcher_view_.get(); | 498 internal::LauncherButtonHost* button_host = launcher_view_.get(); |
480 | 499 |
481 std::vector<std::pair<LauncherID, views::View*> > id_map; | 500 std::vector<std::pair<LauncherID, views::View*> > id_map; |
482 SetupForDragTest(&id_map); | 501 SetupForDragTest(&id_map); |
483 | 502 |
484 // Start a mouse drag. | 503 // Start a mouse drag. |
485 views::View* dragged_button_mouse = SimulateDrag( | 504 views::View* dragged_button_mouse = SimulateDrag( |
486 internal::LauncherButtonHost::MOUSE, 1, 3); | 505 internal::LauncherButtonHost::MOUSE, 0, 2); |
487 std::rotate(id_map.begin() + 1, id_map.begin() + 2, id_map.begin() + 4); | 506 std::rotate(id_map.begin() + kExpectedAppIndex, |
| 507 id_map.begin() + kExpectedAppIndex + 1, |
| 508 id_map.begin() + kExpectedAppIndex + 3); |
488 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 509 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
489 | |
490 // Attempt a touch drag before the mouse drag finishes. | 510 // Attempt a touch drag before the mouse drag finishes. |
491 views::View* dragged_button_touch = SimulateDrag( | 511 views::View* dragged_button_touch = SimulateDrag( |
492 internal::LauncherButtonHost::TOUCH, 4, 2); | 512 internal::LauncherButtonHost::TOUCH, 3, 1); |
493 | 513 |
494 // Nothing changes since 2nd drag is ignored. | 514 // Nothing changes since 2nd drag is ignored. |
495 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 515 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
496 | 516 |
497 // Finish the mouse drag. | 517 // Finish the mouse drag. |
498 button_host->PointerReleasedOnButton(dragged_button_mouse, | 518 button_host->PointerReleasedOnButton(dragged_button_mouse, |
499 internal::LauncherButtonHost::MOUSE, | 519 internal::LauncherButtonHost::MOUSE, |
500 false); | 520 false); |
501 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 521 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
502 | 522 |
503 // Now start a touch drag. | 523 // Now start a touch drag. |
504 dragged_button_touch = SimulateDrag( | 524 dragged_button_touch = SimulateDrag( |
505 internal::LauncherButtonHost::TOUCH, 4, 2); | 525 internal::LauncherButtonHost::TOUCH, 3, 1); |
506 std::rotate(id_map.begin() + 3, id_map.begin() + 4, id_map.begin() + 5); | 526 std::rotate(id_map.begin() + kExpectedAppIndex + 2, |
| 527 id_map.begin() + kExpectedAppIndex + 3, |
| 528 id_map.begin() + kExpectedAppIndex + 4); |
507 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 529 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
508 | 530 |
509 // And attempt a mouse drag before the touch drag finishes. | 531 // And attempt a mouse drag before the touch drag finishes. |
510 dragged_button_mouse = SimulateDrag( | 532 dragged_button_mouse = SimulateDrag( |
511 internal::LauncherButtonHost::MOUSE, 1, 3); | 533 internal::LauncherButtonHost::MOUSE, 0, 1); |
512 | 534 |
513 // Nothing changes since 2nd drag is ignored. | 535 // Nothing changes since 2nd drag is ignored. |
514 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 536 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
515 | 537 |
516 button_host->PointerReleasedOnButton(dragged_button_touch, | 538 button_host->PointerReleasedOnButton(dragged_button_touch, |
517 internal::LauncherButtonHost::TOUCH, | 539 internal::LauncherButtonHost::TOUCH, |
518 false); | 540 false); |
519 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 541 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
520 } | 542 } |
521 | 543 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 button_host->MouseEnteredButton(tab_button); | 624 button_host->MouseEnteredButton(tab_button); |
603 EXPECT_FALSE(tooltip_manager->IsVisible()); | 625 EXPECT_FALSE(tooltip_manager->IsVisible()); |
604 EXPECT_EQ(tab_button, GetTooltipAnchorView()); | 626 EXPECT_EQ(tab_button, GetTooltipAnchorView()); |
605 } | 627 } |
606 | 628 |
607 TEST_F(LauncherViewTest, ShouldHideTooltipTest) { | 629 TEST_F(LauncherViewTest, ShouldHideTooltipTest) { |
608 LauncherID app_button_id = AddAppShortcut(); | 630 LauncherID app_button_id = AddAppShortcut(); |
609 LauncherID tab_button_id = AddTabbedBrowser(); | 631 LauncherID tab_button_id = AddTabbedBrowser(); |
610 | 632 |
611 // The tooltip shouldn't hide if the mouse is on normal buttons. | 633 // The tooltip shouldn't hide if the mouse is on normal buttons. |
612 for (int i = 0; i < test_api_->GetButtonCount() - 1; i++) { | 634 for (int i = 0; i < test_api_->GetButtonCount(); i++) { |
613 internal::LauncherButton* button = test_api_->GetButton(i); | 635 internal::LauncherButton* button = test_api_->GetButton(i); |
| 636 if (!button) |
| 637 continue; |
| 638 |
614 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( | 639 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( |
615 button->GetMirroredBounds().CenterPoint())) | 640 button->GetMirroredBounds().CenterPoint())) |
616 << "LauncherView tries to hide on button " << i; | 641 << "LauncherView tries to hide on button " << i; |
617 } | 642 } |
618 | 643 |
619 // The tooltip should not hide on the app-list button. | 644 // The tooltip should not hide on the app-list button. |
620 views::View* app_list_button = launcher_view_->GetAppListButtonView(); | 645 views::View* app_list_button = launcher_view_->GetAppListButtonView(); |
621 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( | 646 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( |
622 app_list_button->GetMirroredBounds().CenterPoint())); | 647 app_list_button->GetMirroredBounds().CenterPoint())); |
623 | 648 |
624 // The tooltip shouldn't hide if the mouse is in the gap between two buttons. | 649 // The tooltip shouldn't hide if the mouse is in the gap between two buttons. |
625 gfx::Rect app_button_rect = GetButtonByID(app_button_id)->GetMirroredBounds(); | 650 gfx::Rect app_button_rect = GetButtonByID(app_button_id)->GetMirroredBounds(); |
626 gfx::Rect tab_button_rect = GetButtonByID(tab_button_id)->GetMirroredBounds(); | 651 gfx::Rect tab_button_rect = GetButtonByID(tab_button_id)->GetMirroredBounds(); |
627 ASSERT_FALSE(app_button_rect.Intersects(tab_button_rect)); | 652 ASSERT_FALSE(app_button_rect.Intersects(tab_button_rect)); |
628 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( | 653 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( |
629 app_button_rect.Union(tab_button_rect).CenterPoint())); | 654 app_button_rect.Union(tab_button_rect).CenterPoint())); |
630 | 655 |
631 // The tooltip should hide if it's outside of all buttons. | 656 // The tooltip should hide if it's outside of all buttons. |
632 gfx::Rect all_area; | 657 gfx::Rect all_area; |
633 for (int i = 0; i < test_api_->GetButtonCount() - 1; i++) { | 658 for (int i = 0; i < test_api_->GetButtonCount(); i++) { |
634 all_area = all_area.Union(test_api_->GetButton(i)->GetMirroredBounds()); | 659 internal::LauncherButton* button = test_api_->GetButton(i); |
| 660 if (!button) |
| 661 continue; |
| 662 |
| 663 all_area = all_area.Union(button->GetMirroredBounds()); |
635 } | 664 } |
636 all_area = all_area.Union( | 665 all_area = all_area.Union( |
637 launcher_view_->GetAppListButtonView()->GetMirroredBounds()); | 666 launcher_view_->GetAppListButtonView()->GetMirroredBounds()); |
638 EXPECT_FALSE(launcher_view_->ShouldHideTooltip(all_area.origin())); | 667 EXPECT_FALSE(launcher_view_->ShouldHideTooltip(all_area.origin())); |
639 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( | 668 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( |
640 gfx::Point(all_area.right() - 1, all_area.bottom() - 1))); | 669 gfx::Point(all_area.right() - 1, all_area.bottom() - 1))); |
641 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( | 670 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
642 gfx::Point(all_area.right(), all_area.y()))); | 671 gfx::Point(all_area.right(), all_area.y()))); |
643 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( | 672 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
644 gfx::Point(all_area.x() - 1, all_area.y()))); | 673 gfx::Point(all_area.x() - 1, all_area.y()))); |
645 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( | 674 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
646 gfx::Point(all_area.x(), all_area.y() - 1))); | 675 gfx::Point(all_area.x(), all_area.y() - 1))); |
647 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( | 676 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
648 gfx::Point(all_area.x(), all_area.bottom()))); | 677 gfx::Point(all_area.x(), all_area.bottom()))); |
649 } | 678 } |
650 | 679 |
651 TEST_F(LauncherViewTest, ShouldHideTooltipWithAppListWindowTest) { | 680 TEST_F(LauncherViewTest, ShouldHideTooltipWithAppListWindowTest) { |
652 Shell::GetInstance()->ToggleAppList(); | 681 Shell::GetInstance()->ToggleAppList(); |
653 ASSERT_TRUE(Shell::GetInstance()->GetAppListWindow()); | 682 ASSERT_TRUE(Shell::GetInstance()->GetAppListWindow()); |
654 | 683 |
655 // The tooltip shouldn't hide if the mouse is on normal buttons. | 684 // The tooltip shouldn't hide if the mouse is on normal buttons. |
656 for (int i = 0; i < test_api_->GetButtonCount() - 1; i++) { | 685 for (int i = 1; i < test_api_->GetButtonCount(); i++) { |
657 internal::LauncherButton* button = test_api_->GetButton(i); | 686 internal::LauncherButton* button = test_api_->GetButton(i); |
| 687 if (!button) |
| 688 continue; |
| 689 |
658 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( | 690 EXPECT_FALSE(launcher_view_->ShouldHideTooltip( |
659 button->GetMirroredBounds().CenterPoint())) | 691 button->GetMirroredBounds().CenterPoint())) |
660 << "LauncherView tries to hide on button " << i; | 692 << "LauncherView tries to hide on button " << i; |
661 } | 693 } |
662 | 694 |
663 // The tooltip should hide on the app-list button. | 695 // The tooltip should hide on the app-list button. |
664 views::View* app_list_button = launcher_view_->GetAppListButtonView(); | 696 views::View* app_list_button = launcher_view_->GetAppListButtonView(); |
665 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( | 697 EXPECT_TRUE(launcher_view_->ShouldHideTooltip( |
666 app_list_button->GetMirroredBounds().CenterPoint())); | 698 app_list_button->GetMirroredBounds().CenterPoint())); |
667 } | 699 } |
(...skipping 27 matching lines...) Expand all Loading... |
695 const int app_list_button_index = test_api_->GetButtonCount() - 1; | 727 const int app_list_button_index = test_api_->GetButtonCount() - 1; |
696 const gfx::Rect& app_list_ideal_bounds = | 728 const gfx::Rect& app_list_ideal_bounds = |
697 test_api_->GetIdealBoundsByIndex(app_list_button_index); | 729 test_api_->GetIdealBoundsByIndex(app_list_button_index); |
698 const gfx::Rect& app_list_bounds = | 730 const gfx::Rect& app_list_bounds = |
699 test_api_->GetBoundsByIndex(app_list_button_index); | 731 test_api_->GetBoundsByIndex(app_list_button_index); |
700 EXPECT_EQ(app_list_bounds, app_list_ideal_bounds); | 732 EXPECT_EQ(app_list_bounds, app_list_ideal_bounds); |
701 } | 733 } |
702 | 734 |
703 } // namespace test | 735 } // namespace test |
704 } // namespace ash | 736 } // namespace ash |
OLD | NEW |