Chromium Code Reviews| Index: ash/common/shelf/shelf_window_watcher_unittest.cc |
| diff --git a/ash/common/shelf/shelf_window_watcher_unittest.cc b/ash/common/shelf/shelf_window_watcher_unittest.cc |
| index acf5dc2d04dc86c50e89ca904ecbb14561465dfc..9f60b381632f2a8f5826d5b58f817cff8512ba6a 100644 |
| --- a/ash/common/shelf/shelf_window_watcher_unittest.cc |
| +++ b/ash/common/shelf/shelf_window_watcher_unittest.cc |
| @@ -13,6 +13,7 @@ |
| #include "ash/common/wm_window.h" |
| #include "ash/common/wm_window_property.h" |
| #include "ash/public/cpp/shell_window_ids.h" |
| +#include "ash/shell/panel_window.h" |
|
James Cook
2016/11/10 22:32:46
Ah, this might be the reason. I would prefer you e
msw
2016/11/10 23:30:52
Yup, this was the reason. I tested an inlined pane
|
| #include "ash/test/ash_test_base.h" |
| #include "ui/base/hit_test.h" |
| #include "ui/views/widget/widget.h" |
| @@ -268,4 +269,38 @@ TEST_F(ShelfWindowWatcherTest, DragWindow) { |
| EXPECT_EQ(id, model_->items()[index].id); |
| } |
| +// Ensure shelf items are added and removed as panels are opened and closed. |
| +TEST_F(ShelfWindowWatcherTest, PanelWindow) { |
| + // ShelfModel only has an APP_LIST item. |
| + EXPECT_EQ(1, model_->item_count()); |
| + |
| + // Adding windows with valid ShelfItemType properties adds shelf items. |
| + std::unique_ptr<views::Widget> widget1 = |
| + CreateTestWidget(nullptr, kShellWindowId_PanelContainer, gfx::Rect()); |
| + WmWindow* window1 = WmLookup::Get()->GetWindowForWidget(widget1.get()); |
| + window1->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_APP_PANEL); |
| + EXPECT_EQ(2, model_->item_count()); |
| + std::unique_ptr<views::Widget> widget2 = |
| + CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| + WmWindow* window2 = WmLookup::Get()->GetWindowForWidget(widget2.get()); |
| + window2->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_APP_PANEL); |
| + EXPECT_EQ(3, model_->item_count()); |
| + |
| + // Using ash_shell_lib's example PanelWindow also adds shelf items. |
| + views::Widget* widget3 = PanelWindow::CreatePanelWindow(gfx::Rect()); |
| + EXPECT_EQ(4, model_->item_count()); |
| + views::Widget* widget4 = PanelWindow::CreatePanelWindow(gfx::Rect()); |
| + EXPECT_EQ(5, model_->item_count()); |
| + |
| + // Each ShelfItem is removed when the associated window is destroyed. |
| + widget4->CloseNow(); |
| + EXPECT_EQ(4, model_->item_count()); |
| + widget3->CloseNow(); |
| + EXPECT_EQ(3, model_->item_count()); |
| + widget2.reset(); |
| + EXPECT_EQ(2, model_->item_count()); |
| + widget1.reset(); |
| + EXPECT_EQ(1, model_->item_count()); |
| +} |
|
James Cook
2016/11/10 22:32:46
Nice test.
msw
2016/11/10 23:30:52
Acknowledged.
|
| + |
| } // namespace ash |