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

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

Issue 1425093004: Revert of 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: 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"
25 #include "components/signin/core/browser/signin_manager_base.h" 24 #include "components/signin/core/browser/signin_manager_base.h"
26 #include "components/syncable_prefs/testing_pref_service_syncable.h" 25 #include "components/syncable_prefs/testing_pref_service_syncable.h"
27 #include "content/public/test/test_browser_thread_bundle.h" 26 #include "content/public/test/test_browser_thread_bundle.h"
28 #include "device/bluetooth/bluetooth_adapter_factory.h" 27 #include "device/bluetooth/bluetooth_adapter_factory.h"
29 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 28 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
30 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
31 30
32 using chromeos::DBusThreadManagerSetter; 31 using chromeos::DBusThreadManagerSetter;
33 using chromeos::FakePowerManagerClient; 32 using chromeos::FakePowerManagerClient;
34 using chromeos::PowerManagerClient; 33 using chromeos::PowerManagerClient;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 power_manager_client_ = new FakePowerManagerClient; 211 power_manager_client_ = new FakePowerManagerClient;
213 dbus_setter->SetPowerManagerClient( 212 dbus_setter->SetPowerManagerClient(
214 scoped_ptr<PowerManagerClient>(power_manager_client_)); 213 scoped_ptr<PowerManagerClient>(power_manager_client_));
215 214
216 ON_CALL(*mock_user_manager_, Shutdown()).WillByDefault(Return()); 215 ON_CALL(*mock_user_manager_, Shutdown()).WillByDefault(Return());
217 ON_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount()) 216 ON_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount())
218 .WillByDefault(Return(true)); 217 .WillByDefault(Return(true));
219 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral()) 218 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral())
220 .WillByDefault(Return(false)); 219 .WillByDefault(Return(false));
221 220
222 SetUpProfile(&profile_, AccountId::FromUserEmail(kTestUserPrimary)); 221 SetUpProfile(&profile_, kTestUserPrimary);
223 } 222 }
224 223
225 void TearDown() override { 224 void TearDown() override {
226 delete app_manager_factory; 225 delete app_manager_factory;
227 app_manager_factory = NULL; 226 app_manager_factory = NULL;
228 } 227 }
229 228
230 void SetEasyUnlockAllowedPolicy(bool allowed) { 229 void SetEasyUnlockAllowedPolicy(bool allowed) {
231 profile_->GetTestingPrefService()->SetManagedPref( 230 profile_->GetTestingPrefService()->SetManagedPref(
232 prefs::kEasyUnlockAllowed, new base::FundamentalValue(allowed)); 231 prefs::kEasyUnlockAllowed, new base::FundamentalValue(allowed));
(...skipping 23 matching lines...) Expand all
256 } 255 }
257 256
258 void SetAppManagerReady(content::BrowserContext* context) { 257 void SetAppManagerReady(content::BrowserContext* context) {
259 ASSERT_TRUE(app_manager_factory); 258 ASSERT_TRUE(app_manager_factory);
260 TestAppManager* app_manager = app_manager_factory->Find(context); 259 TestAppManager* app_manager = app_manager_factory->Find(context);
261 ASSERT_TRUE(app_manager); 260 ASSERT_TRUE(app_manager);
262 app_manager->SetReady(); 261 app_manager->SetReady();
263 } 262 }
264 263
265 void SetUpSecondaryProfile() { 264 void SetUpSecondaryProfile() {
266 SetUpProfile(&secondary_profile_, 265 SetUpProfile(&secondary_profile_, kTestUserSecondary);
267 AccountId::FromUserEmail(kTestUserSecondary));
268 } 266 }
269 267
270 private: 268 private:
271 // Sets up a test profile with a user id. 269 // Sets up a test profile with a user id.
272 void SetUpProfile(scoped_ptr<TestingProfile>* profile, 270 void SetUpProfile(scoped_ptr<TestingProfile>* profile,
273 const AccountId& account_id) { 271 const std::string& user_id) {
274 ASSERT_TRUE(profile); 272 ASSERT_TRUE(profile);
275 ASSERT_FALSE(profile->get()); 273 ASSERT_FALSE(profile->get());
276 274
277 TestingProfile::Builder builder; 275 TestingProfile::Builder builder;
278 builder.AddTestingFactory(EasyUnlockServiceFactory::GetInstance(), 276 builder.AddTestingFactory(EasyUnlockServiceFactory::GetInstance(),
279 &CreateEasyUnlockServiceForTest); 277 &CreateEasyUnlockServiceForTest);
280 *profile = builder.Build(); 278 *profile = builder.Build();
281 279
282 mock_user_manager_->AddUser(account_id); 280 mock_user_manager_->AddUser(user_id);
283 profile->get()->set_profile_name(account_id.GetUserEmail()); 281 profile->get()->set_profile_name(user_id);
284 282
285 SigninManagerBase* signin_manager = 283 SigninManagerBase* signin_manager =
286 SigninManagerFactory::GetForProfile(profile->get()); 284 SigninManagerFactory::GetForProfile(profile->get());
287 signin_manager->SetAuthenticatedAccountInfo(account_id.GetUserEmail(), 285 signin_manager->SetAuthenticatedAccountInfo(user_id, user_id);
288 account_id.GetUserEmail());
289 } 286 }
290 287
291 protected: 288 protected:
292 scoped_ptr<TestingProfile> profile_; 289 scoped_ptr<TestingProfile> profile_;
293 scoped_ptr<TestingProfile> secondary_profile_; 290 scoped_ptr<TestingProfile> secondary_profile_;
294 chromeos::MockUserManager* mock_user_manager_; 291 chromeos::MockUserManager* mock_user_manager_;
295 292
296 private: 293 private:
297 content::TestBrowserThreadBundle thread_bundle_; 294 content::TestBrowserThreadBundle thread_bundle_;
298 295
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral()) 363 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral())
367 .WillByDefault(Return(true)); 364 .WillByDefault(Return(true));
368 365
369 SetAppManagerReady(profile_.get()); 366 SetAppManagerReady(profile_.get());
370 EXPECT_FALSE(EasyUnlockService::Get(profile_.get())->IsAllowed()); 367 EXPECT_FALSE(EasyUnlockService::Get(profile_.get())->IsAllowed());
371 EXPECT_TRUE( 368 EXPECT_TRUE(
372 EasyUnlockAppInState(profile_.get(), TestAppManager::STATE_NOT_LOADED)); 369 EasyUnlockAppInState(profile_.get(), TestAppManager::STATE_NOT_LOADED));
373 } 370 }
374 371
375 } // namespace 372 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698