| 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/bluetooth_low_energy_connection_finder.h" | 5 #include "components/proximity_auth/bluetooth_low_energy_connection_finder.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 using testing::Return; | 37 using testing::Return; |
| 38 using testing::StrictMock; | 38 using testing::StrictMock; |
| 39 using testing::SaveArg; | 39 using testing::SaveArg; |
| 40 | 40 |
| 41 using device::BluetoothDevice; | 41 using device::BluetoothDevice; |
| 42 using device::MockBluetoothDevice; | 42 using device::MockBluetoothDevice; |
| 43 | 43 |
| 44 namespace proximity_auth { | 44 namespace proximity_auth { |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 const char kBLEGattServiceUUID[] = "b3b7e28e-a000-3e17-bd86-6e97b9e28c11"; |
| 47 const char kAdvertisementUUID[] = "0000fe50-0000-1000-8000-00805f9b34fb"; | 48 const char kAdvertisementUUID[] = "0000fe50-0000-1000-8000-00805f9b34fb"; |
| 48 const int8_t kRssi = -30; | 49 const int8_t kRssi = -30; |
| 49 const char kEidForPreviousTimeQuantum[] = "\x12\x34"; | 50 const char kEidForPreviousTimeQuantum[] = "\x12\x34"; |
| 50 const char kEidForCurrentTimeQuantum[] = "\xab\xcd"; | 51 const char kEidForCurrentTimeQuantum[] = "\xab\xcd"; |
| 51 const char kEidForNextTimeQuantum[] = "\x56\x78"; | 52 const char kEidForNextTimeQuantum[] = "\x56\x78"; |
| 52 const char kWrongEid[] = "\xff\xff"; | 53 const char kWrongEid[] = "\xff\xff"; |
| 53 | 54 |
| 54 std::vector<cryptauth::BeaconSeed> CreateBeaconSeeds() { | 55 std::vector<cryptauth::BeaconSeed> CreateBeaconSeeds() { |
| 55 std::vector<cryptauth::BeaconSeed> beacon_seeds; | 56 std::vector<cryptauth::BeaconSeed> beacon_seeds; |
| 56 cryptauth::BeaconSeed seed; | 57 cryptauth::BeaconSeed seed; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 76 | 77 |
| 77 DISALLOW_COPY_AND_ASSIGN(FakeEidGenerator); | 78 DISALLOW_COPY_AND_ASSIGN(FakeEidGenerator); |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 class MockBluetoothLowEnergyConnectionFinder | 81 class MockBluetoothLowEnergyConnectionFinder |
| 81 : public BluetoothLowEnergyConnectionFinder { | 82 : public BluetoothLowEnergyConnectionFinder { |
| 82 public: | 83 public: |
| 83 MockBluetoothLowEnergyConnectionFinder() | 84 MockBluetoothLowEnergyConnectionFinder() |
| 84 : BluetoothLowEnergyConnectionFinder( | 85 : BluetoothLowEnergyConnectionFinder( |
| 85 cryptauth::CreateLERemoteDeviceForTest(), | 86 cryptauth::CreateLERemoteDeviceForTest(), |
| 87 kBLEGattServiceUUID, |
| 86 CreateBeaconSeeds(), | 88 CreateBeaconSeeds(), |
| 87 base::MakeUnique<FakeEidGenerator>(this), | 89 base::MakeUnique<FakeEidGenerator>(this), |
| 88 nullptr) {} | 90 nullptr) {} |
| 89 | 91 |
| 90 ~MockBluetoothLowEnergyConnectionFinder() override {} | 92 ~MockBluetoothLowEnergyConnectionFinder() override {} |
| 91 | 93 |
| 92 // Mock methods don't support return type std::unique_ptr<>. This is a | 94 // Mock methods don't support return type std::unique_ptr<>. This is a |
| 93 // possible workaround: mock a proxy method to be called by the target | 95 // possible workaround: mock a proxy method to be called by the target |
| 94 // overridden method (CreateConnection). | 96 // overridden method (CreateConnection). |
| 95 MOCK_METHOD0(CreateConnectionProxy, cryptauth::Connection*()); | 97 MOCK_METHOD0(CreateConnectionProxy, cryptauth::Connection*()); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 // Completing the connection. | 427 // Completing the connection. |
| 426 base::RunLoop run_loop; | 428 base::RunLoop run_loop; |
| 427 ASSERT_FALSE(last_found_connection_); | 429 ASSERT_FALSE(last_found_connection_); |
| 428 connection->SetStatus(cryptauth::Connection::IN_PROGRESS); | 430 connection->SetStatus(cryptauth::Connection::IN_PROGRESS); |
| 429 connection->SetStatus(cryptauth::Connection::CONNECTED); | 431 connection->SetStatus(cryptauth::Connection::CONNECTED); |
| 430 run_loop.RunUntilIdle(); | 432 run_loop.RunUntilIdle(); |
| 431 EXPECT_TRUE(last_found_connection_); | 433 EXPECT_TRUE(last_found_connection_); |
| 432 } | 434 } |
| 433 | 435 |
| 434 } // namespace proximity_auth | 436 } // namespace proximity_auth |
| OLD | NEW |