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

Unified Diff: components/proximity_auth/unlock_manager_unittest.cc

Issue 1372283002: Hook up ProximityAuthSystem in EasyUnlockService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_connection
Patch Set: remove log Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/proximity_auth/unlock_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/proximity_auth/unlock_manager_unittest.cc
diff --git a/components/proximity_auth/unlock_manager_unittest.cc b/components/proximity_auth/unlock_manager_unittest.cc
index 56e71a70948811f3ff40025b5b57d3a4190e7e08..6a134bd65c1b9bb46fd370b33f247390f30acae9 100644
--- a/components/proximity_auth/unlock_manager_unittest.cc
+++ b/components/proximity_auth/unlock_manager_unittest.cc
@@ -89,6 +89,8 @@ class MockProximityMonitor : public ProximityMonitor {
MOCK_CONST_METHOD0(IsUnlockAllowed, bool());
MOCK_CONST_METHOD0(IsInRssiRange, bool());
MOCK_METHOD0(RecordProximityMetricsOnAuthSuccess, void());
+ MOCK_METHOD1(AddObserver, void(ProximityMonitorObserver*));
+ MOCK_METHOD1(RemoveObserver, void(ProximityMonitorObserver*));
private:
DISALLOW_COPY_AND_ASSIGN(MockProximityMonitor);
@@ -463,12 +465,11 @@ TEST_F(
CreateUnlockManager(UnlockManager::ScreenlockType::SESSION_LOCK);
SimulateUserPresentState();
- NiceMock<MockRemoteDeviceLifeCycle> life_cycle;
- ON_CALL(life_cycle, GetState())
+ ON_CALL(life_cycle_, GetState())
.WillByDefault(Return(RemoteDeviceLifeCycle::State::FINDING_CONNECTION));
EXPECT_CALL(*proximity_monitor_, Stop()).Times(AtLeast(1));
- unlock_manager_->SetRemoteDeviceLifeCycle(&life_cycle);
+ unlock_manager_->SetRemoteDeviceLifeCycle(&life_cycle_);
}
TEST_F(
@@ -477,25 +478,18 @@ TEST_F(
CreateUnlockManager(UnlockManager::ScreenlockType::SESSION_LOCK);
SimulateUserPresentState();
- NiceMock<MockRemoteDeviceLifeCycle> life_cycle;
- ON_CALL(life_cycle, GetState())
+ ON_CALL(life_cycle_, GetState())
.WillByDefault(
Return(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED));
EXPECT_CALL(*proximity_monitor_, Start()).Times(AtLeast(1));
- unlock_manager_->SetRemoteDeviceLifeCycle(&life_cycle);
+ unlock_manager_->SetRemoteDeviceLifeCycle(&life_cycle_);
}
TEST_F(ProximityAuthUnlockManagerTest,
OnLifeCycleStateChanged_SecureChannelEstablished_RegistersAsObserver) {
CreateUnlockManager(UnlockManager::ScreenlockType::SESSION_LOCK);
SimulateUserPresentState();
-
- NiceMock<MockRemoteDeviceLifeCycle> life_cycle;
- ON_CALL(life_cycle, GetState())
- .WillByDefault(
- Return(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED));
-
EXPECT_CALL(messenger_, AddObserver(unlock_manager_.get()));
unlock_manager_->OnLifeCycleStateChanged();
}
@@ -504,12 +498,6 @@ TEST_F(ProximityAuthUnlockManagerTest,
OnLifeCycleStateChanged_StartsProximityMonitor) {
CreateUnlockManager(UnlockManager::ScreenlockType::SESSION_LOCK);
SimulateUserPresentState();
-
- NiceMock<MockRemoteDeviceLifeCycle> life_cycle;
- ON_CALL(life_cycle, GetState())
- .WillByDefault(
- Return(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED));
-
EXPECT_CALL(*proximity_monitor_, Start()).Times(AtLeast(1));
unlock_manager_->OnLifeCycleStateChanged();
}
@@ -612,8 +600,10 @@ TEST_F(ProximityAuthUnlockManagerTest, OnDisconnected_UnregistersAsObserver) {
.WillByDefault(
Return(RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED));
- EXPECT_CALL(messenger_, RemoveObserver(unlock_manager_.get()));
+ EXPECT_CALL(messenger_, RemoveObserver(unlock_manager_.get()))
+ .Times(testing::AtLeast(1));
unlock_manager_.get()->OnDisconnected();
+ unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
}
TEST_F(ProximityAuthUnlockManagerTest,
« no previous file with comments | « components/proximity_auth/unlock_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698