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

Unified Diff: components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc

Issue 1351473003: Refactor fake Connection subclasses in proximity_auth/ tests to a single file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client_rename
Patch Set: rebase 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/BUILD.gn ('k') | components/proximity_auth/bluetooth_throttler_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc
diff --git a/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc b/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc
index 1f48015eae499f81da95d475766d7f733c16c216..64700d1c605aa42c29997c5ef988bd83d9f26ae5 100644
--- a/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc
+++ b/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc
@@ -14,7 +14,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "components/proximity_auth/ble/bluetooth_low_energy_device_whitelist.h"
-#include "components/proximity_auth/connection.h"
+#include "components/proximity_auth/fake_connection.h"
#include "components/proximity_auth/remote_device.h"
#include "components/proximity_auth/wire_message.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
@@ -51,22 +51,6 @@ RemoteDevice CreateRemoteDevice() {
kPersistentSymmetricKey);
}
-class MockConnection : public Connection {
- public:
- MockConnection() : Connection(CreateRemoteDevice()) {}
- ~MockConnection() override {}
-
- MOCK_METHOD0(Connect, void());
-
- using Connection::SetStatus;
-
- private:
- void Disconnect() override {}
- void SendMessageImpl(scoped_ptr<WireMessage> message) override {}
-
- DISALLOW_COPY_AND_ASSIGN(MockConnection);
-};
-
class MockBluetoothLowEnergyDeviceWhitelist
: public BluetoothLowEnergyDeviceWhitelist {
public:
@@ -102,9 +86,10 @@ class MockBluetoothLowEnergyConnectionFinder
// created connection. Returns a reference to the created connection.
// NOTE: The returned connection's lifetime is managed by the connection
// finder.
- MockConnection* ExpectCreateConnection() {
- scoped_ptr<MockConnection> connection(new NiceMock<MockConnection>());
- MockConnection* connection_alias = connection.get();
+ FakeConnection* ExpectCreateConnection() {
+ scoped_ptr<FakeConnection> connection(
+ new FakeConnection(CreateRemoteDevice()));
+ FakeConnection* connection_alias = connection.get();
EXPECT_CALL(*this, CreateConnectionProxy())
.WillOnce(Return(connection.release()));
return connection_alias;
@@ -389,7 +374,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest,
ExpectStopDiscoveryAndRemoveObserver();
// Finding and creating a connection to the right device.
- MockConnection* connection = connection_finder.ExpectCreateConnection();
+ FakeConnection* connection = connection_finder.ExpectCreateConnection();
PrepareDevice(kServiceUUID, kBluetoothAddress, true);
connection_finder.DeviceAdded(adapter_.get(), device_.get());
@@ -415,7 +400,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest,
// Preparing to create a GATT connection to the right device.
PrepareDevice(kServiceUUID, kBluetoothAddress, true);
- MockConnection* connection = connection_finder.ExpectCreateConnection();
+ FakeConnection* connection = connection_finder.ExpectCreateConnection();
// Trying to create a connection.
connection_finder.DeviceAdded(adapter_.get(), device_.get());
@@ -500,7 +485,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyConnectionFinderTest,
// Preparing to create a GATT connection to the right device.
PrepareDevice(kServiceUUID, kBluetoothAddress, true);
- MockConnection* connection = connection_finder.ExpectCreateConnection();
+ FakeConnection* connection = connection_finder.ExpectCreateConnection();
// Trying to create a connection.
connection_finder.DeviceAdded(adapter_.get(), device_.get());
« no previous file with comments | « components/proximity_auth/BUILD.gn ('k') | components/proximity_auth/bluetooth_throttler_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698