| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "ash/shelf/shelf_button.h" | 7 #include "ash/shelf/shelf_button.h" |
| 8 #include "ash/shelf/shelf_model.h" | 8 #include "ash/shelf/shelf_model.h" |
| 9 #include "ash/shelf/shelf_view.h" | 9 #include "ash/shelf/shelf_view.h" |
| 10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
| 11 #include "ash/shelf/wm_shelf.h" | 11 #include "ash/shelf/wm_shelf.h" |
| 12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/test/shelf_view_test_api.h" | 13 #include "ash/test/shelf_view_test_api.h" |
| 14 #include "ash/test/test_shelf_item_delegate.h" | |
| 15 | 14 |
| 16 namespace ash { | 15 namespace ash { |
| 17 | 16 |
| 18 class ShelfTest : public test::AshTestBase { | 17 class ShelfTest : public test::AshTestBase { |
| 19 public: | 18 public: |
| 20 ShelfTest() : shelf_model_(nullptr) {} | 19 ShelfTest() : shelf_model_(nullptr) {} |
| 21 | 20 |
| 22 ~ShelfTest() override {} | 21 ~ShelfTest() override {} |
| 23 | 22 |
| 24 void SetUp() override { | 23 void SetUp() override { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 TEST_F(ShelfTest, CheckHoverAfterMenu) { | 64 TEST_F(ShelfTest, CheckHoverAfterMenu) { |
| 66 // Initially we have the app list. | 65 // Initially we have the app list. |
| 67 int button_count = test_api()->GetButtonCount(); | 66 int button_count = test_api()->GetButtonCount(); |
| 68 | 67 |
| 69 // Add a running app. | 68 // Add a running app. |
| 70 ShelfItem item; | 69 ShelfItem item; |
| 71 item.type = TYPE_APP; | 70 item.type = TYPE_APP; |
| 72 item.status = STATUS_RUNNING; | 71 item.status = STATUS_RUNNING; |
| 73 int index = shelf_model()->Add(item); | 72 int index = shelf_model()->Add(item); |
| 74 | 73 |
| 75 shelf_model()->SetShelfItemDelegate( | |
| 76 shelf_model()->items()[index].id, | |
| 77 base::MakeUnique<test::TestShelfItemDelegate>(nullptr)); | |
| 78 | |
| 79 ASSERT_EQ(++button_count, test_api()->GetButtonCount()); | 74 ASSERT_EQ(++button_count, test_api()->GetButtonCount()); |
| 80 ShelfButton* button = test_api()->GetButton(index); | 75 ShelfButton* button = test_api()->GetButton(index); |
| 81 button->AddState(ShelfButton::STATE_HOVERED); | 76 button->AddState(ShelfButton::STATE_HOVERED); |
| 82 button->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); | 77 button->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); |
| 83 EXPECT_FALSE(button->state() & ShelfButton::STATE_HOVERED); | 78 EXPECT_FALSE(button->state() & ShelfButton::STATE_HOVERED); |
| 84 | 79 |
| 85 // Remove it. | 80 // Remove it. |
| 86 shelf_model()->RemoveItemAt(index); | 81 shelf_model()->RemoveItemAt(index); |
| 87 } | 82 } |
| 88 | 83 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 108 | 103 |
| 109 // Removes the first item in main shelf view. | 104 // Removes the first item in main shelf view. |
| 110 shelf_model()->RemoveItemAt(shelf_model()->ItemIndexByID(first_item_id)); | 105 shelf_model()->RemoveItemAt(shelf_model()->ItemIndexByID(first_item_id)); |
| 111 | 106 |
| 112 // Waits for all transitions to finish and there should be no crash. | 107 // Waits for all transitions to finish and there should be no crash. |
| 113 test_api()->RunMessageLoopUntilAnimationsDone(); | 108 test_api()->RunMessageLoopUntilAnimationsDone(); |
| 114 EXPECT_FALSE(shelf_widget->IsShowingOverflowBubble()); | 109 EXPECT_FALSE(shelf_widget->IsShowingOverflowBubble()); |
| 115 } | 110 } |
| 116 | 111 |
| 117 } // namespace ash | 112 } // namespace ash |
| OLD | NEW |