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

Side by Side Diff: components/proximity_auth/cryptauth/cryptauth_device_manager_unittest.cc

Issue 2250023005: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 "components/proximity_auth/cryptauth/cryptauth_device_manager.h" 5 #include "components/proximity_auth/cryptauth/cryptauth_device_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 MOCK_METHOD2(OnSyncFinishedProxy, 249 MOCK_METHOD2(OnSyncFinishedProxy,
250 void(CryptAuthDeviceManager::SyncResult, 250 void(CryptAuthDeviceManager::SyncResult,
251 CryptAuthDeviceManager::DeviceChangeResult)); 251 CryptAuthDeviceManager::DeviceChangeResult));
252 252
253 // Simulates firing the SyncScheduler to trigger a device sync attempt. 253 // Simulates firing the SyncScheduler to trigger a device sync attempt.
254 void FireSchedulerForSync( 254 void FireSchedulerForSync(
255 cryptauth::InvocationReason expected_invocation_reason) { 255 cryptauth::InvocationReason expected_invocation_reason) {
256 SyncScheduler::Delegate* delegate = 256 SyncScheduler::Delegate* delegate =
257 static_cast<SyncScheduler::Delegate*>(device_manager_.get()); 257 static_cast<SyncScheduler::Delegate*>(device_manager_.get());
258 258
259 std::unique_ptr<SyncScheduler::SyncRequest> sync_request = base::WrapUnique( 259 std::unique_ptr<SyncScheduler::SyncRequest> sync_request =
260 new SyncScheduler::SyncRequest(device_manager_->GetSyncScheduler())); 260 base::MakeUnique<SyncScheduler::SyncRequest>(
261 device_manager_->GetSyncScheduler());
261 EXPECT_CALL(*this, OnSyncStartedProxy()); 262 EXPECT_CALL(*this, OnSyncStartedProxy());
262 delegate->OnSyncRequested(std::move(sync_request)); 263 delegate->OnSyncRequested(std::move(sync_request));
263 264
264 EXPECT_EQ(expected_invocation_reason, 265 EXPECT_EQ(expected_invocation_reason,
265 get_my_devices_request_.invocation_reason()); 266 get_my_devices_request_.invocation_reason());
266 267
267 // The allow_stale_read flag is set if the sync was not forced. 268 // The allow_stale_read flag is set if the sync was not forced.
268 bool allow_stale_read = 269 bool allow_stale_read =
269 pref_service_.GetInteger(prefs::kCryptAuthDeviceSyncReason) != 270 pref_service_.GetInteger(prefs::kCryptAuthDeviceSyncReason) !=
270 cryptauth::INVOCATION_REASON_UNKNOWN; 271 cryptauth::INVOCATION_REASON_UNKNOWN;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 TEST_F(ProximityAuthCryptAuthDeviceManagerTest, InitWithDefaultPrefs) { 347 TEST_F(ProximityAuthCryptAuthDeviceManagerTest, InitWithDefaultPrefs) {
347 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock); 348 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock);
348 clock->SetNow(base::Time::FromDoubleT(kInitialTimeNowSeconds)); 349 clock->SetNow(base::Time::FromDoubleT(kInitialTimeNowSeconds));
349 base::TimeDelta elapsed_time = clock->Now() - base::Time::FromDoubleT(0); 350 base::TimeDelta elapsed_time = clock->Now() - base::Time::FromDoubleT(0);
350 351
351 TestingPrefServiceSimple pref_service; 352 TestingPrefServiceSimple pref_service;
352 CryptAuthDeviceManager::RegisterPrefs(pref_service.registry()); 353 CryptAuthDeviceManager::RegisterPrefs(pref_service.registry());
353 354
354 TestCryptAuthDeviceManager device_manager( 355 TestCryptAuthDeviceManager device_manager(
355 std::move(clock), 356 std::move(clock),
356 base::WrapUnique(new MockCryptAuthClientFactory( 357 base::MakeUnique<MockCryptAuthClientFactory>(
357 MockCryptAuthClientFactory::MockType::MAKE_STRICT_MOCKS)), 358 MockCryptAuthClientFactory::MockType::MAKE_STRICT_MOCKS),
358 &gcm_manager_, &pref_service); 359 &gcm_manager_, &pref_service);
359 360
360 EXPECT_CALL( 361 EXPECT_CALL(
361 *(device_manager.GetSyncScheduler()), 362 *(device_manager.GetSyncScheduler()),
362 Start(elapsed_time, SyncScheduler::Strategy::AGGRESSIVE_RECOVERY)); 363 Start(elapsed_time, SyncScheduler::Strategy::AGGRESSIVE_RECOVERY));
363 device_manager.Start(); 364 device_manager.Start();
364 EXPECT_TRUE(device_manager.GetLastSyncTime().is_null()); 365 EXPECT_TRUE(device_manager.GetLastSyncTime().is_null());
365 EXPECT_EQ(0u, device_manager.unlock_keys().size()); 366 EXPECT_EQ(0u, device_manager.unlock_keys().size());
366 } 367 }
367 368
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 CryptAuthDeviceManager::DeviceChangeResult::CHANGED)); 600 CryptAuthDeviceManager::DeviceChangeResult::CHANGED));
600 success_callback_.Run(get_my_devices_response_); 601 success_callback_.Run(get_my_devices_response_);
601 602
602 ExpectUnlockKeysAndPrefAreEqual(std::vector<cryptauth::ExternalDeviceInfo>( 603 ExpectUnlockKeysAndPrefAreEqual(std::vector<cryptauth::ExternalDeviceInfo>(
603 1, get_my_devices_response_.devices(0)), 604 1, get_my_devices_response_.devices(0)),
604 device_manager_->unlock_keys(), 605 device_manager_->unlock_keys(),
605 pref_service_); 606 pref_service_);
606 } 607 }
607 608
608 } // namespace proximity_auth 609 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698