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

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

Issue 2618333004: Add ShelfWindowWatcher support for pre-existing windows. (Closed)
Patch Set: Address comments. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/shelf/shelf_window_watcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ash/common/shelf/shelf_window_watcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698