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

Side by Side Diff: ash/common/shelf/shelf_window_watcher_unittest.cc

Issue 2700523004: Remove docked windows entirely in M59. (Closed)
Patch Set: Rebase Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // Restore window |window|. 218 // Restore window |window|.
219 window_state->Restore(); 219 window_state->Restore();
220 EXPECT_FALSE(window_state->IsMaximized()); 220 EXPECT_FALSE(window_state->IsMaximized());
221 // No new item is created after restoring a window |window|. 221 // No new item is created after restoring a window |window|.
222 EXPECT_EQ(2, model_->item_count()); 222 EXPECT_EQ(2, model_->item_count());
223 // Index and id are not changed after maximizing a window |window|. 223 // Index and id are not changed after maximizing a window |window|.
224 EXPECT_EQ(index, model_->ItemIndexByID(id)); 224 EXPECT_EQ(index, model_->ItemIndexByID(id));
225 EXPECT_EQ(id, model_->items()[index].id); 225 EXPECT_EQ(id, model_->items()[index].id);
226 } 226 }
227 227
228 // Check that an item is maintained when its associated Window is docked.
229 TEST_F(ShelfWindowWatcherTest, DockWindow) {
230 // TODO: investigate failure in mash. http://crbug.com/695562.
231 if (WmShell::Get()->IsRunningInMash())
232 return;
233
234 // ShelfModel only has an APP_LIST item.
235 EXPECT_EQ(1, model_->item_count());
236
237 std::unique_ptr<views::Widget> widget =
238 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect());
239 WmWindow* window = WmWindow::Get(widget->GetNativeWindow());
240
241 // Create a ShelfItem for |window|.
242 ShelfID id = CreateShelfItem(window);
243 EXPECT_EQ(2, model_->item_count());
244
245 int index = model_->ItemIndexByID(id);
246 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status);
247
248 WmWindow* root_window = window->GetRootWindow();
249 WmWindow* default_container =
250 root_window->GetChildByShellWindowId(kShellWindowId_DefaultContainer);
251 EXPECT_EQ(default_container, window->GetParent());
252
253 WmWindow* docked_container =
254 root_window->GetChildByShellWindowId(kShellWindowId_DockedContainer);
255
256 // Check |window|'s item is not removed when it is re-parented to the dock.
257 docked_container->AddChild(window);
258 EXPECT_EQ(docked_container, window->GetParent());
259 EXPECT_EQ(2, model_->item_count());
260
261 // The shelf item is removed when the window is closed, even if it is in the
262 // docked container at the time.
263 widget.reset();
264 EXPECT_EQ(1, model_->item_count());
265 }
266
267 // Check |window|'s item is not changed during the dragging. 228 // Check |window|'s item is not changed during the dragging.
268 // TODO(simonhong): Add a test for removing a Window during the dragging. 229 // TODO(simonhong): Add a test for removing a Window during the dragging.
269 TEST_F(ShelfWindowWatcherTest, DragWindow) { 230 TEST_F(ShelfWindowWatcherTest, DragWindow) {
270 // TODO: investigate failure in mash. http://crbug.com/695562. 231 // TODO: investigate failure in mash. http://crbug.com/695562.
271 if (WmShell::Get()->IsRunningInMash()) 232 if (WmShell::Get()->IsRunningInMash())
272 return; 233 return;
273 234
274 // ShelfModel only has an APP_LIST item. 235 // ShelfModel only has an APP_LIST item.
275 EXPECT_EQ(1, model_->item_count()); 236 EXPECT_EQ(1, model_->item_count());
276 237
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 WmWindow* window = WmWindow::Get(widget->GetNativeWindow()); 349 WmWindow* window = WmWindow::Get(widget->GetNativeWindow());
389 ShelfWindowWatcherTest::CreateShelfItem(window); 350 ShelfWindowWatcherTest::CreateShelfItem(window);
390 EXPECT_EQ(1, model->item_count()); 351 EXPECT_EQ(1, model->item_count());
391 352
392 // Start the test user session; ShelfWindowWatcher will find the open window. 353 // Start the test user session; ShelfWindowWatcher will find the open window.
393 SetSessionStarted(true); 354 SetSessionStarted(true);
394 EXPECT_EQ(2, model->item_count()); 355 EXPECT_EQ(2, model->item_count());
395 } 356 }
396 357
397 } // namespace ash 358 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698