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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 window_state->Restore(); | 212 window_state->Restore(); |
213 EXPECT_FALSE(window_state->IsMaximized()); | 213 EXPECT_FALSE(window_state->IsMaximized()); |
214 // No new item is created after restoring a window |window|. | 214 // No new item is created after restoring a window |window|. |
215 EXPECT_EQ(2, model_->item_count()); | 215 EXPECT_EQ(2, model_->item_count()); |
216 // Index and id are not changed after maximizing a window |window|. | 216 // Index and id are not changed after maximizing a window |window|. |
217 EXPECT_EQ(index, model_->ItemIndexByID(id)); | 217 EXPECT_EQ(index, model_->ItemIndexByID(id)); |
218 EXPECT_EQ(id, model_->items()[index].id); | 218 EXPECT_EQ(id, model_->items()[index].id); |
219 } | 219 } |
220 | 220 |
221 // Check that an item is maintained when its associated Window is docked. | 221 // Check that an item is maintained when its associated Window is docked. |
222 TEST_F(ShelfWindowWatcherTest, DockWindow) { | 222 TEST_F(ShelfWindowWatcherTest, DockWindow) { |
varkha
2017/02/28 00:59:02
Do we still need this test?
afakhry
2017/03/09 22:28:26
Nope. Removed.
| |
223 // TODO: investigate failure in mash. http://crbug.com/695562. | 223 // TODO: investigate failure in mash. http://crbug.com/695562. |
224 if (WmShell::Get()->IsRunningInMash()) | 224 if (WmShell::Get()->IsRunningInMash()) |
225 return; | 225 return; |
226 | 226 |
227 // ShelfModel only has an APP_LIST item. | 227 // ShelfModel only has an APP_LIST item. |
228 EXPECT_EQ(1, model_->item_count()); | 228 EXPECT_EQ(1, model_->item_count()); |
229 | 229 |
230 std::unique_ptr<views::Widget> widget = | 230 std::unique_ptr<views::Widget> widget = |
231 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); | 231 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
232 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 232 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
233 | 233 |
234 // Create a ShelfItem for |window|. | 234 // Create a ShelfItem for |window|. |
235 ShelfID id = CreateShelfItem(window); | 235 ShelfID id = CreateShelfItem(window); |
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 |