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

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

Issue 11362166: Merge 166715 - Revert r165772: Keep browser process alive while there are platform apps with backgr… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1320/src/
Patch Set: 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 = 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
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
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 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) { 346 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) {
352 int item_count = launcher_->model()->item_count(); 347 int item_count = launcher_->model()->item_count();
353 348
354 // First run app. 349 // First run app.
355 const Extension* extension1 = LoadPlatformApp("launch"); 350 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
356 ShellWindow* window1 = CreateShellWindow(extension1); 351 ShellWindow* window1 = CreateShellWindow(extension1);
357 ++item_count; 352 ++item_count;
358 ASSERT_EQ(item_count, launcher_->model()->item_count()); 353 ASSERT_EQ(item_count, launcher_->model()->item_count());
359 ash::LauncherItem item1 = 354 ash::LauncherItem item1 =
360 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 355 launcher_->model()->items()[launcher_->model()->item_count() - 2];
361 ash::LauncherID item_id1 = item1.id; 356 ash::LauncherID item_id1 = item1.id;
362 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 357 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
363 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 358 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
364 359
365 // Then run second app. 360 // Then run second app.
366 const Extension* extension2 = LoadPlatformApp("launch_2"); 361 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2");
367 ShellWindow* window2 = CreateShellWindow(extension2); 362 ShellWindow* window2 = CreateShellWindow(extension2);
368 ++item_count; 363 ++item_count;
369 ASSERT_EQ(item_count, launcher_->model()->item_count()); 364 ASSERT_EQ(item_count, launcher_->model()->item_count());
370 ash::LauncherItem item2 = 365 ash::LauncherItem item2 =
371 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 366 launcher_->model()->items()[launcher_->model()->item_count() - 2];
372 ash::LauncherID item_id2 = item2.id; 367 ash::LauncherID item_id2 = item2.id;
373 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); 368 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
374 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 369 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
375 370
376 EXPECT_NE(item_id1, item_id2); 371 EXPECT_NE(item_id1, item_id2);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 --item_count; 420 --item_count;
426 EXPECT_EQ(item_count, launcher_->model()->item_count()); 421 EXPECT_EQ(item_count, launcher_->model()->item_count());
427 // First app should be active again. 422 // First app should be active again.
428 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status); 423 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_->model()->ItemByID(item_id1)->status);
429 424
430 // Close first app. 425 // Close first app.
431 CloseShellWindow(window1b); 426 CloseShellWindow(window1b);
432 CloseShellWindow(window1); 427 CloseShellWindow(window1);
433 --item_count; 428 --item_count;
434 EXPECT_EQ(item_count, launcher_->model()->item_count()); 429 EXPECT_EQ(item_count, launcher_->model()->item_count());
435 CloseShellWindowsAndWaitForAppToExit();
436 } 430 }
437 431
438 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { 432 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) {
439 int item_count = launcher_->model()->item_count(); 433 int item_count = launcher_->model()->item_count();
440 434
441 // First run app. 435 // First run app.
442 const Extension* extension1 = LoadPlatformApp("launch"); 436 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
443 CreateShellWindow(extension1); 437 CreateShellWindow(extension1);
444 ++item_count; 438 ++item_count;
445 ASSERT_EQ(item_count, launcher_->model()->item_count()); 439 ASSERT_EQ(item_count, launcher_->model()->item_count());
446 ash::LauncherItem item1 = 440 ash::LauncherItem item1 =
447 launcher_->model()->items()[launcher_->model()->item_count() - 2]; 441 launcher_->model()->items()[launcher_->model()->item_count() - 2];
448 ash::LauncherID item_id1 = item1.id; 442 ash::LauncherID item_id1 = item1.id;
449 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 443 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
450 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 444 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
451 445
452 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); 446 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow());
453 EXPECT_EQ(ash::STATUS_RUNNING, 447 EXPECT_EQ(ash::STATUS_RUNNING,
454 launcher_->model()->ItemByID(item_id1)->status); 448 launcher_->model()->ItemByID(item_id1)->status);
455 CloseShellWindowsAndWaitForAppToExit();
456 } 449 }
457 450
458 // Test that we can launch an app with a shortcut. 451 // Test that we can launch an app with a shortcut.
459 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { 452 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) {
460 TabStripModel* tab_strip = browser()->tab_strip_model(); 453 TabStripModel* tab_strip = browser()->tab_strip_model();
461 int tab_count = tab_strip->count(); 454 int tab_count = tab_strip->count();
462 ash::LauncherID shortcut_id = CreateShortcut("app1"); 455 ash::LauncherID shortcut_id = CreateShortcut("app1");
463 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); 456 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
464 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 457 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
465 EXPECT_EQ(++tab_count, tab_strip->count()); 458 EXPECT_EQ(++tab_count, tab_strip->count());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 725
733 // Activating app should launch new tab, because second tab isn't 726 // Activating app should launch new tab, because second tab isn't
734 // in its refocus url path. 727 // in its refocus url path.
735 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 728 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
736 EXPECT_EQ(++tab_count, tab_strip->count()); 729 EXPECT_EQ(++tab_count, tab_strip->count());
737 TabContents* second_tab = tab_strip->GetActiveTabContents(); 730 TabContents* second_tab = tab_strip->GetActiveTabContents();
738 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 731 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
739 EXPECT_NE(first_tab, second_tab); 732 EXPECT_NE(first_tab, second_tab);
740 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); 733 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab);
741 } 734 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_dependency_manager.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698