Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(741)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc

Issue 11117011: Keep browser process alive while there are platform apps with background pages running. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ProfileDependencyManager to create PlatformAppService Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 = LoadAndLaunchPlatformApp("launch"); 127 const Extension* extension = LoadPlatformApp("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();
138 } 139 }
139 140
140 // Test that we can launch a platform app that already has a shortcut. 141 // Test that we can launch a platform app that already has a shortcut.
141 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { 142 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) {
142 int item_count = launcher_->model()->item_count(); 143 int item_count = launcher_->model()->item_count();
143 144
144 // First get app_id. 145 // First get app_id.
145 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 146 const Extension* extension = LoadPlatformApp("launch");
146 const std::string app_id = extension->id(); 147 const std::string app_id = extension->id();
147 148
148 // Then create a shortcut. 149 // Then create a shortcut.
149 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); 150 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id);
150 ++item_count; 151 ++item_count;
151 ASSERT_EQ(item_count, launcher_->model()->item_count()); 152 ASSERT_EQ(item_count, launcher_->model()->item_count());
152 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); 153 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id);
153 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); 154 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
154 EXPECT_EQ(ash::STATUS_CLOSED, item.status); 155 EXPECT_EQ(ash::STATUS_CLOSED, item.status);
155 156
156 // Open a window. Confirm the item is now running. 157 // Open a window. Confirm the item is now running.
157 ShellWindow* window = CreateShellWindow(extension); 158 ShellWindow* window = CreateShellWindow(extension);
158 ash::wm::ActivateWindow(window->GetNativeWindow()); 159 ash::wm::ActivateWindow(window->GetNativeWindow());
159 ASSERT_EQ(item_count, launcher_->model()->item_count()); 160 ASSERT_EQ(item_count, launcher_->model()->item_count());
160 item = *launcher_->model()->ItemByID(shortcut_id); 161 item = *launcher_->model()->ItemByID(shortcut_id);
161 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); 162 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
162 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 163 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
163 164
164 // Then close it, make sure there's still an item. 165 // Then close it, make sure there's still an item.
165 CloseShellWindow(window); 166 CloseShellWindow(window);
166 ASSERT_EQ(item_count, launcher_->model()->item_count()); 167 ASSERT_EQ(item_count, launcher_->model()->item_count());
167 item = *launcher_->model()->ItemByID(shortcut_id); 168 item = *launcher_->model()->ItemByID(shortcut_id);
168 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); 169 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
169 EXPECT_EQ(ash::STATUS_CLOSED, item.status); 170 EXPECT_EQ(ash::STATUS_CLOSED, item.status);
171 CloseShellWindowsAndWaitForAppToExit();
170 } 172 }
171 173
172 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { 174 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) {
173 // Run. 175 // Run.
174 int item_count = launcher_->model()->item_count(); 176 int item_count = launcher_->model()->item_count();
175 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 177 const Extension* extension = LoadPlatformApp("launch");
176 ShellWindow* window = CreateShellWindow(extension); 178 ShellWindow* window = CreateShellWindow(extension);
177 ++item_count; 179 ++item_count;
178 ASSERT_EQ(item_count, launcher_->model()->item_count()); 180 ASSERT_EQ(item_count, launcher_->model()->item_count());
179 ash::LauncherItem item = 181 ash::LauncherItem item =
180 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 182 launcher_->model()->items()[launcher_->model()->item_count() - 2];
181 ash::LauncherID id = item.id; 183 ash::LauncherID id = item.id;
182 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); 184 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
183 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 185 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
184 186
185 // Create a shortcut. The app item should be after it. 187 // Create a shortcut. The app item should be after it.
(...skipping 13 matching lines...) Expand all
199 // New shortcuts should come after the item. 201 // New shortcuts should come after the item.
200 ash::LauncherID bar_id = CreateAppShortcutLauncherItem("bar"); 202 ash::LauncherID bar_id = CreateAppShortcutLauncherItem("bar");
201 ++item_count; 203 ++item_count;
202 ASSERT_EQ(item_count, launcher_->model()->item_count()); 204 ASSERT_EQ(item_count, launcher_->model()->item_count());
203 EXPECT_LT(launcher_->model()->ItemIndexByID(id), 205 EXPECT_LT(launcher_->model()->ItemIndexByID(id),
204 launcher_->model()->ItemIndexByID(bar_id)); 206 launcher_->model()->ItemIndexByID(bar_id));
205 207
206 // Then close it, make sure the item remains. 208 // Then close it, make sure the item remains.
207 CloseShellWindow(window); 209 CloseShellWindow(window);
208 ASSERT_EQ(item_count, launcher_->model()->item_count()); 210 ASSERT_EQ(item_count, launcher_->model()->item_count());
211 CloseShellWindowsAndWaitForAppToExit();
209 } 212 }
210 213
211 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { 214 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) {
212 int item_count = launcher_->model()->item_count(); 215 int item_count = launcher_->model()->item_count();
213 216
214 // First get app_id. 217 // First get app_id.
215 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 218 const Extension* extension = LoadPlatformApp("launch");
216 const std::string app_id = extension->id(); 219 const std::string app_id = extension->id();
217 220
218 // Then create a shortcut. 221 // Then create a shortcut.
219 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); 222 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id);
220 ++item_count; 223 ++item_count;
221 ASSERT_EQ(item_count, launcher_->model()->item_count()); 224 ASSERT_EQ(item_count, launcher_->model()->item_count());
222 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id); 225 ash::LauncherItem item = *launcher_->model()->ItemByID(shortcut_id);
223 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); 226 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
224 EXPECT_EQ(ash::STATUS_CLOSED, item.status); 227 EXPECT_EQ(ash::STATUS_CLOSED, item.status);
225 228
(...skipping 20 matching lines...) Expand all
246 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); 249 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
247 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 250 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
248 // The item should have moved after the other shortcuts. 251 // The item should have moved after the other shortcuts.
249 EXPECT_GT(launcher_->model()->ItemIndexByID(shortcut_id), 252 EXPECT_GT(launcher_->model()->ItemIndexByID(shortcut_id),
250 launcher_->model()->ItemIndexByID(foo_id)); 253 launcher_->model()->ItemIndexByID(foo_id));
251 254
252 // Then close it, make sure the item's gone. 255 // Then close it, make sure the item's gone.
253 CloseShellWindow(window); 256 CloseShellWindow(window);
254 --item_count; 257 --item_count;
255 ASSERT_EQ(item_count, launcher_->model()->item_count()); 258 ASSERT_EQ(item_count, launcher_->model()->item_count());
259 CloseShellWindowsAndWaitForAppToExit();
256 } 260 }
257 261
258 // Test that we can launch a platform app with more than one window. 262 // Test that we can launch a platform app with more than one window.
259 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { 263 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) {
260 int item_count = launcher_->model()->item_count(); 264 int item_count = launcher_->model()->item_count();
261 265
262 // First run app. 266 // First run app.
263 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 267 const Extension* extension = LoadPlatformApp("launch");
264 ShellWindow* window1 = CreateShellWindow(extension); 268 ShellWindow* window1 = CreateShellWindow(extension);
265 ++item_count; 269 ++item_count;
266 ASSERT_EQ(item_count, launcher_->model()->item_count()); 270 ASSERT_EQ(item_count, launcher_->model()->item_count());
267 ash::LauncherItem item = 271 ash::LauncherItem item =
268 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 272 launcher_->model()->items()[launcher_->model()->item_count() - 2];
269 ash::LauncherID item_id = item.id; 273 ash::LauncherID item_id = item.id;
270 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); 274 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
271 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 275 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
272 276
273 // Add second window. 277 // Add second window.
274 ShellWindow* window2 = CreateShellWindow(extension); 278 ShellWindow* window2 = CreateShellWindow(extension);
275 // Confirm item stays. 279 // Confirm item stays.
276 ASSERT_EQ(item_count, launcher_->model()->item_count()); 280 ASSERT_EQ(item_count, launcher_->model()->item_count());
277 item = *launcher_->model()->ItemByID(item_id); 281 item = *launcher_->model()->ItemByID(item_id);
278 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 282 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
279 283
280 // Close second window. 284 // Close second window.
281 CloseShellWindow(window2); 285 CloseShellWindow(window2);
282 // Confirm item stays. 286 // Confirm item stays.
283 ASSERT_EQ(item_count, launcher_->model()->item_count()); 287 ASSERT_EQ(item_count, launcher_->model()->item_count());
284 item = *launcher_->model()->ItemByID(item_id); 288 item = *launcher_->model()->ItemByID(item_id);
285 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 289 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
286 290
287 // Close first window. 291 // Close first window.
288 CloseShellWindow(window1); 292 CloseShellWindow(window1);
289 // Confirm item is removed. 293 // Confirm item is removed.
290 --item_count; 294 --item_count;
291 ASSERT_EQ(item_count, launcher_->model()->item_count()); 295 ASSERT_EQ(item_count, launcher_->model()->item_count());
296 CloseShellWindowsAndWaitForAppToExit();
292 } 297 }
293 298
294 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) { 299 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) {
295 int item_count = launcher_->model()->item_count(); 300 int item_count = launcher_->model()->item_count();
296 301
297 // First run app. 302 // First run app.
298 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 303 const Extension* extension1 = LoadPlatformApp("launch");
299 ShellWindow* window1 = CreateShellWindow(extension1); 304 ShellWindow* window1 = CreateShellWindow(extension1);
300 ++item_count; 305 ++item_count;
301 ASSERT_EQ(item_count, launcher_->model()->item_count()); 306 ASSERT_EQ(item_count, launcher_->model()->item_count());
302 ash::LauncherItem item1 = 307 ash::LauncherItem item1 =
303 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 308 launcher_->model()->items()[launcher_->model()->item_count() - 2];
304 ash::LauncherID item_id1 = item1.id; 309 ash::LauncherID item_id1 = item1.id;
305 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 310 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
306 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 311 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
307 312
308 // Then run second app. 313 // Then run second app.
309 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); 314 const Extension* extension2 = LoadPlatformApp("launch_2");
310 ShellWindow* window2 = CreateShellWindow(extension2); 315 ShellWindow* window2 = CreateShellWindow(extension2);
311 ++item_count; 316 ++item_count;
312 ASSERT_EQ(item_count, launcher_->model()->item_count()); 317 ASSERT_EQ(item_count, launcher_->model()->item_count());
313 ash::LauncherItem item2 = 318 ash::LauncherItem item2 =
314 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 319 launcher_->model()->items()[launcher_->model()->item_count() - 2];
315 ash::LauncherID item_id2 = item2.id; 320 ash::LauncherID item_id2 = item2.id;
316 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); 321 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
317 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 322 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
318 323
319 EXPECT_NE(item_id1, item_id2); 324 EXPECT_NE(item_id1, item_id2);
320 EXPECT_EQ(ash::STATUS_RUNNING, 325 EXPECT_EQ(ash::STATUS_RUNNING,
321 launcher_->model()->ItemByID(item_id1)->status); 326 launcher_->model()->ItemByID(item_id1)->status);
322 327
323 // Close second app. 328 // Close second app.
324 CloseShellWindow(window2); 329 CloseShellWindow(window2);
325 --item_count; 330 --item_count;
326 ASSERT_EQ(item_count, launcher_->model()->item_count()); 331 ASSERT_EQ(item_count, launcher_->model()->item_count());
327 // First app should be active again. 332 // First app should be active again.
328 EXPECT_EQ(ash::STATUS_ACTIVE, 333 EXPECT_EQ(ash::STATUS_ACTIVE,
329 launcher_->model()->ItemByID(item_id1)->status); 334 launcher_->model()->ItemByID(item_id1)->status);
330 335
331 // Close first app. 336 // Close first app.
332 CloseShellWindow(window1); 337 CloseShellWindow(window1);
333 --item_count; 338 --item_count;
334 ASSERT_EQ(item_count, launcher_->model()->item_count()); 339 ASSERT_EQ(item_count, launcher_->model()->item_count());
335 340 CloseShellWindowsAndWaitForAppToExit();
336 } 341 }
337 342
338 // Confirm that app windows can be reactivated by clicking their icons and that 343 // Confirm that app windows can be reactivated by clicking their icons and that
339 // the correct activation order is maintained. 344 // the correct activation order is maintained.
340 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) { 345 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) {
341 int item_count = launcher_->model()->item_count(); 346 int item_count = launcher_->model()->item_count();
342 347
343 // First run app. 348 // First run app.
344 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 349 const Extension* extension1 = LoadPlatformApp("launch");
345 ShellWindow* window1 = CreateShellWindow(extension1); 350 ShellWindow* window1 = CreateShellWindow(extension1);
346 ++item_count; 351 ++item_count;
347 ASSERT_EQ(item_count, launcher_->model()->item_count()); 352 ASSERT_EQ(item_count, launcher_->model()->item_count());
348 ash::LauncherItem item1 = 353 ash::LauncherItem item1 =
349 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 354 launcher_->model()->items()[launcher_->model()->item_count() - 2];
350 ash::LauncherID item_id1 = item1.id; 355 ash::LauncherID item_id1 = item1.id;
351 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 356 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
352 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 357 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
353 358
354 // Then run second app. 359 // Then run second app.
355 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); 360 const Extension* extension2 = LoadPlatformApp("launch_2");
356 ShellWindow* window2 = CreateShellWindow(extension2); 361 ShellWindow* window2 = CreateShellWindow(extension2);
357 ++item_count; 362 ++item_count;
358 ASSERT_EQ(item_count, launcher_->model()->item_count()); 363 ASSERT_EQ(item_count, launcher_->model()->item_count());
359 ash::LauncherItem item2 = 364 ash::LauncherItem item2 =
360 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 365 launcher_->model()->items()[launcher_->model()->item_count() - 2];
361 ash::LauncherID item_id2 = item2.id; 366 ash::LauncherID item_id2 = item2.id;
362 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); 367 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
363 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 368 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
364 369
365 EXPECT_NE(item_id1, item_id2); 370 EXPECT_NE(item_id1, item_id2);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 --item_count; 419 --item_count;
415 EXPECT_EQ(item_count, launcher_->model()->item_count()); 420 EXPECT_EQ(item_count, launcher_->model()->item_count());
416 // First app should be active again. 421 // First app should be active again.
417 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status); 422 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status);
418 423
419 // Close first app. 424 // Close first app.
420 CloseShellWindow(window1b); 425 CloseShellWindow(window1b);
421 CloseShellWindow(window1); 426 CloseShellWindow(window1);
422 --item_count; 427 --item_count;
423 EXPECT_EQ(item_count, launcher_->model()->item_count()); 428 EXPECT_EQ(item_count, launcher_->model()->item_count());
429 CloseShellWindowsAndWaitForAppToExit();
424 } 430 }
425 431
426 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { 432 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) {
427 int item_count = launcher_->model()->item_count(); 433 int item_count = launcher_->model()->item_count();
428 434
429 // First run app. 435 // First run app.
430 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 436 const Extension* extension1 = LoadPlatformApp("launch");
431 CreateShellWindow(extension1); 437 CreateShellWindow(extension1);
432 ++item_count; 438 ++item_count;
433 ASSERT_EQ(item_count, launcher_->model()->item_count()); 439 ASSERT_EQ(item_count, launcher_->model()->item_count());
434 ash::LauncherItem item1 = 440 ash::LauncherItem item1 =
435 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 441 launcher_->model()->items()[launcher_->model()->item_count() - 2];
436 ash::LauncherID item_id1 = item1.id; 442 ash::LauncherID item_id1 = item1.id;
437 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 443 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
438 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 444 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
439 445
440 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); 446 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow());
441 EXPECT_EQ(ash::STATUS_RUNNING, 447 EXPECT_EQ(ash::STATUS_RUNNING,
442 launcher_->model()->ItemByID(item_id1)->status); 448 launcher_->model()->ItemByID(item_id1)->status);
449 CloseShellWindowsAndWaitForAppToExit();
443 } 450 }
444 451
445 // Test that we can launch an app with a shortcut. 452 // Test that we can launch an app with a shortcut.
446 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { 453 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) {
447 TabStripModel* tab_strip = browser()->tab_strip_model(); 454 TabStripModel* tab_strip = browser()->tab_strip_model();
448 int tab_count = tab_strip->count(); 455 int tab_count = tab_strip->count();
449 ash::LauncherID shortcut_id = CreateShortcut("app1"); 456 ash::LauncherID shortcut_id = CreateShortcut("app1");
450 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); 457 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
451 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 458 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
452 EXPECT_EQ(++tab_count, tab_strip->count()); 459 EXPECT_EQ(++tab_count, tab_strip->count());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 726
720 // Activating app should launch new tab, because second tab isn't 727 // Activating app should launch new tab, because second tab isn't
721 // in its refocus url path. 728 // in its refocus url path.
722 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 729 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
723 EXPECT_EQ(++tab_count, tab_strip->count()); 730 EXPECT_EQ(++tab_count, tab_strip->count());
724 TabContents* second_tab = tab_strip->GetActiveTabContents(); 731 TabContents* second_tab = tab_strip->GetActiveTabContents();
725 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 732 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
726 EXPECT_NE(first_tab, second_tab); 733 EXPECT_NE(first_tab, second_tab);
727 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); 734 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab);
728 } 735 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698