| 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/throttled_bluetooth_connection_finder.h" | 5 #include "components/proximity_auth/throttled_bluetooth_connection_finder.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/test/test_simple_task_runner.h" | 11 #include "base/test/test_simple_task_runner.h" |
| 10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 11 #include "components/proximity_auth/bluetooth_connection_finder.h" | 13 #include "components/proximity_auth/bluetooth_connection_finder.h" |
| 12 #include "components/proximity_auth/bluetooth_throttler.h" | 14 #include "components/proximity_auth/bluetooth_throttler.h" |
| 13 #include "components/proximity_auth/fake_connection.h" | 15 #include "components/proximity_auth/fake_connection.h" |
| 14 #include "components/proximity_auth/remote_device.h" | 16 #include "components/proximity_auth/remote_device.h" |
| 15 #include "components/proximity_auth/wire_message.h" | 17 #include "components/proximity_auth/wire_message.h" |
| 16 #include "device/bluetooth/bluetooth_uuid.h" | 18 #include "device/bluetooth/bluetooth_uuid.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 21 |
| 20 using testing::NiceMock; | 22 using testing::NiceMock; |
| 21 using testing::Return; | 23 using testing::Return; |
| 22 using testing::_; | 24 using testing::_; |
| 23 | 25 |
| 24 namespace proximity_auth { | 26 namespace proximity_auth { |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 const int kPollingIntervalSeconds = 7; | 29 const int kPollingIntervalSeconds = 7; |
| 28 const char kUuid[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEF"; | 30 const char kUuid[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEF"; |
| 29 | 31 |
| 30 // A callback that stores a found |connection| into |out|. | 32 // A callback that stores a found |connection| into |out|. |
| 31 void SaveConnection(scoped_ptr<Connection>* out, | 33 void SaveConnection(scoped_ptr<Connection>* out, |
| 32 scoped_ptr<Connection> connection) { | 34 scoped_ptr<Connection> connection) { |
| 33 *out = connection.Pass(); | 35 *out = std::move(connection); |
| 34 } | 36 } |
| 35 | 37 |
| 36 class MockBluetoothThrottler : public BluetoothThrottler { | 38 class MockBluetoothThrottler : public BluetoothThrottler { |
| 37 public: | 39 public: |
| 38 MockBluetoothThrottler() {} | 40 MockBluetoothThrottler() {} |
| 39 ~MockBluetoothThrottler() override {} | 41 ~MockBluetoothThrottler() override {} |
| 40 | 42 |
| 41 MOCK_CONST_METHOD0(GetDelay, base::TimeDelta()); | 43 MOCK_CONST_METHOD0(GetDelay, base::TimeDelta()); |
| 42 MOCK_METHOD1(OnConnection, void(Connection* connection)); | 44 MOCK_METHOD1(OnConnection, void(Connection* connection)); |
| 43 | 45 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 ThrottledBluetoothConnectionFinder connection_finder( | 115 ThrottledBluetoothConnectionFinder connection_finder( |
| 114 make_scoped_ptr(new FakeBluetoothConnectionFinder), task_runner_, | 116 make_scoped_ptr(new FakeBluetoothConnectionFinder), task_runner_, |
| 115 &throttler_); | 117 &throttler_); |
| 116 scoped_ptr<Connection> connection; | 118 scoped_ptr<Connection> connection; |
| 117 EXPECT_CALL(throttler_, OnConnection(_)); | 119 EXPECT_CALL(throttler_, OnConnection(_)); |
| 118 connection_finder.Find(base::Bind(&SaveConnection, &connection)); | 120 connection_finder.Find(base::Bind(&SaveConnection, &connection)); |
| 119 EXPECT_TRUE(connection); | 121 EXPECT_TRUE(connection); |
| 120 } | 122 } |
| 121 | 123 |
| 122 } // namespace proximity_auth | 124 } // namespace proximity_auth |
| OLD | NEW |