OLD | NEW |
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_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
10 #include "ash/common/shelf/app_list_button.h" | 10 #include "ash/common/shelf/app_list_button.h" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 ++item_count; | 408 ++item_count; |
409 ASSERT_EQ(item_count, shelf_model()->item_count()); | 409 ASSERT_EQ(item_count, shelf_model()->item_count()); |
410 const ash::ShelfItem& item = GetLastLauncherItem(); | 410 const ash::ShelfItem& item = GetLastLauncherItem(); |
411 EXPECT_EQ(ash::TYPE_APP, item.type); | 411 EXPECT_EQ(ash::TYPE_APP, item.type); |
412 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 412 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
413 CloseAppWindow(window); | 413 CloseAppWindow(window); |
414 --item_count; | 414 --item_count; |
415 EXPECT_EQ(item_count, shelf_model()->item_count()); | 415 EXPECT_EQ(item_count, shelf_model()->item_count()); |
416 } | 416 } |
417 | 417 |
| 418 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
| 419 LaunchUnpinnedShowInShelfWindow) { |
| 420 int item_count = shelf_model()->item_count(); |
| 421 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 422 AppWindow::CreateParams params; |
| 423 |
| 424 // Open a window shown in shelf. |
| 425 params.show_in_shelf = true; |
| 426 params.window_key = "window"; |
| 427 AppWindow* window = |
| 428 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 429 ++item_count; |
| 430 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 431 const ash::ShelfItem& item = GetLastLauncherItem(); |
| 432 EXPECT_EQ(ash::TYPE_APP, item.type); |
| 433 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
| 434 CloseAppWindow(window); |
| 435 --item_count; |
| 436 EXPECT_EQ(item_count, shelf_model()->item_count()); |
| 437 } |
| 438 |
418 // Test that we can launch a platform app that already has a shortcut. | 439 // Test that we can launch a platform app that already has a shortcut. |
419 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { | 440 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { |
420 int item_count = shelf_model()->item_count(); | 441 int item_count = shelf_model()->item_count(); |
421 | 442 |
422 // First get app_id. | 443 // First get app_id. |
423 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 444 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
424 const std::string app_id = extension->id(); | 445 const std::string app_id = extension->id(); |
425 | 446 |
426 // Then create a shortcut. | 447 // Then create a shortcut. |
427 ash::ShelfID shortcut_id = | 448 ash::ShelfID shortcut_id = |
(...skipping 13 matching lines...) Expand all Loading... |
441 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 462 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
442 | 463 |
443 // Then close it, make sure there's still an item. | 464 // Then close it, make sure there's still an item. |
444 CloseAppWindow(window); | 465 CloseAppWindow(window); |
445 ASSERT_EQ(item_count, shelf_model()->item_count()); | 466 ASSERT_EQ(item_count, shelf_model()->item_count()); |
446 item = *shelf_model()->ItemByID(shortcut_id); | 467 item = *shelf_model()->ItemByID(shortcut_id); |
447 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 468 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
448 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 469 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
449 } | 470 } |
450 | 471 |
| 472 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
| 473 LaunchPinnedShowInShelfWindow) { |
| 474 int item_count = shelf_model()->item_count(); |
| 475 |
| 476 // First get app_id. |
| 477 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 478 const std::string app_id = extension->id(); |
| 479 AppWindow::CreateParams params; |
| 480 |
| 481 // Then create a shortcut. |
| 482 ash::ShelfID shortcut_id = CreateAppShortcutLauncherItem( |
| 483 ash::launcher::AppLauncherId(app_id, "window")); |
| 484 ++item_count; |
| 485 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 486 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); |
| 487 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
| 488 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 489 |
| 490 // Open a window shown in shelf. Confirm the item is now running. |
| 491 params.show_in_shelf = true; |
| 492 params.window_key = "window"; |
| 493 AppWindow* window = |
| 494 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 495 ash::wm::ActivateWindow(window->GetNativeWindow()); |
| 496 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 497 item = *shelf_model()->ItemByID(shortcut_id); |
| 498 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
| 499 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
| 500 |
| 501 // Then close it, make sure there's still an item. |
| 502 CloseAppWindow(window); |
| 503 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 504 item = *shelf_model()->ItemByID(shortcut_id); |
| 505 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
| 506 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
| 507 } |
| 508 |
451 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { | 509 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { |
452 // Run. | 510 // Run. |
453 int item_count = shelf_model()->item_count(); | 511 int item_count = shelf_model()->item_count(); |
454 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 512 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
455 AppWindow* window = CreateAppWindow(browser()->profile(), extension); | 513 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
456 ++item_count; | 514 ++item_count; |
457 ASSERT_EQ(item_count, shelf_model()->item_count()); | 515 ASSERT_EQ(item_count, shelf_model()->item_count()); |
458 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 516 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
459 ash::ShelfID id = item1.id; | 517 ash::ShelfID id = item1.id; |
460 EXPECT_EQ(ash::TYPE_APP, item1.type); | 518 EXPECT_EQ(ash::TYPE_APP, item1.type); |
(...skipping 20 matching lines...) Expand all Loading... |
481 ++item_count; | 539 ++item_count; |
482 ASSERT_EQ(item_count, shelf_model()->item_count()); | 540 ASSERT_EQ(item_count, shelf_model()->item_count()); |
483 EXPECT_LT(shelf_model()->ItemIndexByID(id), | 541 EXPECT_LT(shelf_model()->ItemIndexByID(id), |
484 shelf_model()->ItemIndexByID(bar_id)); | 542 shelf_model()->ItemIndexByID(bar_id)); |
485 | 543 |
486 // Then close it, make sure the item remains. | 544 // Then close it, make sure the item remains. |
487 CloseAppWindow(window); | 545 CloseAppWindow(window); |
488 ASSERT_EQ(item_count, shelf_model()->item_count()); | 546 ASSERT_EQ(item_count, shelf_model()->item_count()); |
489 } | 547 } |
490 | 548 |
| 549 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
| 550 PinRunningShowInShelfWindow) { |
| 551 // Run. |
| 552 int item_count = shelf_model()->item_count(); |
| 553 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 554 AppWindow::CreateParams params; |
| 555 |
| 556 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension); |
| 557 ++item_count; |
| 558 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 559 const ash::ShelfItem& item_window1 = GetLastLauncherItem(); |
| 560 ash::ShelfID id_window1 = item_window1.id; |
| 561 EXPECT_EQ(ash::TYPE_APP, item_window1.type); |
| 562 EXPECT_EQ(ash::STATUS_ACTIVE, item_window1.status); |
| 563 |
| 564 // Open a window shown in shelf. |
| 565 params.show_in_shelf = true; |
| 566 params.window_key = "window2"; |
| 567 AppWindow* window2 = |
| 568 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 569 ++item_count; |
| 570 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 571 const ash::ShelfItem& item_window2 = GetLastLauncherItem(); |
| 572 ash::ShelfID id_window2 = item_window2.id; |
| 573 EXPECT_EQ(ash::TYPE_APP, item_window2.type); |
| 574 EXPECT_EQ(ash::STATUS_ACTIVE, item_window2.status); |
| 575 |
| 576 // Create a shortcut. The app window1 and window2 should be after it. |
| 577 ash::ShelfID foo_id = |
| 578 CreateAppShortcutLauncherItem(ash::launcher::AppLauncherId("foo")); |
| 579 ++item_count; |
| 580 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 581 EXPECT_LT(shelf_model()->ItemIndexByID(foo_id), |
| 582 shelf_model()->ItemIndexByID(id_window1)); |
| 583 EXPECT_LT(shelf_model()->ItemIndexByID(foo_id), |
| 584 shelf_model()->ItemIndexByID(id_window2)); |
| 585 |
| 586 // Pin the app window1. The item should remain. |
| 587 controller_->Pin(id_window1); |
| 588 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 589 const ash::ShelfItem& item_window = *shelf_model()->ItemByID(id_window1); |
| 590 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item_window.type); |
| 591 EXPECT_EQ(ash::STATUS_RUNNING, item_window.status); |
| 592 |
| 593 // New shortcuts should come after the app window1 and before window2. |
| 594 ash::ShelfID bar_id = |
| 595 CreateAppShortcutLauncherItem(ash::launcher::AppLauncherId("bar")); |
| 596 ++item_count; |
| 597 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 598 EXPECT_LT(shelf_model()->ItemIndexByID(id_window1), |
| 599 shelf_model()->ItemIndexByID(bar_id)); |
| 600 EXPECT_LT(shelf_model()->ItemIndexByID(bar_id), |
| 601 shelf_model()->ItemIndexByID(id_window2)); |
| 602 |
| 603 // Then close the app window1, make sure the item remains. |
| 604 CloseAppWindow(window1); |
| 605 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 606 // Then close the app window2. |
| 607 CloseAppWindow(window2); |
| 608 --item_count; |
| 609 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 610 } |
| 611 |
491 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { | 612 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) { |
492 int item_count = shelf_model()->item_count(); | 613 int item_count = shelf_model()->item_count(); |
493 | 614 |
494 // First get app_id. | 615 // First get app_id. |
495 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 616 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
496 const std::string app_id = extension->id(); | 617 const std::string app_id = extension->id(); |
497 | 618 |
498 // Then create a shortcut. | 619 // Then create a shortcut. |
499 ash::ShelfID shortcut_id = | 620 ash::ShelfID shortcut_id = |
500 CreateAppShortcutLauncherItem(ash::launcher::AppLauncherId(app_id)); | 621 CreateAppShortcutLauncherItem(ash::launcher::AppLauncherId(app_id)); |
(...skipping 29 matching lines...) Expand all Loading... |
530 // The item should have moved after the other shortcuts. | 651 // The item should have moved after the other shortcuts. |
531 EXPECT_GT(shelf_model()->ItemIndexByID(shortcut_id), | 652 EXPECT_GT(shelf_model()->ItemIndexByID(shortcut_id), |
532 shelf_model()->ItemIndexByID(foo_id)); | 653 shelf_model()->ItemIndexByID(foo_id)); |
533 | 654 |
534 // Then close it, make sure the item's gone. | 655 // Then close it, make sure the item's gone. |
535 CloseAppWindow(window); | 656 CloseAppWindow(window); |
536 --item_count; | 657 --item_count; |
537 ASSERT_EQ(item_count, shelf_model()->item_count()); | 658 ASSERT_EQ(item_count, shelf_model()->item_count()); |
538 } | 659 } |
539 | 660 |
| 661 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
| 662 UnpinRunningShowInShelfWindow) { |
| 663 int item_count = shelf_model()->item_count(); |
| 664 |
| 665 // First get app_id. |
| 666 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 667 const std::string app_id = extension->id(); |
| 668 AppWindow::CreateParams params; |
| 669 |
| 670 // Then create a shortcut window1. |
| 671 ash::ShelfID shortcut_id_window1 = |
| 672 CreateAppShortcutLauncherItem(ash::launcher::AppLauncherId(app_id)); |
| 673 ++item_count; |
| 674 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 675 ash::ShelfItem item_window1 = *shelf_model()->ItemByID(shortcut_id_window1); |
| 676 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item_window1.type); |
| 677 EXPECT_EQ(ash::STATUS_CLOSED, item_window1.status); |
| 678 |
| 679 // Create a second shortcut. This will be needed to force the first one to |
| 680 // move once it gets unpinned. |
| 681 ash::ShelfID foo_id = |
| 682 CreateAppShortcutLauncherItem(ash::launcher::AppLauncherId("foo")); |
| 683 ++item_count; |
| 684 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 685 EXPECT_LT(shelf_model()->ItemIndexByID(shortcut_id_window1), |
| 686 shelf_model()->ItemIndexByID(foo_id)); |
| 687 |
| 688 // Open app window1. Confirm the item is now running. |
| 689 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension); |
| 690 ash::wm::ActivateWindow(window1->GetNativeWindow()); |
| 691 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 692 item_window1 = *shelf_model()->ItemByID(shortcut_id_window1); |
| 693 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item_window1.type); |
| 694 EXPECT_EQ(ash::STATUS_ACTIVE, item_window1.status); |
| 695 |
| 696 // Open the app window2 shown in shelf. |
| 697 params.show_in_shelf = true; |
| 698 params.window_key = "window2"; |
| 699 AppWindow* window2 = |
| 700 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 701 ++item_count; |
| 702 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 703 const ash::ShelfItem& item_window2 = GetLastLauncherItem(); |
| 704 ash::ShelfID id_window2 = item_window2.id; |
| 705 EXPECT_EQ(ash::TYPE_APP, item_window2.type); |
| 706 EXPECT_EQ(ash::STATUS_ACTIVE, item_window2.status); |
| 707 EXPECT_GT(shelf_model()->ItemIndexByID(id_window2), |
| 708 shelf_model()->ItemIndexByID(foo_id)); |
| 709 |
| 710 // Unpin the app window1. The item should remain. |
| 711 controller_->Unpin(shortcut_id_window1); |
| 712 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 713 item_window1 = *shelf_model()->ItemByID(shortcut_id_window1); |
| 714 EXPECT_EQ(ash::TYPE_APP, item_window1.type); |
| 715 EXPECT_EQ(ash::STATUS_RUNNING, item_window1.status); |
| 716 // The app window1 should have moved after the other shortcuts. |
| 717 EXPECT_GT(shelf_model()->ItemIndexByID(shortcut_id_window1), |
| 718 shelf_model()->ItemIndexByID(foo_id)); |
| 719 |
| 720 // Then close app window1 and window2, make sure the item's gone. |
| 721 CloseAppWindow(window1); |
| 722 --item_count; |
| 723 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 724 CloseAppWindow(window2); |
| 725 --item_count; |
| 726 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 727 } |
| 728 |
540 // Test that we can launch a platform app with more than one window. | 729 // Test that we can launch a platform app with more than one window. |
541 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { | 730 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { |
542 int item_count = shelf_model()->item_count(); | 731 int item_count = shelf_model()->item_count(); |
543 | 732 |
544 // First run app. | 733 // First run app. |
545 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 734 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
546 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension); | 735 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension); |
547 ++item_count; | 736 ++item_count; |
548 ASSERT_EQ(item_count, shelf_model()->item_count()); | 737 ASSERT_EQ(item_count, shelf_model()->item_count()); |
549 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 738 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
(...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 | 2606 |
2418 // Close all windows via the menu item. | 2607 // Close all windows via the menu item. |
2419 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2608 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
2420 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2609 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
2421 | 2610 |
2422 // Check if "Close" is removed from the context menu. | 2611 // Check if "Close" is removed from the context menu. |
2423 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2612 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
2424 ASSERT_FALSE( | 2613 ASSERT_FALSE( |
2425 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2614 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
2426 } | 2615 } |
| 2616 |
| 2617 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
| 2618 PinAndRestoreShowInShelfWindow) { |
| 2619 // Run. |
| 2620 int item_count = shelf_model()->item_count(); |
| 2621 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 2622 AppWindow::CreateParams params; |
| 2623 |
| 2624 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension); |
| 2625 ++item_count; |
| 2626 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 2627 const ash::ShelfItem& item_window1 = GetLastLauncherItem(); |
| 2628 EXPECT_EQ(ash::TYPE_APP, item_window1.type); |
| 2629 EXPECT_EQ(ash::STATUS_ACTIVE, item_window1.status); |
| 2630 |
| 2631 // Open a window shown in shelf. |
| 2632 params.show_in_shelf = true; |
| 2633 params.window_key = "window2"; |
| 2634 AppWindow* window2 = |
| 2635 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 2636 ++item_count; |
| 2637 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 2638 const ash::ShelfItem& item_window2 = GetLastLauncherItem(); |
| 2639 ash::ShelfID id_window2 = item_window2.id; |
| 2640 EXPECT_EQ(ash::TYPE_APP, item_window2.type); |
| 2641 EXPECT_EQ(ash::STATUS_ACTIVE, item_window2.status); |
| 2642 |
| 2643 // Open the second window shown in shelf. |
| 2644 params.show_in_shelf = true; |
| 2645 params.window_key = "window3"; |
| 2646 AppWindow* window3 = |
| 2647 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 2648 ++item_count; |
| 2649 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 2650 const ash::ShelfItem& item_window3 = GetLastLauncherItem(); |
| 2651 ash::ShelfID id_window3 = item_window3.id; |
| 2652 EXPECT_EQ(ash::TYPE_APP, item_window3.type); |
| 2653 EXPECT_EQ(ash::STATUS_ACTIVE, item_window3.status); |
| 2654 |
| 2655 // Pin the app window2. The item should remain. |
| 2656 controller_->Pin(id_window2); |
| 2657 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 2658 const ash::ShelfItem& item_window_p2 = *shelf_model()->ItemByID(id_window2); |
| 2659 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item_window_p2.type); |
| 2660 EXPECT_EQ(ash::STATUS_RUNNING, item_window_p2.status); |
| 2661 |
| 2662 // Pin the app window3. The item should remain. |
| 2663 controller_->Pin(id_window3); |
| 2664 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 2665 const ash::ShelfItem& item_window_p3 = *shelf_model()->ItemByID(id_window3); |
| 2666 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item_window_p3.type); |
| 2667 EXPECT_EQ(ash::STATUS_ACTIVE, item_window_p3.status); |
| 2668 |
| 2669 // Then close the app window2, make sure the item remains. |
| 2670 CloseAppWindow(window2); |
| 2671 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 2672 // Then close the app window1. |
| 2673 CloseAppWindow(window1); |
| 2674 --item_count; |
| 2675 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 2676 // Then close the app window3, make sure the item remains. |
| 2677 CloseAppWindow(window3); |
| 2678 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 2679 |
| 2680 // Open app window2. Confirm the item is now running. |
| 2681 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item_window_p2.type); |
| 2682 EXPECT_EQ(ash::STATUS_CLOSED, item_window_p2.status); |
| 2683 params.show_in_shelf = true; |
| 2684 params.window_key = "window2"; |
| 2685 AppWindow* window_p2 = |
| 2686 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 2687 ash::wm::ActivateWindow(window_p2->GetNativeWindow()); |
| 2688 ASSERT_EQ(item_count, shelf_model()->item_count()); |
| 2689 const ash::ShelfItem& item_window_r2 = *shelf_model()->ItemByID(id_window2); |
| 2690 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item_window_r2.type); |
| 2691 EXPECT_EQ(ash::STATUS_ACTIVE, item_window_r2.status); |
| 2692 } |
OLD | NEW |