| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 EXPECT_EQ(2, model_->item_count()); | 236 EXPECT_EQ(2, model_->item_count()); |
| 237 | 237 |
| 238 int index = model_->ItemIndexByID(id); | 238 int index = model_->ItemIndexByID(id); |
| 239 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status); | 239 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status); |
| 240 | 240 |
| 241 WmWindow* root_window = window->GetRootWindow(); | 241 WmWindow* root_window = window->GetRootWindow(); |
| 242 WmWindow* default_container = | 242 WmWindow* default_container = |
| 243 root_window->GetChildByShellWindowId(kShellWindowId_DefaultContainer); | 243 root_window->GetChildByShellWindowId(kShellWindowId_DefaultContainer); |
| 244 EXPECT_EQ(default_container, window->GetParent()); | 244 EXPECT_EQ(default_container, window->GetParent()); |
| 245 | 245 |
| 246 WmWindow* docked_container = | |
| 247 root_window->GetChildByShellWindowId(kShellWindowId_DockedContainer); | |
| 248 | |
| 249 // Check |window|'s item is not removed when it is re-parented to the dock. | |
| 250 docked_container->AddChild(window); | |
| 251 EXPECT_EQ(docked_container, window->GetParent()); | |
| 252 EXPECT_EQ(2, model_->item_count()); | |
| 253 | |
| 254 // The shelf item is removed when the window is closed, even if it is in the | 246 // The shelf item is removed when the window is closed, even if it is in the |
| 255 // docked container at the time. | 247 // docked container at the time. |
| 256 widget.reset(); | 248 widget.reset(); |
| 257 EXPECT_EQ(1, model_->item_count()); | 249 EXPECT_EQ(1, model_->item_count()); |
| 258 } | 250 } |
| 259 | 251 |
| 260 // Check |window|'s item is not changed during the dragging. | 252 // Check |window|'s item is not changed during the dragging. |
| 261 // TODO(simonhong): Add a test for removing a Window during the dragging. | 253 // TODO(simonhong): Add a test for removing a Window during the dragging. |
| 262 TEST_F(ShelfWindowWatcherTest, DragWindow) { | 254 TEST_F(ShelfWindowWatcherTest, DragWindow) { |
| 263 // TODO: investigate failure in mash. http://crbug.com/695562. | 255 // TODO: investigate failure in mash. http://crbug.com/695562. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 370 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
| 379 ShelfWindowWatcherTest::CreateShelfItem(window); | 371 ShelfWindowWatcherTest::CreateShelfItem(window); |
| 380 EXPECT_EQ(1, model->item_count()); | 372 EXPECT_EQ(1, model->item_count()); |
| 381 | 373 |
| 382 // Start the test user session; ShelfWindowWatcher will find the open window. | 374 // Start the test user session; ShelfWindowWatcher will find the open window. |
| 383 SetSessionStarted(true); | 375 SetSessionStarted(true); |
| 384 EXPECT_EQ(2, model->item_count()); | 376 EXPECT_EQ(2, model->item_count()); |
| 385 } | 377 } |
| 386 | 378 |
| 387 } // namespace ash | 379 } // namespace ash |
| OLD | NEW |