| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w2].status); | 98 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w2].status); |
| 99 | 99 |
| 100 // ShelfItem is removed when the item type window property is cleared. | 100 // ShelfItem is removed when the item type window property is cleared. |
| 101 window1->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_UNDEFINED); | 101 window1->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_UNDEFINED); |
| 102 EXPECT_EQ(2, model_->item_count()); | 102 EXPECT_EQ(2, model_->item_count()); |
| 103 window2->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_UNDEFINED); | 103 window2->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_UNDEFINED); |
| 104 EXPECT_EQ(1, model_->item_count()); | 104 EXPECT_EQ(1, model_->item_count()); |
| 105 // Clearing twice doesn't do anything. | 105 // Clearing twice doesn't do anything. |
| 106 window2->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_UNDEFINED); | 106 window2->SetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE, TYPE_UNDEFINED); |
| 107 EXPECT_EQ(1, model_->item_count()); | 107 EXPECT_EQ(1, model_->item_count()); |
| 108 | |
| 109 // Setting an icon id (without a valid item type) does not add a shelf item. | |
| 110 window2->SetIntProperty(WmWindowProperty::SHELF_ICON_RESOURCE_ID, 1234); | |
| 111 EXPECT_EQ(1, model_->item_count()); | |
| 112 } | 108 } |
| 113 | 109 |
| 114 TEST_F(ShelfWindowWatcherTest, ActivateWindow) { | 110 TEST_F(ShelfWindowWatcherTest, ActivateWindow) { |
| 115 // ShelfModel only have APP_LIST item. | 111 // ShelfModel only have APP_LIST item. |
| 116 EXPECT_EQ(1, model_->item_count()); | 112 EXPECT_EQ(1, model_->item_count()); |
| 117 std::unique_ptr<views::Widget> widget1 = | 113 std::unique_ptr<views::Widget> widget1 = |
| 118 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); | 114 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 119 WmWindow* window1 = WmLookup::Get()->GetWindowForWidget(widget1.get()); | 115 WmWindow* window1 = WmLookup::Get()->GetWindowForWidget(widget1.get()); |
| 120 std::unique_ptr<views::Widget> widget2 = | 116 std::unique_ptr<views::Widget> widget2 = |
| 121 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); | 117 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Each ShelfItem is removed when the associated window is destroyed. | 301 // Each ShelfItem is removed when the associated window is destroyed. |
| 306 panel_widget.CloseNow(); | 302 panel_widget.CloseNow(); |
| 307 EXPECT_EQ(3, model_->item_count()); | 303 EXPECT_EQ(3, model_->item_count()); |
| 308 widget2.reset(); | 304 widget2.reset(); |
| 309 EXPECT_EQ(2, model_->item_count()); | 305 EXPECT_EQ(2, model_->item_count()); |
| 310 widget1.reset(); | 306 widget1.reset(); |
| 311 EXPECT_EQ(1, model_->item_count()); | 307 EXPECT_EQ(1, model_->item_count()); |
| 312 } | 308 } |
| 313 | 309 |
| 314 } // namespace ash | 310 } // namespace ash |
| OLD | NEW |