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

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

Issue 1165913002: [Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finish renaming profile -> context Created 5 years, 6 months 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/run_loop.h" 10 #include "base/run_loop.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 12 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
12 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 13 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
13 #include "chrome/browser/chromeos/profiles/profile_helper.h" 14 #include "chrome/browser/chromeos/profiles/profile_helper.h"
14 #include "chrome/browser/signin/easy_unlock_app_manager.h" 15 #include "chrome/browser/signin/easy_unlock_app_manager.h"
15 #include "chrome/browser/signin/easy_unlock_service.h" 16 #include "chrome/browser/signin/easy_unlock_service.h"
16 #include "chrome/browser/signin/easy_unlock_service_factory.h" 17 #include "chrome/browser/signin/easy_unlock_service_factory.h"
17 #include "chrome/browser/signin/easy_unlock_service_regular.h" 18 #include "chrome/browser/signin/easy_unlock_service_regular.h"
18 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 DISALLOW_COPY_AND_ASSIGN(TestAppManagerFactory); 163 DISALLOW_COPY_AND_ASSIGN(TestAppManagerFactory);
163 }; 164 };
164 165
165 // Global TestAppManager factory. It should be created and desctructed in 166 // Global TestAppManager factory. It should be created and desctructed in
166 // EasyUnlockServiceTest::SetUp and EasyUnlockServiceTest::TearDown 167 // EasyUnlockServiceTest::SetUp and EasyUnlockServiceTest::TearDown
167 // respectively. 168 // respectively.
168 TestAppManagerFactory* app_manager_factory = NULL; 169 TestAppManagerFactory* app_manager_factory = NULL;
169 170
170 // EasyUnlockService factory function injected into testing profiles. 171 // EasyUnlockService factory function injected into testing profiles.
171 // It creates an EasyUnlockService with test AppManager. 172 // It creates an EasyUnlockService with test AppManager.
172 KeyedService* CreateEasyUnlockServiceForTest(content::BrowserContext* context) { 173 scoped_ptr<KeyedService> CreateEasyUnlockServiceForTest(
174 content::BrowserContext* context) {
173 EXPECT_TRUE(app_manager_factory); 175 EXPECT_TRUE(app_manager_factory);
174 if (!app_manager_factory) 176 if (!app_manager_factory)
175 return NULL; 177 return nullptr;
176 178
177 scoped_ptr<EasyUnlockAppManager> app_manager = 179 scoped_ptr<EasyUnlockAppManager> app_manager =
178 app_manager_factory->Create(context); 180 app_manager_factory->Create(context);
179 EXPECT_TRUE(app_manager.get()); 181 EXPECT_TRUE(app_manager.get());
180 if (!app_manager.get()) 182 if (!app_manager.get())
181 return NULL; 183 return nullptr;
182 184
183 EasyUnlockService* service = 185 scoped_ptr<EasyUnlockServiceRegular> service(
184 new EasyUnlockServiceRegular(Profile::FromBrowserContext(context)); 186 new EasyUnlockServiceRegular(Profile::FromBrowserContext(context)));
185 service->Initialize(app_manager.Pass()); 187 service->Initialize(app_manager.Pass());
186 return service; 188 return service.Pass();
187 } 189 }
188 190
189 class EasyUnlockServiceTest : public testing::Test { 191 class EasyUnlockServiceTest : public testing::Test {
190 public: 192 public:
191 EasyUnlockServiceTest() 193 EasyUnlockServiceTest()
192 : mock_user_manager_(new testing::NiceMock<chromeos::MockUserManager>()), 194 : mock_user_manager_(new testing::NiceMock<chromeos::MockUserManager>()),
193 scoped_user_manager_(mock_user_manager_), 195 scoped_user_manager_(mock_user_manager_),
194 is_bluetooth_adapter_present_(true) {} 196 is_bluetooth_adapter_present_(true) {}
195 197
196 ~EasyUnlockServiceTest() override {} 198 ~EasyUnlockServiceTest() override {}
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral()) 363 ON_CALL(*mock_user_manager_, IsCurrentUserNonCryptohomeDataEphemeral())
362 .WillByDefault(Return(true)); 364 .WillByDefault(Return(true));
363 365
364 SetAppManagerReady(profile_.get()); 366 SetAppManagerReady(profile_.get());
365 EXPECT_FALSE(EasyUnlockService::Get(profile_.get())->IsAllowed()); 367 EXPECT_FALSE(EasyUnlockService::Get(profile_.get())->IsAllowed());
366 EXPECT_TRUE( 368 EXPECT_TRUE(
367 EasyUnlockAppInState(profile_.get(), TestAppManager::STATE_NOT_LOADED)); 369 EasyUnlockAppInState(profile_.get(), TestAppManager::STATE_NOT_LOADED));
368 } 370 }
369 371
370 } // namespace 372 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/signin/easy_unlock_app_manager_unittest.cc ('k') | chrome/browser/signin/fake_account_tracker_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698