| 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 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
| 9 #include <set> | 11 #include <set> |
| 10 #include <string> | 12 #include <string> |
| 11 #include <utility> | 13 #include <utility> |
| 12 #include <vector> | 14 #include <vector> |
| 13 | 15 |
| 14 #include "ash/ash_switches.h" | 16 #include "ash/ash_switches.h" |
| 15 #include "ash/shelf/shelf_item_delegate_manager.h" | 17 #include "ash/shelf/shelf_item_delegate_manager.h" |
| 16 #include "ash/shelf/shelf_model.h" | 18 #include "ash/shelf/shelf_model.h" |
| 17 #include "ash/shelf/shelf_model_observer.h" | 19 #include "ash/shelf/shelf_model_observer.h" |
| 18 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 19 #include "ash/test/shelf_item_delegate_manager_test_api.h" | 21 #include "ash/test/shelf_item_delegate_manager_test_api.h" |
| 20 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 21 #include "base/compiler_specific.h" | 23 #include "base/compiler_specific.h" |
| 22 #include "base/files/file_path.h" | 24 #include "base/files/file_path.h" |
| 23 #include "base/macros.h" | 25 #include "base/macros.h" |
| 24 #include "base/memory/scoped_ptr.h" | 26 #include "base/memory/ptr_util.h" |
| 25 #include "base/message_loop/message_loop.h" | 27 #include "base/message_loop/message_loop.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/values.h" | 29 #include "base/values.h" |
| 28 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 29 #include "chrome/browser/extensions/extension_service.h" | 31 #include "chrome/browser/extensions/extension_service.h" |
| 30 #include "chrome/browser/extensions/test_extension_system.h" | 32 #include "chrome/browser/extensions/test_extension_system.h" |
| 31 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 33 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 32 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont
roller.h" | 34 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont
roller.h" |
| 33 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 35 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
| 34 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 36 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 450 |
| 449 model_.reset(); | 451 model_.reset(); |
| 450 | 452 |
| 451 BrowserWithTestWindowTest::TearDown(); | 453 BrowserWithTestWindowTest::TearDown(); |
| 452 } | 454 } |
| 453 | 455 |
| 454 BrowserWindow* CreateBrowserWindow() override { | 456 BrowserWindow* CreateBrowserWindow() override { |
| 455 return CreateTestBrowserWindowAura(); | 457 return CreateTestBrowserWindowAura(); |
| 456 } | 458 } |
| 457 | 459 |
| 458 scoped_ptr<Browser> CreateBrowserWithTestWindowForProfile(Profile* profile) { | 460 std::unique_ptr<Browser> CreateBrowserWithTestWindowForProfile( |
| 461 Profile* profile) { |
| 459 TestBrowserWindow* browser_window = CreateTestBrowserWindowAura(); | 462 TestBrowserWindow* browser_window = CreateTestBrowserWindowAura(); |
| 460 new TestBrowserWindowOwner(browser_window); | 463 new TestBrowserWindowOwner(browser_window); |
| 461 return make_scoped_ptr( | 464 return base::WrapUnique( |
| 462 CreateBrowser(profile, Browser::TYPE_TABBED, false, browser_window)); | 465 CreateBrowser(profile, Browser::TYPE_TABBED, false, browser_window)); |
| 463 } | 466 } |
| 464 | 467 |
| 465 void AddAppListLauncherItem() { | 468 void AddAppListLauncherItem() { |
| 466 ash::ShelfItem app_list; | 469 ash::ShelfItem app_list; |
| 467 app_list.type = ash::TYPE_APP_LIST; | 470 app_list.type = ash::TYPE_APP_LIST; |
| 468 model_->Add(app_list); | 471 model_->Add(app_list); |
| 469 } | 472 } |
| 470 | 473 |
| 471 void InitLauncherController() { | 474 void InitLauncherController() { |
| 472 AddAppListLauncherItem(); | 475 AddAppListLauncherItem(); |
| 473 launcher_controller_.reset( | 476 launcher_controller_.reset( |
| 474 new ChromeLauncherController(profile(), model_.get())); | 477 new ChromeLauncherController(profile(), model_.get())); |
| 475 if (!ash::Shell::HasInstance()) | 478 if (!ash::Shell::HasInstance()) |
| 476 SetShelfItemDelegateManager(item_delegate_manager_); | 479 SetShelfItemDelegateManager(item_delegate_manager_); |
| 477 launcher_controller_->Init(); | 480 launcher_controller_->Init(); |
| 478 } | 481 } |
| 479 | 482 |
| 480 void InitLauncherControllerWithBrowser() { | 483 void InitLauncherControllerWithBrowser() { |
| 481 InitLauncherController(); | 484 InitLauncherController(); |
| 482 chrome::NewTab(browser()); | 485 chrome::NewTab(browser()); |
| 483 browser()->window()->Show(); | 486 browser()->window()->Show(); |
| 484 } | 487 } |
| 485 | 488 |
| 486 void SetAppIconLoader(scoped_ptr<AppIconLoader> loader) { | 489 void SetAppIconLoader(std::unique_ptr<AppIconLoader> loader) { |
| 487 std::vector<scoped_ptr<AppIconLoader>> loaders; | 490 std::vector<std::unique_ptr<AppIconLoader>> loaders; |
| 488 loaders.push_back(std::move(loader)); | 491 loaders.push_back(std::move(loader)); |
| 489 launcher_controller_->SetAppIconLoadersForTest(loaders); | 492 launcher_controller_->SetAppIconLoadersForTest(loaders); |
| 490 } | 493 } |
| 491 | 494 |
| 492 void SetAppIconLoaders(scoped_ptr<AppIconLoader> loader1, | 495 void SetAppIconLoaders(std::unique_ptr<AppIconLoader> loader1, |
| 493 scoped_ptr<AppIconLoader> loader2) { | 496 std::unique_ptr<AppIconLoader> loader2) { |
| 494 std::vector<scoped_ptr<AppIconLoader>> loaders; | 497 std::vector<std::unique_ptr<AppIconLoader>> loaders; |
| 495 loaders.push_back(std::move(loader1)); | 498 loaders.push_back(std::move(loader1)); |
| 496 loaders.push_back(std::move(loader2)); | 499 loaders.push_back(std::move(loader2)); |
| 497 launcher_controller_->SetAppIconLoadersForTest(loaders); | 500 launcher_controller_->SetAppIconLoadersForTest(loaders); |
| 498 } | 501 } |
| 499 | 502 |
| 500 void SetAppTabHelper(ChromeLauncherController::AppTabHelper* helper) { | 503 void SetAppTabHelper(ChromeLauncherController::AppTabHelper* helper) { |
| 501 launcher_controller_->SetAppTabHelperForTest(helper); | 504 launcher_controller_->SetAppTabHelperForTest(helper); |
| 502 } | 505 } |
| 503 | 506 |
| 504 void SetShelfItemDelegateManager(ash::ShelfItemDelegateManager* manager) { | 507 void SetShelfItemDelegateManager(ash::ShelfItemDelegateManager* manager) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 scoped_refptr<Extension> extension2_; | 685 scoped_refptr<Extension> extension2_; |
| 683 scoped_refptr<Extension> extension3_; | 686 scoped_refptr<Extension> extension3_; |
| 684 scoped_refptr<Extension> extension4_; | 687 scoped_refptr<Extension> extension4_; |
| 685 scoped_refptr<Extension> extension5_; | 688 scoped_refptr<Extension> extension5_; |
| 686 scoped_refptr<Extension> extension6_; | 689 scoped_refptr<Extension> extension6_; |
| 687 scoped_refptr<Extension> extension7_; | 690 scoped_refptr<Extension> extension7_; |
| 688 scoped_refptr<Extension> extension8_; | 691 scoped_refptr<Extension> extension8_; |
| 689 #if defined(OS_CHROMEOS) | 692 #if defined(OS_CHROMEOS) |
| 690 ArcAppTest arc_test_; | 693 ArcAppTest arc_test_; |
| 691 #endif // defined(OS_CHROMEOS) | 694 #endif // defined(OS_CHROMEOS) |
| 692 scoped_ptr<ChromeLauncherController> launcher_controller_; | 695 std::unique_ptr<ChromeLauncherController> launcher_controller_; |
| 693 scoped_ptr<TestShelfModelObserver> model_observer_; | 696 std::unique_ptr<TestShelfModelObserver> model_observer_; |
| 694 scoped_ptr<ash::ShelfModel> model_; | 697 std::unique_ptr<ash::ShelfModel> model_; |
| 695 | 698 |
| 696 // |item_delegate_manager_| owns |test_controller_|. | 699 // |item_delegate_manager_| owns |test_controller_|. |
| 697 LauncherItemController* test_controller_; | 700 LauncherItemController* test_controller_; |
| 698 | 701 |
| 699 ExtensionService* extension_service_; | 702 ExtensionService* extension_service_; |
| 700 | 703 |
| 701 ash::ShelfItemDelegateManager* item_delegate_manager_; | 704 ash::ShelfItemDelegateManager* item_delegate_manager_; |
| 702 | 705 |
| 703 private: | 706 private: |
| 704 TestBrowserWindow* CreateTestBrowserWindowAura() { | 707 TestBrowserWindow* CreateTestBrowserWindowAura() { |
| 705 scoped_ptr<aura::Window> window(new aura::Window(nullptr)); | 708 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); |
| 706 window->set_id(0); | 709 window->set_id(0); |
| 707 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 710 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 708 window->Init(ui::LAYER_TEXTURED); | 711 window->Init(ui::LAYER_TEXTURED); |
| 709 aura::client::ParentWindowWithContext(window.get(), GetContext(), | 712 aura::client::ParentWindowWithContext(window.get(), GetContext(), |
| 710 gfx::Rect(200, 200)); | 713 gfx::Rect(200, 200)); |
| 711 | 714 |
| 712 return new TestBrowserWindowAura(std::move(window)); | 715 return new TestBrowserWindowAura(std::move(window)); |
| 713 } | 716 } |
| 714 | 717 |
| 715 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); | 718 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 773 |
| 771 Browser* browser() { return browser_.get(); } | 774 Browser* browser() { return browser_.get(); } |
| 772 | 775 |
| 773 // TestBrowserWindow override: | 776 // TestBrowserWindow override: |
| 774 gfx::NativeWindow GetNativeWindow() const override { | 777 gfx::NativeWindow GetNativeWindow() const override { |
| 775 return native_window_.get(); | 778 return native_window_.get(); |
| 776 } | 779 } |
| 777 | 780 |
| 778 private: | 781 private: |
| 779 // The associated browser with this app. | 782 // The associated browser with this app. |
| 780 scoped_ptr<Browser> browser_; | 783 std::unique_ptr<Browser> browser_; |
| 781 | 784 |
| 782 // The native window we use. | 785 // The native window we use. |
| 783 scoped_ptr<aura::Window> native_window_; | 786 std::unique_ptr<aura::Window> native_window_; |
| 784 | 787 |
| 785 DISALLOW_COPY_AND_ASSIGN(V1App); | 788 DISALLOW_COPY_AND_ASSIGN(V1App); |
| 786 }; | 789 }; |
| 787 | 790 |
| 788 // A V2 application which gets created with an |extension| and for a |profile|. | 791 // A V2 application which gets created with an |extension| and for a |profile|. |
| 789 // Upon destruction it will properly close the application. | 792 // Upon destruction it will properly close the application. |
| 790 class V2App { | 793 class V2App { |
| 791 public: | 794 public: |
| 792 V2App(Profile* profile, const extensions::Extension* extension) | 795 V2App(Profile* profile, const extensions::Extension* extension) |
| 793 : creator_web_contents_( | 796 : creator_web_contents_( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 808 | 811 |
| 809 virtual ~V2App() { | 812 virtual ~V2App() { |
| 810 WebContentsDestroyedWatcher destroyed_watcher(window_->web_contents()); | 813 WebContentsDestroyedWatcher destroyed_watcher(window_->web_contents()); |
| 811 window_->GetBaseWindow()->Close(); | 814 window_->GetBaseWindow()->Close(); |
| 812 destroyed_watcher.Wait(); | 815 destroyed_watcher.Wait(); |
| 813 } | 816 } |
| 814 | 817 |
| 815 extensions::AppWindow* window() { return window_; } | 818 extensions::AppWindow* window() { return window_; } |
| 816 | 819 |
| 817 private: | 820 private: |
| 818 scoped_ptr<content::WebContents> creator_web_contents_; | 821 std::unique_ptr<content::WebContents> creator_web_contents_; |
| 819 | 822 |
| 820 // The app window which represents the application. Note that the window | 823 // The app window which represents the application. Note that the window |
| 821 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets | 824 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets |
| 822 // called. | 825 // called. |
| 823 extensions::AppWindow* window_; | 826 extensions::AppWindow* window_; |
| 824 | 827 |
| 825 DISALLOW_COPY_AND_ASSIGN(V2App); | 828 DISALLOW_COPY_AND_ASSIGN(V2App); |
| 826 }; | 829 }; |
| 827 | 830 |
| 828 // The testing framework to test multi profile scenarios. | 831 // The testing framework to test multi profile scenarios. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 manager->SetAnimationSpeedForTest( | 916 manager->SetAnimationSpeedForTest( |
| 914 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); | 917 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); |
| 915 manager->ActiveUserChanged(account_id); | 918 manager->ActiveUserChanged(account_id); |
| 916 launcher_controller_->browser_status_monitor_for_test()->ActiveUserChanged( | 919 launcher_controller_->browser_status_monitor_for_test()->ActiveUserChanged( |
| 917 account_id.GetUserEmail()); | 920 account_id.GetUserEmail()); |
| 918 launcher_controller_->app_window_controller_for_test()->ActiveUserChanged( | 921 launcher_controller_->app_window_controller_for_test()->ActiveUserChanged( |
| 919 account_id.GetUserEmail()); | 922 account_id.GetUserEmail()); |
| 920 } | 923 } |
| 921 | 924 |
| 922 // Creates a browser with a |profile| and load a tab with a |title| and |url|. | 925 // Creates a browser with a |profile| and load a tab with a |title| and |url|. |
| 923 scoped_ptr<Browser> CreateBrowserAndTabWithProfile(Profile* profile, | 926 std::unique_ptr<Browser> CreateBrowserAndTabWithProfile( |
| 924 const std::string& title, | 927 Profile* profile, |
| 925 const std::string& url) { | 928 const std::string& title, |
| 926 scoped_ptr<Browser> browser(CreateBrowserWithTestWindowForProfile(profile)); | 929 const std::string& url) { |
| 930 std::unique_ptr<Browser> browser( |
| 931 CreateBrowserWithTestWindowForProfile(profile)); |
| 927 chrome::NewTab(browser.get()); | 932 chrome::NewTab(browser.get()); |
| 928 | 933 |
| 929 browser->window()->Show(); | 934 browser->window()->Show(); |
| 930 NavigateAndCommitActiveTabWithTitle(browser.get(), GURL(url), | 935 NavigateAndCommitActiveTabWithTitle(browser.get(), GURL(url), |
| 931 ASCIIToUTF16(title)); | 936 ASCIIToUTF16(title)); |
| 932 return browser; | 937 return browser; |
| 933 } | 938 } |
| 934 | 939 |
| 935 // Creates a running V1 application. | 940 // Creates a running V1 application. |
| 936 // Note that with the use of the app_tab_helper as done below, this is only | 941 // Note that with the use of the app_tab_helper as done below, this is only |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 | 979 |
| 975 private: | 980 private: |
| 976 typedef std::map<Profile*, std::string> ProfileToNameMap; | 981 typedef std::map<Profile*, std::string> ProfileToNameMap; |
| 977 TestingProfileManager* profile_manager() { return profile_manager_.get(); } | 982 TestingProfileManager* profile_manager() { return profile_manager_.get(); } |
| 978 | 983 |
| 979 chromeos::FakeChromeUserManager* GetFakeUserManager() { | 984 chromeos::FakeChromeUserManager* GetFakeUserManager() { |
| 980 return static_cast<chromeos::FakeChromeUserManager*>( | 985 return static_cast<chromeos::FakeChromeUserManager*>( |
| 981 user_manager::UserManager::Get()); | 986 user_manager::UserManager::Get()); |
| 982 } | 987 } |
| 983 | 988 |
| 984 scoped_ptr<TestingProfileManager> profile_manager_; | 989 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 985 scoped_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; | 990 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; |
| 986 | 991 |
| 987 ash::test::TestShellDelegate* shell_delegate_; | 992 ash::test::TestShellDelegate* shell_delegate_; |
| 988 | 993 |
| 989 ProfileToNameMap created_profiles_; | 994 ProfileToNameMap created_profiles_; |
| 990 | 995 |
| 991 DISALLOW_COPY_AND_ASSIGN( | 996 DISALLOW_COPY_AND_ASSIGN( |
| 992 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest); | 997 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest); |
| 993 }; | 998 }; |
| 994 #endif // defined(OS_CHROMEOS) | 999 #endif // defined(OS_CHROMEOS) |
| 995 | 1000 |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 | 1530 |
| 1526 // Check that with multi profile V1 apps are properly added / removed from the | 1531 // Check that with multi profile V1 apps are properly added / removed from the |
| 1527 // shelf. | 1532 // shelf. |
| 1528 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 1533 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
| 1529 V1AppUpdateOnUserSwitch) { | 1534 V1AppUpdateOnUserSwitch) { |
| 1530 // Create a browser item in the LauncherController. | 1535 // Create a browser item in the LauncherController. |
| 1531 InitLauncherController(); | 1536 InitLauncherController(); |
| 1532 EXPECT_EQ(2, model_->item_count()); | 1537 EXPECT_EQ(2, model_->item_count()); |
| 1533 { | 1538 { |
| 1534 // Create a "windowed gmail app". | 1539 // Create a "windowed gmail app". |
| 1535 scoped_ptr<V1App> v1_app(CreateRunningV1App( | 1540 std::unique_ptr<V1App> v1_app( |
| 1536 profile(), extension_misc::kGmailAppId, gmail_url)); | 1541 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); |
| 1537 EXPECT_EQ(3, model_->item_count()); | 1542 EXPECT_EQ(3, model_->item_count()); |
| 1538 | 1543 |
| 1539 // After switching to a second user the item should be gone. | 1544 // After switching to a second user the item should be gone. |
| 1540 std::string user2 = "user2"; | 1545 std::string user2 = "user2"; |
| 1541 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 1546 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 1542 const AccountId account_id2( | 1547 const AccountId account_id2( |
| 1543 multi_user_util::GetAccountIdFromProfile(profile2)); | 1548 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 1544 const AccountId account_id( | 1549 const AccountId account_id( |
| 1545 multi_user_util::GetAccountIdFromProfile(profile())); | 1550 multi_user_util::GetAccountIdFromProfile(profile())); |
| 1546 SwitchActiveUser(account_id2); | 1551 SwitchActiveUser(account_id2); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1562 | 1567 |
| 1563 // First test: Create an app when the user is not active. | 1568 // First test: Create an app when the user is not active. |
| 1564 std::string user2 = "user2"; | 1569 std::string user2 = "user2"; |
| 1565 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 1570 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 1566 const AccountId account_id2( | 1571 const AccountId account_id2( |
| 1567 multi_user_util::GetAccountIdFromProfile(profile2)); | 1572 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 1568 const AccountId account_id( | 1573 const AccountId account_id( |
| 1569 multi_user_util::GetAccountIdFromProfile(profile())); | 1574 multi_user_util::GetAccountIdFromProfile(profile())); |
| 1570 { | 1575 { |
| 1571 // Create a "windowed gmail app". | 1576 // Create a "windowed gmail app". |
| 1572 scoped_ptr<V1App> v1_app(CreateRunningV1App( | 1577 std::unique_ptr<V1App> v1_app( |
| 1573 profile2, extension_misc::kGmailAppId, gmail_url)); | 1578 CreateRunningV1App(profile2, extension_misc::kGmailAppId, gmail_url)); |
| 1574 EXPECT_EQ(2, model_->item_count()); | 1579 EXPECT_EQ(2, model_->item_count()); |
| 1575 | 1580 |
| 1576 // However - switching to the user should show it. | 1581 // However - switching to the user should show it. |
| 1577 SwitchActiveUser(account_id2); | 1582 SwitchActiveUser(account_id2); |
| 1578 EXPECT_EQ(3, model_->item_count()); | 1583 EXPECT_EQ(3, model_->item_count()); |
| 1579 | 1584 |
| 1580 // Second test: Remove the app when the user is not active and see that it | 1585 // Second test: Remove the app when the user is not active and see that it |
| 1581 // works. | 1586 // works. |
| 1582 SwitchActiveUser(account_id); | 1587 SwitchActiveUser(account_id); |
| 1583 EXPECT_EQ(2, model_->item_count()); | 1588 EXPECT_EQ(2, model_->item_count()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1601 | 1606 |
| 1602 // First create an app when the user is active. | 1607 // First create an app when the user is active. |
| 1603 std::string user2 = "user2"; | 1608 std::string user2 = "user2"; |
| 1604 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 1609 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 1605 const AccountId account_id( | 1610 const AccountId account_id( |
| 1606 multi_user_util::GetAccountIdFromProfile(profile())); | 1611 multi_user_util::GetAccountIdFromProfile(profile())); |
| 1607 const AccountId account_id2( | 1612 const AccountId account_id2( |
| 1608 multi_user_util::GetAccountIdFromProfile(profile2)); | 1613 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 1609 { | 1614 { |
| 1610 // Create a "windowed gmail app". | 1615 // Create a "windowed gmail app". |
| 1611 scoped_ptr<V1App> v1_app(CreateRunningV1App( | 1616 std::unique_ptr<V1App> v1_app(CreateRunningV1App( |
| 1612 profile(), | 1617 profile(), extension_misc::kGmailAppId, kGmailLaunchURL)); |
| 1613 extension_misc::kGmailAppId, | |
| 1614 kGmailLaunchURL)); | |
| 1615 EXPECT_EQ(3, model_->item_count()); | 1618 EXPECT_EQ(3, model_->item_count()); |
| 1616 | 1619 |
| 1617 // Transfer the app to the other screen and switch users. | 1620 // Transfer the app to the other screen and switch users. |
| 1618 manager->ShowWindowForUser(v1_app->browser()->window()->GetNativeWindow(), | 1621 manager->ShowWindowForUser(v1_app->browser()->window()->GetNativeWindow(), |
| 1619 account_id2); | 1622 account_id2); |
| 1620 EXPECT_EQ(3, model_->item_count()); | 1623 EXPECT_EQ(3, model_->item_count()); |
| 1621 SwitchActiveUser(account_id2); | 1624 SwitchActiveUser(account_id2); |
| 1622 EXPECT_EQ(2, model_->item_count()); | 1625 EXPECT_EQ(2, model_->item_count()); |
| 1623 } | 1626 } |
| 1624 // After the app was destroyed, switch back. (which caused already a crash). | 1627 // After the app was destroyed, switch back. (which caused already a crash). |
| 1625 SwitchActiveUser(account_id); | 1628 SwitchActiveUser(account_id); |
| 1626 | 1629 |
| 1627 // Create the same app again - which was also causing the crash. | 1630 // Create the same app again - which was also causing the crash. |
| 1628 EXPECT_EQ(2, model_->item_count()); | 1631 EXPECT_EQ(2, model_->item_count()); |
| 1629 { | 1632 { |
| 1630 // Create a "windowed gmail app". | 1633 // Create a "windowed gmail app". |
| 1631 scoped_ptr<V1App> v1_app(CreateRunningV1App( | 1634 std::unique_ptr<V1App> v1_app(CreateRunningV1App( |
| 1632 profile(), | 1635 profile(), extension_misc::kGmailAppId, kGmailLaunchURL)); |
| 1633 extension_misc::kGmailAppId, | |
| 1634 kGmailLaunchURL)); | |
| 1635 EXPECT_EQ(3, model_->item_count()); | 1636 EXPECT_EQ(3, model_->item_count()); |
| 1636 } | 1637 } |
| 1637 SwitchActiveUser(account_id2); | 1638 SwitchActiveUser(account_id2); |
| 1638 EXPECT_EQ(2, model_->item_count()); | 1639 EXPECT_EQ(2, model_->item_count()); |
| 1639 } | 1640 } |
| 1640 | 1641 |
| 1641 // Check edge cases with multi profile V1 apps in the shelf. | 1642 // Check edge cases with multi profile V1 apps in the shelf. |
| 1642 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 1643 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
| 1643 V1AppUpdateOnUserSwitchEdgecases2) { | 1644 V1AppUpdateOnUserSwitchEdgecases2) { |
| 1644 // Create a browser item in the LauncherController. | 1645 // Create a browser item in the LauncherController. |
| 1645 InitLauncherController(); | 1646 InitLauncherController(); |
| 1646 TestAppTabHelperImpl* app_tab_helper = new TestAppTabHelperImpl; | 1647 TestAppTabHelperImpl* app_tab_helper = new TestAppTabHelperImpl; |
| 1647 SetAppTabHelper(app_tab_helper); | 1648 SetAppTabHelper(app_tab_helper); |
| 1648 | 1649 |
| 1649 // First test: Create an app when the user is not active. | 1650 // First test: Create an app when the user is not active. |
| 1650 std::string user2 = "user2"; | 1651 std::string user2 = "user2"; |
| 1651 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 1652 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 1652 const AccountId account_id( | 1653 const AccountId account_id( |
| 1653 multi_user_util::GetAccountIdFromProfile(profile())); | 1654 multi_user_util::GetAccountIdFromProfile(profile())); |
| 1654 const AccountId account_id2( | 1655 const AccountId account_id2( |
| 1655 multi_user_util::GetAccountIdFromProfile(profile2)); | 1656 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 1656 SwitchActiveUser(account_id2); | 1657 SwitchActiveUser(account_id2); |
| 1657 { | 1658 { |
| 1658 // Create a "windowed gmail app". | 1659 // Create a "windowed gmail app". |
| 1659 scoped_ptr<V1App> v1_app(CreateRunningV1App( | 1660 std::unique_ptr<V1App> v1_app( |
| 1660 profile(), extension_misc::kGmailAppId, gmail_url)); | 1661 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); |
| 1661 EXPECT_EQ(2, model_->item_count()); | 1662 EXPECT_EQ(2, model_->item_count()); |
| 1662 | 1663 |
| 1663 // However - switching to the user should show it. | 1664 // However - switching to the user should show it. |
| 1664 SwitchActiveUser(account_id); | 1665 SwitchActiveUser(account_id); |
| 1665 EXPECT_EQ(3, model_->item_count()); | 1666 EXPECT_EQ(3, model_->item_count()); |
| 1666 | 1667 |
| 1667 // Second test: Remove the app when the user is not active and see that it | 1668 // Second test: Remove the app when the user is not active and see that it |
| 1668 // works. | 1669 // works. |
| 1669 SwitchActiveUser(account_id2); | 1670 SwitchActiveUser(account_id2); |
| 1670 EXPECT_EQ(2, model_->item_count()); | 1671 EXPECT_EQ(2, model_->item_count()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1689 // Create a second test profile. The first is the one in profile() created in | 1690 // Create a second test profile. The first is the one in profile() created in |
| 1690 // BrowserWithTestWindowTest::SetUp(). | 1691 // BrowserWithTestWindowTest::SetUp(). |
| 1691 // No need to add the profiles to the MultiUserWindowManager here. | 1692 // No need to add the profiles to the MultiUserWindowManager here. |
| 1692 // CreateMultiUserProfile() already does that. | 1693 // CreateMultiUserProfile() already does that. |
| 1693 TestingProfile* profile2 = CreateMultiUserProfile("user2"); | 1694 TestingProfile* profile2 = CreateMultiUserProfile("user2"); |
| 1694 const AccountId current_user = | 1695 const AccountId current_user = |
| 1695 multi_user_util::GetAccountIdFromProfile(profile()); | 1696 multi_user_util::GetAccountIdFromProfile(profile()); |
| 1696 | 1697 |
| 1697 // Create a browser window with a native window for the current user. | 1698 // Create a browser window with a native window for the current user. |
| 1698 Browser::CreateParams params(profile()); | 1699 Browser::CreateParams params(profile()); |
| 1699 scoped_ptr<Browser> browser( | 1700 std::unique_ptr<Browser> browser( |
| 1700 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); | 1701 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); |
| 1701 BrowserWindow* browser_window = browser->window(); | 1702 BrowserWindow* browser_window = browser->window(); |
| 1702 aura::Window* window = browser_window->GetNativeWindow(); | 1703 aura::Window* window = browser_window->GetNativeWindow(); |
| 1703 manager->SetWindowOwner(window, current_user); | 1704 manager->SetWindowOwner(window, current_user); |
| 1704 | 1705 |
| 1705 // Check that an activation of the window on its owner's desktop does not | 1706 // Check that an activation of the window on its owner's desktop does not |
| 1706 // change the visibility to another user. | 1707 // change the visibility to another user. |
| 1707 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); | 1708 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); |
| 1708 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); | 1709 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); |
| 1709 | 1710 |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 EXPECT_FALSE(items[0]->IsEnabled()); | 2130 EXPECT_FALSE(items[0]->IsEnabled()); |
| 2130 for (size_t i = 0; i < expected_items; i++) { | 2131 for (size_t i = 0; i < expected_items; i++) { |
| 2131 EXPECT_EQ(title[i], items[1 + i]->title()); | 2132 EXPECT_EQ(title[i], items[1 + i]->title()); |
| 2132 // Check that the first real item has a leading separator. | 2133 // Check that the first real item has a leading separator. |
| 2133 if (i == 1) | 2134 if (i == 1) |
| 2134 EXPECT_TRUE(items[i]->HasLeadingSeparator()); | 2135 EXPECT_TRUE(items[i]->HasLeadingSeparator()); |
| 2135 else | 2136 else |
| 2136 EXPECT_FALSE(items[i]->HasLeadingSeparator()); | 2137 EXPECT_FALSE(items[i]->HasLeadingSeparator()); |
| 2137 } | 2138 } |
| 2138 | 2139 |
| 2139 scoped_ptr<ash::ShelfMenuModel> menu(new LauncherApplicationMenuItemModel( | 2140 std::unique_ptr<ash::ShelfMenuModel> menu( |
| 2140 controller->GetApplicationList(item, 0))); | 2141 new LauncherApplicationMenuItemModel( |
| 2142 controller->GetApplicationList(item, 0))); |
| 2141 // The first element in the menu is a spacing separator. On some systems | 2143 // The first element in the menu is a spacing separator. On some systems |
| 2142 // (e.g. Windows) such things do not exist. As such we check the existence | 2144 // (e.g. Windows) such things do not exist. As such we check the existence |
| 2143 // and adjust dynamically. | 2145 // and adjust dynamically. |
| 2144 int first_item = menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR ? 1 : 0; | 2146 int first_item = menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR ? 1 : 0; |
| 2145 int expected_menu_items = first_item + | 2147 int expected_menu_items = first_item + |
| 2146 (expected_items ? (expected_items + 3) : 2); | 2148 (expected_items ? (expected_items + 3) : 2); |
| 2147 EXPECT_EQ(expected_menu_items, menu->GetItemCount()); | 2149 EXPECT_EQ(expected_menu_items, menu->GetItemCount()); |
| 2148 EXPECT_FALSE(menu->IsEnabledAt(first_item)); | 2150 EXPECT_FALSE(menu->IsEnabledAt(first_item)); |
| 2149 if (expected_items) { | 2151 if (expected_items) { |
| 2150 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR, | 2152 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2171 // Now make the created browser() visible by showing its browser window. | 2173 // Now make the created browser() visible by showing its browser window. |
| 2172 browser()->window()->Show(); | 2174 browser()->window()->Show(); |
| 2173 base::string16 title1 = ASCIIToUTF16("Test1"); | 2175 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 2174 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); | 2176 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); |
| 2175 base::string16 one_menu_item[] = { title1 }; | 2177 base::string16 one_menu_item[] = { title1 }; |
| 2176 | 2178 |
| 2177 EXPECT_TRUE(CheckMenuCreation( | 2179 EXPECT_TRUE(CheckMenuCreation( |
| 2178 launcher_controller_.get(), item_browser, 1, one_menu_item, true)); | 2180 launcher_controller_.get(), item_browser, 1, one_menu_item, true)); |
| 2179 | 2181 |
| 2180 // Create one more browser/window and check that one more was added. | 2182 // Create one more browser/window and check that one more was added. |
| 2181 scoped_ptr<Browser> browser2( | 2183 std::unique_ptr<Browser> browser2( |
| 2182 CreateBrowserWithTestWindowForProfile(profile())); | 2184 CreateBrowserWithTestWindowForProfile(profile())); |
| 2183 chrome::NewTab(browser2.get()); | 2185 chrome::NewTab(browser2.get()); |
| 2184 browser2->window()->Show(); | 2186 browser2->window()->Show(); |
| 2185 base::string16 title2 = ASCIIToUTF16("Test2"); | 2187 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 2186 NavigateAndCommitActiveTabWithTitle(browser2.get(), GURL("http://test2"), | 2188 NavigateAndCommitActiveTabWithTitle(browser2.get(), GURL("http://test2"), |
| 2187 title2); | 2189 title2); |
| 2188 | 2190 |
| 2189 // Check that the list contains now two entries - make furthermore sure that | 2191 // Check that the list contains now two entries - make furthermore sure that |
| 2190 // the active item is the first entry. | 2192 // the active item is the first entry. |
| 2191 base::string16 two_menu_items[] = {title1, title2}; | 2193 base::string16 two_menu_items[] = {title1, title2}; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2221 base::string16 one_menu_item1[] = { title1 }; | 2223 base::string16 one_menu_item1[] = { title1 }; |
| 2222 EXPECT_TRUE(CheckMenuCreation( | 2224 EXPECT_TRUE(CheckMenuCreation( |
| 2223 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); | 2225 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); |
| 2224 | 2226 |
| 2225 // Create a browser for another user and check that it is not included in the | 2227 // Create a browser for another user and check that it is not included in the |
| 2226 // users running browser list. | 2228 // users running browser list. |
| 2227 std::string user2 = "user2"; | 2229 std::string user2 = "user2"; |
| 2228 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 2230 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 2229 const AccountId account_id2( | 2231 const AccountId account_id2( |
| 2230 multi_user_util::GetAccountIdFromProfile(profile2)); | 2232 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 2231 scoped_ptr<Browser> browser2( | 2233 std::unique_ptr<Browser> browser2( |
| 2232 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2")); | 2234 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2")); |
| 2233 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) }; | 2235 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) }; |
| 2234 EXPECT_TRUE(CheckMenuCreation( | 2236 EXPECT_TRUE(CheckMenuCreation( |
| 2235 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); | 2237 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); |
| 2236 | 2238 |
| 2237 // Switch to the other user and make sure that only that browser window gets | 2239 // Switch to the other user and make sure that only that browser window gets |
| 2238 // shown. | 2240 // shown. |
| 2239 SwitchActiveUser(account_id2); | 2241 SwitchActiveUser(account_id2); |
| 2240 EXPECT_TRUE(CheckMenuCreation( | 2242 EXPECT_TRUE(CheckMenuCreation( |
| 2241 launcher_controller_.get(), item_browser, 1, one_menu_item2, true)); | 2243 launcher_controller_.get(), item_browser, 1, one_menu_item2, true)); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2617 ash::ShelfItem item_gmail; | 2619 ash::ShelfItem item_gmail; |
| 2618 item_gmail.type = ash::TYPE_APP_SHORTCUT; | 2620 item_gmail.type = ash::TYPE_APP_SHORTCUT; |
| 2619 item_gmail.id = gmail_id; | 2621 item_gmail.id = gmail_id; |
| 2620 base::string16 two_menu_items[] = {title1, title2}; | 2622 base::string16 two_menu_items[] = {title1, title2}; |
| 2621 EXPECT_TRUE(CheckMenuCreation( | 2623 EXPECT_TRUE(CheckMenuCreation( |
| 2622 launcher_controller_.get(), item_gmail, 2, two_menu_items, false)); | 2624 launcher_controller_.get(), item_gmail, 2, two_menu_items, false)); |
| 2623 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 2625 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 2624 // Execute the second item in the list (which shouldn't do anything since that | 2626 // Execute the second item in the list (which shouldn't do anything since that |
| 2625 // item is per definition already the active tab). | 2627 // item is per definition already the active tab). |
| 2626 { | 2628 { |
| 2627 scoped_ptr<ash::ShelfMenuModel> menu(new LauncherApplicationMenuItemModel( | 2629 std::unique_ptr<ash::ShelfMenuModel> menu( |
| 2628 launcher_controller_->GetApplicationList(item_gmail, 0))); | 2630 new LauncherApplicationMenuItemModel( |
| 2631 launcher_controller_->GetApplicationList(item_gmail, 0))); |
| 2629 // The first element in the menu is a spacing separator. On some systems | 2632 // The first element in the menu is a spacing separator. On some systems |
| 2630 // (e.g. Windows) such things do not exist. As such we check the existence | 2633 // (e.g. Windows) such things do not exist. As such we check the existence |
| 2631 // and adjust dynamically. | 2634 // and adjust dynamically. |
| 2632 int first_item = | 2635 int first_item = |
| 2633 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; | 2636 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; |
| 2634 menu->ActivatedAt(first_item + 3); | 2637 menu->ActivatedAt(first_item + 3); |
| 2635 } | 2638 } |
| 2636 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 2639 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 2637 | 2640 |
| 2638 // Execute the first item. | 2641 // Execute the first item. |
| 2639 { | 2642 { |
| 2640 scoped_ptr<ash::ShelfMenuModel> menu(new LauncherApplicationMenuItemModel( | 2643 std::unique_ptr<ash::ShelfMenuModel> menu( |
| 2641 launcher_controller_->GetApplicationList(item_gmail, 0))); | 2644 new LauncherApplicationMenuItemModel( |
| 2645 launcher_controller_->GetApplicationList(item_gmail, 0))); |
| 2642 int first_item = | 2646 int first_item = |
| 2643 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; | 2647 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; |
| 2644 menu->ActivatedAt(first_item + 2); | 2648 menu->ActivatedAt(first_item + 2); |
| 2645 } | 2649 } |
| 2646 // Now the active tab should be the second item. | 2650 // Now the active tab should be the second item. |
| 2647 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 2651 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 2648 } | 2652 } |
| 2649 | 2653 |
| 2650 // Checks that the generated menu list properly deletes items. | 2654 // Checks that the generated menu list properly deletes items. |
| 2651 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) { | 2655 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2691 // Tests that panels create launcher items correctly | 2695 // Tests that panels create launcher items correctly |
| 2692 TEST_F(ChromeLauncherControllerTest, AppPanels) { | 2696 TEST_F(ChromeLauncherControllerTest, AppPanels) { |
| 2693 InitLauncherControllerWithBrowser(); | 2697 InitLauncherControllerWithBrowser(); |
| 2694 // App list and Browser shortcut ShelfItems are added. | 2698 // App list and Browser shortcut ShelfItems are added. |
| 2695 EXPECT_EQ(2, model_observer_->added()); | 2699 EXPECT_EQ(2, model_observer_->added()); |
| 2696 | 2700 |
| 2697 const std::string app_id = extension1_->id(); | 2701 const std::string app_id = extension1_->id(); |
| 2698 // app_icon_loader is owned by ChromeLauncherController. | 2702 // app_icon_loader is owned by ChromeLauncherController. |
| 2699 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); | 2703 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); |
| 2700 app_icon_loader->AddSupportedApp(app_id); | 2704 app_icon_loader->AddSupportedApp(app_id); |
| 2701 SetAppIconLoader(scoped_ptr<AppIconLoader>(app_icon_loader)); | 2705 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); |
| 2702 | 2706 |
| 2703 // Test adding an app panel | 2707 // Test adding an app panel |
| 2704 AppWindowLauncherItemController* app_panel_controller = | 2708 AppWindowLauncherItemController* app_panel_controller = |
| 2705 new ExtensionAppWindowLauncherItemController( | 2709 new ExtensionAppWindowLauncherItemController( |
| 2706 LauncherItemController::TYPE_APP_PANEL, "id", app_id, | 2710 LauncherItemController::TYPE_APP_PANEL, "id", app_id, |
| 2707 launcher_controller_.get()); | 2711 launcher_controller_.get()); |
| 2708 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( | 2712 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( |
| 2709 app_panel_controller, app_id, ash::STATUS_RUNNING); | 2713 app_panel_controller, app_id, ash::STATUS_RUNNING); |
| 2710 int panel_index = model_observer_->last_index(); | 2714 int panel_index = model_observer_->last_index(); |
| 2711 EXPECT_EQ(3, model_observer_->added()); | 2715 EXPECT_EQ(3, model_observer_->added()); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2873 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 2877 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
| 2874 EXPECT_EQ(1, tab_strip_model->count()); | 2878 EXPECT_EQ(1, tab_strip_model->count()); |
| 2875 | 2879 |
| 2876 TestAppTabHelperImpl* app_tab_helper = new TestAppTabHelperImpl; | 2880 TestAppTabHelperImpl* app_tab_helper = new TestAppTabHelperImpl; |
| 2877 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 2881 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 2878 SetAppTabHelper(app_tab_helper); | 2882 SetAppTabHelper(app_tab_helper); |
| 2879 | 2883 |
| 2880 // app_icon_loader is owned by ChromeLauncherController. | 2884 // app_icon_loader is owned by ChromeLauncherController. |
| 2881 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl; | 2885 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl; |
| 2882 app_icon_loader->AddSupportedApp("1"); | 2886 app_icon_loader->AddSupportedApp("1"); |
| 2883 SetAppIconLoader(scoped_ptr<AppIconLoader>(app_icon_loader)); | 2887 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); |
| 2884 EXPECT_EQ(0, app_icon_loader->fetch_count()); | 2888 EXPECT_EQ(0, app_icon_loader->fetch_count()); |
| 2885 | 2889 |
| 2886 launcher_controller_->PinAppWithID("1"); | 2890 launcher_controller_->PinAppWithID("1"); |
| 2887 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1"); | 2891 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1"); |
| 2888 int app_index = model_->ItemIndexByID(id); | 2892 int app_index = model_->ItemIndexByID(id); |
| 2889 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2893 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 2890 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2894 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 2891 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2895 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 2892 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2896 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 2893 EXPECT_EQ(initial_size + 1, model_->items().size()); | 2897 EXPECT_EQ(initial_size + 1, model_->items().size()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2905 | 2909 |
| 2906 AddAppListLauncherItem(); | 2910 AddAppListLauncherItem(); |
| 2907 launcher_controller_.reset( | 2911 launcher_controller_.reset( |
| 2908 ChromeLauncherController::CreateInstance(profile(), model_.get())); | 2912 ChromeLauncherController::CreateInstance(profile(), model_.get())); |
| 2909 app_tab_helper = new TestAppTabHelperImpl; | 2913 app_tab_helper = new TestAppTabHelperImpl; |
| 2910 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 2914 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 2911 SetAppTabHelper(app_tab_helper); | 2915 SetAppTabHelper(app_tab_helper); |
| 2912 // app_icon_loader is owned by ChromeLauncherController. | 2916 // app_icon_loader is owned by ChromeLauncherController. |
| 2913 app_icon_loader = new TestAppIconLoaderImpl; | 2917 app_icon_loader = new TestAppIconLoaderImpl; |
| 2914 app_icon_loader->AddSupportedApp("1"); | 2918 app_icon_loader->AddSupportedApp("1"); |
| 2915 SetAppIconLoader(scoped_ptr<AppIconLoader>(app_icon_loader)); | 2919 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); |
| 2916 if (!ash::Shell::HasInstance()) { | 2920 if (!ash::Shell::HasInstance()) { |
| 2917 item_delegate_manager_ = new ash::ShelfItemDelegateManager(model_.get()); | 2921 item_delegate_manager_ = new ash::ShelfItemDelegateManager(model_.get()); |
| 2918 SetShelfItemDelegateManager(item_delegate_manager_); | 2922 SetShelfItemDelegateManager(item_delegate_manager_); |
| 2919 } | 2923 } |
| 2920 launcher_controller_->Init(); | 2924 launcher_controller_->Init(); |
| 2921 | 2925 |
| 2922 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2926 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 2923 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2927 ASSERT_EQ(initial_size + 1, model_->items().size()); |
| 2924 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2928 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 2925 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2929 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 2926 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2930 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 2927 | 2931 |
| 2928 launcher_controller_->UnpinAppWithID("1"); | 2932 launcher_controller_->UnpinAppWithID("1"); |
| 2929 ASSERT_EQ(initial_size, model_->items().size()); | 2933 ASSERT_EQ(initial_size, model_->items().size()); |
| 2930 } | 2934 } |
| 2931 | 2935 |
| 2932 TEST_F(ChromeLauncherControllerTest, MultipleAppIconLoaders) { | 2936 TEST_F(ChromeLauncherControllerTest, MultipleAppIconLoaders) { |
| 2933 InitLauncherControllerWithBrowser(); | 2937 InitLauncherControllerWithBrowser(); |
| 2934 | 2938 |
| 2935 const std::string app_id1 = extension1_->id(); | 2939 const std::string app_id1 = extension1_->id(); |
| 2936 const std::string app_id2 = extension2_->id(); | 2940 const std::string app_id2 = extension2_->id(); |
| 2937 const std::string app_id3 = extension3_->id(); | 2941 const std::string app_id3 = extension3_->id(); |
| 2938 // app_icon_loader1 and app_icon_loader2 are owned by | 2942 // app_icon_loader1 and app_icon_loader2 are owned by |
| 2939 // ChromeLauncherController. | 2943 // ChromeLauncherController. |
| 2940 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); | 2944 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); |
| 2941 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); | 2945 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); |
| 2942 app_icon_loader1->AddSupportedApp(app_id1); | 2946 app_icon_loader1->AddSupportedApp(app_id1); |
| 2943 app_icon_loader2->AddSupportedApp(app_id2); | 2947 app_icon_loader2->AddSupportedApp(app_id2); |
| 2944 SetAppIconLoaders(scoped_ptr<AppIconLoader>(app_icon_loader1), | 2948 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), |
| 2945 scoped_ptr<AppIconLoader>(app_icon_loader2)); | 2949 std::unique_ptr<AppIconLoader>(app_icon_loader2)); |
| 2946 | 2950 |
| 2947 AppWindowLauncherItemController* app_panel_controller3 = | 2951 AppWindowLauncherItemController* app_panel_controller3 = |
| 2948 new ExtensionAppWindowLauncherItemController( | 2952 new ExtensionAppWindowLauncherItemController( |
| 2949 LauncherItemController::TYPE_APP_PANEL, "id", app_id3, | 2953 LauncherItemController::TYPE_APP_PANEL, "id", app_id3, |
| 2950 launcher_controller_.get()); | 2954 launcher_controller_.get()); |
| 2951 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( | 2955 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( |
| 2952 app_panel_controller3, app_id3, ash::STATUS_RUNNING); | 2956 app_panel_controller3, app_id3, ash::STATUS_RUNNING); |
| 2953 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 2957 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
| 2954 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 2958 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 2955 EXPECT_EQ(0, app_icon_loader2->fetch_count()); | 2959 EXPECT_EQ(0, app_icon_loader2->fetch_count()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2990 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 2994 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 2991 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 2995 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 2992 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 2996 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 2993 | 2997 |
| 2994 launcher_controller_->CloseLauncherItem(shelfId3); | 2998 launcher_controller_->CloseLauncherItem(shelfId3); |
| 2995 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 2999 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 2996 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 3000 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 2997 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3001 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 2998 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3002 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 2999 } | 3003 } |
| OLD | NEW |