| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |