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

Side by Side Diff: ash/shelf/shelf_tooltip_manager_unittest.cc

Issue 2825533003: mash: Prerequisites for removing ShelfDelegate. (Closed)
Patch Set: Refine TestShelfDelegate::IsAppPinned; cleanup. Created 3 years, 8 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
OLDNEW
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/public/cpp/config.h" 7 #include "ash/public/cpp/config.h"
8 #include "ash/shelf/app_list_button.h" 8 #include "ash/shelf/app_list_button.h"
9 #include "ash/shelf/shelf_model.h" 9 #include "ash/shelf/shelf_model.h"
10 #include "ash/shelf/shelf_view.h" 10 #include "ash/shelf/shelf_view.h"
11 #include "ash/shelf/wm_shelf.h" 11 #include "ash/shelf/wm_shelf.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
14 #include "ash/test/shelf_view_test_api.h" 14 #include "ash/test/shelf_view_test_api.h"
15 #include "ash/test/test_shelf_item_delegate.h"
16 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
17 #include "ui/events/event_constants.h" 16 #include "ui/events/event_constants.h"
18 #include "ui/events/test/event_generator.h" 17 #include "ui/events/test/event_generator.h"
19 #include "ui/views/bubble/bubble_dialog_delegate.h" 18 #include "ui/views/bubble/bubble_dialog_delegate.h"
20 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
21 20
22 namespace ash { 21 namespace ash {
23 namespace test { 22 namespace test {
24 23
25 class ShelfTooltipManagerTest : public AshTestBase { 24 class ShelfTooltipManagerTest : public AshTestBase {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 tooltip_manager_->ShowTooltip(&view); 80 tooltip_manager_->ShowTooltip(&view);
82 EXPECT_FALSE(tooltip_manager_->IsVisible()); 81 EXPECT_FALSE(tooltip_manager_->IsVisible());
83 tooltip_manager_->ShowTooltipWithDelay(&view); 82 tooltip_manager_->ShowTooltipWithDelay(&view);
84 EXPECT_FALSE(IsTimerRunning()); 83 EXPECT_FALSE(IsTimerRunning());
85 84
86 // The manager should start the timer for a view on the shelf. 85 // The manager should start the timer for a view on the shelf.
87 ShelfModel* model = shelf_view_->model(); 86 ShelfModel* model = shelf_view_->model();
88 ShelfItem item; 87 ShelfItem item;
89 item.type = TYPE_PINNED_APP; 88 item.type = TYPE_PINNED_APP;
90 const int index = model->Add(item); 89 const int index = model->Add(item);
91 const ShelfID id = model->items()[index].id;
92 model->SetShelfItemDelegate(id,
93 base::MakeUnique<TestShelfItemDelegate>(nullptr));
94 // Note: There's no easy way to correlate shelf a model index/id to its view. 90 // Note: There's no easy way to correlate shelf a model index/id to its view.
95 tooltip_manager_->ShowTooltipWithDelay( 91 tooltip_manager_->ShowTooltipWithDelay(
96 shelf_view_->child_at(shelf_view_->child_count() - 1)); 92 shelf_view_->child_at(shelf_view_->child_count() - 1));
97 EXPECT_TRUE(IsTimerRunning()); 93 EXPECT_TRUE(IsTimerRunning());
98 94
99 // Removing the view won't stop the timer, but the tooltip shouldn't be shown. 95 // Removing the view won't stop the timer, but the tooltip shouldn't be shown.
100 model->RemoveItemAt(index); 96 model->RemoveItemAt(index);
101 EXPECT_TRUE(IsTimerRunning()); 97 EXPECT_TRUE(IsTimerRunning());
102 RunAllPendingInMessageLoop(); 98 RunAllPendingInMessageLoop();
103 EXPECT_FALSE(IsTimerRunning()); 99 EXPECT_FALSE(IsTimerRunning());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 234
239 // Should not hide for key events. 235 // Should not hide for key events.
240 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton()); 236 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton());
241 ASSERT_TRUE(tooltip_manager_->IsVisible()); 237 ASSERT_TRUE(tooltip_manager_->IsVisible());
242 generator.PressKey(ui::VKEY_A, ui::EF_NONE); 238 generator.PressKey(ui::VKEY_A, ui::EF_NONE);
243 EXPECT_TRUE(tooltip_manager_->IsVisible()); 239 EXPECT_TRUE(tooltip_manager_->IsVisible());
244 } 240 }
245 241
246 } // namespace test 242 } // namespace test
247 } // namespace ash 243 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698