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 1a8e5ce5babecfdc749df720eed2eb066bc6bff7..4faa8336f2391c62dde79479ed8c1e23ea3a92c4 100644 |
| --- a/ash/common/shelf/shelf_window_watcher_unittest.cc |
| +++ b/ash/common/shelf/shelf_window_watcher_unittest.cc |
| @@ -6,6 +6,7 @@ |
| #include "ash/common/shelf/shelf_item_types.h" |
| #include "ash/common/shelf/shelf_model.h" |
| +#include "ash/common/test/test_session_state_delegate.h" |
|
James Cook
2017/01/10 19:51:15
nit: still needed?
msw
2017/01/10 20:06:30
Changed to ash/common/session/session_state_delega
|
| #include "ash/common/wm/window_resizer.h" |
| #include "ash/common/wm/window_state.h" |
| #include "ash/common/wm_lookup.h" |
| @@ -333,4 +334,37 @@ TEST_F(ShelfWindowWatcherTest, DontCreateShelfEntriesForChildWindows) { |
| EXPECT_EQ(initial_item_count, model_->item_count()); |
| } |
| +// A ShelfWindowWatcherTest subclass that doesn't start a user session in SetUp. |
| +class ShelfWindowWatcherSessionStartTest : public ShelfWindowWatcherTest { |
|
James Cook
2017/01/10 19:51:15
For future reference there is also NoSessionAshTes
msw
2017/01/10 20:06:30
I updated my test fixture to use that; thanks!
|
| + public: |
| + ShelfWindowWatcherSessionStartTest() { |
| + // Let the test fixture start running before starting the user session. |
| + set_start_session(false); |
| + } |
| + ~ShelfWindowWatcherSessionStartTest() override {} |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcherSessionStartTest); |
| +}; |
| + |
| +// Ensures ShelfWindowWatcher supports windows opened prior to session start. |
| +TEST_F(ShelfWindowWatcherSessionStartTest, PreExistingWindow) { |
| + 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()); |
| + 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 |