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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "chrome/browser/ui/apps/chrome_app_delegate.h" | 56 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
57 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" | 57 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
58 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | 58 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
59 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 59 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
60 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 60 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
61 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 61 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
62 #include "chrome/common/chrome_constants.h" | 62 #include "chrome/common/chrome_constants.h" |
63 #include "chrome/common/chrome_switches.h" | 63 #include "chrome/common/chrome_switches.h" |
64 #include "chrome/test/base/testing_browser_process.h" | 64 #include "chrome/test/base/testing_browser_process.h" |
65 #include "chrome/test/base/testing_profile_manager.h" | 65 #include "chrome/test/base/testing_profile_manager.h" |
| 66 #include "components/signin/core/account_id/account_id.h" |
66 #include "components/user_manager/fake_user_manager.h" | 67 #include "components/user_manager/fake_user_manager.h" |
67 #include "content/public/browser/web_contents_observer.h" | 68 #include "content/public/browser/web_contents_observer.h" |
68 #include "content/public/test/test_utils.h" | 69 #include "content/public/test/test_utils.h" |
69 #include "extensions/browser/app_window/app_window_contents.h" | 70 #include "extensions/browser/app_window/app_window_contents.h" |
70 #include "extensions/browser/app_window/app_window_registry.h" | 71 #include "extensions/browser/app_window/app_window_registry.h" |
71 #include "extensions/browser/app_window/native_app_window.h" | 72 #include "extensions/browser/app_window/native_app_window.h" |
72 #include "ui/aura/window.h" | 73 #include "ui/aura/window.h" |
73 #endif | 74 #endif |
74 | 75 |
75 #if defined(USE_AURA) | 76 #if defined(USE_AURA) |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 // A Task is leaked if we don't destroy everything, then run the message | 802 // A Task is leaked if we don't destroy everything, then run the message |
802 // loop. | 803 // loop. |
803 base::MessageLoop::current()->PostTask( | 804 base::MessageLoop::current()->PostTask( |
804 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 805 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
805 base::MessageLoop::current()->Run(); | 806 base::MessageLoop::current()->Run(); |
806 } | 807 } |
807 | 808 |
808 // Creates a profile for a given |user_name|. Note that this class will keep | 809 // Creates a profile for a given |user_name|. Note that this class will keep |
809 // the ownership of the created object. | 810 // the ownership of the created object. |
810 TestingProfile* CreateMultiUserProfile(const std::string& user_name) { | 811 TestingProfile* CreateMultiUserProfile(const std::string& user_name) { |
811 std::string email_string = user_name + "@example.com"; | 812 const std::string email_string = user_name + "@example.com"; |
| 813 const AccountId account_id(AccountId::FromUserEmail(email_string)); |
812 static_cast<ash::test::TestSessionStateDelegate*>( | 814 static_cast<ash::test::TestSessionStateDelegate*>( |
813 ash::Shell::GetInstance()->session_state_delegate()) | 815 ash::Shell::GetInstance()->session_state_delegate()) |
814 ->AddUser(email_string); | 816 ->AddUser(account_id.GetUserEmail()); |
815 // Add a user to the fake user manager. | 817 // Add a user to the fake user manager. |
816 session_delegate()->AddUser(email_string); | 818 session_delegate()->AddUser(account_id.GetUserEmail()); |
817 GetFakeUserManager()->AddUser(email_string); | 819 GetFakeUserManager()->AddUser(account_id); |
818 | 820 |
819 GetFakeUserManager()->LoginUser(email_string); | 821 GetFakeUserManager()->LoginUser(account_id); |
820 | 822 |
821 TestingProfile* profile = | 823 TestingProfile* profile = |
822 profile_manager()->CreateTestingProfile(email_string); | 824 profile_manager()->CreateTestingProfile(account_id.GetUserEmail()); |
823 EXPECT_TRUE(profile); | 825 EXPECT_TRUE(profile); |
824 | 826 |
825 // Remember the profile name so that we can destroy it upon destruction. | 827 // Remember the profile name so that we can destroy it upon destruction. |
826 created_profiles_[profile] = email_string; | 828 created_profiles_[profile] = account_id.GetUserEmail(); |
827 if (chrome::MultiUserWindowManager::GetInstance()) | 829 if (chrome::MultiUserWindowManager::GetInstance()) |
828 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); | 830 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); |
829 if (launcher_controller_) | 831 if (launcher_controller_) |
830 launcher_controller_->AdditionalUserAddedToSession(profile); | 832 launcher_controller_->AdditionalUserAddedToSession(profile); |
831 return profile; | 833 return profile; |
832 } | 834 } |
833 | 835 |
834 // Switch to another user. | 836 // Switch to another user. |
835 void SwitchActiveUser(const std::string& name) { | 837 void SwitchActiveUser(const std::string& name) { |
836 session_delegate()->SwitchActiveUser(name); | 838 const AccountId account_id(AccountId::FromUserEmail(name)); |
837 GetFakeUserManager()->SwitchActiveUser(name); | 839 session_delegate()->SwitchActiveUser(account_id.GetUserEmail()); |
| 840 GetFakeUserManager()->SwitchActiveUser(account_id); |
838 chrome::MultiUserWindowManagerChromeOS* manager = | 841 chrome::MultiUserWindowManagerChromeOS* manager = |
839 static_cast<chrome::MultiUserWindowManagerChromeOS*>( | 842 static_cast<chrome::MultiUserWindowManagerChromeOS*>( |
840 chrome::MultiUserWindowManager::GetInstance()); | 843 chrome::MultiUserWindowManager::GetInstance()); |
841 manager->SetAnimationSpeedForTest( | 844 manager->SetAnimationSpeedForTest( |
842 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); | 845 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); |
843 manager->ActiveUserChanged(name); | 846 manager->ActiveUserChanged(account_id.GetUserEmail()); |
844 launcher_controller_->browser_status_monitor_for_test()-> | 847 launcher_controller_->browser_status_monitor_for_test()->ActiveUserChanged( |
845 ActiveUserChanged(name); | 848 account_id.GetUserEmail()); |
846 launcher_controller_->app_window_controller_for_test()-> | 849 launcher_controller_->app_window_controller_for_test()->ActiveUserChanged( |
847 ActiveUserChanged(name); | 850 account_id.GetUserEmail()); |
848 } | 851 } |
849 | 852 |
850 // Creates a browser with a |profile| and load a tab with a |title| and |url|. | 853 // Creates a browser with a |profile| and load a tab with a |title| and |url|. |
851 scoped_ptr<Browser> CreateBrowserAndTabWithProfile(Profile* profile, | 854 scoped_ptr<Browser> CreateBrowserAndTabWithProfile(Profile* profile, |
852 const std::string& title, | 855 const std::string& title, |
853 const std::string& url) { | 856 const std::string& url) { |
854 scoped_ptr<Browser> browser(CreateBrowserWithTestWindowForProfile(profile)); | 857 scoped_ptr<Browser> browser(CreateBrowserWithTestWindowForProfile(profile)); |
855 chrome::NewTab(browser.get()); | 858 chrome::NewTab(browser.get()); |
856 | 859 |
857 browser->window()->Show(); | 860 browser->window()->Show(); |
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2673 | 2676 |
2674 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2677 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
2675 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2678 ASSERT_EQ(initial_size + 1, model_->items().size()); |
2676 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2679 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
2677 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2680 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
2678 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2681 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
2679 | 2682 |
2680 launcher_controller_->UnpinAppWithID("1"); | 2683 launcher_controller_->UnpinAppWithID("1"); |
2681 ASSERT_EQ(initial_size, model_->items().size()); | 2684 ASSERT_EQ(initial_size, model_->items().size()); |
2682 } | 2685 } |
OLD | NEW |