| 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 "components/proximity_auth/ble/proximity_auth_ble_system.h" | 5 #include "components/proximity_auth/ble/proximity_auth_ble_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
| 10 #include "base/test/test_mock_time_task_runner.h" | 10 #include "base/test/test_mock_time_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "components/proximity_auth/ble/bluetooth_low_energy_device_whitelist.h" | 12 #include "components/proximity_auth/ble/bluetooth_low_energy_device_whitelist.h" |
| 13 #include "components/proximity_auth/connection_finder.h" | 13 #include "components/proximity_auth/connection_finder.h" |
| 14 #include "components/proximity_auth/cryptauth/mock_cryptauth_client.h" | 14 #include "components/proximity_auth/cryptauth/mock_cryptauth_client.h" |
| 15 #include "components/proximity_auth/proximity_auth_client.h" | 15 #include "components/proximity_auth/mock_proximity_auth_client.h" |
| 16 #include "components/proximity_auth/screenlock_bridge.h" | 16 #include "components/proximity_auth/screenlock_bridge.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 using testing::_; | 20 using testing::_; |
| 21 using testing::NiceMock; | 21 using testing::NiceMock; |
| 22 using testing::Return; | 22 using testing::Return; |
| 23 | 23 |
| 24 namespace proximity_auth { | 24 namespace proximity_auth { |
| 25 | 25 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 MOCK_METHOD1(Unlock, void(const std::string& user_email)); | 54 MOCK_METHOD1(Unlock, void(const std::string& user_email)); |
| 55 MOCK_METHOD3(AttemptEasySignin, | 55 MOCK_METHOD3(AttemptEasySignin, |
| 56 void(const std::string& user_email, | 56 void(const std::string& user_email, |
| 57 const std::string& secret, | 57 const std::string& secret, |
| 58 const std::string& key_label)); | 58 const std::string& key_label)); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 DISALLOW_COPY_AND_ASSIGN(MockLockHandler); | 61 DISALLOW_COPY_AND_ASSIGN(MockLockHandler); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 const char kTestUser[] = "example@gmail.com"; | |
| 65 | |
| 66 class MockProximityAuthClient : public ProximityAuthClient { | |
| 67 public: | |
| 68 MockProximityAuthClient() {} | |
| 69 ~MockProximityAuthClient() override {} | |
| 70 | |
| 71 // ProximityAuthClient: | |
| 72 std::string GetAuthenticatedUsername() const override { return kTestUser; } | |
| 73 | |
| 74 MOCK_METHOD1(UpdateScreenlockState, | |
| 75 void(proximity_auth::ScreenlockState state)); | |
| 76 MOCK_METHOD1(FinalizeUnlock, void(bool success)); | |
| 77 MOCK_METHOD1(FinalizeSignin, void(const std::string& secret)); | |
| 78 | |
| 79 private: | |
| 80 DISALLOW_COPY_AND_ASSIGN(MockProximityAuthClient); | |
| 81 }; | |
| 82 | |
| 83 } // namespace | 64 } // namespace |
| 84 | 65 |
| 85 class ProximityAuthBleSystemTestable : public ProximityAuthBleSystem { | 66 class ProximityAuthBleSystemTestable : public ProximityAuthBleSystem { |
| 86 public: | 67 public: |
| 87 ProximityAuthBleSystemTestable( | 68 ProximityAuthBleSystemTestable( |
| 88 ScreenlockBridge* screenlock_bridge, | 69 ScreenlockBridge* screenlock_bridge, |
| 89 ProximityAuthClient* proximity_auth_client, | 70 ProximityAuthClient* proximity_auth_client, |
| 90 scoped_ptr<CryptAuthClientFactory> cryptauth_client_factory, | 71 scoped_ptr<CryptAuthClientFactory> cryptauth_client_factory, |
| 91 PrefService* pref_service) | 72 PrefService* pref_service) |
| 92 : ProximityAuthBleSystem(screenlock_bridge, | 73 : ProximityAuthBleSystem(screenlock_bridge, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // Show the screen. | 133 // Show the screen. |
| 153 ON_CALL(lock_handler_, GetScreenType()) | 134 ON_CALL(lock_handler_, GetScreenType()) |
| 154 .WillByDefault(Return(ScreenlockBridge::LockHandler::OTHER_SCREEN)); | 135 .WillByDefault(Return(ScreenlockBridge::LockHandler::OTHER_SCREEN)); |
| 155 ScreenlockBridge::Get()->SetLockHandler(&lock_handler_); | 136 ScreenlockBridge::Get()->SetLockHandler(&lock_handler_); |
| 156 | 137 |
| 157 // Hide the screen. | 138 // Hide the screen. |
| 158 ScreenlockBridge::Get()->SetLockHandler(nullptr); | 139 ScreenlockBridge::Get()->SetLockHandler(nullptr); |
| 159 } | 140 } |
| 160 | 141 |
| 161 } // namespace proximity_auth | 142 } // namespace proximity_auth |
| OLD | NEW |