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 "ash/shelf/shelf_tooltip_manager.h" | 5 #include "ash/shelf/shelf_tooltip_manager.h" |
6 | 6 |
7 #include "ash/common/shelf/app_list_button.h" | 7 #include "ash/common/shelf/app_list_button.h" |
8 #include "ash/common/shelf/shelf_item_delegate_manager.h" | |
9 #include "ash/common/shelf/shelf_model.h" | 8 #include "ash/common/shelf/shelf_model.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
11 #include "ash/shelf/shelf_view.h" | 10 #include "ash/shelf/shelf_view.h" |
12 #include "ash/shelf/shelf_widget.h" | 11 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 12 #include "ash/shell.h" |
14 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
15 #include "ash/test/shelf_test_api.h" | 14 #include "ash/test/shelf_test_api.h" |
16 #include "ash/test/shelf_view_test_api.h" | 15 #include "ash/test/shelf_view_test_api.h" |
17 #include "ash/test/test_shelf_item_delegate.h" | 16 #include "ash/test/test_shelf_item_delegate.h" |
18 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 EXPECT_FALSE(tooltip_manager_->IsVisible()); | 75 EXPECT_FALSE(tooltip_manager_->IsVisible()); |
77 tooltip_manager_->ShowTooltipWithDelay(&view); | 76 tooltip_manager_->ShowTooltipWithDelay(&view); |
78 EXPECT_FALSE(IsTimerRunning()); | 77 EXPECT_FALSE(IsTimerRunning()); |
79 | 78 |
80 // The manager should start the timer for a view on the shelf. | 79 // The manager should start the timer for a view on the shelf. |
81 ShelfModel* model = shelf_view_->model(); | 80 ShelfModel* model = shelf_view_->model(); |
82 ShelfItem item; | 81 ShelfItem item; |
83 item.type = TYPE_APP_SHORTCUT; | 82 item.type = TYPE_APP_SHORTCUT; |
84 const int index = model->Add(item); | 83 const int index = model->Add(item); |
85 const ShelfID id = model->items()[index].id; | 84 const ShelfID id = model->items()[index].id; |
86 Shell::GetInstance()->shelf_item_delegate_manager()->SetShelfItemDelegate( | 85 model->SetShelfItemDelegate( |
87 id, base::WrapUnique(new TestShelfItemDelegate(nullptr))); | 86 id, base::WrapUnique(new TestShelfItemDelegate(nullptr))); |
88 // Note: There's no easy way to correlate shelf a model index/id to its view. | 87 // Note: There's no easy way to correlate shelf a model index/id to its view. |
89 tooltip_manager_->ShowTooltipWithDelay( | 88 tooltip_manager_->ShowTooltipWithDelay( |
90 shelf_view_->child_at(shelf_view_->child_count() - 1)); | 89 shelf_view_->child_at(shelf_view_->child_count() - 1)); |
91 EXPECT_TRUE(IsTimerRunning()); | 90 EXPECT_TRUE(IsTimerRunning()); |
92 | 91 |
93 // Removing the view won't stop the timer, but the tooltip shouldn't be shown. | 92 // Removing the view won't stop the timer, but the tooltip shouldn't be shown. |
94 model->RemoveItemAt(index); | 93 model->RemoveItemAt(index); |
95 EXPECT_TRUE(IsTimerRunning()); | 94 EXPECT_TRUE(IsTimerRunning()); |
96 RunAllPendingInMessageLoop(); | 95 RunAllPendingInMessageLoop(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 220 |
222 // Should not hide for key events. | 221 // Should not hide for key events. |
223 tooltip_manager_->ShowTooltip(shelf_->GetAppListButton()); | 222 tooltip_manager_->ShowTooltip(shelf_->GetAppListButton()); |
224 ASSERT_TRUE(tooltip_manager_->IsVisible()); | 223 ASSERT_TRUE(tooltip_manager_->IsVisible()); |
225 generator.PressKey(ui::VKEY_A, ui::EF_NONE); | 224 generator.PressKey(ui::VKEY_A, ui::EF_NONE); |
226 EXPECT_TRUE(tooltip_manager_->IsVisible()); | 225 EXPECT_TRUE(tooltip_manager_->IsVisible()); |
227 } | 226 } |
228 | 227 |
229 } // namespace test | 228 } // namespace test |
230 } // namespace ash | 229 } // namespace ash |
OLD | NEW |