OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 | 121 |
122 ash::Launcher* launcher_; | 122 ash::Launcher* launcher_; |
123 ash::LauncherModel* model_; | 123 ash::LauncherModel* model_; |
124 }; | 124 }; |
125 | 125 |
126 // Test that we can launch a platform app and get a running item. | 126 // Test that we can launch a platform app and get a running item. |
127 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { | 127 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { |
128 ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay(); | 128 ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay(); |
129 int item_count = launcher->model()->item_count(); | 129 int item_count = launcher->model()->item_count(); |
130 const Extension* extension = LoadAndLaunchPlatformApp("launch"); | 130 const Extension* extension = LoadPlatformApp("launch"); |
131 ShellWindow* window = CreateShellWindow(extension); | 131 ShellWindow* window = CreateShellWindow(extension); |
132 ++item_count; | 132 ++item_count; |
133 ASSERT_EQ(item_count, launcher->model()->item_count()); | 133 ASSERT_EQ(item_count, launcher->model()->item_count()); |
134 ash::LauncherItem item = | 134 ash::LauncherItem item = |
135 launcher->model()->items()[launcher->model()->item_count() - 2]; | 135 launcher->model()->items()[launcher->model()->item_count() - 2]; |
136 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 136 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
137 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 137 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
138 CloseShellWindow(window); | 138 CloseShellWindow(window); |
139 --item_count; | 139 --item_count; |
140 EXPECT_EQ(item_count, launcher->model()->item_count()); | 140 EXPECT_EQ(item_count, launcher->model()->item_count()); |
| 141 CloseShellWindowsAndWaitForAppToExit(); |
141 } | 142 } |
142 | 143 |
143 // Test that we can launch a platform app that already has a shortcut. | 144 // Test that we can launch a platform app that already has a shortcut. |
144 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { | 145 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { |
145 int item_count = launcher_->model()->item_count(); | 146 int item_count = launcher_->model()->item_count(); |
146 | 147 |
147 // First get app_id. | 148 // First get app_id. |
148 const Extension* extension = LoadAndLaunchPlatformApp("launch"); | 149 const Extension* extension = LoadPlatformApp("launch"); |
149 const std::string app_id = extension->id(); | 150 const std::string app_id = extension->id(); |
150 | 151 |
151 // Then create a shortcut. | 152 // Then create a shortcut. |
152 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); | 153 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); |
153 ++item_count; | 154 ++item_count; |
154 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 155 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
155 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); | 156 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); |
156 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 157 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
157 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 158 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
158 | 159 |
159 // Open a window. Confirm the item is now running. | 160 // Open a window. Confirm the item is now running. |
160 ShellWindow* window = CreateShellWindow(extension); | 161 ShellWindow* window = CreateShellWindow(extension); |
161 ash::wm::ActivateWindow(window->GetNativeWindow()); | 162 ash::wm::ActivateWindow(window->GetNativeWindow()); |
162 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 163 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
163 item = *launcher_->model()->ItemByID(shortcut_id); | 164 item = *launcher_->model()->ItemByID(shortcut_id); |
164 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 165 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
165 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 166 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
166 | 167 |
167 // Then close it, make sure there's still an item. | 168 // Then close it, make sure there's still an item. |
168 CloseShellWindow(window); | 169 CloseShellWindow(window); |
169 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 170 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
170 item = *launcher_->model()->ItemByID(shortcut_id); | 171 item = *launcher_->model()->ItemByID(shortcut_id); |
171 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 172 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
172 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 173 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 174 CloseShellWindowsAndWaitForAppToExit(); |
173 } | 175 } |
174 | 176 |
175 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { | 177 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { |
176 // Run. | 178 // Run. |
177 int item_count = launcher_->model()->item_count(); | 179 int item_count = launcher_->model()->item_count(); |
178 const Extension* extension = LoadAndLaunchPlatformApp("launch"); | 180 const Extension* extension = LoadPlatformApp("launch"); |
179 ShellWindow* window = CreateShellWindow(extension); | 181 ShellWindow* window = CreateShellWindow(extension); |
180 ++item_count; | 182 ++item_count; |
181 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 183 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
182 ash::LauncherItem item = | 184 ash::LauncherItem item = |
183 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 185 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
184 ash::LauncherID id = item.id; | 186 ash::LauncherID id = item.id; |
185 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 187 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
186 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 188 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
187 | 189 |
188 // Create a shortcut. The app item should be after it. | 190 // Create a shortcut. The app item should be after it. |
(...skipping 13 matching lines...) Expand all Loading... |
202 // New shortcuts should come after the item. | 204 // New shortcuts should come after the item. |
203 ash::LauncherID bar_id = CreateAppShortcutLauncherItem("bar"); | 205 ash::LauncherID bar_id = CreateAppShortcutLauncherItem("bar"); |
204 ++item_count; | 206 ++item_count; |
205 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 207 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
206 EXPECT_LT(launcher_->model()->ItemIndexByID(id), | 208 EXPECT_LT(launcher_->model()->ItemIndexByID(id), |
207 launcher_->model()->ItemIndexByID(bar_id)); | 209 launcher_->model()->ItemIndexByID(bar_id)); |
208 | 210 |
209 // Then close it, make sure the item remains. | 211 // Then close it, make sure the item remains. |
210 CloseShellWindow(window); | 212 CloseShellWindow(window); |
211 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 213 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 214 CloseShellWindowsAndWaitForAppToExit(); |
212 } | 215 } |
213 | 216 |
214 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { | 217 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { |
215 int item_count = launcher_->model()->item_count(); | 218 int item_count = launcher_->model()->item_count(); |
216 | 219 |
217 // First get app_id. | 220 // First get app_id. |
218 const Extension* extension = LoadAndLaunchPlatformApp("launch"); | 221 const Extension* extension = LoadPlatformApp("launch"); |
219 const std::string app_id = extension->id(); | 222 const std::string app_id = extension->id(); |
220 | 223 |
221 // Then create a shortcut. | 224 // Then create a shortcut. |
222 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); | 225 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); |
223 ++item_count; | 226 ++item_count; |
224 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 227 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
225 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); | 228 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); |
226 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 229 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
227 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 230 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
228 | 231 |
(...skipping 20 matching lines...) Expand all Loading... |
249 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 252 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
250 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 253 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
251 // The item should have moved after the other shortcuts. | 254 // The item should have moved after the other shortcuts. |
252 EXPECT_GT(launcher_->model()->ItemIndexByID(shortcut_id), | 255 EXPECT_GT(launcher_->model()->ItemIndexByID(shortcut_id), |
253 launcher_->model()->ItemIndexByID(foo_id)); | 256 launcher_->model()->ItemIndexByID(foo_id)); |
254 | 257 |
255 // Then close it, make sure the item's gone. | 258 // Then close it, make sure the item's gone. |
256 CloseShellWindow(window); | 259 CloseShellWindow(window); |
257 --item_count; | 260 --item_count; |
258 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 261 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 262 CloseShellWindowsAndWaitForAppToExit(); |
259 } | 263 } |
260 | 264 |
261 // Test that we can launch a platform app with more than one window. | 265 // Test that we can launch a platform app with more than one window. |
262 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { | 266 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { |
263 int item_count = launcher_->model()->item_count(); | 267 int item_count = launcher_->model()->item_count(); |
264 | 268 |
265 // First run app. | 269 // First run app. |
266 const Extension* extension = LoadAndLaunchPlatformApp("launch"); | 270 const Extension* extension = LoadPlatformApp("launch"); |
267 ShellWindow* window1 = CreateShellWindow(extension); | 271 ShellWindow* window1 = CreateShellWindow(extension); |
268 ++item_count; | 272 ++item_count; |
269 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 273 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
270 ash::LauncherItem item = | 274 ash::LauncherItem item = |
271 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 275 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
272 ash::LauncherID item_id = item.id; | 276 ash::LauncherID item_id = item.id; |
273 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 277 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
274 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 278 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
275 | 279 |
276 // Add second window. | 280 // Add second window. |
277 ShellWindow* window2 = CreateShellWindow(extension); | 281 ShellWindow* window2 = CreateShellWindow(extension); |
278 // Confirm item stays. | 282 // Confirm item stays. |
279 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 283 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
280 item = *launcher_->model()->ItemByID(item_id); | 284 item = *launcher_->model()->ItemByID(item_id); |
281 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 285 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
282 | 286 |
283 // Close second window. | 287 // Close second window. |
284 CloseShellWindow(window2); | 288 CloseShellWindow(window2); |
285 // Confirm item stays. | 289 // Confirm item stays. |
286 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 290 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
287 item = *launcher_->model()->ItemByID(item_id); | 291 item = *launcher_->model()->ItemByID(item_id); |
288 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 292 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
289 | 293 |
290 // Close first window. | 294 // Close first window. |
291 CloseShellWindow(window1); | 295 CloseShellWindow(window1); |
292 // Confirm item is removed. | 296 // Confirm item is removed. |
293 --item_count; | 297 --item_count; |
294 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 298 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
| 299 CloseShellWindowsAndWaitForAppToExit(); |
295 } | 300 } |
296 | 301 |
297 // Times out on ChromeOS: http://crbug.com/159394 | 302 // Times out on ChromeOS: http://crbug.com/159394 |
298 #if defined(OS_CHROMEOS) | 303 #if defined(OS_CHROMEOS) |
299 #define MAYBE_MultipleApps DISABLED_MultipleApps | 304 #define MAYBE_MultipleApps DISABLED_MultipleApps |
300 #else | 305 #else |
301 #define MAYBE_MultipleApps MultipleApps | 306 #define MAYBE_MultipleApps MultipleApps |
302 #endif | 307 #endif |
303 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_MultipleApps) { | 308 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_MultipleApps) { |
304 int item_count = launcher_->model()->item_count(); | 309 int item_count = launcher_->model()->item_count(); |
305 | 310 |
306 // First run app. | 311 // First run app. |
307 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); | 312 const Extension* extension1 = LoadPlatformApp("launch"); |
308 ShellWindow* window1 = CreateShellWindow(extension1); | 313 ShellWindow* window1 = CreateShellWindow(extension1); |
309 ++item_count; | 314 ++item_count; |
310 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 315 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
311 ash::LauncherItem item1 = | 316 ash::LauncherItem item1 = |
312 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 317 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
313 ash::LauncherID item_id1 = item1.id; | 318 ash::LauncherID item_id1 = item1.id; |
314 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 319 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
315 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 320 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
316 | 321 |
317 // Then run second app. | 322 // Then run second app. |
318 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); | 323 const Extension* extension2 = LoadPlatformApp("launch_2"); |
319 ShellWindow* window2 = CreateShellWindow(extension2); | 324 ShellWindow* window2 = CreateShellWindow(extension2); |
320 ++item_count; | 325 ++item_count; |
321 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 326 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
322 ash::LauncherItem item2 = | 327 ash::LauncherItem item2 = |
323 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 328 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
324 ash::LauncherID item_id2 = item2.id; | 329 ash::LauncherID item_id2 = item2.id; |
325 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); | 330 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); |
326 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 331 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
327 | 332 |
328 EXPECT_NE(item_id1, item_id2); | 333 EXPECT_NE(item_id1, item_id2); |
329 EXPECT_EQ(ash::STATUS_RUNNING, | 334 EXPECT_EQ(ash::STATUS_RUNNING, |
330 launcher_->model()->ItemByID(item_id1)->status); | 335 launcher_->model()->ItemByID(item_id1)->status); |
331 | 336 |
332 // Close second app. | 337 // Close second app. |
333 CloseShellWindow(window2); | 338 CloseShellWindow(window2); |
334 --item_count; | 339 --item_count; |
335 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 340 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
336 // First app should be active again. | 341 // First app should be active again. |
337 EXPECT_EQ(ash::STATUS_ACTIVE, | 342 EXPECT_EQ(ash::STATUS_ACTIVE, |
338 launcher_->model()->ItemByID(item_id1)->status); | 343 launcher_->model()->ItemByID(item_id1)->status); |
339 | 344 |
340 // Close first app. | 345 // Close first app. |
341 CloseShellWindow(window1); | 346 CloseShellWindow(window1); |
342 --item_count; | 347 --item_count; |
343 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 348 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
344 | 349 CloseShellWindowsAndWaitForAppToExit(); |
345 } | 350 } |
346 | 351 |
347 // Confirm that app windows can be reactivated by clicking their icons and that | 352 // Confirm that app windows can be reactivated by clicking their icons and that |
348 // the correct activation order is maintained. | 353 // the correct activation order is maintained. |
349 // Times out on ChromeOS: http://crbug.com/159394 | 354 // Times out on ChromeOS: http://crbug.com/159394 |
350 #if defined(OS_CHROMEOS) | 355 #if defined(OS_CHROMEOS) |
351 #define MAYBE_WindowActivation DISABLED_WindowActivation | 356 #define MAYBE_WindowActivation DISABLED_WindowActivation |
352 #else | 357 #else |
353 #define MAYBE_WindowActivation WindowActivation | 358 #define MAYBE_WindowActivation WindowActivation |
354 #endif | 359 #endif |
355 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) { | 360 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) { |
356 int item_count = launcher_->model()->item_count(); | 361 int item_count = launcher_->model()->item_count(); |
357 | 362 |
358 // First run app. | 363 // First run app. |
359 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); | 364 const Extension* extension1 = LoadPlatformApp("launch"); |
360 ShellWindow* window1 = CreateShellWindow(extension1); | 365 ShellWindow* window1 = CreateShellWindow(extension1); |
361 ++item_count; | 366 ++item_count; |
362 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 367 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
363 ash::LauncherItem item1 = | 368 ash::LauncherItem item1 = |
364 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 369 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
365 ash::LauncherID item_id1 = item1.id; | 370 ash::LauncherID item_id1 = item1.id; |
366 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 371 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
367 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 372 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
368 | 373 |
369 // Then run second app. | 374 // Then run second app. |
370 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); | 375 const Extension* extension2 = LoadPlatformApp("launch_2"); |
371 ShellWindow* window2 = CreateShellWindow(extension2); | 376 ShellWindow* window2 = CreateShellWindow(extension2); |
372 ++item_count; | 377 ++item_count; |
373 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 378 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
374 ash::LauncherItem item2 = | 379 ash::LauncherItem item2 = |
375 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 380 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
376 ash::LauncherID item_id2 = item2.id; | 381 ash::LauncherID item_id2 = item2.id; |
377 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); | 382 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); |
378 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 383 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
379 | 384 |
380 EXPECT_NE(item_id1, item_id2); | 385 EXPECT_NE(item_id1, item_id2); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 --item_count; | 434 --item_count; |
430 EXPECT_EQ(item_count, launcher_->model()->item_count()); | 435 EXPECT_EQ(item_count, launcher_->model()->item_count()); |
431 // First app should be active again. | 436 // First app should be active again. |
432 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status); | 437 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status); |
433 | 438 |
434 // Close first app. | 439 // Close first app. |
435 CloseShellWindow(window1b); | 440 CloseShellWindow(window1b); |
436 CloseShellWindow(window1); | 441 CloseShellWindow(window1); |
437 --item_count; | 442 --item_count; |
438 EXPECT_EQ(item_count, launcher_->model()->item_count()); | 443 EXPECT_EQ(item_count, launcher_->model()->item_count()); |
| 444 CloseShellWindowsAndWaitForAppToExit(); |
439 } | 445 } |
440 | 446 |
441 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { | 447 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { |
442 int item_count = launcher_->model()->item_count(); | 448 int item_count = launcher_->model()->item_count(); |
443 | 449 |
444 // First run app. | 450 // First run app. |
445 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); | 451 const Extension* extension1 = LoadPlatformApp("launch"); |
446 CreateShellWindow(extension1); | 452 CreateShellWindow(extension1); |
447 ++item_count; | 453 ++item_count; |
448 ASSERT_EQ(item_count, launcher_->model()->item_count()); | 454 ASSERT_EQ(item_count, launcher_->model()->item_count()); |
449 ash::LauncherItem item1 = | 455 ash::LauncherItem item1 = |
450 launcher_->model()->items()[launcher_->model()->item_count() - 2]; | 456 launcher_->model()->items()[launcher_->model()->item_count() - 2]; |
451 ash::LauncherID item_id1 = item1.id; | 457 ash::LauncherID item_id1 = item1.id; |
452 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 458 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
453 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 459 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
454 | 460 |
455 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); | 461 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); |
456 EXPECT_EQ(ash::STATUS_RUNNING, | 462 EXPECT_EQ(ash::STATUS_RUNNING, |
457 launcher_->model()->ItemByID(item_id1)->status); | 463 launcher_->model()->ItemByID(item_id1)->status); |
| 464 CloseShellWindowsAndWaitForAppToExit(); |
458 } | 465 } |
459 | 466 |
460 // Test that we can launch an app with a shortcut. | 467 // Test that we can launch an app with a shortcut. |
461 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { | 468 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { |
462 TabStripModel* tab_strip = browser()->tab_strip_model(); | 469 TabStripModel* tab_strip = browser()->tab_strip_model(); |
463 int tab_count = tab_strip->count(); | 470 int tab_count = tab_strip->count(); |
464 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 471 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
465 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 472 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
466 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 473 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); |
467 EXPECT_EQ(++tab_count, tab_strip->count()); | 474 EXPECT_EQ(++tab_count, tab_strip->count()); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 | 741 |
735 // Activating app should launch new tab, because second tab isn't | 742 // Activating app should launch new tab, because second tab isn't |
736 // in its refocus url path. | 743 // in its refocus url path. |
737 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 744 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); |
738 EXPECT_EQ(++tab_count, tab_strip->count()); | 745 EXPECT_EQ(++tab_count, tab_strip->count()); |
739 TabContents* second_tab = tab_strip->GetActiveTabContents(); | 746 TabContents* second_tab = tab_strip->GetActiveTabContents(); |
740 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 747 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
741 EXPECT_NE(first_tab, second_tab); | 748 EXPECT_NE(first_tab, second_tab); |
742 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); | 749 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); |
743 } | 750 } |
OLD | NEW |