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/shelf/shelf_window_watcher.h" | 5 #include "ash/common/shelf/shelf_window_watcher.h" |
6 | 6 |
7 #include "ash/aura/wm_window_aura.h" | |
8 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
9 #include "ash/common/shelf/shelf_item_types.h" | 8 #include "ash/common/shelf/shelf_item_types.h" |
10 #include "ash/common/shelf/shelf_model.h" | 9 #include "ash/common/shelf/shelf_model.h" |
11 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
12 #include "ash/common/wm/window_resizer.h" | 11 #include "ash/common/wm/window_resizer.h" |
13 #include "ash/common/wm/window_state.h" | 12 #include "ash/common/wm/window_state.h" |
| 13 #include "ash/common/wm_lookup.h" |
14 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
15 #include "ash/shelf/shelf_util.h" | 15 #include "ash/common/wm_window.h" |
16 #include "ash/shell.h" | |
17 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
18 #include "ash/wm/window_state_aura.h" | |
19 #include "ash/wm/window_util.h" | |
20 #include "base/command_line.h" | |
21 #include "ui/aura/client/aura_constants.h" | |
22 #include "ui/aura/window.h" | |
23 #include "ui/base/hit_test.h" | 17 #include "ui/base/hit_test.h" |
| 18 #include "ui/views/widget/widget.h" |
24 | 19 |
25 namespace ash { | 20 namespace ash { |
26 | 21 |
27 class ShelfWindowWatcherTest : public test::AshTestBase { | 22 class ShelfWindowWatcherTest : public test::AshTestBase { |
28 public: | 23 public: |
29 ShelfWindowWatcherTest() : model_(NULL) {} | 24 ShelfWindowWatcherTest() : model_(nullptr) {} |
30 ~ShelfWindowWatcherTest() override {} | 25 ~ShelfWindowWatcherTest() override {} |
31 | 26 |
32 void SetUp() override { | 27 void SetUp() override { |
33 test::AshTestBase::SetUp(); | 28 test::AshTestBase::SetUp(); |
34 model_ = WmShell::Get()->shelf_model(); | 29 model_ = WmShell::Get()->shelf_model(); |
35 } | 30 } |
36 | 31 |
37 void TearDown() override { | 32 void TearDown() override { |
38 model_ = NULL; | 33 model_ = nullptr; |
39 test::AshTestBase::TearDown(); | 34 test::AshTestBase::TearDown(); |
40 } | 35 } |
41 | 36 |
42 ShelfID CreateShelfItem(aura::Window* window) { | 37 ShelfID CreateShelfItem(WmWindow* window) { |
43 ShelfID id = model_->next_id(); | 38 ShelfID id = model_->next_id(); |
44 ShelfItemDetails item_details; | 39 ShelfItemDetails item_details; |
45 item_details.type = TYPE_PLATFORM_APP; | 40 item_details.type = TYPE_PLATFORM_APP; |
46 SetShelfItemDetailsForWindow(window, item_details); | 41 window->SetShelfItemDetails(item_details); |
47 return id; | 42 return id; |
48 } | 43 } |
49 | 44 |
50 // Creates a window with ShelfItemDetails and adds it to the default window | |
51 // container. | |
52 std::unique_ptr<aura::Window> CreateWindowWithShelfItemDetails() { | |
53 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); | |
54 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | |
55 window->Init(ui::LAYER_TEXTURED); | |
56 window->Show(); | |
57 | |
58 CreateShelfItem(window.get()); | |
59 | |
60 ParentWindowInPrimaryRootWindow(window.get()); | |
61 return window; | |
62 } | |
63 | |
64 protected: | 45 protected: |
65 ShelfModel* model_; | 46 ShelfModel* model_; |
66 | 47 |
67 private: | 48 private: |
68 DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcherTest); | 49 DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcherTest); |
69 }; | 50 }; |
70 | 51 |
71 // Tests that shelf items are added and removed as windows are opened and | 52 // Ensure shelf items are added and removed as windows are opened and closed. |
72 // closed. | |
73 TEST_F(ShelfWindowWatcherTest, OpenAndClose) { | 53 TEST_F(ShelfWindowWatcherTest, OpenAndClose) { |
74 // ShelfModel only has an APP_LIST item. | 54 // ShelfModel only has an APP_LIST item. |
75 EXPECT_EQ(1, model_->item_count()); | 55 EXPECT_EQ(1, model_->item_count()); |
76 | 56 |
77 // Adding windows with ShelfItemDetails properties adds shelf items. | 57 // Adding windows with ShelfItemDetails properties adds shelf items. |
78 std::unique_ptr<aura::Window> w1(CreateWindowWithShelfItemDetails()); | 58 std::unique_ptr<views::Widget> widget1 = |
| 59 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 60 CreateShelfItem(WmLookup::Get()->GetWindowForWidget(widget1.get())); |
79 EXPECT_EQ(2, model_->item_count()); | 61 EXPECT_EQ(2, model_->item_count()); |
80 std::unique_ptr<aura::Window> w2(CreateWindowWithShelfItemDetails()); | 62 std::unique_ptr<views::Widget> widget2 = |
| 63 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 64 CreateShelfItem(WmLookup::Get()->GetWindowForWidget(widget2.get())); |
81 EXPECT_EQ(3, model_->item_count()); | 65 EXPECT_EQ(3, model_->item_count()); |
82 | 66 |
83 // Each ShelfItem is removed when the associated window is destroyed. | 67 // Each ShelfItem is removed when the associated window is destroyed. |
84 w1.reset(); | 68 widget1.reset(); |
85 EXPECT_EQ(2, model_->item_count()); | 69 EXPECT_EQ(2, model_->item_count()); |
86 w2.reset(); | 70 widget2.reset(); |
87 EXPECT_EQ(1, model_->item_count()); | 71 EXPECT_EQ(1, model_->item_count()); |
88 } | 72 } |
89 | 73 |
90 TEST_F(ShelfWindowWatcherTest, CreateAndRemoveShelfItemDetails) { | 74 TEST_F(ShelfWindowWatcherTest, CreateAndRemoveShelfItemDetails) { |
91 // ShelfModel only has an APP_LIST item. | 75 // ShelfModel only has an APP_LIST item. |
92 EXPECT_EQ(1, model_->item_count()); | 76 EXPECT_EQ(1, model_->item_count()); |
93 | 77 |
94 // Creating windows without ShelfItemDetails does not add items. | 78 // Creating windows without ShelfItemDetails does not add items. |
95 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(0)); | 79 std::unique_ptr<views::Widget> widget1 = |
96 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithId(0)); | 80 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 81 WmWindow* window1 = WmLookup::Get()->GetWindowForWidget(widget1.get()); |
| 82 std::unique_ptr<views::Widget> widget2 = |
| 83 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 84 WmWindow* window2 = WmLookup::Get()->GetWindowForWidget(widget2.get()); |
97 EXPECT_EQ(1, model_->item_count()); | 85 EXPECT_EQ(1, model_->item_count()); |
98 | 86 |
99 // Create a ShelfItem for w1. | 87 // Create a ShelfItem for the first window. |
100 ShelfID id_w1 = CreateShelfItem(w1.get()); | 88 ShelfID id_w1 = CreateShelfItem(window1); |
101 EXPECT_EQ(2, model_->item_count()); | 89 EXPECT_EQ(2, model_->item_count()); |
102 | 90 |
103 int index_w1 = model_->ItemIndexByID(id_w1); | 91 int index_w1 = model_->ItemIndexByID(id_w1); |
104 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); | 92 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); |
105 | 93 |
106 // Create a ShelfItem for w2. | 94 // Create a ShelfItem for the second window. |
107 ShelfID id_w2 = CreateShelfItem(w2.get()); | 95 ShelfID id_w2 = CreateShelfItem(window2); |
108 EXPECT_EQ(3, model_->item_count()); | 96 EXPECT_EQ(3, model_->item_count()); |
109 | 97 |
110 int index_w2 = model_->ItemIndexByID(id_w2); | 98 int index_w2 = model_->ItemIndexByID(id_w2); |
111 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w2].status); | 99 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w2].status); |
112 | 100 |
113 // ShelfItem is removed when its window property is cleared. | 101 // ShelfItem is removed when its window property is cleared. |
114 ClearShelfItemDetailsForWindow(w1.get()); | 102 window1->ClearShelfItemDetails(); |
115 EXPECT_EQ(2, model_->item_count()); | 103 EXPECT_EQ(2, model_->item_count()); |
116 ClearShelfItemDetailsForWindow(w2.get()); | 104 window2->ClearShelfItemDetails(); |
117 EXPECT_EQ(1, model_->item_count()); | 105 EXPECT_EQ(1, model_->item_count()); |
118 // Clearing twice doesn't do anything. | 106 // Clearing twice doesn't do anything. |
119 ClearShelfItemDetailsForWindow(w2.get()); | 107 window2->ClearShelfItemDetails(); |
120 EXPECT_EQ(1, model_->item_count()); | 108 EXPECT_EQ(1, model_->item_count()); |
121 } | 109 } |
122 | 110 |
123 TEST_F(ShelfWindowWatcherTest, ActivateWindow) { | 111 TEST_F(ShelfWindowWatcherTest, ActivateWindow) { |
124 // ShelfModel only have APP_LIST item. | 112 // ShelfModel only have APP_LIST item. |
125 EXPECT_EQ(1, model_->item_count()); | 113 EXPECT_EQ(1, model_->item_count()); |
126 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(0)); | 114 std::unique_ptr<views::Widget> widget1 = |
127 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithId(0)); | 115 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 116 WmWindow* window1 = WmLookup::Get()->GetWindowForWidget(widget1.get()); |
| 117 std::unique_ptr<views::Widget> widget2 = |
| 118 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 119 WmWindow* window2 = WmLookup::Get()->GetWindowForWidget(widget2.get()); |
128 | 120 |
129 // Create a ShelfItem for w1. | 121 // Create a ShelfItem for the first window. |
130 ShelfID id_w1 = CreateShelfItem(w1.get()); | 122 ShelfID id_w1 = CreateShelfItem(window1); |
131 EXPECT_EQ(2, model_->item_count()); | 123 EXPECT_EQ(2, model_->item_count()); |
132 int index_w1 = model_->ItemIndexByID(id_w1); | 124 int index_w1 = model_->ItemIndexByID(id_w1); |
133 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); | 125 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); |
134 | 126 |
135 // Create a ShelfItem for w2. | 127 // Create a ShelfItem for the second window. |
136 ShelfID id_w2 = CreateShelfItem(w2.get()); | 128 ShelfID id_w2 = CreateShelfItem(window2); |
137 EXPECT_EQ(3, model_->item_count()); | 129 EXPECT_EQ(3, model_->item_count()); |
138 int index_w2 = model_->ItemIndexByID(id_w2); | 130 int index_w2 = model_->ItemIndexByID(id_w2); |
139 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); | 131 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); |
| 132 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w2].status); |
| 133 |
| 134 // The ShelfItem for the first window is active when the window is activated. |
| 135 widget1->Activate(); |
| 136 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w1].status); |
140 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w2].status); | 137 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w2].status); |
141 | 138 |
142 // ShelfItem for w1 is active when w1 is activated. | 139 // The ShelfItem for the second window is active when the window is activated. |
143 wm::ActivateWindow(w1.get()); | 140 widget2->Activate(); |
144 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w1].status); | |
145 | |
146 // ShelfItem for w2 is active state when w2 is activated. | |
147 wm::ActivateWindow(w2.get()); | |
148 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); | 141 EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); |
149 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w2].status); | 142 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w2].status); |
150 } | 143 } |
151 | 144 |
152 TEST_F(ShelfWindowWatcherTest, UpdateWindowProperty) { | 145 TEST_F(ShelfWindowWatcherTest, UpdateWindowProperty) { |
153 // ShelfModel only has an APP_LIST item. | 146 // ShelfModel only has an APP_LIST item. |
154 EXPECT_EQ(1, model_->item_count()); | 147 EXPECT_EQ(1, model_->item_count()); |
155 | 148 |
156 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 149 std::unique_ptr<views::Widget> widget = |
| 150 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 151 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
157 | 152 |
158 // Create a ShelfItem for |window|. | 153 // Create a ShelfItem for |window|. |
159 ShelfID id = CreateShelfItem(window.get()); | 154 ShelfID id = CreateShelfItem(window); |
160 EXPECT_EQ(2, model_->item_count()); | 155 EXPECT_EQ(2, model_->item_count()); |
161 | 156 |
162 int index = model_->ItemIndexByID(id); | 157 int index = model_->ItemIndexByID(id); |
163 EXPECT_EQ(STATUS_RUNNING, model_->items()[index].status); | 158 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status); |
164 | 159 |
165 // Update ShelfItem for |window|. | 160 // Update ShelfItem for |window|. |
166 ShelfItemDetails details; | 161 ShelfItemDetails details; |
167 details.type = TYPE_PLATFORM_APP; | 162 details.type = TYPE_PLATFORM_APP; |
168 | 163 |
169 SetShelfItemDetailsForWindow(window.get(), details); | 164 window->SetShelfItemDetails(details); |
170 // No new item is created after updating a launcher item. | 165 // No new item is created after updating a launcher item. |
171 EXPECT_EQ(2, model_->item_count()); | 166 EXPECT_EQ(2, model_->item_count()); |
172 // index and id are not changed after updating a launcher item. | 167 // index and id are not changed after updating a launcher item. |
173 EXPECT_EQ(index, model_->ItemIndexByID(id)); | 168 EXPECT_EQ(index, model_->ItemIndexByID(id)); |
174 EXPECT_EQ(id, model_->items()[index].id); | 169 EXPECT_EQ(id, model_->items()[index].id); |
175 } | 170 } |
176 | 171 |
177 TEST_F(ShelfWindowWatcherTest, MaximizeAndRestoreWindow) { | 172 TEST_F(ShelfWindowWatcherTest, MaximizeAndRestoreWindow) { |
178 // ShelfModel only has an APP_LIST item. | 173 // ShelfModel only has an APP_LIST item. |
179 EXPECT_EQ(1, model_->item_count()); | 174 EXPECT_EQ(1, model_->item_count()); |
180 | 175 |
181 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 176 std::unique_ptr<views::Widget> widget = |
182 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 177 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 178 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
| 179 wm::WindowState* window_state = window->GetWindowState(); |
183 | 180 |
184 // Create a ShelfItem for |window|. | 181 // Create a ShelfItem for |window|. |
185 ShelfID id = CreateShelfItem(window.get()); | 182 ShelfID id = CreateShelfItem(window); |
186 EXPECT_EQ(2, model_->item_count()); | 183 EXPECT_EQ(2, model_->item_count()); |
187 | 184 |
188 int index = model_->ItemIndexByID(id); | 185 int index = model_->ItemIndexByID(id); |
189 EXPECT_EQ(STATUS_RUNNING, model_->items()[index].status); | 186 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status); |
190 | 187 |
191 // Maximize window |window|. | 188 // Maximize window |window|. |
192 EXPECT_FALSE(window_state->IsMaximized()); | 189 EXPECT_FALSE(window_state->IsMaximized()); |
193 window_state->Maximize(); | 190 window_state->Maximize(); |
194 EXPECT_TRUE(window_state->IsMaximized()); | 191 EXPECT_TRUE(window_state->IsMaximized()); |
195 // No new item is created after maximizing a window |window|. | 192 // No new item is created after maximizing a window |window|. |
196 EXPECT_EQ(2, model_->item_count()); | 193 EXPECT_EQ(2, model_->item_count()); |
197 // index and id are not changed after maximizing a window |window|. | 194 // index and id are not changed after maximizing a window |window|. |
198 EXPECT_EQ(index, model_->ItemIndexByID(id)); | 195 EXPECT_EQ(index, model_->ItemIndexByID(id)); |
199 EXPECT_EQ(id, model_->items()[index].id); | 196 EXPECT_EQ(id, model_->items()[index].id); |
200 | 197 |
201 // Restore window |window|. | 198 // Restore window |window|. |
202 window_state->Restore(); | 199 window_state->Restore(); |
203 EXPECT_FALSE(window_state->IsMaximized()); | 200 EXPECT_FALSE(window_state->IsMaximized()); |
204 // No new item is created after restoring a window |window|. | 201 // No new item is created after restoring a window |window|. |
205 EXPECT_EQ(2, model_->item_count()); | 202 EXPECT_EQ(2, model_->item_count()); |
206 // Index and id are not changed after maximizing a window |window|. | 203 // Index and id are not changed after maximizing a window |window|. |
207 EXPECT_EQ(index, model_->ItemIndexByID(id)); | 204 EXPECT_EQ(index, model_->ItemIndexByID(id)); |
208 EXPECT_EQ(id, model_->items()[index].id); | 205 EXPECT_EQ(id, model_->items()[index].id); |
209 } | 206 } |
210 | 207 |
211 // Check that an item is maintained when its associated Window is docked. | 208 // Check that an item is maintained when its associated Window is docked. |
212 TEST_F(ShelfWindowWatcherTest, DockWindow) { | 209 TEST_F(ShelfWindowWatcherTest, DockWindow) { |
213 // ShelfModel only has an APP_LIST item. | 210 // ShelfModel only has an APP_LIST item. |
214 EXPECT_EQ(1, model_->item_count()); | 211 EXPECT_EQ(1, model_->item_count()); |
215 | 212 |
216 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 213 std::unique_ptr<views::Widget> widget = |
217 window->set_owned_by_parent(false); | 214 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 215 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
218 | 216 |
219 // Create a ShelfItem for |window|. | 217 // Create a ShelfItem for |window|. |
220 ShelfID id = CreateShelfItem(window.get()); | 218 ShelfID id = CreateShelfItem(window); |
221 EXPECT_EQ(2, model_->item_count()); | 219 EXPECT_EQ(2, model_->item_count()); |
222 | 220 |
223 int index = model_->ItemIndexByID(id); | 221 int index = model_->ItemIndexByID(id); |
224 EXPECT_EQ(STATUS_RUNNING, model_->items()[index].status); | 222 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status); |
225 | 223 |
226 aura::Window* root_window = window->GetRootWindow(); | 224 WmWindow* root_window = window->GetRootWindow(); |
227 aura::Window* default_container = | 225 WmWindow* default_container = |
228 Shell::GetContainer(root_window, kShellWindowId_DefaultContainer); | 226 root_window->GetChildByShellWindowId(kShellWindowId_DefaultContainer); |
229 EXPECT_EQ(default_container, window->parent()); | 227 EXPECT_EQ(default_container, window->GetParent()); |
230 | 228 |
231 aura::Window* docked_container = | 229 WmWindow* docked_container = |
232 Shell::GetContainer(root_window, kShellWindowId_DockedContainer); | 230 root_window->GetChildByShellWindowId(kShellWindowId_DockedContainer); |
233 | 231 |
234 // Check |window|'s item is not removed when it is re-parented to the dock. | 232 // Check |window|'s item is not removed when it is re-parented to the dock. |
235 docked_container->AddChild(window.get()); | 233 docked_container->AddChild(window); |
| 234 EXPECT_EQ(docked_container, window->GetParent()); |
236 EXPECT_EQ(2, model_->item_count()); | 235 EXPECT_EQ(2, model_->item_count()); |
237 | 236 |
238 // The shelf item is removed when the window is closed, even if it is in the | 237 // The shelf item is removed when the window is closed, even if it is in the |
239 // docked container at the time. | 238 // docked container at the time. |
240 window.reset(); | 239 widget.reset(); |
241 EXPECT_EQ(1, model_->item_count()); | 240 EXPECT_EQ(1, model_->item_count()); |
242 } | 241 } |
243 | 242 |
244 // Check |window|'s item is not changed during the dragging. | 243 // Check |window|'s item is not changed during the dragging. |
245 // TODO(simonhong): Add a test for removing a Window during the dragging. | 244 // TODO(simonhong): Add a test for removing a Window during the dragging. |
246 TEST_F(ShelfWindowWatcherTest, DragWindow) { | 245 TEST_F(ShelfWindowWatcherTest, DragWindow) { |
247 // ShelfModel only has an APP_LIST item. | 246 // ShelfModel only has an APP_LIST item. |
248 EXPECT_EQ(1, model_->item_count()); | 247 EXPECT_EQ(1, model_->item_count()); |
249 | 248 |
250 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 249 std::unique_ptr<views::Widget> widget = |
| 250 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 251 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
251 | 252 |
252 // Create a ShelfItem for |window|. | 253 // Create a ShelfItem for |window|. |
253 ShelfID id = CreateShelfItem(window.get()); | 254 ShelfID id = CreateShelfItem(window); |
254 EXPECT_EQ(2, model_->item_count()); | 255 EXPECT_EQ(2, model_->item_count()); |
255 | 256 |
256 int index = model_->ItemIndexByID(id); | 257 int index = model_->ItemIndexByID(id); |
257 EXPECT_EQ(STATUS_RUNNING, model_->items()[index].status); | 258 EXPECT_EQ(STATUS_ACTIVE, model_->items()[index].status); |
258 | 259 |
259 // Simulate dragging of |window| and check its item is not changed. | 260 // Simulate dragging of |window| and check its item is not changed. |
260 std::unique_ptr<WindowResizer> resizer( | 261 std::unique_ptr<WindowResizer> resizer(CreateWindowResizer( |
261 CreateWindowResizer(WmWindowAura::Get(window.get()), gfx::Point(), | 262 window, gfx::Point(), HTCAPTION, aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
262 HTCAPTION, aura::client::WINDOW_MOVE_SOURCE_MOUSE)); | |
263 ASSERT_TRUE(resizer.get()); | 263 ASSERT_TRUE(resizer.get()); |
264 resizer->Drag(gfx::Point(50, 50), 0); | 264 resizer->Drag(gfx::Point(50, 50), 0); |
265 resizer->CompleteDrag(); | 265 resizer->CompleteDrag(); |
266 | 266 |
267 // Index and id are not changed after dragging a |window|. | 267 // Index and id are not changed after dragging a |window|. |
268 EXPECT_EQ(index, model_->ItemIndexByID(id)); | 268 EXPECT_EQ(index, model_->ItemIndexByID(id)); |
269 EXPECT_EQ(id, model_->items()[index].id); | 269 EXPECT_EQ(id, model_->items()[index].id); |
270 } | 270 } |
271 | 271 |
272 } // namespace ash | 272 } // namespace ash |
OLD | NEW |