| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
| 28 #include "chromeos/chromeos_switches.h" | 28 #include "chromeos/chromeos_switches.h" |
| 29 #include "chromeos/dbus/dbus_thread_manager.h" | 29 #include "chromeos/dbus/dbus_thread_manager.h" |
| 30 #include "chromeos/dbus/fake_session_manager_client.h" | 30 #include "chromeos/dbus/fake_session_manager_client.h" |
| 31 #include "chromeos/dbus/session_manager_client.h" | 31 #include "chromeos/dbus/session_manager_client.h" |
| 32 #include "components/arc/arc_bridge_service_impl.h" | 32 #include "components/arc/arc_bridge_service_impl.h" |
| 33 #include "components/arc/arc_service_manager.h" | 33 #include "components/arc/arc_service_manager.h" |
| 34 #include "components/arc/test/fake_arc_bridge_bootstrap.h" | 34 #include "components/arc/test/fake_arc_bridge_bootstrap.h" |
| 35 #include "components/arc/test/fake_arc_bridge_instance.h" | 35 #include "components/arc/test/fake_arc_bridge_instance.h" |
| 36 #include "components/policy/core/common/policy_switches.h" | 36 #include "components/policy/core/common/policy_switches.h" |
| 37 #include "components/prefs/pref_member.h" |
| 37 #include "components/prefs/pref_service.h" | 38 #include "components/prefs/pref_service.h" |
| 38 #include "components/signin/core/account_id/account_id.h" | 39 #include "components/signin/core/account_id/account_id.h" |
| 39 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 40 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
| 40 #include "components/user_manager/user_manager.h" | 41 #include "components/user_manager/user_manager.h" |
| 41 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
| 42 #include "url/gurl.h" | 43 #include "url/gurl.h" |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 46 const char kRefreshToken[] = "fake-refresh-token"; | 47 const char kRefreshToken[] = "fake-refresh-token"; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 token_service_->UpdateCredentials("", kRefreshToken); | 168 token_service_->UpdateCredentials("", kRefreshToken); |
| 168 | 169 |
| 169 profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | 170 profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); |
| 170 | 171 |
| 171 const AccountId account_id( | 172 const AccountId account_id( |
| 172 AccountId::FromUserEmailGaiaId(kFakeUserName, "1234567890")); | 173 AccountId::FromUserEmailGaiaId(kFakeUserName, "1234567890")); |
| 173 GetFakeUserManager()->AddUser(account_id); | 174 GetFakeUserManager()->AddUser(account_id); |
| 174 GetFakeUserManager()->LoginUser(account_id); | 175 GetFakeUserManager()->LoginUser(account_id); |
| 175 | 176 |
| 176 // Set up ARC for test profile. | 177 // Set up ARC for test profile. |
| 178 std::unique_ptr<BooleanPrefMember> arc_enabled_pref = |
| 179 base::MakeUnique<BooleanPrefMember>(); |
| 180 arc_enabled_pref->Init(prefs::kArcEnabled, profile()->GetPrefs()); |
| 177 ArcServiceManager::Get()->OnPrimaryUserProfilePrepared( | 181 ArcServiceManager::Get()->OnPrimaryUserProfilePrepared( |
| 178 multi_user_util::GetAccountIdFromProfile(profile())); | 182 multi_user_util::GetAccountIdFromProfile(profile()), |
| 183 std::move(arc_enabled_pref)); |
| 179 ArcAuthService::Get()->OnPrimaryUserProfilePrepared(profile()); | 184 ArcAuthService::Get()->OnPrimaryUserProfilePrepared(profile()); |
| 180 } | 185 } |
| 181 | 186 |
| 182 void TearDownOnMainThread() override { | 187 void TearDownOnMainThread() override { |
| 183 ArcAuthService::Get()->Shutdown(); | 188 ArcAuthService::Get()->Shutdown(); |
| 189 ArcServiceManager::Get()->Shutdown(); |
| 184 profile_.reset(); | 190 profile_.reset(); |
| 185 user_manager_enabler_.reset(); | 191 user_manager_enabler_.reset(); |
| 186 } | 192 } |
| 187 | 193 |
| 188 chromeos::FakeChromeUserManager* GetFakeUserManager() const { | 194 chromeos::FakeChromeUserManager* GetFakeUserManager() const { |
| 189 return static_cast<chromeos::FakeChromeUserManager*>( | 195 return static_cast<chromeos::FakeChromeUserManager*>( |
| 190 user_manager::UserManager::Get()); | 196 user_manager::UserManager::Get()); |
| 191 } | 197 } |
| 192 | 198 |
| 193 void set_profile_name(const std::string& username) { | 199 void set_profile_name(const std::string& username) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 249 |
| 244 prefs->SetBoolean(prefs::kArcEnabled, true); | 250 prefs->SetBoolean(prefs::kArcEnabled, true); |
| 245 token_service()->IssueTokenForAllPendingRequests(kManagedAuthToken, | 251 token_service()->IssueTokenForAllPendingRequests(kManagedAuthToken, |
| 246 base::Time::Max()); | 252 base::Time::Max()); |
| 247 ArcAuthServiceShutdownObserver observer; | 253 ArcAuthServiceShutdownObserver observer; |
| 248 observer.Wait(); | 254 observer.Wait(); |
| 249 ASSERT_EQ(ArcAuthService::State::STOPPED, ArcAuthService::Get()->state()); | 255 ASSERT_EQ(ArcAuthService::State::STOPPED, ArcAuthService::Get()->state()); |
| 250 } | 256 } |
| 251 | 257 |
| 252 } // namespace arc | 258 } // namespace arc |
| OLD | NEW |