| 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.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "ash/ash_switches.h" | 16 #include "ash/ash_switches.h" |
| 17 #include "ash/shelf/shelf_item_delegate_manager.h" | 17 #include "ash/shelf/shelf_item_delegate_manager.h" |
| 18 #include "ash/shelf/shelf_model.h" | 18 #include "ash/shelf/shelf_model.h" |
| 19 #include "ash/shelf/shelf_model_observer.h" | 19 #include "ash/shelf/shelf_model_observer.h" |
| 20 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 21 #include "ash/test/shelf_item_delegate_manager_test_api.h" | 21 #include "ash/test/shelf_item_delegate_manager_test_api.h" |
| 22 #include "ash/test/test_session_state_delegate.h" |
| 23 #include "ash/test/test_shell_delegate.h" |
| 22 #include "base/command_line.h" | 24 #include "base/command_line.h" |
| 23 #include "base/compiler_specific.h" | 25 #include "base/compiler_specific.h" |
| 24 #include "base/files/file_path.h" | 26 #include "base/files/file_path.h" |
| 25 #include "base/macros.h" | 27 #include "base/macros.h" |
| 26 #include "base/memory/ptr_util.h" | 28 #include "base/memory/ptr_util.h" |
| 27 #include "base/message_loop/message_loop.h" | 29 #include "base/message_loop/message_loop.h" |
| 28 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
| 29 #include "base/values.h" | 31 #include "base/values.h" |
| 30 #include "build/build_config.h" | 32 #include "build/build_config.h" |
| 33 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 34 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 35 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 31 #include "chrome/browser/extensions/extension_service.h" | 36 #include "chrome/browser/extensions/extension_service.h" |
| 32 #include "chrome/browser/extensions/test_extension_system.h" | 37 #include "chrome/browser/extensions/test_extension_system.h" |
| 38 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 39 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
| 40 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
| 33 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 41 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 42 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
| 43 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
| 34 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont
roller.h" | 44 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont
roller.h" |
| 35 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 45 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
| 36 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 46 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
| 37 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 47 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 48 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 49 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 50 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
| 38 #include "chrome/browser/ui/browser.h" | 51 #include "chrome/browser/ui/browser.h" |
| 39 #include "chrome/browser/ui/browser_commands.h" | 52 #include "chrome/browser/ui/browser_commands.h" |
| 40 #include "chrome/browser/ui/browser_finder.h" | 53 #include "chrome/browser/ui/browser_finder.h" |
| 41 #include "chrome/browser/ui/browser_list.h" | 54 #include "chrome/browser/ui/browser_list.h" |
| 42 #include "chrome/browser/ui/browser_tabstrip.h" | 55 #include "chrome/browser/ui/browser_tabstrip.h" |
| 43 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 56 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 57 #include "chrome/common/chrome_constants.h" |
| 58 #include "chrome/common/chrome_switches.h" |
| 44 #include "chrome/common/extensions/extension_constants.h" | 59 #include "chrome/common/extensions/extension_constants.h" |
| 45 #include "chrome/common/pref_names.h" | 60 #include "chrome/common/pref_names.h" |
| 46 #include "chrome/test/base/browser_with_test_window_test.h" | 61 #include "chrome/test/base/browser_with_test_window_test.h" |
| 62 #include "chrome/test/base/test_browser_window_aura.h" |
| 63 #include "chrome/test/base/testing_browser_process.h" |
| 47 #include "chrome/test/base/testing_profile.h" | 64 #include "chrome/test/base/testing_profile.h" |
| 65 #include "chrome/test/base/testing_profile_manager.h" |
| 66 #include "components/arc/common/app.mojom.h" |
| 67 #include "components/arc/test/fake_app_instance.h" |
| 68 #include "components/arc/test/fake_arc_bridge_service.h" |
| 69 #include "components/exo/shell_surface.h" |
| 48 #include "components/signin/core/account_id/account_id.h" | 70 #include "components/signin/core/account_id/account_id.h" |
| 49 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 71 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
| 72 #include "components/user_manager/fake_user_manager.h" |
| 50 #include "content/public/browser/web_contents.h" | 73 #include "content/public/browser/web_contents.h" |
| 51 #include "extensions/common/extension.h" | |
| 52 #include "extensions/common/manifest_constants.h" | |
| 53 #include "testing/gtest/include/gtest/gtest.h" | |
| 54 #include "ui/aura/client/window_tree_client.h" | |
| 55 #include "ui/base/models/menu_model.h" | |
| 56 #include "ui/views/widget/widget.h" | |
| 57 | |
| 58 #if defined(OS_CHROMEOS) | |
| 59 #include "ash/test/test_session_state_delegate.h" | |
| 60 #include "ash/test/test_shell_delegate.h" | |
| 61 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | |
| 62 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | |
| 63 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | |
| 64 #include "chrome/browser/lifetime/scoped_keep_alive.h" | |
| 65 #include "chrome/browser/ui/apps/chrome_app_delegate.h" | |
| 66 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" | |
| 67 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | |
| 68 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | |
| 69 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | |
| 70 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | |
| 71 #include "chrome/common/chrome_constants.h" | |
| 72 #include "chrome/common/chrome_switches.h" | |
| 73 #include "chrome/test/base/testing_browser_process.h" | |
| 74 #include "chrome/test/base/testing_profile_manager.h" | |
| 75 #include "components/exo/shell_surface.h" | |
| 76 #include "components/user_manager/fake_user_manager.h" | |
| 77 #include "content/public/browser/web_contents_observer.h" | 74 #include "content/public/browser/web_contents_observer.h" |
| 78 #include "content/public/test/test_utils.h" | 75 #include "content/public/test/test_utils.h" |
| 79 #include "content/public/test/web_contents_tester.h" | 76 #include "content/public/test/web_contents_tester.h" |
| 80 #include "extensions/browser/app_window/app_window_contents.h" | 77 #include "extensions/browser/app_window/app_window_contents.h" |
| 81 #include "extensions/browser/app_window/app_window_registry.h" | 78 #include "extensions/browser/app_window/app_window_registry.h" |
| 82 #include "extensions/browser/app_window/native_app_window.h" | 79 #include "extensions/browser/app_window/native_app_window.h" |
| 80 #include "extensions/common/extension.h" |
| 81 #include "extensions/common/manifest_constants.h" |
| 82 #include "testing/gtest/include/gtest/gtest.h" |
| 83 #include "ui/aura/client/window_tree_client.h" |
| 83 #include "ui/aura/window.h" | 84 #include "ui/aura/window.h" |
| 84 #endif | 85 #include "ui/base/models/menu_model.h" |
| 85 | 86 #include "ui/views/widget/widget.h" |
| 86 #if defined(USE_AURA) | |
| 87 #include "chrome/test/base/test_browser_window_aura.h" | |
| 88 #endif // defined(USE_AURA) | |
| 89 | |
| 90 #if defined(OS_CHROMEOS) | |
| 91 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" | |
| 92 #include "components/arc/common/app.mojom.h" | |
| 93 #include "components/arc/test/fake_app_instance.h" | |
| 94 #include "components/arc/test/fake_arc_bridge_service.h" | |
| 95 #endif // defined(OS_CHROMEOS) | |
| 96 | 87 |
| 97 using base::ASCIIToUTF16; | 88 using base::ASCIIToUTF16; |
| 98 using extensions::Extension; | 89 using extensions::Extension; |
| 99 using extensions::Manifest; | 90 using extensions::Manifest; |
| 100 using extensions::UnloadedExtensionInfo; | 91 using extensions::UnloadedExtensionInfo; |
| 101 | 92 |
| 102 namespace { | 93 namespace { |
| 103 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; | 94 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; |
| 104 const char* gmail_url = "https://mail.google.com/mail/u"; | 95 const char* gmail_url = "https://mail.google.com/mail/u"; |
| 105 const char* kGmailLaunchURL = "https://mail.google.com/mail/ca"; | 96 const char* kGmailLaunchURL = "https://mail.google.com/mail/ca"; |
| 106 | 97 |
| 107 #if defined(OS_CHROMEOS) | |
| 108 // An extension prefix. | 98 // An extension prefix. |
| 109 const char kCrxAppPrefix[] = "_crx_"; | 99 const char kCrxAppPrefix[] = "_crx_"; |
| 110 #endif | |
| 111 | 100 |
| 112 // ShelfModelObserver implementation that tracks what messages are invoked. | 101 // ShelfModelObserver implementation that tracks what messages are invoked. |
| 113 class TestShelfModelObserver : public ash::ShelfModelObserver { | 102 class TestShelfModelObserver : public ash::ShelfModelObserver { |
| 114 public: | 103 public: |
| 115 TestShelfModelObserver() | 104 TestShelfModelObserver() |
| 116 : added_(0), | 105 : added_(0), |
| 117 removed_(0), | 106 removed_(0), |
| 118 changed_(0) { | 107 changed_(0) { |
| 119 } | 108 } |
| 120 | 109 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 extension7_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 359 extension7_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 371 manifest, | 360 manifest, |
| 372 Extension::NO_FLAGS, | 361 Extension::NO_FLAGS, |
| 373 "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", | 362 "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", |
| 374 &error); | 363 &error); |
| 375 extension8_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 364 extension8_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 376 manifest, | 365 manifest, |
| 377 Extension::NO_FLAGS, | 366 Extension::NO_FLAGS, |
| 378 "ffffffffffffffffffffffffffffffff", | 367 "ffffffffffffffffffffffffffffffff", |
| 379 &error); | 368 &error); |
| 380 | |
| 381 #if defined(OS_CHROMEOS) | |
| 382 arc_test_.SetUp(profile()); | 369 arc_test_.SetUp(profile()); |
| 383 arc_test_.bridge_service()->SetReady(); | 370 arc_test_.bridge_service()->SetReady(); |
| 384 #endif // defined(OS_CHROMEOS) | |
| 385 } | 371 } |
| 386 | 372 |
| 387 // Creates a running V2 app (not pinned) of type |app_id|. | 373 // Creates a running V2 app (not pinned) of type |app_id|. |
| 388 virtual void CreateRunningV2App(const std::string& app_id) { | 374 virtual void CreateRunningV2App(const std::string& app_id) { |
| 389 DCHECK(!test_controller_); | 375 DCHECK(!test_controller_); |
| 390 ash::ShelfID id = | 376 ash::ShelfID id = |
| 391 launcher_controller_->CreateAppShortcutLauncherItemWithType( | 377 launcher_controller_->CreateAppShortcutLauncherItemWithType( |
| 392 app_id, | 378 app_id, |
| 393 model_->item_count(), | 379 model_->item_count(), |
| 394 ash::TYPE_PLATFORM_APP); | 380 ash::TYPE_PLATFORM_APP); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension5_->id())); | 591 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension5_->id())); |
| 606 } else if (app == extension6_->id()) { | 592 } else if (app == extension6_->id()) { |
| 607 result += "App6"; | 593 result += "App6"; |
| 608 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension6_->id())); | 594 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension6_->id())); |
| 609 } else if (app == extension7_->id()) { | 595 } else if (app == extension7_->id()) { |
| 610 result += "App7"; | 596 result += "App7"; |
| 611 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension7_->id())); | 597 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension7_->id())); |
| 612 } else if (app == extension8_->id()) { | 598 } else if (app == extension8_->id()) { |
| 613 result += "App8"; | 599 result += "App8"; |
| 614 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension8_->id())); | 600 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension8_->id())); |
| 615 #if defined(OS_CHROMEOS) | |
| 616 } else if (app == ArcAppTest::GetAppId(arc_test_.fake_apps()[0])) { | 601 } else if (app == ArcAppTest::GetAppId(arc_test_.fake_apps()[0])) { |
| 617 result += arc_test_.fake_apps()[0].name; | 602 result += arc_test_.fake_apps()[0].name; |
| 618 #endif // defined(OS_CHROMEOS) | |
| 619 } else { | 603 } else { |
| 620 result += "unknown"; | 604 result += "unknown"; |
| 621 } | 605 } |
| 622 break; | 606 break; |
| 623 } | 607 } |
| 624 case ash::TYPE_BROWSER_SHORTCUT: | 608 case ash::TYPE_BROWSER_SHORTCUT: |
| 625 result += "Chrome"; | 609 result += "Chrome"; |
| 626 break; | 610 break; |
| 627 case ash::TYPE_APP_LIST: | 611 case ash::TYPE_APP_LIST: |
| 628 result += "AppList"; | 612 result += "AppList"; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 646 void RememberUnpinnedRunningApplicationOrder() { | 630 void RememberUnpinnedRunningApplicationOrder() { |
| 647 launcher_controller_->RememberUnpinnedRunningApplicationOrder(); | 631 launcher_controller_->RememberUnpinnedRunningApplicationOrder(); |
| 648 } | 632 } |
| 649 | 633 |
| 650 // Restore the order of running but unpinned applications for a given user. | 634 // Restore the order of running but unpinned applications for a given user. |
| 651 void RestoreUnpinnedRunningApplicationOrder(const AccountId& account_id) { | 635 void RestoreUnpinnedRunningApplicationOrder(const AccountId& account_id) { |
| 652 launcher_controller_->RestoreUnpinnedRunningApplicationOrder( | 636 launcher_controller_->RestoreUnpinnedRunningApplicationOrder( |
| 653 account_id.GetUserEmail()); | 637 account_id.GetUserEmail()); |
| 654 } | 638 } |
| 655 | 639 |
| 656 #if defined(OS_CHROMEOS) | |
| 657 void InstallArcApps() { | 640 void InstallArcApps() { |
| 658 arc_test_.app_instance()->RefreshAppList(); | 641 arc_test_.app_instance()->RefreshAppList(); |
| 659 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); | 642 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); |
| 660 } | 643 } |
| 661 | 644 |
| 662 void UninstallArcApps() { | 645 void UninstallArcApps() { |
| 663 arc_test_.app_instance()->RefreshAppList(); | 646 arc_test_.app_instance()->RefreshAppList(); |
| 664 arc_test_.app_instance()->SendRefreshAppList( | 647 arc_test_.app_instance()->SendRefreshAppList( |
| 665 std::vector<arc::mojom::AppInfo>()); | 648 std::vector<arc::mojom::AppInfo>()); |
| 666 } | 649 } |
| 667 | 650 |
| 668 // Creates app window and set optional Arc application id. | 651 // Creates app window and set optional Arc application id. |
| 669 views::Widget* CreateAppWindow(std::string* window_app_id) { | 652 views::Widget* CreateAppWindow(std::string* window_app_id) { |
| 670 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 653 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 671 params.bounds = gfx::Rect(5, 5, 20, 20); | 654 params.bounds = gfx::Rect(5, 5, 20, 20); |
| 672 views::Widget* widget = new views::Widget(); | 655 views::Widget* widget = new views::Widget(); |
| 673 widget->Init(params); | 656 widget->Init(params); |
| 674 widget->Show(); | 657 widget->Show(); |
| 675 widget->Activate(); | 658 widget->Activate(); |
| 676 if (window_app_id) { | 659 if (window_app_id) { |
| 677 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), | 660 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), |
| 678 window_app_id); | 661 window_app_id); |
| 679 } | 662 } |
| 680 return widget; | 663 return widget; |
| 681 } | 664 } |
| 682 | 665 |
| 683 #endif // defined(OS_CHROMEOS) | |
| 684 | |
| 685 // Needed for extension service & friends to work. | 666 // Needed for extension service & friends to work. |
| 686 scoped_refptr<Extension> extension1_; | 667 scoped_refptr<Extension> extension1_; |
| 687 scoped_refptr<Extension> extension2_; | 668 scoped_refptr<Extension> extension2_; |
| 688 scoped_refptr<Extension> extension3_; | 669 scoped_refptr<Extension> extension3_; |
| 689 scoped_refptr<Extension> extension4_; | 670 scoped_refptr<Extension> extension4_; |
| 690 scoped_refptr<Extension> extension5_; | 671 scoped_refptr<Extension> extension5_; |
| 691 scoped_refptr<Extension> extension6_; | 672 scoped_refptr<Extension> extension6_; |
| 692 scoped_refptr<Extension> extension7_; | 673 scoped_refptr<Extension> extension7_; |
| 693 scoped_refptr<Extension> extension8_; | 674 scoped_refptr<Extension> extension8_; |
| 694 #if defined(OS_CHROMEOS) | 675 |
| 695 ArcAppTest arc_test_; | 676 ArcAppTest arc_test_; |
| 696 #endif // defined(OS_CHROMEOS) | |
| 697 std::unique_ptr<ChromeLauncherController> launcher_controller_; | 677 std::unique_ptr<ChromeLauncherController> launcher_controller_; |
| 698 std::unique_ptr<TestShelfModelObserver> model_observer_; | 678 std::unique_ptr<TestShelfModelObserver> model_observer_; |
| 699 std::unique_ptr<ash::ShelfModel> model_; | 679 std::unique_ptr<ash::ShelfModel> model_; |
| 700 | 680 |
| 701 // |item_delegate_manager_| owns |test_controller_|. | 681 // |item_delegate_manager_| owns |test_controller_|. |
| 702 LauncherItemController* test_controller_; | 682 LauncherItemController* test_controller_; |
| 703 | 683 |
| 704 ExtensionService* extension_service_; | 684 ExtensionService* extension_service_; |
| 705 | 685 |
| 706 ash::ShelfItemDelegateManager* item_delegate_manager_; | 686 ash::ShelfItemDelegateManager* item_delegate_manager_; |
| 707 | 687 |
| 708 private: | 688 private: |
| 709 TestBrowserWindow* CreateTestBrowserWindowAura() { | 689 TestBrowserWindow* CreateTestBrowserWindowAura() { |
| 710 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); | 690 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); |
| 711 window->set_id(0); | 691 window->set_id(0); |
| 712 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 692 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 713 window->Init(ui::LAYER_TEXTURED); | 693 window->Init(ui::LAYER_TEXTURED); |
| 714 aura::client::ParentWindowWithContext(window.get(), GetContext(), | 694 aura::client::ParentWindowWithContext(window.get(), GetContext(), |
| 715 gfx::Rect(200, 200)); | 695 gfx::Rect(200, 200)); |
| 716 | 696 |
| 717 return new TestBrowserWindowAura(std::move(window)); | 697 return new TestBrowserWindowAura(std::move(window)); |
| 718 } | 698 } |
| 719 | 699 |
| 720 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); | 700 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); |
| 721 }; | 701 }; |
| 722 | 702 |
| 723 #if defined(OS_CHROMEOS) | |
| 724 | |
| 725 // Watches WebContents and blocks until it is destroyed. This is needed for | 703 // Watches WebContents and blocks until it is destroyed. This is needed for |
| 726 // the destruction of a V2 application. | 704 // the destruction of a V2 application. |
| 727 class WebContentsDestroyedWatcher : public content::WebContentsObserver { | 705 class WebContentsDestroyedWatcher : public content::WebContentsObserver { |
| 728 public: | 706 public: |
| 729 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) | 707 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) |
| 730 : content::WebContentsObserver(web_contents), | 708 : content::WebContentsObserver(web_contents), |
| 731 message_loop_runner_(new content::MessageLoopRunner) { | 709 message_loop_runner_(new content::MessageLoopRunner) { |
| 732 EXPECT_TRUE(web_contents != NULL); | 710 EXPECT_TRUE(web_contents != NULL); |
| 733 } | 711 } |
| 734 ~WebContentsDestroyedWatcher() override {} | 712 ~WebContentsDestroyedWatcher() override {} |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 std::unique_ptr<TestingProfileManager> profile_manager_; | 968 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 991 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; | 969 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; |
| 992 | 970 |
| 993 ash::test::TestShellDelegate* shell_delegate_; | 971 ash::test::TestShellDelegate* shell_delegate_; |
| 994 | 972 |
| 995 ProfileToNameMap created_profiles_; | 973 ProfileToNameMap created_profiles_; |
| 996 | 974 |
| 997 DISALLOW_COPY_AND_ASSIGN( | 975 DISALLOW_COPY_AND_ASSIGN( |
| 998 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest); | 976 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest); |
| 999 }; | 977 }; |
| 1000 #endif // defined(OS_CHROMEOS) | |
| 1001 | |
| 1002 | 978 |
| 1003 TEST_F(ChromeLauncherControllerTest, DefaultApps) { | 979 TEST_F(ChromeLauncherControllerTest, DefaultApps) { |
| 1004 InitLauncherController(); | 980 InitLauncherController(); |
| 1005 // Model should only contain the browser shortcut and app list items. | 981 // Model should only contain the browser shortcut and app list items. |
| 1006 EXPECT_EQ(2, model_->item_count()); | 982 EXPECT_EQ(2, model_->item_count()); |
| 1007 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 983 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1008 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 984 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1009 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 985 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1010 | 986 |
| 1011 // Installing |extension3_| should add it to the launcher - behind the | 987 // Installing |extension3_| should add it to the launcher - behind the |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 EXPECT_EQ(3, model_->item_count()); | 1360 EXPECT_EQ(3, model_->item_count()); |
| 1385 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1361 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 1386 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1362 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1387 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1363 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 1388 | 1364 |
| 1389 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1365 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1390 | 1366 |
| 1391 EXPECT_EQ(2, model_->item_count()); | 1367 EXPECT_EQ(2, model_->item_count()); |
| 1392 } | 1368 } |
| 1393 | 1369 |
| 1394 #if defined(OS_CHROMEOS) | |
| 1395 // Check that running applications wich are not pinned get properly restored | 1370 // Check that running applications wich are not pinned get properly restored |
| 1396 // upon user change. | 1371 // upon user change. |
| 1397 TEST_F(ChromeLauncherControllerTest, CheckRunningAppOrder) { | 1372 TEST_F(ChromeLauncherControllerTest, CheckRunningAppOrder) { |
| 1398 InitLauncherController(); | 1373 InitLauncherController(); |
| 1399 // Model should only contain the browser shortcut and app list items. | 1374 // Model should only contain the browser shortcut and app list items. |
| 1400 EXPECT_EQ(2, model_->item_count()); | 1375 EXPECT_EQ(2, model_->item_count()); |
| 1401 | 1376 |
| 1402 // Add a few running applications. | 1377 // Add a few running applications. |
| 1403 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1378 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1404 launcher_controller_->LockV1AppWithID(extension2_->id()); | 1379 launcher_controller_->LockV1AppWithID(extension2_->id()); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); | 1628 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); |
| 1654 | 1629 |
| 1655 // Transfer the window to another user's desktop and check that activating it | 1630 // Transfer the window to another user's desktop and check that activating it |
| 1656 // does pull it back to that user. | 1631 // does pull it back to that user. |
| 1657 manager->ShowWindowForUser( | 1632 manager->ShowWindowForUser( |
| 1658 window, multi_user_util::GetAccountIdFromProfile(profile2)); | 1633 window, multi_user_util::GetAccountIdFromProfile(profile2)); |
| 1659 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user)); | 1634 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user)); |
| 1660 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); | 1635 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); |
| 1661 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); | 1636 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); |
| 1662 } | 1637 } |
| 1663 #endif | |
| 1664 | 1638 |
| 1665 // Check that lock -> pin -> unlock -> unpin does properly transition. | 1639 // Check that lock -> pin -> unlock -> unpin does properly transition. |
| 1666 TEST_F(ChromeLauncherControllerTest, CheckLockPinUnlockUnpin) { | 1640 TEST_F(ChromeLauncherControllerTest, CheckLockPinUnlockUnpin) { |
| 1667 InitLauncherController(); | 1641 InitLauncherController(); |
| 1668 // Model should only contain the browser shortcut and app list items. | 1642 // Model should only contain the browser shortcut and app list items. |
| 1669 EXPECT_EQ(2, model_->item_count()); | 1643 EXPECT_EQ(2, model_->item_count()); |
| 1670 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1644 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1671 EXPECT_FALSE( | 1645 EXPECT_FALSE( |
| 1672 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1646 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 1673 | 1647 |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 // Check that the list contains now two entries - make furthermore sure that | 2109 // Check that the list contains now two entries - make furthermore sure that |
| 2136 // the active item is the first entry. | 2110 // the active item is the first entry. |
| 2137 base::string16 two_menu_items[] = {title1, title2}; | 2111 base::string16 two_menu_items[] = {title1, title2}; |
| 2138 EXPECT_TRUE(CheckMenuCreation( | 2112 EXPECT_TRUE(CheckMenuCreation( |
| 2139 launcher_controller_.get(), item_browser, 2, two_menu_items, true)); | 2113 launcher_controller_.get(), item_browser, 2, two_menu_items, true)); |
| 2140 | 2114 |
| 2141 // Apparently we have to close all tabs we have. | 2115 // Apparently we have to close all tabs we have. |
| 2142 chrome::CloseTab(browser2.get()); | 2116 chrome::CloseTab(browser2.get()); |
| 2143 } | 2117 } |
| 2144 | 2118 |
| 2145 #if defined(OS_CHROMEOS) | |
| 2146 // Check the multi profile case where only user related browsers should show | 2119 // Check the multi profile case where only user related browsers should show |
| 2147 // up. | 2120 // up. |
| 2148 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2121 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
| 2149 BrowserMenuGenerationTwoUsers) { | 2122 BrowserMenuGenerationTwoUsers) { |
| 2150 // Create a browser item in the LauncherController. | 2123 // Create a browser item in the LauncherController. |
| 2151 InitLauncherController(); | 2124 InitLauncherController(); |
| 2152 | 2125 |
| 2153 ash::ShelfItem item_browser; | 2126 ash::ShelfItem item_browser; |
| 2154 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 2127 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 2155 item_browser.id = | 2128 item_browser.id = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 launcher_controller_.get(), item_browser, 1, one_menu_item2, true)); | 2160 launcher_controller_.get(), item_browser, 1, one_menu_item2, true)); |
| 2188 | 2161 |
| 2189 // Transferred browsers of other users should not show up in the list. | 2162 // Transferred browsers of other users should not show up in the list. |
| 2190 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( | 2163 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( |
| 2191 browser()->window()->GetNativeWindow(), account_id2); | 2164 browser()->window()->GetNativeWindow(), account_id2); |
| 2192 EXPECT_TRUE(CheckMenuCreation( | 2165 EXPECT_TRUE(CheckMenuCreation( |
| 2193 launcher_controller_.get(), item_browser, 1, one_menu_item2, true)); | 2166 launcher_controller_.get(), item_browser, 1, one_menu_item2, true)); |
| 2194 | 2167 |
| 2195 chrome::CloseTab(browser2.get()); | 2168 chrome::CloseTab(browser2.get()); |
| 2196 } | 2169 } |
| 2197 #endif // defined(OS_CHROMEOS) | |
| 2198 | 2170 |
| 2199 // Check that V1 apps are correctly reflected in the launcher menu using the | 2171 // Check that V1 apps are correctly reflected in the launcher menu using the |
| 2200 // refocus logic. | 2172 // refocus logic. |
| 2201 // Note that the extension matching logic is tested by the extension system | 2173 // Note that the extension matching logic is tested by the extension system |
| 2202 // and does not need a separate test here. | 2174 // and does not need a separate test here. |
| 2203 TEST_F(ChromeLauncherControllerTest, V1AppMenuGeneration) { | 2175 TEST_F(ChromeLauncherControllerTest, V1AppMenuGeneration) { |
| 2204 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 2176 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
| 2205 EXPECT_EQ(0, browser()->tab_strip_model()->count()); | 2177 EXPECT_EQ(0, browser()->tab_strip_model()->count()); |
| 2206 | 2178 |
| 2207 InitLauncherControllerWithBrowser(); | 2179 InitLauncherControllerWithBrowser(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2265 // updated properly). | 2237 // updated properly). |
| 2266 launcher_controller_->Close(item_gmail.id); | 2238 launcher_controller_->Close(item_gmail.id); |
| 2267 | 2239 |
| 2268 EXPECT_TRUE(CheckMenuCreation( | 2240 EXPECT_TRUE(CheckMenuCreation( |
| 2269 launcher_controller_.get(), item_gmail, 0, NULL, false)); | 2241 launcher_controller_.get(), item_gmail, 0, NULL, false)); |
| 2270 base::string16 browser_menu_item2[] = { title2 }; | 2242 base::string16 browser_menu_item2[] = { title2 }; |
| 2271 EXPECT_TRUE(CheckMenuCreation( | 2243 EXPECT_TRUE(CheckMenuCreation( |
| 2272 launcher_controller_.get(), item_browser, 1, browser_menu_item2, false)); | 2244 launcher_controller_.get(), item_browser, 1, browser_menu_item2, false)); |
| 2273 } | 2245 } |
| 2274 | 2246 |
| 2275 #if defined(OS_CHROMEOS) | |
| 2276 // Check the multi profile case where only user related apps should show up. | 2247 // Check the multi profile case where only user related apps should show up. |
| 2277 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2248 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
| 2278 V1AppMenuGenerationTwoUsers) { | 2249 V1AppMenuGenerationTwoUsers) { |
| 2279 // Create a browser item in the LauncherController. | 2250 // Create a browser item in the LauncherController. |
| 2280 InitLauncherController(); | 2251 InitLauncherController(); |
| 2281 chrome::NewTab(browser()); | 2252 chrome::NewTab(browser()); |
| 2282 | 2253 |
| 2283 // Installing |extension3_| adds it to the launcher. | 2254 // Installing |extension3_| adds it to the launcher. |
| 2284 ash::ShelfID gmail_id = model_->next_id(); | 2255 ash::ShelfID gmail_id = model_->next_id(); |
| 2285 extension_service_->AddExtension(extension3_.get()); | 2256 extension_service_->AddExtension(extension3_.get()); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 EXPECT_EQ(3, model_->item_count()); | 2506 EXPECT_EQ(3, model_->item_count()); |
| 2536 | 2507 |
| 2537 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE); | 2508 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE); |
| 2538 EXPECT_EQ(3, model_->item_count()); | 2509 EXPECT_EQ(3, model_->item_count()); |
| 2539 | 2510 |
| 2540 v2_app_1.window()->Hide(); | 2511 v2_app_1.window()->Hide(); |
| 2541 v2_app_2.window()->Hide(); | 2512 v2_app_2.window()->Hide(); |
| 2542 EXPECT_EQ(2, model_->item_count()); | 2513 EXPECT_EQ(2, model_->item_count()); |
| 2543 } | 2514 } |
| 2544 } | 2515 } |
| 2545 #endif // defined(OS_CHROMEOS) | |
| 2546 | 2516 |
| 2547 // Checks that the generated menu list properly activates items. | 2517 // Checks that the generated menu list properly activates items. |
| 2548 TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) { | 2518 TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) { |
| 2549 InitLauncherControllerWithBrowser(); | 2519 InitLauncherControllerWithBrowser(); |
| 2550 | 2520 |
| 2551 // Add |extension3_| to the launcher and add two items. | 2521 // Add |extension3_| to the launcher and add two items. |
| 2552 GURL gmail = GURL("https://mail.google.com/mail/u"); | 2522 GURL gmail = GURL("https://mail.google.com/mail/u"); |
| 2553 ash::ShelfID gmail_id = model_->next_id(); | 2523 ash::ShelfID gmail_id = model_->next_id(); |
| 2554 extension_service_->AddExtension(extension3_.get()); | 2524 extension_service_->AddExtension(extension3_.get()); |
| 2555 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); | 2525 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2938 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 2908 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 2939 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 2909 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 2940 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 2910 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 2941 | 2911 |
| 2942 launcher_controller_->CloseLauncherItem(shelfId3); | 2912 launcher_controller_->CloseLauncherItem(shelfId3); |
| 2943 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 2913 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 2944 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 2914 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 2945 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 2915 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 2946 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 2916 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 2947 } | 2917 } |
| OLD | NEW |