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

Side by Side Diff: components/proximity_auth/bluetooth_connection_finder_unittest.cc

Issue 1356943004: Add RemoteDeviceLoader to create RemoteDevice from CryptAuth data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webui
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_connection_finder.h" 5 #include "components/proximity_auth/bluetooth_connection_finder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "components/proximity_auth/remote_device.h" 13 #include "components/proximity_auth/remote_device.h"
14 #include "components/proximity_auth/wire_message.h" 14 #include "components/proximity_auth/wire_message.h"
15 #include "device/bluetooth/bluetooth_adapter_factory.h" 15 #include "device/bluetooth/bluetooth_adapter_factory.h"
16 #include "device/bluetooth/bluetooth_uuid.h" 16 #include "device/bluetooth/bluetooth_uuid.h"
17 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 17 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
18 #include "device/bluetooth/test/mock_bluetooth_device.h" 18 #include "device/bluetooth/test/mock_bluetooth_device.h"
19 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 using testing::_; 22 using testing::_;
23 using testing::NiceMock; 23 using testing::NiceMock;
24 using testing::Return; 24 using testing::Return;
25 using testing::StrictMock; 25 using testing::StrictMock;
26 26
27 namespace proximity_auth { 27 namespace proximity_auth {
28 namespace { 28 namespace {
29 29
30 const char kDeviceUserId[] = "example@gmail.com";
30 const char kDeviceName[] = "Device name"; 31 const char kDeviceName[] = "Device name";
31 const char kPublicKey[] = "Public key"; 32 const char kPublicKey[] = "Public key";
32 const char kBluetoothAddress[] = "11:22:33:44:55:66"; 33 const char kBluetoothAddress[] = "11:22:33:44:55:66";
33 const char kPersistentSymmetricKey[] = "PSK"; 34 const char kPersistentSymmetricKey[] = "PSK";
34 35
35 const char kUuid[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEF"; 36 const char kUuid[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEF";
36 37
37 RemoteDevice CreateRemoteDevice() { 38 RemoteDevice CreateRemoteDevice() {
38 return RemoteDevice(kDeviceName, kPublicKey, kBluetoothAddress, 39 return RemoteDevice(kDeviceUserId, kDeviceName, kPublicKey, kBluetoothAddress,
39 kPersistentSymmetricKey); 40 kPersistentSymmetricKey);
40 } 41 }
41 42
42 class MockConnection : public Connection { 43 class MockConnection : public Connection {
43 public: 44 public:
44 MockConnection() : Connection(CreateRemoteDevice()), do_not_destroy_(false) {} 45 MockConnection() : Connection(CreateRemoteDevice()), do_not_destroy_(false) {}
45 ~MockConnection() override { EXPECT_FALSE(do_not_destroy_); } 46 ~MockConnection() override { EXPECT_FALSE(do_not_destroy_); }
46 47
47 MOCK_METHOD0(Connect, void()); 48 MOCK_METHOD0(Connect, void());
48 49
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 362
362 // Successfully connect to the Bluetooth device. 363 // Successfully connect to the Bluetooth device.
363 ON_CALL(*adapter_, GetDevice(kBluetoothAddress)) 364 ON_CALL(*adapter_, GetDevice(kBluetoothAddress))
364 .WillByDefault(Return(bluetooth_device_.get())); 365 .WillByDefault(Return(bluetooth_device_.get()));
365 MockConnection* connection = connection_finder_.ExpectCreateConnection(); 366 MockConnection* connection = connection_finder_.ExpectCreateConnection();
366 connection_finder_.seek_callback().Run(); 367 connection_finder_.seek_callback().Run();
367 SimulateDeviceConnection(connection); 368 SimulateDeviceConnection(connection);
368 } 369 }
369 370
370 } // namespace proximity_auth 371 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698