| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <utility> | 14 #include <utility> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "ash/common/ash_switches.h" | 17 #include "ash/common/ash_switches.h" |
| 18 #include "ash/common/shelf/shelf_item_delegate_manager.h" | 18 #include "ash/common/shelf/shelf_item_delegate_manager.h" |
| 19 #include "ash/common/shelf/shelf_model.h" | 19 #include "ash/common/shelf/shelf_model.h" |
| 20 #include "ash/common/shelf/shelf_model_observer.h" | 20 #include "ash/common/shelf/shelf_model_observer.h" |
| 21 #include "ash/shell.h" | 21 #include "ash/shell.h" |
| 22 #include "ash/test/ash_test_helper.h" |
| 22 #include "ash/test/shelf_item_delegate_manager_test_api.h" | 23 #include "ash/test/shelf_item_delegate_manager_test_api.h" |
| 23 #include "ash/test/test_session_state_delegate.h" | 24 #include "ash/test/test_session_state_delegate.h" |
| 24 #include "ash/test/test_shell_delegate.h" | 25 #include "ash/test/test_shell_delegate.h" |
| 25 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 26 #include "base/compiler_specific.h" | 27 #include "base/compiler_specific.h" |
| 27 #include "base/files/file_path.h" | 28 #include "base/files/file_path.h" |
| 28 #include "base/location.h" | 29 #include "base/location.h" |
| 29 #include "base/macros.h" | 30 #include "base/macros.h" |
| 30 #include "base/memory/ptr_util.h" | 31 #include "base/memory/ptr_util.h" |
| 31 #include "base/message_loop/message_loop.h" | 32 #include "base/message_loop/message_loop.h" |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler( | 1028 user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler( |
| 1028 new chromeos::FakeChromeUserManager)); | 1029 new chromeos::FakeChromeUserManager)); |
| 1029 | 1030 |
| 1030 // Initialize the WallpaperManager singleton. | 1031 // Initialize the WallpaperManager singleton. |
| 1031 chromeos::WallpaperManager::Initialize(); | 1032 chromeos::WallpaperManager::Initialize(); |
| 1032 | 1033 |
| 1033 // Initialize the rest. | 1034 // Initialize the rest. |
| 1034 ChromeLauncherControllerImplTest::SetUp(); | 1035 ChromeLauncherControllerImplTest::SetUp(); |
| 1035 | 1036 |
| 1036 // Get some base objects. | 1037 // Get some base objects. |
| 1037 session_delegate()->set_logged_in_users(2); | 1038 ash::test::AshTestHelper::GetTestSessionStateDelegate() |
| 1039 ->set_logged_in_users(2); |
| 1038 shell_delegate_ = static_cast<ash::test::TestShellDelegate*>( | 1040 shell_delegate_ = static_cast<ash::test::TestShellDelegate*>( |
| 1039 ash::Shell::GetInstance()->delegate()); | 1041 ash::Shell::GetInstance()->delegate()); |
| 1040 shell_delegate_->set_multi_profiles_enabled(true); | 1042 shell_delegate_->set_multi_profiles_enabled(true); |
| 1041 } | 1043 } |
| 1042 | 1044 |
| 1043 void TearDown() override { | 1045 void TearDown() override { |
| 1044 ChromeLauncherControllerImplTest::TearDown(); | 1046 ChromeLauncherControllerImplTest::TearDown(); |
| 1045 user_manager_enabler_.reset(); | 1047 user_manager_enabler_.reset(); |
| 1046 for (ProfileToNameMap::iterator it = created_profiles_.begin(); | 1048 for (ProfileToNameMap::iterator it = created_profiles_.begin(); |
| 1047 it != created_profiles_.end(); ++it) | 1049 it != created_profiles_.end(); ++it) |
| 1048 profile_manager_->DeleteTestingProfile(it->second); | 1050 profile_manager_->DeleteTestingProfile(it->second); |
| 1049 chromeos::WallpaperManager::Shutdown(); | 1051 chromeos::WallpaperManager::Shutdown(); |
| 1050 | 1052 |
| 1051 // A Task is leaked if we don't destroy everything, then run the message | 1053 // A Task is leaked if we don't destroy everything, then run the message |
| 1052 // loop. | 1054 // loop. |
| 1053 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1055 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1054 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 1056 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 1055 base::MessageLoop::current()->Run(); | 1057 base::MessageLoop::current()->Run(); |
| 1056 } | 1058 } |
| 1057 | 1059 |
| 1058 // Creates a profile for a given |user_name|. Note that this class will keep | 1060 // Creates a profile for a given |user_name|. Note that this class will keep |
| 1059 // the ownership of the created object. | 1061 // the ownership of the created object. |
| 1060 TestingProfile* CreateMultiUserProfile(const std::string& user_name) { | 1062 TestingProfile* CreateMultiUserProfile(const std::string& user_name) { |
| 1061 const std::string email_string = user_name + "@example.com"; | 1063 const std::string email_string = user_name + "@example.com"; |
| 1062 const AccountId account_id(AccountId::FromUserEmail(email_string)); | 1064 const AccountId account_id(AccountId::FromUserEmail(email_string)); |
| 1063 static_cast<ash::test::TestSessionStateDelegate*>( | 1065 ash::test::AshTestHelper::GetTestSessionStateDelegate()->AddUser( |
| 1064 ash::Shell::GetInstance()->session_state_delegate()) | 1066 account_id); |
| 1065 ->AddUser(account_id); | |
| 1066 // Add a user to the fake user manager. | 1067 // Add a user to the fake user manager. |
| 1067 session_delegate()->AddUser(account_id); | 1068 ash::test::AshTestHelper::GetTestSessionStateDelegate()->AddUser( |
| 1069 account_id); |
| 1068 GetFakeUserManager()->AddUser(account_id); | 1070 GetFakeUserManager()->AddUser(account_id); |
| 1069 | 1071 |
| 1070 GetFakeUserManager()->LoginUser(account_id); | 1072 GetFakeUserManager()->LoginUser(account_id); |
| 1071 | 1073 |
| 1072 TestingProfile* profile = | 1074 TestingProfile* profile = |
| 1073 profile_manager()->CreateTestingProfile(account_id.GetUserEmail()); | 1075 profile_manager()->CreateTestingProfile(account_id.GetUserEmail()); |
| 1074 EXPECT_TRUE(profile); | 1076 EXPECT_TRUE(profile); |
| 1075 | 1077 |
| 1076 // Remember the profile name so that we can destroy it upon destruction. | 1078 // Remember the profile name so that we can destroy it upon destruction. |
| 1077 created_profiles_[profile] = account_id.GetUserEmail(); | 1079 created_profiles_[profile] = account_id.GetUserEmail(); |
| 1078 if (chrome::MultiUserWindowManager::GetInstance()) | 1080 if (chrome::MultiUserWindowManager::GetInstance()) |
| 1079 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); | 1081 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); |
| 1080 if (launcher_controller_) | 1082 if (launcher_controller_) |
| 1081 launcher_controller_->AdditionalUserAddedToSession(profile); | 1083 launcher_controller_->AdditionalUserAddedToSession(profile); |
| 1082 return profile; | 1084 return profile; |
| 1083 } | 1085 } |
| 1084 | 1086 |
| 1085 // Switch to another user. | 1087 // Switch to another user. |
| 1086 void SwitchActiveUser(const AccountId& account_id) { | 1088 void SwitchActiveUser(const AccountId& account_id) { |
| 1087 session_delegate()->SwitchActiveUser(account_id); | 1089 ash::test::AshTestHelper::GetTestSessionStateDelegate()->SwitchActiveUser( |
| 1090 account_id); |
| 1088 GetFakeUserManager()->SwitchActiveUser(account_id); | 1091 GetFakeUserManager()->SwitchActiveUser(account_id); |
| 1089 chrome::MultiUserWindowManagerChromeOS* manager = | 1092 chrome::MultiUserWindowManagerChromeOS* manager = |
| 1090 static_cast<chrome::MultiUserWindowManagerChromeOS*>( | 1093 static_cast<chrome::MultiUserWindowManagerChromeOS*>( |
| 1091 chrome::MultiUserWindowManager::GetInstance()); | 1094 chrome::MultiUserWindowManager::GetInstance()); |
| 1092 manager->SetAnimationSpeedForTest( | 1095 manager->SetAnimationSpeedForTest( |
| 1093 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); | 1096 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); |
| 1094 manager->ActiveUserChanged(account_id); | 1097 manager->ActiveUserChanged(account_id); |
| 1095 launcher_controller_->browser_status_monitor_for_test()->ActiveUserChanged( | 1098 launcher_controller_->browser_status_monitor_for_test()->ActiveUserChanged( |
| 1096 account_id.GetUserEmail()); | 1099 account_id.GetUserEmail()); |
| 1097 launcher_controller_->app_window_controller_for_test()->ActiveUserChanged( | 1100 launcher_controller_->app_window_controller_for_test()->ActiveUserChanged( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1127 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper; | 1130 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper; |
| 1128 helper->SetAppID(v1_app->browser()->tab_strip_model()->GetWebContentsAt(0), | 1131 helper->SetAppID(v1_app->browser()->tab_strip_model()->GetWebContentsAt(0), |
| 1129 app_name); | 1132 app_name); |
| 1130 SetLauncherControllerHelper(helper); | 1133 SetLauncherControllerHelper(helper); |
| 1131 | 1134 |
| 1132 NavigateAndCommitActiveTabWithTitle( | 1135 NavigateAndCommitActiveTabWithTitle( |
| 1133 v1_app->browser(), GURL(url), ASCIIToUTF16("")); | 1136 v1_app->browser(), GURL(url), ASCIIToUTF16("")); |
| 1134 return v1_app; | 1137 return v1_app; |
| 1135 } | 1138 } |
| 1136 | 1139 |
| 1137 ash::test::TestSessionStateDelegate* session_delegate() { | |
| 1138 return static_cast<ash::test::TestSessionStateDelegate*>( | |
| 1139 ash::Shell::GetInstance()->session_state_delegate()); | |
| 1140 } | |
| 1141 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; } | 1140 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; } |
| 1142 | 1141 |
| 1143 // Override BrowserWithTestWindowTest: | 1142 // Override BrowserWithTestWindowTest: |
| 1144 TestingProfile* CreateProfile() override { | 1143 TestingProfile* CreateProfile() override { |
| 1145 return CreateMultiUserProfile("user1"); | 1144 return CreateMultiUserProfile("user1"); |
| 1146 } | 1145 } |
| 1147 void DestroyProfile(TestingProfile* profile) override { | 1146 void DestroyProfile(TestingProfile* profile) override { |
| 1148 // Delete the profile through our profile manager. | 1147 // Delete the profile through our profile manager. |
| 1149 ProfileToNameMap::iterator it = created_profiles_.find(profile); | 1148 ProfileToNameMap::iterator it = created_profiles_.find(profile); |
| 1150 DCHECK(it != created_profiles_.end()); | 1149 DCHECK(it != created_profiles_.end()); |
| (...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3422 // be automatically removed. | 3421 // be automatically removed. |
| 3423 EnableArc(false); | 3422 EnableArc(false); |
| 3424 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED, | 3423 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED, |
| 3425 "AppList, Chrome"); | 3424 "AppList, Chrome"); |
| 3426 | 3425 |
| 3427 // Even if re-enable it again, Play Store pin does not appear automatically. | 3426 // Even if re-enable it again, Play Store pin does not appear automatically. |
| 3428 EnableArc(true); | 3427 EnableArc(true); |
| 3429 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE, | 3428 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE, |
| 3430 "AppList, Chrome"); | 3429 "AppList, Chrome"); |
| 3431 } | 3430 } |
| OLD | NEW |