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