Chromium Code Reviews| 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/shelf/shelf_item_types.h" | 7 #include "ash/common/shelf/shelf_item_types.h" |
| 8 #include "ash/common/shelf/shelf_model.h" | 8 #include "ash/common/shelf/shelf_model.h" |
| 9 #include "ash/common/wm/window_resizer.h" | 9 #include "ash/common/wm/window_resizer.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 window, gfx::Point(), HTCAPTION, aura::client::WINDOW_MOVE_SOURCE_MOUSE)); | 261 window, gfx::Point(), HTCAPTION, aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
| 262 ASSERT_TRUE(resizer.get()); | 262 ASSERT_TRUE(resizer.get()); |
| 263 resizer->Drag(gfx::Point(50, 50), 0); | 263 resizer->Drag(gfx::Point(50, 50), 0); |
| 264 resizer->CompleteDrag(); | 264 resizer->CompleteDrag(); |
| 265 | 265 |
| 266 // Index and id are not changed after dragging a |window|. | 266 // Index and id are not changed after dragging a |window|. |
| 267 EXPECT_EQ(index, model_->ItemIndexByID(id)); | 267 EXPECT_EQ(index, model_->ItemIndexByID(id)); |
| 268 EXPECT_EQ(id, model_->items()[index].id); | 268 EXPECT_EQ(id, model_->items()[index].id); |
| 269 } | 269 } |
| 270 | 270 |
| 271 // Ensure shelf items are added and removed as panels are opened and closed. | |
| 272 TEST_F(ShelfWindowWatcherTest, PanelWindow) { | |
| 273 // ShelfModel only has an APP_LIST item. | |
| 274 EXPECT_EQ(1, model_->item_count()); | |
| 275 | |
| 276 // Adding windows with valid ShelfItemType properties adds shelf items. | |
| 277 std::unique_ptr<views::Widget> widget1 = | |
| 278 CreateTestWidget(nullptr, kShellWindowId_PanelContainer, gfx::Rect()); | |
| 279 WmWindow* window_1 = WmLookup::Get()->GetWindowForWidget(widget1.get()); | |
|
James Cook
2016/11/02 17:53:44
super nit: maybe window1 here or widget_1 above?
msw
2016/11/10 21:07:46
Done.
| |
| 280 window_1->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_APP_PANEL); | |
| 281 EXPECT_EQ(2, model_->item_count()); | |
| 282 std::unique_ptr<views::Widget> widget2 = | |
| 283 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); | |
| 284 WmWindow* window_2 = WmLookup::Get()->GetWindowForWidget(widget2.get()); | |
| 285 window_2->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_APP_PANEL); | |
| 286 EXPECT_EQ(3, model_->item_count()); | |
| 287 | |
| 288 // Each ShelfItem is removed when the associated window is destroyed. | |
| 289 widget1.reset(); | |
| 290 EXPECT_EQ(2, model_->item_count()); | |
| 291 widget2.reset(); | |
| 292 EXPECT_EQ(1, model_->item_count()); | |
| 293 } | |
|
James Cook
2016/11/02 17:53:44
Thanks for writing a test.
Is it possible to writ
msw
2016/11/10 21:07:46
I added LauncherPlatformAppBrowserTest.AppPanel, r
| |
| 294 | |
| 271 } // namespace ash | 295 } // namespace ash |
| OLD | NEW |