| 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 1a8e5ce5babecfdc749df720eed2eb066bc6bff7..698abdf2fe40457b17560bb2a789d0b670683fd6 100644
|
| --- a/ash/common/shelf/shelf_window_watcher_unittest.cc
|
| +++ b/ash/common/shelf/shelf_window_watcher_unittest.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "ash/common/shelf/shelf_window_watcher.h"
|
|
|
| +#include "ash/common/session/session_state_delegate.h"
|
| #include "ash/common/shelf/shelf_item_types.h"
|
| #include "ash/common/shelf/shelf_model.h"
|
| #include "ash/common/wm/window_resizer.h"
|
| @@ -35,8 +36,8 @@ class ShelfWindowWatcherTest : public test::AshTestBase {
|
| test::AshTestBase::TearDown();
|
| }
|
|
|
| - ShelfID CreateShelfItem(WmWindow* window) {
|
| - ShelfID id = model_->next_id();
|
| + static ShelfID CreateShelfItem(WmWindow* window) {
|
| + ShelfID id = WmShell::Get()->shelf_model()->next_id();
|
| window->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_DIALOG);
|
| return id;
|
| }
|
| @@ -333,4 +334,26 @@ TEST_F(ShelfWindowWatcherTest, DontCreateShelfEntriesForChildWindows) {
|
| EXPECT_EQ(initial_item_count, model_->item_count());
|
| }
|
|
|
| +// Ensures ShelfWindowWatcher supports windows opened prior to session start.
|
| +using ShelfWindowWatcherSessionStartTest = test::NoSessionAshTestBase;
|
| +TEST_F(ShelfWindowWatcherSessionStartTest, PreExistingWindow) {
|
| + ShelfModel* model = WmShell::Get()->shelf_model();
|
| + ASSERT_FALSE(
|
| + WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted());
|
| +
|
| + // ShelfModel only has an APP_LIST item.
|
| + EXPECT_EQ(1, model->item_count());
|
| +
|
| + // Construct a window that should get a shelf item once the session starts.
|
| + std::unique_ptr<views::Widget> widget =
|
| + CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect());
|
| + WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get());
|
| + ShelfWindowWatcherTest::CreateShelfItem(window);
|
| + EXPECT_EQ(1, model->item_count());
|
| +
|
| + // Start the test user session; ShelfWindowWatcher will find the open window.
|
| + SetSessionStarted(true);
|
| + EXPECT_EQ(2, model->item_count());
|
| +}
|
| +
|
| } // namespace ash
|
|
|