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

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

Issue 71653003: ash: Rename LauncherModel to ShelfModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chrome changes Created 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "apps/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "apps/ui/native_app_window.h" 9 #include "apps/ui/native_app_window.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/display/display_controller.h" 11 #include "ash/display/display_controller.h"
12 #include "ash/launcher/launcher.h" 12 #include "ash/launcher/launcher.h"
13 #include "ash/launcher/launcher_button.h" 13 #include "ash/launcher/launcher_button.h"
14 #include "ash/launcher/launcher_model.h" 14 #include "ash/shelf/shelf_model.h"
15 #include "ash/shelf/shelf_model_util.h" 15 #include "ash/shelf/shelf_model_util.h"
16 #include "ash/shelf/shelf_view.h" 16 #include "ash/shelf/shelf_view.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "ash/test/app_list_controller_test_api.h" 18 #include "ash/test/app_list_controller_test_api.h"
19 #include "ash/test/launcher_test_api.h" 19 #include "ash/test/launcher_test_api.h"
20 #include "ash/test/shelf_view_test_api.h" 20 #include "ash/test/shelf_view_test_api.h"
21 #include "ash/test/shell_test_api.h" 21 #include "ash/test/shell_test_api.h"
22 #include "ash/wm/window_state.h" 22 #include "ash/wm/window_state.h"
23 #include "ash/wm/window_util.h" 23 #include "ash/wm/window_util.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 virtual ~LauncherPlatformAppBrowserTest() {} 120 virtual ~LauncherPlatformAppBrowserTest() {}
121 121
122 virtual void RunTestOnMainThreadLoop() OVERRIDE { 122 virtual void RunTestOnMainThreadLoop() OVERRIDE {
123 launcher_ = ash::Launcher::ForPrimaryDisplay(); 123 launcher_ = ash::Launcher::ForPrimaryDisplay();
124 controller_ = ChromeLauncherController::instance(); 124 controller_ = ChromeLauncherController::instance();
125 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); 125 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop();
126 } 126 }
127 127
128 ash::LauncherModel* launcher_model() { 128 ash::ShelfModel* shelf_model() {
129 return ash::test::ShellTestApi(ash::Shell::GetInstance()).launcher_model(); 129 return ash::test::ShellTestApi(ash::Shell::GetInstance()).shelf_model();
130 } 130 }
131 131
132 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& name) { 132 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& name) {
133 return controller_->CreateAppShortcutLauncherItem( 133 return controller_->CreateAppShortcutLauncherItem(
134 name, controller_->model()->item_count()); 134 name, controller_->model()->item_count());
135 } 135 }
136 136
137 const ash::LauncherItem& GetLastLauncherItem() { 137 const ash::LauncherItem& GetLastLauncherItem() {
138 // Unless there are any panels, the item at index [count - 1] will be 138 // Unless there are any panels, the item at index [count - 1] will be
139 // the desired item. 139 // the desired item.
140 return launcher_model()->items()[launcher_model()->item_count() - 1]; 140 return shelf_model()->items()[shelf_model()->item_count() - 1];
141 } 141 }
142 142
143 const ash::LauncherItem& GetLastLauncherPanelItem() { 143 const ash::LauncherItem& GetLastLauncherPanelItem() {
144 // Panels show up on the right side of the launcher, so the desired item 144 // Panels show up on the right side of the launcher, so the desired item
145 // will be the last one. 145 // will be the last one.
146 return launcher_model()->items()[launcher_model()->item_count() - 1]; 146 return shelf_model()->items()[shelf_model()->item_count() - 1];
147 } 147 }
148 148
149 LauncherItemController* GetItemController(ash::LauncherID id) { 149 LauncherItemController* GetItemController(ash::LauncherID id) {
150 return controller_->id_to_item_controller_map_[id]; 150 return controller_->id_to_item_controller_map_[id];
151 } 151 }
152 152
153 // Returns the number of menu items, ignoring separators. 153 // Returns the number of menu items, ignoring separators.
154 int GetNumApplicationMenuItems(const ash::LauncherItem& item) { 154 int GetNumApplicationMenuItems(const ash::LauncherItem& item) {
155 const int event_flags = 0; 155 const int event_flags = 0;
156 scoped_ptr<ash::LauncherMenuModel> menu( 156 scoped_ptr<ash::LauncherMenuModel> menu(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 class LauncherAppBrowserTest : public ExtensionBrowserTest { 191 class LauncherAppBrowserTest : public ExtensionBrowserTest {
192 protected: 192 protected:
193 LauncherAppBrowserTest() : launcher_(NULL), model_(NULL), controller_(NULL) { 193 LauncherAppBrowserTest() : launcher_(NULL), model_(NULL), controller_(NULL) {
194 } 194 }
195 195
196 virtual ~LauncherAppBrowserTest() {} 196 virtual ~LauncherAppBrowserTest() {}
197 197
198 virtual void RunTestOnMainThreadLoop() OVERRIDE { 198 virtual void RunTestOnMainThreadLoop() OVERRIDE {
199 launcher_ = ash::Launcher::ForPrimaryDisplay(); 199 launcher_ = ash::Launcher::ForPrimaryDisplay();
200 model_ = 200 model_ = ash::test::ShellTestApi(ash::Shell::GetInstance()).shelf_model();
201 ash::test::ShellTestApi(ash::Shell::GetInstance()).launcher_model();
202 controller_ = ChromeLauncherController::instance(); 201 controller_ = ChromeLauncherController::instance();
203 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); 202 return ExtensionBrowserTest::RunTestOnMainThreadLoop();
204 } 203 }
205 204
206 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { 205 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) {
207 LauncherItemController* item_controller = 206 LauncherItemController* item_controller =
208 controller_->GetBrowserShortcutLauncherItemController(); 207 controller_->GetBrowserShortcutLauncherItemController();
209 int items = item_controller->GetApplicationList( 208 int items = item_controller->GetApplicationList(
210 show_all_tabs ? ui::EF_SHIFT_DOWN : 0).size(); 209 show_all_tabs ? ui::EF_SHIFT_DOWN : 0).size();
211 // If we have at least one item, we have also a title which we remove here. 210 // If we have at least one item, we have also a title which we remove here.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // This triggers an internal cancel. Using VKEY_ESCAPE was too unreliable. 294 // This triggers an internal cancel. Using VKEY_ESCAPE was too unreliable.
296 button->OnMouseCaptureLost(); 295 button->OnMouseCaptureLost();
297 } 296 }
298 if (command != RIP_OFF_ITEM_AND_DONT_RELEASE_MOUSE) { 297 if (command != RIP_OFF_ITEM_AND_DONT_RELEASE_MOUSE) {
299 generator->ReleaseLeftButton(); 298 generator->ReleaseLeftButton();
300 test->RunMessageLoopUntilAnimationsDone(); 299 test->RunMessageLoopUntilAnimationsDone();
301 } 300 }
302 } 301 }
303 302
304 ash::Launcher* launcher_; 303 ash::Launcher* launcher_;
305 ash::LauncherModel* model_; 304 ash::ShelfModel* model_;
306 ChromeLauncherController* controller_; 305 ChromeLauncherController* controller_;
307 306
308 private: 307 private:
309 308
310 DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserTest); 309 DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserTest);
311 }; 310 };
312 311
313 class LauncherAppBrowserTestNoDefaultBrowser : public LauncherAppBrowserTest { 312 class LauncherAppBrowserTestNoDefaultBrowser : public LauncherAppBrowserTest {
314 protected: 313 protected:
315 LauncherAppBrowserTestNoDefaultBrowser() {} 314 LauncherAppBrowserTestNoDefaultBrowser() {}
(...skipping 25 matching lines...) Expand all
341 340
342 private: 341 private:
343 342
344 DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserNoMinimizeOnClick); 343 DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserNoMinimizeOnClick);
345 }; 344 };
346 345
347 typedef LauncherPlatformAppBrowserTest LauncherAppBrowserMinimizeOnClick; 346 typedef LauncherPlatformAppBrowserTest LauncherAppBrowserMinimizeOnClick;
348 347
349 // Test that we can launch a platform app and get a running item. 348 // Test that we can launch a platform app and get a running item.
350 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { 349 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) {
351 int item_count = launcher_model()->item_count(); 350 int item_count = shelf_model()->item_count();
352 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 351 const Extension* extension = LoadAndLaunchPlatformApp("launch");
353 ShellWindow* window = CreateShellWindow(extension); 352 ShellWindow* window = CreateShellWindow(extension);
354 ++item_count; 353 ++item_count;
355 ASSERT_EQ(item_count, launcher_model()->item_count()); 354 ASSERT_EQ(item_count, shelf_model()->item_count());
356 const ash::LauncherItem& item = GetLastLauncherItem(); 355 const ash::LauncherItem& item = GetLastLauncherItem();
357 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); 356 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
358 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 357 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
359 CloseShellWindow(window); 358 CloseShellWindow(window);
360 --item_count; 359 --item_count;
361 EXPECT_EQ(item_count, launcher_model()->item_count()); 360 EXPECT_EQ(item_count, shelf_model()->item_count());
362 } 361 }
363 362
364 // Test that we can launch a platform app that already has a shortcut. 363 // Test that we can launch a platform app that already has a shortcut.
365 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { 364 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) {
366 int item_count = launcher_model()->item_count(); 365 int item_count = shelf_model()->item_count();
367 366
368 // First get app_id. 367 // First get app_id.
369 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 368 const Extension* extension = LoadAndLaunchPlatformApp("launch");
370 const std::string app_id = extension->id(); 369 const std::string app_id = extension->id();
371 370
372 // Then create a shortcut. 371 // Then create a shortcut.
373 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); 372 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id);
374 ++item_count; 373 ++item_count;
375 ASSERT_EQ(item_count, launcher_model()->item_count()); 374 ASSERT_EQ(item_count, shelf_model()->item_count());
376 ash::LauncherItem item = *launcher_model()->ItemByID(shortcut_id); 375 ash::LauncherItem item = *shelf_model()->ItemByID(shortcut_id);
377 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); 376 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
378 EXPECT_EQ(ash::STATUS_CLOSED, item.status); 377 EXPECT_EQ(ash::STATUS_CLOSED, item.status);
379 378
380 // Open a window. Confirm the item is now running. 379 // Open a window. Confirm the item is now running.
381 ShellWindow* window = CreateShellWindow(extension); 380 ShellWindow* window = CreateShellWindow(extension);
382 ash::wm::ActivateWindow(window->GetNativeWindow()); 381 ash::wm::ActivateWindow(window->GetNativeWindow());
383 ASSERT_EQ(item_count, launcher_model()->item_count()); 382 ASSERT_EQ(item_count, shelf_model()->item_count());
384 item = *launcher_model()->ItemByID(shortcut_id); 383 item = *shelf_model()->ItemByID(shortcut_id);
385 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); 384 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
386 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 385 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
387 386
388 // Then close it, make sure there's still an item. 387 // Then close it, make sure there's still an item.
389 CloseShellWindow(window); 388 CloseShellWindow(window);
390 ASSERT_EQ(item_count, launcher_model()->item_count()); 389 ASSERT_EQ(item_count, shelf_model()->item_count());
391 item = *launcher_model()->ItemByID(shortcut_id); 390 item = *shelf_model()->ItemByID(shortcut_id);
392 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); 391 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
393 EXPECT_EQ(ash::STATUS_CLOSED, item.status); 392 EXPECT_EQ(ash::STATUS_CLOSED, item.status);
394 } 393 }
395 394
396 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { 395 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) {
397 // Run. 396 // Run.
398 int item_count = launcher_model()->item_count(); 397 int item_count = shelf_model()->item_count();
399 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 398 const Extension* extension = LoadAndLaunchPlatformApp("launch");
400 ShellWindow* window = CreateShellWindow(extension); 399 ShellWindow* window = CreateShellWindow(extension);
401 ++item_count; 400 ++item_count;
402 ASSERT_EQ(item_count, launcher_model()->item_count()); 401 ASSERT_EQ(item_count, shelf_model()->item_count());
403 const ash::LauncherItem& item1 = GetLastLauncherItem(); 402 const ash::LauncherItem& item1 = GetLastLauncherItem();
404 ash::LauncherID id = item1.id; 403 ash::LauncherID id = item1.id;
405 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 404 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
406 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 405 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
407 406
408 // Create a shortcut. The app item should be after it. 407 // Create a shortcut. The app item should be after it.
409 ash::LauncherID foo_id = CreateAppShortcutLauncherItem("foo"); 408 ash::LauncherID foo_id = CreateAppShortcutLauncherItem("foo");
410 ++item_count; 409 ++item_count;
411 ASSERT_EQ(item_count, launcher_model()->item_count()); 410 ASSERT_EQ(item_count, shelf_model()->item_count());
412 EXPECT_LT(launcher_model()->ItemIndexByID(foo_id), 411 EXPECT_LT(shelf_model()->ItemIndexByID(foo_id),
413 launcher_model()->ItemIndexByID(id)); 412 shelf_model()->ItemIndexByID(id));
414 413
415 // Pin the app. The item should remain. 414 // Pin the app. The item should remain.
416 controller_->Pin(id); 415 controller_->Pin(id);
417 ASSERT_EQ(item_count, launcher_model()->item_count()); 416 ASSERT_EQ(item_count, shelf_model()->item_count());
418 const ash::LauncherItem& item2 = *launcher_model()->ItemByID(id); 417 const ash::LauncherItem& item2 = *shelf_model()->ItemByID(id);
419 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item2.type); 418 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item2.type);
420 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 419 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
421 420
422 // New shortcuts should come after the item. 421 // New shortcuts should come after the item.
423 ash::LauncherID bar_id = CreateAppShortcutLauncherItem("bar"); 422 ash::LauncherID bar_id = CreateAppShortcutLauncherItem("bar");
424 ++item_count; 423 ++item_count;
425 ASSERT_EQ(item_count, launcher_model()->item_count()); 424 ASSERT_EQ(item_count, shelf_model()->item_count());
426 EXPECT_LT(launcher_model()->ItemIndexByID(id), 425 EXPECT_LT(shelf_model()->ItemIndexByID(id),
427 launcher_model()->ItemIndexByID(bar_id)); 426 shelf_model()->ItemIndexByID(bar_id));
428 427
429 // Then close it, make sure the item remains. 428 // Then close it, make sure the item remains.
430 CloseShellWindow(window); 429 CloseShellWindow(window);
431 ASSERT_EQ(item_count, launcher_model()->item_count()); 430 ASSERT_EQ(item_count, shelf_model()->item_count());
432 } 431 }
433 432
434 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { 433 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) {
435 int item_count = launcher_model()->item_count(); 434 int item_count = shelf_model()->item_count();
436 435
437 // First get app_id. 436 // First get app_id.
438 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 437 const Extension* extension = LoadAndLaunchPlatformApp("launch");
439 const std::string app_id = extension->id(); 438 const std::string app_id = extension->id();
440 439
441 // Then create a shortcut. 440 // Then create a shortcut.
442 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id); 441 ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id);
443 ++item_count; 442 ++item_count;
444 ASSERT_EQ(item_count, launcher_model()->item_count()); 443 ASSERT_EQ(item_count, shelf_model()->item_count());
445 ash::LauncherItem item = *launcher_model()->ItemByID(shortcut_id); 444 ash::LauncherItem item = *shelf_model()->ItemByID(shortcut_id);
446 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); 445 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
447 EXPECT_EQ(ash::STATUS_CLOSED, item.status); 446 EXPECT_EQ(ash::STATUS_CLOSED, item.status);
448 447
449 // Create a second shortcut. This will be needed to force the first one to 448 // Create a second shortcut. This will be needed to force the first one to
450 // move once it gets unpinned. 449 // move once it gets unpinned.
451 ash::LauncherID foo_id = CreateAppShortcutLauncherItem("foo"); 450 ash::LauncherID foo_id = CreateAppShortcutLauncherItem("foo");
452 ++item_count; 451 ++item_count;
453 ASSERT_EQ(item_count, launcher_model()->item_count()); 452 ASSERT_EQ(item_count, shelf_model()->item_count());
454 EXPECT_LT(launcher_model()->ItemIndexByID(shortcut_id), 453 EXPECT_LT(shelf_model()->ItemIndexByID(shortcut_id),
455 launcher_model()->ItemIndexByID(foo_id)); 454 shelf_model()->ItemIndexByID(foo_id));
456 455
457 // Open a window. Confirm the item is now running. 456 // Open a window. Confirm the item is now running.
458 ShellWindow* window = CreateShellWindow(extension); 457 ShellWindow* window = CreateShellWindow(extension);
459 ash::wm::ActivateWindow(window->GetNativeWindow()); 458 ash::wm::ActivateWindow(window->GetNativeWindow());
460 ASSERT_EQ(item_count, launcher_model()->item_count()); 459 ASSERT_EQ(item_count, shelf_model()->item_count());
461 item = *launcher_model()->ItemByID(shortcut_id); 460 item = *shelf_model()->ItemByID(shortcut_id);
462 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); 461 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
463 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 462 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
464 463
465 // Unpin the app. The item should remain. 464 // Unpin the app. The item should remain.
466 controller_->Unpin(shortcut_id); 465 controller_->Unpin(shortcut_id);
467 ASSERT_EQ(item_count, launcher_model()->item_count()); 466 ASSERT_EQ(item_count, shelf_model()->item_count());
468 item = *launcher_model()->ItemByID(shortcut_id); 467 item = *shelf_model()->ItemByID(shortcut_id);
469 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); 468 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
470 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 469 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
471 // The item should have moved after the other shortcuts. 470 // The item should have moved after the other shortcuts.
472 EXPECT_GT(launcher_model()->ItemIndexByID(shortcut_id), 471 EXPECT_GT(shelf_model()->ItemIndexByID(shortcut_id),
473 launcher_model()->ItemIndexByID(foo_id)); 472 shelf_model()->ItemIndexByID(foo_id));
474 473
475 // Then close it, make sure the item's gone. 474 // Then close it, make sure the item's gone.
476 CloseShellWindow(window); 475 CloseShellWindow(window);
477 --item_count; 476 --item_count;
478 ASSERT_EQ(item_count, launcher_model()->item_count()); 477 ASSERT_EQ(item_count, shelf_model()->item_count());
479 } 478 }
480 479
481 // Test that we can launch a platform app with more than one window. 480 // Test that we can launch a platform app with more than one window.
482 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { 481 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) {
483 int item_count = launcher_model()->item_count(); 482 int item_count = shelf_model()->item_count();
484 483
485 // First run app. 484 // First run app.
486 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 485 const Extension* extension = LoadAndLaunchPlatformApp("launch");
487 ShellWindow* window1 = CreateShellWindow(extension); 486 ShellWindow* window1 = CreateShellWindow(extension);
488 ++item_count; 487 ++item_count;
489 ASSERT_EQ(item_count, launcher_model()->item_count()); 488 ASSERT_EQ(item_count, shelf_model()->item_count());
490 const ash::LauncherItem& item1 = GetLastLauncherItem(); 489 const ash::LauncherItem& item1 = GetLastLauncherItem();
491 ash::LauncherID item_id = item1.id; 490 ash::LauncherID item_id = item1.id;
492 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 491 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
493 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 492 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
494 EXPECT_EQ(2, GetNumApplicationMenuItems(item1)); // Title + 1 window 493 EXPECT_EQ(2, GetNumApplicationMenuItems(item1)); // Title + 1 window
495 494
496 // Add second window. 495 // Add second window.
497 ShellWindow* window2 = CreateShellWindow(extension); 496 ShellWindow* window2 = CreateShellWindow(extension);
498 // Confirm item stays. 497 // Confirm item stays.
499 ASSERT_EQ(item_count, launcher_model()->item_count()); 498 ASSERT_EQ(item_count, shelf_model()->item_count());
500 const ash::LauncherItem& item2 = *launcher_model()->ItemByID(item_id); 499 const ash::LauncherItem& item2 = *shelf_model()->ItemByID(item_id);
501 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 500 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
502 EXPECT_EQ(3, GetNumApplicationMenuItems(item2)); // Title + 2 windows 501 EXPECT_EQ(3, GetNumApplicationMenuItems(item2)); // Title + 2 windows
503 502
504 // Close second window. 503 // Close second window.
505 CloseShellWindow(window2); 504 CloseShellWindow(window2);
506 // Confirm item stays. 505 // Confirm item stays.
507 ASSERT_EQ(item_count, launcher_model()->item_count()); 506 ASSERT_EQ(item_count, shelf_model()->item_count());
508 const ash::LauncherItem& item3 = *launcher_model()->ItemByID(item_id); 507 const ash::LauncherItem& item3 = *shelf_model()->ItemByID(item_id);
509 EXPECT_EQ(ash::STATUS_ACTIVE, item3.status); 508 EXPECT_EQ(ash::STATUS_ACTIVE, item3.status);
510 EXPECT_EQ(2, GetNumApplicationMenuItems(item3)); // Title + 1 window 509 EXPECT_EQ(2, GetNumApplicationMenuItems(item3)); // Title + 1 window
511 510
512 // Close first window. 511 // Close first window.
513 CloseShellWindow(window1); 512 CloseShellWindow(window1);
514 // Confirm item is removed. 513 // Confirm item is removed.
515 --item_count; 514 --item_count;
516 ASSERT_EQ(item_count, launcher_model()->item_count()); 515 ASSERT_EQ(item_count, shelf_model()->item_count());
517 } 516 }
518 517
519 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) { 518 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) {
520 int item_count = launcher_model()->item_count(); 519 int item_count = shelf_model()->item_count();
521 520
522 // First run app. 521 // First run app.
523 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 522 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
524 ShellWindow* window1 = CreateShellWindow(extension1); 523 ShellWindow* window1 = CreateShellWindow(extension1);
525 ++item_count; 524 ++item_count;
526 ASSERT_EQ(item_count, launcher_model()->item_count()); 525 ASSERT_EQ(item_count, shelf_model()->item_count());
527 const ash::LauncherItem& item1 = GetLastLauncherItem(); 526 const ash::LauncherItem& item1 = GetLastLauncherItem();
528 ash::LauncherID item_id1 = item1.id; 527 ash::LauncherID item_id1 = item1.id;
529 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 528 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
530 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 529 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
531 530
532 // Then run second app. 531 // Then run second app.
533 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); 532 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2");
534 ShellWindow* window2 = CreateShellWindow(extension2); 533 ShellWindow* window2 = CreateShellWindow(extension2);
535 ++item_count; 534 ++item_count;
536 ASSERT_EQ(item_count, launcher_model()->item_count()); 535 ASSERT_EQ(item_count, shelf_model()->item_count());
537 const ash::LauncherItem& item2 = GetLastLauncherItem(); 536 const ash::LauncherItem& item2 = GetLastLauncherItem();
538 ash::LauncherID item_id2 = item2.id; 537 ash::LauncherID item_id2 = item2.id;
539 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); 538 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
540 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 539 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
541 540
542 EXPECT_NE(item_id1, item_id2); 541 EXPECT_NE(item_id1, item_id2);
543 EXPECT_EQ(ash::STATUS_RUNNING, 542 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status);
544 launcher_model()->ItemByID(item_id1)->status);
545 543
546 // Close second app. 544 // Close second app.
547 CloseShellWindow(window2); 545 CloseShellWindow(window2);
548 --item_count; 546 --item_count;
549 ASSERT_EQ(item_count, launcher_model()->item_count()); 547 ASSERT_EQ(item_count, shelf_model()->item_count());
550 // First app should be active again. 548 // First app should be active again.
551 EXPECT_EQ(ash::STATUS_ACTIVE, 549 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status);
552 launcher_model()->ItemByID(item_id1)->status);
553 550
554 // Close first app. 551 // Close first app.
555 CloseShellWindow(window1); 552 CloseShellWindow(window1);
556 --item_count; 553 --item_count;
557 ASSERT_EQ(item_count, launcher_model()->item_count()); 554 ASSERT_EQ(item_count, shelf_model()->item_count());
558 } 555 }
559 556
560 // Confirm that app windows can be reactivated by clicking their icons and that 557 // Confirm that app windows can be reactivated by clicking their icons and that
561 // the correct activation order is maintained. 558 // the correct activation order is maintained.
562 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) { 559 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) {
563 int item_count = launcher_model()->item_count(); 560 int item_count = shelf_model()->item_count();
564 561
565 // First run app. 562 // First run app.
566 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 563 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
567 ShellWindow* window1 = CreateShellWindow(extension1); 564 ShellWindow* window1 = CreateShellWindow(extension1);
568 ++item_count; 565 ++item_count;
569 ASSERT_EQ(item_count, launcher_model()->item_count()); 566 ASSERT_EQ(item_count, shelf_model()->item_count());
570 const ash::LauncherItem& item1 = GetLastLauncherItem(); 567 const ash::LauncherItem& item1 = GetLastLauncherItem();
571 ash::LauncherID item_id1 = item1.id; 568 ash::LauncherID item_id1 = item1.id;
572 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 569 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
573 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 570 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
574 571
575 // Then run second app. 572 // Then run second app.
576 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); 573 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2");
577 ShellWindow* window2 = CreateShellWindow(extension2); 574 ShellWindow* window2 = CreateShellWindow(extension2);
578 ++item_count; 575 ++item_count;
579 ASSERT_EQ(item_count, launcher_model()->item_count()); 576 ASSERT_EQ(item_count, shelf_model()->item_count());
580 const ash::LauncherItem& item2 = GetLastLauncherItem(); 577 const ash::LauncherItem& item2 = GetLastLauncherItem();
581 ash::LauncherID item_id2 = item2.id; 578 ash::LauncherID item_id2 = item2.id;
582 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); 579 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
583 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 580 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
584 581
585 EXPECT_NE(item_id1, item_id2); 582 EXPECT_NE(item_id1, item_id2);
586 EXPECT_EQ(ash::STATUS_RUNNING, 583 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status);
587 launcher_model()->ItemByID(item_id1)->status);
588 584
589 // Activate first one. 585 // Activate first one.
590 ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1)); 586 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id1));
591 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status); 587 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status);
592 EXPECT_EQ(ash::STATUS_RUNNING, 588 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id2)->status);
593 launcher_model()->ItemByID(item_id2)->status);
594 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 589 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
595 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); 590 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
596 591
597 // Activate second one. 592 // Activate second one.
598 ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id2)); 593 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id2));
599 EXPECT_EQ(ash::STATUS_RUNNING, 594 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status);
600 launcher_model()->ItemByID(item_id1)->status); 595 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id2)->status);
601 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id2)->status);
602 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 596 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
603 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); 597 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
604 598
605 // Add window for app1. This will activate it. 599 // Add window for app1. This will activate it.
606 ShellWindow* window1b = CreateShellWindow(extension1); 600 ShellWindow* window1b = CreateShellWindow(extension1);
607 ash::wm::ActivateWindow(window1b->GetNativeWindow()); 601 ash::wm::ActivateWindow(window1b->GetNativeWindow());
608 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 602 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
609 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); 603 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
610 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); 604 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
611 605
612 // Activate launcher item for app1, this will activate the first app window. 606 // Activate launcher item for app1, this will activate the first app window.
613 ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1)); 607 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id1));
614 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 608 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
615 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); 609 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
616 ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1)); 610 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id1));
617 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); 611 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
618 612
619 // Activate the second app again 613 // Activate the second app again
620 ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id2)); 614 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id2));
621 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 615 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
622 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); 616 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
623 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); 617 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
624 618
625 // Activate the first app again 619 // Activate the first app again
626 ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1)); 620 ActivateLauncherItem(shelf_model()->ItemIndexByID(item_id1));
627 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); 621 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
628 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); 622 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
629 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); 623 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
630 624
631 // Close second app. 625 // Close second app.
632 CloseShellWindow(window2); 626 CloseShellWindow(window2);
633 --item_count; 627 --item_count;
634 EXPECT_EQ(item_count, launcher_model()->item_count()); 628 EXPECT_EQ(item_count, shelf_model()->item_count());
635 // First app should be active again. 629 // First app should be active again.
636 EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status); 630 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status);
637 631
638 // Close first app. 632 // Close first app.
639 CloseShellWindow(window1b); 633 CloseShellWindow(window1b);
640 CloseShellWindow(window1); 634 CloseShellWindow(window1);
641 --item_count; 635 --item_count;
642 EXPECT_EQ(item_count, launcher_model()->item_count()); 636 EXPECT_EQ(item_count, shelf_model()->item_count());
643 } 637 }
644 638
645 // Confirm that Click behavior for app windows is correnct. 639 // Confirm that Click behavior for app windows is correnct.
646 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserNoMinimizeOnClick, 640 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserNoMinimizeOnClick,
647 AppClickBehavior) { 641 AppClickBehavior) {
648 // Launch a platform app and create a window for it. 642 // Launch a platform app and create a window for it.
649 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 643 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
650 ShellWindow* window1 = CreateShellWindow(extension1); 644 ShellWindow* window1 = CreateShellWindow(extension1);
651 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); 645 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
652 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); 646 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); 762 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized());
769 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); 763 EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
770 // Click the item again and confirm that the panel is activated. 764 // Click the item again and confirm that the panel is activated.
771 item1_controller->ItemSelected(click_event); 765 item1_controller->ItemSelected(click_event);
772 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); 766 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible());
773 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); 767 EXPECT_TRUE(panel->GetBaseWindow()->IsActive());
774 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 768 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
775 } 769 }
776 770
777 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { 771 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) {
778 int item_count = launcher_model()->item_count(); 772 int item_count = shelf_model()->item_count();
779 773
780 // First run app. 774 // First run app.
781 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 775 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
782 CreateShellWindow(extension1); 776 CreateShellWindow(extension1);
783 ++item_count; 777 ++item_count;
784 ASSERT_EQ(item_count, launcher_model()->item_count()); 778 ASSERT_EQ(item_count, shelf_model()->item_count());
785 const ash::LauncherItem& item1 = GetLastLauncherItem(); 779 const ash::LauncherItem& item1 = GetLastLauncherItem();
786 ash::LauncherID item_id1 = item1.id; 780 ash::LauncherID item_id1 = item1.id;
787 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 781 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
788 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 782 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
789 783
790 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); 784 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow());
791 EXPECT_EQ(ash::STATUS_RUNNING, 785 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status);
792 launcher_model()->ItemByID(item_id1)->status);
793 } 786 }
794 787
795 // Test that opening an app sets the correct icon 788 // Test that opening an app sets the correct icon
796 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) { 789 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) {
797 TestShellWindowRegistryObserver test_observer(browser()->profile()); 790 TestShellWindowRegistryObserver test_observer(browser()->profile());
798 791
799 // Enable experimental APIs to allow panel creation. 792 // Enable experimental APIs to allow panel creation.
800 CommandLine::ForCurrentProcess()->AppendSwitch( 793 CommandLine::ForCurrentProcess()->AppendSwitch(
801 extensions::switches::kEnableExperimentalExtensionApis); 794 extensions::switches::kEnableExperimentalExtensionApis);
802 795
803 int base_launcher_item_count = launcher_model()->item_count(); 796 int base_launcher_item_count = shelf_model()->item_count();
804 ExtensionTestMessageListener launched_listener("Launched", false); 797 ExtensionTestMessageListener launched_listener("Launched", false);
805 ExtensionTestMessageListener completed_listener("Completed", false); 798 ExtensionTestMessageListener completed_listener("Completed", false);
806 LoadAndLaunchPlatformApp("app_icon"); 799 LoadAndLaunchPlatformApp("app_icon");
807 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 800 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
808 ASSERT_TRUE(completed_listener.WaitUntilSatisfied()); 801 ASSERT_TRUE(completed_listener.WaitUntilSatisfied());
809 802
810 // Now wait until the WebContent has decoded the icons and chrome has 803 // Now wait until the WebContent has decoded the icons and chrome has
811 // processed it. This needs to be in a loop since the renderer runs in a 804 // processed it. This needs to be in a loop since the renderer runs in a
812 // different process. 805 // different process.
813 while (test_observer.icon_updates() < 3) { 806 while (test_observer.icon_updates() < 3) {
814 base::RunLoop run_loop; 807 base::RunLoop run_loop;
815 run_loop.RunUntilIdle(); 808 run_loop.RunUntilIdle();
816 } 809 }
817 810
818 // This test creates one shell window and one panel window. 811 // This test creates one shell window and one panel window.
819 int launcher_item_count = launcher_model()->item_count(); 812 int launcher_item_count = shelf_model()->item_count();
820 ASSERT_EQ(base_launcher_item_count + 2, launcher_item_count); 813 ASSERT_EQ(base_launcher_item_count + 2, launcher_item_count);
821 // The Panel will be the last item, the app second-to-last. 814 // The Panel will be the last item, the app second-to-last.
822 const ash::LauncherItem& app_item = 815 const ash::LauncherItem& app_item =
823 launcher_model()->items()[launcher_item_count - 2]; 816 shelf_model()->items()[launcher_item_count - 2];
824 const ash::LauncherItem& panel_item = 817 const ash::LauncherItem& panel_item =
825 launcher_model()->items()[launcher_item_count - 1]; 818 shelf_model()->items()[launcher_item_count - 1];
826 const LauncherItemController* app_item_controller = 819 const LauncherItemController* app_item_controller =
827 GetItemController(app_item.id); 820 GetItemController(app_item.id);
828 const LauncherItemController* panel_item_controller = 821 const LauncherItemController* panel_item_controller =
829 GetItemController(panel_item.id); 822 GetItemController(panel_item.id);
830 // Icons for Apps are set by the ShellWindowLauncherController, so 823 // Icons for Apps are set by the ShellWindowLauncherController, so
831 // image_set_by_controller() should be set. 824 // image_set_by_controller() should be set.
832 EXPECT_TRUE(app_item_controller->image_set_by_controller()); 825 EXPECT_TRUE(app_item_controller->image_set_by_controller());
833 EXPECT_TRUE(panel_item_controller->image_set_by_controller()); 826 EXPECT_TRUE(panel_item_controller->image_set_by_controller());
834 // Ensure icon heights are correct (see test.js in app_icon/ test directory) 827 // Ensure icon heights are correct (see test.js in app_icon/ test directory)
835 EXPECT_EQ(48, app_item.image.height()); 828 EXPECT_EQ(48, app_item.image.height());
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 1328
1336 // Check that the keyboard activation of a launcher item tabs properly through 1329 // Check that the keyboard activation of a launcher item tabs properly through
1337 // the items at hand. 1330 // the items at hand.
1338 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, 1331 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest,
1339 AltNumberAppsTabbing) { 1332 AltNumberAppsTabbing) {
1340 // First run app. 1333 // First run app.
1341 const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); 1334 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
1342 ui::BaseWindow* window1 = CreateShellWindow(extension1)->GetBaseWindow(); 1335 ui::BaseWindow* window1 = CreateShellWindow(extension1)->GetBaseWindow();
1343 const ash::LauncherItem& item1 = GetLastLauncherItem(); 1336 const ash::LauncherItem& item1 = GetLastLauncherItem();
1344 ash::LauncherID app_id = item1.id; 1337 ash::LauncherID app_id = item1.id;
1345 int app_index = launcher_model()->ItemIndexByID(app_id); 1338 int app_index = shelf_model()->ItemIndexByID(app_id);
1346 1339
1347 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); 1340 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
1348 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 1341 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
1349 1342
1350 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); 1343 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2");
1351 ui::BaseWindow* window2 = CreateShellWindow(extension2)->GetBaseWindow(); 1344 ui::BaseWindow* window2 = CreateShellWindow(extension2)->GetBaseWindow();
1352 1345
1353 // By now the browser should be active. Issue Alt keystrokes several times to 1346 // By now the browser should be active. Issue Alt keystrokes several times to
1354 // see that we stay on that application. 1347 // see that we stay on that application.
1355 EXPECT_TRUE(window2->IsActive()); 1348 EXPECT_TRUE(window2->IsActive());
1356 ActivateLauncherItem(app_index); 1349 ActivateLauncherItem(app_index);
1357 EXPECT_TRUE(window1->IsActive()); 1350 EXPECT_TRUE(window1->IsActive());
1358 ActivateLauncherItem(app_index); 1351 ActivateLauncherItem(app_index);
1359 EXPECT_TRUE(window1->IsActive()); 1352 EXPECT_TRUE(window1->IsActive());
1360 1353
1361 ui::BaseWindow* window1a = CreateShellWindow(extension1)->GetBaseWindow(); 1354 ui::BaseWindow* window1a = CreateShellWindow(extension1)->GetBaseWindow();
1362 1355
1363 EXPECT_TRUE(window1a->IsActive()); 1356 EXPECT_TRUE(window1a->IsActive());
1364 EXPECT_FALSE(window1->IsActive()); 1357 EXPECT_FALSE(window1->IsActive());
1365 ActivateLauncherItem(app_index); 1358 ActivateLauncherItem(app_index);
1366 EXPECT_TRUE(window1->IsActive()); 1359 EXPECT_TRUE(window1->IsActive());
1367 ActivateLauncherItem(app_index); 1360 ActivateLauncherItem(app_index);
1368 EXPECT_TRUE(window1a->IsActive()); 1361 EXPECT_TRUE(window1a->IsActive());
1369 } 1362 }
1370 1363
1371 // Test that we can launch a platform app panel and get a running item. 1364 // Test that we can launch a platform app panel and get a running item.
1372 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPanelWindow) { 1365 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPanelWindow) {
1373 int item_count = launcher_model()->item_count(); 1366 int item_count = shelf_model()->item_count();
1374 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 1367 const Extension* extension = LoadAndLaunchPlatformApp("launch");
1375 ShellWindow::CreateParams params; 1368 ShellWindow::CreateParams params;
1376 params.window_type = ShellWindow::WINDOW_TYPE_PANEL; 1369 params.window_type = ShellWindow::WINDOW_TYPE_PANEL;
1377 params.focused = false; 1370 params.focused = false;
1378 ShellWindow* window = CreateShellWindowFromParams(extension, params); 1371 ShellWindow* window = CreateShellWindowFromParams(extension, params);
1379 ++item_count; 1372 ++item_count;
1380 ASSERT_EQ(item_count, launcher_model()->item_count()); 1373 ASSERT_EQ(item_count, shelf_model()->item_count());
1381 const ash::LauncherItem& item = GetLastLauncherPanelItem(); 1374 const ash::LauncherItem& item = GetLastLauncherPanelItem();
1382 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); 1375 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type);
1383 // Opening a panel does not activate it. 1376 // Opening a panel does not activate it.
1384 EXPECT_EQ(ash::STATUS_RUNNING, item.status); 1377 EXPECT_EQ(ash::STATUS_RUNNING, item.status);
1385 CloseShellWindow(window); 1378 CloseShellWindow(window);
1386 --item_count; 1379 --item_count;
1387 EXPECT_EQ(item_count, launcher_model()->item_count()); 1380 EXPECT_EQ(item_count, shelf_model()->item_count());
1388 } 1381 }
1389 1382
1390 // Test attention states of windows. 1383 // Test attention states of windows.
1391 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowAttentionStatus) { 1384 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowAttentionStatus) {
1392 const Extension* extension = LoadAndLaunchPlatformApp("launch"); 1385 const Extension* extension = LoadAndLaunchPlatformApp("launch");
1393 ShellWindow::CreateParams params; 1386 ShellWindow::CreateParams params;
1394 params.window_type = ShellWindow::WINDOW_TYPE_PANEL; 1387 params.window_type = ShellWindow::WINDOW_TYPE_PANEL;
1395 params.focused = false; 1388 params.focused = false;
1396 ShellWindow* panel = CreateShellWindowFromParams(extension, params); 1389 ShellWindow* panel = CreateShellWindowFromParams(extension, params);
1397 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); 1390 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible());
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 // Now show overflow bubble. 1866 // Now show overflow bubble.
1874 test.ShowOverflowBubble(); 1867 test.ShowOverflowBubble();
1875 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); 1868 EXPECT_TRUE(launcher_->IsShowingOverflowBubble());
1876 1869
1877 // Unpin first pinned app and there should be no crash. 1870 // Unpin first pinned app and there should be no crash.
1878 controller_->UnpinAppWithID(std::string("fake_app_0")); 1871 controller_->UnpinAppWithID(std::string("fake_app_0"));
1879 1872
1880 test.RunMessageLoopUntilAnimationsDone(); 1873 test.RunMessageLoopUntilAnimationsDone();
1881 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); 1874 EXPECT_FALSE(launcher_->IsShowingOverflowBubble());
1882 } 1875 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698