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

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: Updates for tests Created 8 years 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 // Times out on ChromeOS: http://crbug.com/159394 299 // Times out on ChromeOS: http://crbug.com/159394
295 #if defined(OS_CHROMEOS) 300 #if defined(OS_CHROMEOS)
296 #define MAYBE_MultipleApps DISABLED_MultipleApps 301 #define MAYBE_MultipleApps DISABLED_MultipleApps
297 #else 302 #else
298 #define MAYBE_MultipleApps MultipleApps 303 #define MAYBE_MultipleApps MultipleApps
299 #endif 304 #endif
300 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_MultipleApps) { 305 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_MultipleApps) {
301 int item_count = launcher_->model()->item_count(); 306 int item_count = launcher_->model()->item_count();
302 307
303 // First run app. 308 // First run app.
304 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 309 const Extension* extension1 = LoadPlatformApp("launch");
305 ShellWindow* window1 = CreateShellWindow(extension1); 310 ShellWindow* window1 = CreateShellWindow(extension1);
306 ++item_count; 311 ++item_count;
307 ASSERT_EQ(item_count, launcher_->model()->item_count()); 312 ASSERT_EQ(item_count, launcher_->model()->item_count());
308 ash::LauncherItem item1 = 313 ash::LauncherItem item1 =
309 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 314 launcher_->model()->items()[launcher_->model()->item_count() - 2];
310 ash::LauncherID item_id1 = item1.id; 315 ash::LauncherID item_id1 = item1.id;
311 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 316 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
312 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 317 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
313 318
314 // Then run second app. 319 // Then run second app.
315 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); 320 const Extension* extension2 = LoadPlatformApp("launch_2");
316 ShellWindow* window2 = CreateShellWindow(extension2); 321 ShellWindow* window2 = CreateShellWindow(extension2);
317 ++item_count; 322 ++item_count;
318 ASSERT_EQ(item_count, launcher_->model()->item_count()); 323 ASSERT_EQ(item_count, launcher_->model()->item_count());
319 ash::LauncherItem item2 = 324 ash::LauncherItem item2 =
320 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 325 launcher_->model()->items()[launcher_->model()->item_count() - 2];
321 ash::LauncherID item_id2 = item2.id; 326 ash::LauncherID item_id2 = item2.id;
322 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); 327 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
323 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 328 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
324 329
325 EXPECT_NE(item_id1, item_id2); 330 EXPECT_NE(item_id1, item_id2);
326 EXPECT_EQ(ash::STATUS_RUNNING, 331 EXPECT_EQ(ash::STATUS_RUNNING,
327 launcher_->model()->ItemByID(item_id1)->status); 332 launcher_->model()->ItemByID(item_id1)->status);
328 333
329 // Close second app. 334 // Close second app.
330 CloseShellWindow(window2); 335 CloseShellWindow(window2);
331 --item_count; 336 --item_count;
332 ASSERT_EQ(item_count, launcher_->model()->item_count()); 337 ASSERT_EQ(item_count, launcher_->model()->item_count());
333 // First app should be active again. 338 // First app should be active again.
334 EXPECT_EQ(ash::STATUS_ACTIVE, 339 EXPECT_EQ(ash::STATUS_ACTIVE,
335 launcher_->model()->ItemByID(item_id1)->status); 340 launcher_->model()->ItemByID(item_id1)->status);
336 341
337 // Close first app. 342 // Close first app.
338 CloseShellWindow(window1); 343 CloseShellWindow(window1);
339 --item_count; 344 --item_count;
340 ASSERT_EQ(item_count, launcher_->model()->item_count()); 345 ASSERT_EQ(item_count, launcher_->model()->item_count());
341 346 CloseShellWindowsAndWaitForAppToExit();
342 } 347 }
343 348
344 // Confirm that app windows can be reactivated by clicking their icons and that 349 // Confirm that app windows can be reactivated by clicking their icons and that
345 // the correct activation order is maintained. 350 // the correct activation order is maintained.
346 // Times out on ChromeOS: http://crbug.com/159394 351 // Times out on ChromeOS: http://crbug.com/159394
347 #if defined(OS_CHROMEOS) 352 #if defined(OS_CHROMEOS)
348 #define MAYBE_WindowActivation DISABLED_WindowActivation 353 #define MAYBE_WindowActivation DISABLED_WindowActivation
349 #else 354 #else
350 #define MAYBE_WindowActivation WindowActivation 355 #define MAYBE_WindowActivation WindowActivation
351 #endif 356 #endif
352 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) { 357 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) {
353 int item_count = launcher_->model()->item_count(); 358 int item_count = launcher_->model()->item_count();
354 359
355 // First run app. 360 // First run app.
356 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 361 const Extension* extension1 = LoadPlatformApp("launch");
357 ShellWindow* window1 = CreateShellWindow(extension1); 362 ShellWindow* window1 = CreateShellWindow(extension1);
358 ++item_count; 363 ++item_count;
359 ASSERT_EQ(item_count, launcher_->model()->item_count()); 364 ASSERT_EQ(item_count, launcher_->model()->item_count());
360 ash::LauncherItem item1 = 365 ash::LauncherItem item1 =
361 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 366 launcher_->model()->items()[launcher_->model()->item_count() - 2];
362 ash::LauncherID item_id1 = item1.id; 367 ash::LauncherID item_id1 = item1.id;
363 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 368 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
364 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 369 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
365 370
366 // Then run second app. 371 // Then run second app.
367 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); 372 const Extension* extension2 = LoadPlatformApp("launch_2");
368 ShellWindow* window2 = CreateShellWindow(extension2); 373 ShellWindow* window2 = CreateShellWindow(extension2);
369 ++item_count; 374 ++item_count;
370 ASSERT_EQ(item_count, launcher_->model()->item_count()); 375 ASSERT_EQ(item_count, launcher_->model()->item_count());
371 ash::LauncherItem item2 = 376 ash::LauncherItem item2 =
372 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 377 launcher_->model()->items()[launcher_->model()->item_count() - 2];
373 ash::LauncherID item_id2 = item2.id; 378 ash::LauncherID item_id2 = item2.id;
374 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); 379 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
375 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 380 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
376 381
377 EXPECT_NE(item_id1, item_id2); 382 EXPECT_NE(item_id1, item_id2);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 --item_count; 431 --item_count;
427 EXPECT_EQ(item_count, launcher_->model()->item_count()); 432 EXPECT_EQ(item_count, launcher_->model()->item_count());
428 // First app should be active again. 433 // First app should be active again.
429 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status); 434 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status);
430 435
431 // Close first app. 436 // Close first app.
432 CloseShellWindow(window1b); 437 CloseShellWindow(window1b);
433 CloseShellWindow(window1); 438 CloseShellWindow(window1);
434 --item_count; 439 --item_count;
435 EXPECT_EQ(item_count, launcher_->model()->item_count()); 440 EXPECT_EQ(item_count, launcher_->model()->item_count());
441 CloseShellWindowsAndWaitForAppToExit();
436 } 442 }
437 443
438 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { 444 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) {
439 int item_count = launcher_->model()->item_count(); 445 int item_count = launcher_->model()->item_count();
440 446
441 // First run app. 447 // First run app.
442 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 448 const Extension* extension1 = LoadPlatformApp("launch");
443 CreateShellWindow(extension1); 449 CreateShellWindow(extension1);
444 ++item_count; 450 ++item_count;
445 ASSERT_EQ(item_count, launcher_->model()->item_count()); 451 ASSERT_EQ(item_count, launcher_->model()->item_count());
446 ash::LauncherItem item1 = 452 ash::LauncherItem item1 =
447 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 453 launcher_->model()->items()[launcher_->model()->item_count() - 2];
448 ash::LauncherID item_id1 = item1.id; 454 ash::LauncherID item_id1 = item1.id;
449 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 455 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
450 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 456 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
451 457
452 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); 458 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow());
453 EXPECT_EQ(ash::STATUS_RUNNING, 459 EXPECT_EQ(ash::STATUS_RUNNING,
454 launcher_->model()->ItemByID(item_id1)->status); 460 launcher_->model()->ItemByID(item_id1)->status);
461 CloseShellWindowsAndWaitForAppToExit();
455 } 462 }
456 463
457 // Test that we can launch an app with a shortcut. 464 // Test that we can launch an app with a shortcut.
458 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { 465 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) {
459 TabStripModel* tab_strip = browser()->tab_strip_model(); 466 TabStripModel* tab_strip = browser()->tab_strip_model();
460 int tab_count = tab_strip->count(); 467 int tab_count = tab_strip->count();
461 ash::LauncherID shortcut_id = CreateShortcut("app1"); 468 ash::LauncherID shortcut_id = CreateShortcut("app1");
462 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); 469 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
463 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 470 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
464 EXPECT_EQ(++tab_count, tab_strip->count()); 471 EXPECT_EQ(++tab_count, tab_strip->count());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 738
732 // Activating app should launch new tab, because second tab isn't 739 // Activating app should launch new tab, because second tab isn't
733 // in its refocus url path. 740 // in its refocus url path.
734 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 741 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
735 EXPECT_EQ(++tab_count, tab_strip->count()); 742 EXPECT_EQ(++tab_count, tab_strip->count());
736 TabContents* second_tab = tab_strip->GetActiveTabContents(); 743 TabContents* second_tab = tab_strip->GetActiveTabContents();
737 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 744 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
738 EXPECT_NE(first_tab, second_tab); 745 EXPECT_NE(first_tab, second_tab);
739 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); 746 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab);
740 } 747 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698