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

Unified Diff: ash/common/shelf/shelf_window_watcher_unittest.cc

Issue 2462753002: Use Ash's ShelfWindowWatcher for app panel windows. (Closed)
Patch Set: Add ShelfWindowWatcherTest, remove ChromeLauncherControllerImplTest panel use. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..cf59b4fc1289a2880252f0f634609836d630c0ab 100644
--- a/ash/common/shelf/shelf_window_watcher_unittest.cc
+++ b/ash/common/shelf/shelf_window_watcher_unittest.cc
@@ -268,4 +268,28 @@ 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* window_1 = WmLookup::Get()->GetWindowForWidget(widget1.get());
James Cook 2016/11/02 17:53:44 super nit: maybe window1 here or widget_1 above?
msw 2016/11/10 21:07:46 Done.
+ window_1->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* window_2 = WmLookup::Get()->GetWindowForWidget(widget2.get());
+ window_2->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_APP_PANEL);
+ EXPECT_EQ(3, model_->item_count());
+
+ // Each ShelfItem is removed when the associated window is destroyed.
+ widget1.reset();
+ EXPECT_EQ(2, model_->item_count());
+ widget2.reset();
+ EXPECT_EQ(1, model_->item_count());
+}
James Cook 2016/11/02 17:53:44 Thanks for writing a test. Is it possible to writ
msw 2016/11/10 21:07:46 I added LauncherPlatformAppBrowserTest.AppPanel, r
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698