| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/shelf/shelf_window_watcher.h" | 5 #include "ash/common/shelf/shelf_window_watcher.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/shelf/shelf_item_types.h" | 8 #include "ash/common/shelf/shelf_item_types.h" |
| 9 #include "ash/common/shelf/shelf_model.h" | 9 #include "ash/common/shelf/shelf_model.h" |
| 10 #include "ash/common/wm/window_resizer.h" | 10 #include "ash/common/wm/window_resizer.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 EXPECT_EQ(2, model_->item_count()); | 216 EXPECT_EQ(2, model_->item_count()); |
| 217 | 217 |
| 218 int index = model_->ItemIndexByID(id); | 218 int index = model_->ItemIndexByID(id); |
| 219 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status); | 219 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status); |
| 220 | 220 |
| 221 WmWindow* root_window = window->GetRootWindow(); | 221 WmWindow* root_window = window->GetRootWindow(); |
| 222 WmWindow* default_container = | 222 WmWindow* default_container = |
| 223 root_window->GetChildByShellWindowId(kShellWindowId_DefaultContainer); | 223 root_window->GetChildByShellWindowId(kShellWindowId_DefaultContainer); |
| 224 EXPECT_EQ(default_container, window->GetParent()); | 224 EXPECT_EQ(default_container, window->GetParent()); |
| 225 | 225 |
| 226 WmWindow* docked_container = | |
| 227 root_window->GetChildByShellWindowId(kShellWindowId_DockedContainer); | |
| 228 | |
| 229 // Check |window|'s item is not removed when it is re-parented to the dock. | |
| 230 docked_container->AddChild(window); | |
| 231 EXPECT_EQ(docked_container, window->GetParent()); | |
| 232 EXPECT_EQ(2, model_->item_count()); | |
| 233 | |
| 234 // The shelf item is removed when the window is closed, even if it is in the | 226 // The shelf item is removed when the window is closed, even if it is in the |
| 235 // docked container at the time. | 227 // docked container at the time. |
| 236 widget.reset(); | 228 widget.reset(); |
| 237 EXPECT_EQ(1, model_->item_count()); | 229 EXPECT_EQ(1, model_->item_count()); |
| 238 } | 230 } |
| 239 | 231 |
| 240 // Check |window|'s item is not changed during the dragging. | 232 // Check |window|'s item is not changed during the dragging. |
| 241 // TODO(simonhong): Add a test for removing a Window during the dragging. | 233 // TODO(simonhong): Add a test for removing a Window during the dragging. |
| 242 TEST_F(ShelfWindowWatcherTest, DragWindow) { | 234 TEST_F(ShelfWindowWatcherTest, DragWindow) { |
| 243 // ShelfModel only has an APP_LIST item. | 235 // ShelfModel only has an APP_LIST item. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 342 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
| 351 ShelfWindowWatcherTest::CreateShelfItem(window); | 343 ShelfWindowWatcherTest::CreateShelfItem(window); |
| 352 EXPECT_EQ(1, model->item_count()); | 344 EXPECT_EQ(1, model->item_count()); |
| 353 | 345 |
| 354 // Start the test user session; ShelfWindowWatcher will find the open window. | 346 // Start the test user session; ShelfWindowWatcher will find the open window. |
| 355 SetSessionStarted(true); | 347 SetSessionStarted(true); |
| 356 EXPECT_EQ(2, model->item_count()); | 348 EXPECT_EQ(2, model->item_count()); |
| 357 } | 349 } |
| 358 | 350 |
| 359 } // namespace ash | 351 } // namespace ash |
| OLD | NEW |