Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 12 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
13 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 13 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
14 #include "chrome/browser/chromeos/profiles/profile_helper.h" 14 #include "chrome/browser/chromeos/profiles/profile_helper.h"
15 #include "chrome/browser/signin/easy_unlock_app_manager.h" 15 #include "chrome/browser/signin/easy_unlock_app_manager.h"
16 #include "chrome/browser/signin/easy_unlock_service.h" 16 #include "chrome/browser/signin/easy_unlock_service.h"
17 #include "chrome/browser/signin/easy_unlock_service_factory.h" 17 #include "chrome/browser/signin/easy_unlock_service_factory.h"
18 #include "chrome/browser/signin/easy_unlock_service_regular.h" 18 #include "chrome/browser/signin/easy_unlock_service_regular.h"
19 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "chromeos/dbus/dbus_thread_manager.h" 22 #include "chromeos/dbus/dbus_thread_manager.h"
23 #include "chromeos/dbus/fake_power_manager_client.h" 23 #include "chromeos/dbus/fake_power_manager_client.h"
24 #include "components/signin/core/account_id/account_id.h"
24 #include "components/signin/core/browser/signin_manager_base.h" 25 #include "components/signin/core/browser/signin_manager_base.h"
25 #include "components/syncable_prefs/testing_pref_service_syncable.h" 26 #include "components/syncable_prefs/testing_pref_service_syncable.h"
26 #include "content/public/test/test_browser_thread_bundle.h" 27 #include "content/public/test/test_browser_thread_bundle.h"
27 #include "device/bluetooth/bluetooth_adapter_factory.h" 28 #include "device/bluetooth/bluetooth_adapter_factory.h"
28 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 29 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
29 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
30 31
31 using chromeos::DBusThreadManagerSetter; 32 using chromeos::DBusThreadManagerSetter;
32 using chromeos::FakePowerManagerClient; 33 using chromeos::FakePowerManagerClient;
33 using chromeos::PowerManagerClient; 34 using chromeos::PowerManagerClient;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 power_manager_client_ = new FakePowerManagerClient; 212 power_manager_client_ = new FakePowerManagerClient;
212 dbus_setter->SetPowerManagerClient( 213 dbus_setter->SetPowerManagerClient(
213 scoped_ptr<PowerManagerClient>(power_manager_client_)); 214 scoped_ptr<PowerManagerClient>(power_manager_client_));
214 215
215 ON_CALL(*mock_user_manager_, Shutdown()).WillByDefault(Return()); 216 ON_CALL(*mock_user_manager_, Shutdown()).WillByDefault(Return());
216 ON_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount()) 217 ON_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount())
217 .WillByDefault(Return(true)); 218 .WillByDefault(Return(true));
218 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral()) 219 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral())
219 .WillByDefault(Return(false)); 220 .WillByDefault(Return(false));
220 221
221 SetUpProfile(&profile_, kTestUserPrimary); 222 SetUpProfile(&profile_, AccountId::FromUserEmail(kTestUserPrimary));
222 } 223 }
223 224
224 void TearDown() override { 225 void TearDown() override {
225 delete app_manager_factory; 226 delete app_manager_factory;
226 app_manager_factory = NULL; 227 app_manager_factory = NULL;
227 } 228 }
228 229
229 void SetEasyUnlockAllowedPolicy(bool allowed) { 230 void SetEasyUnlockAllowedPolicy(bool allowed) {
230 profile_->GetTestingPrefService()->SetManagedPref( 231 profile_->GetTestingPrefService()->SetManagedPref(
231 prefs::kEasyUnlockAllowed, new base::FundamentalValue(allowed)); 232 prefs::kEasyUnlockAllowed, new base::FundamentalValue(allowed));
(...skipping 23 matching lines...) Expand all
255 } 256 }
256 257
257 void SetAppManagerReady(content::BrowserContext* context) { 258 void SetAppManagerReady(content::BrowserContext* context) {
258 ASSERT_TRUE(app_manager_factory); 259 ASSERT_TRUE(app_manager_factory);
259 TestAppManager* app_manager = app_manager_factory->Find(context); 260 TestAppManager* app_manager = app_manager_factory->Find(context);
260 ASSERT_TRUE(app_manager); 261 ASSERT_TRUE(app_manager);
261 app_manager->SetReady(); 262 app_manager->SetReady();
262 } 263 }
263 264
264 void SetUpSecondaryProfile() { 265 void SetUpSecondaryProfile() {
265 SetUpProfile(&secondary_profile_, kTestUserSecondary); 266 SetUpProfile(&secondary_profile_,
267 AccountId::FromUserEmail(kTestUserSecondary));
266 } 268 }
267 269
268 private: 270 private:
269 // Sets up a test profile with a user id. 271 // Sets up a test profile with a user id.
270 void SetUpProfile(scoped_ptr<TestingProfile>* profile, 272 void SetUpProfile(scoped_ptr<TestingProfile>* profile,
271 const std::string& user_id) { 273 const AccountId& account_id) {
272 ASSERT_TRUE(profile); 274 ASSERT_TRUE(profile);
273 ASSERT_FALSE(profile->get()); 275 ASSERT_FALSE(profile->get());
274 276
275 TestingProfile::Builder builder; 277 TestingProfile::Builder builder;
276 builder.AddTestingFactory(EasyUnlockServiceFactory::GetInstance(), 278 builder.AddTestingFactory(EasyUnlockServiceFactory::GetInstance(),
277 &CreateEasyUnlockServiceForTest); 279 &CreateEasyUnlockServiceForTest);
278 *profile = builder.Build(); 280 *profile = builder.Build();
279 281
280 mock_user_manager_->AddUser(user_id); 282 mock_user_manager_->AddUser(account_id);
281 profile->get()->set_profile_name(user_id); 283 profile->get()->set_profile_name(account_id.GetUserEmail());
282 284
283 SigninManagerBase* signin_manager = 285 SigninManagerBase* signin_manager =
284 SigninManagerFactory::GetForProfile(profile->get()); 286 SigninManagerFactory::GetForProfile(profile->get());
285 signin_manager->SetAuthenticatedAccountInfo(user_id, user_id); 287 signin_manager->SetAuthenticatedAccountInfo(account_id.GetUserEmail(),
288 account_id.GetUserEmail());
286 } 289 }
287 290
288 protected: 291 protected:
289 scoped_ptr<TestingProfile> profile_; 292 scoped_ptr<TestingProfile> profile_;
290 scoped_ptr<TestingProfile> secondary_profile_; 293 scoped_ptr<TestingProfile> secondary_profile_;
291 chromeos::MockUserManager* mock_user_manager_; 294 chromeos::MockUserManager* mock_user_manager_;
292 295
293 private: 296 private:
294 content::TestBrowserThreadBundle thread_bundle_; 297 content::TestBrowserThreadBundle thread_bundle_;
295 298
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral()) 366 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral())
364 .WillByDefault(Return(true)); 367 .WillByDefault(Return(true));
365 368
366 SetAppManagerReady(profile_.get()); 369 SetAppManagerReady(profile_.get());
367 EXPECT_FALSE(EasyUnlockService::Get(profile_.get())->IsAllowed()); 370 EXPECT_FALSE(EasyUnlockService::Get(profile_.get())->IsAllowed());
368 EXPECT_TRUE( 371 EXPECT_TRUE(
369 EasyUnlockAppInState(profile_.get(), TestAppManager::STATE_NOT_LOADED)); 372 EasyUnlockAppInState(profile_.get(), TestAppManager::STATE_NOT_LOADED));
370 } 373 }
371 374
372 } // namespace 375 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698