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

Side by Side Diff: components/proximity_auth/bluetooth_connection_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.h" 5 #include "components/proximity_auth/bluetooth_connection.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "components/proximity_auth/remote_device.h" 10 #include "components/proximity_auth/remote_device.h"
(...skipping 11 matching lines...) Expand all
22 using testing::AnyNumber; 22 using testing::AnyNumber;
23 using testing::NiceMock; 23 using testing::NiceMock;
24 using testing::Ref; 24 using testing::Ref;
25 using testing::Return; 25 using testing::Return;
26 using testing::SaveArg; 26 using testing::SaveArg;
27 using testing::StrictMock; 27 using testing::StrictMock;
28 28
29 namespace proximity_auth { 29 namespace proximity_auth {
30 namespace { 30 namespace {
31 31
32 const char kDeviceUserId[] = "example@gmail.com";
32 const char kDeviceName[] = "Device name"; 33 const char kDeviceName[] = "Device name";
33 const char kOtherDeviceName[] = "Other device name"; 34 const char kOtherDeviceName[] = "Other device name";
34 35
35 const char kBluetoothAddress[] = "11:22:33:44:55:66"; 36 const char kBluetoothAddress[] = "11:22:33:44:55:66";
36 const char kOtherBluetoothAddress[] = "AA:BB:CC:DD:EE:FF"; 37 const char kOtherBluetoothAddress[] = "AA:BB:CC:DD:EE:FF";
37 38
38 const char kPublicKey[] = "Public key"; 39 const char kPublicKey[] = "Public key";
39 const char kPersistentSymmetricKey[] = "PSK"; 40 const char kPersistentSymmetricKey[] = "PSK";
40 41
41 const char kSerializedMessage[] = "Yarrr, this be a serialized message. Yarr!"; 42 const char kSerializedMessage[] = "Yarrr, this be a serialized message. Yarr!";
(...skipping 28 matching lines...) Expand all
70 BluetoothConnection::SetStatus(status); 71 BluetoothConnection::SetStatus(status);
71 } 72 }
72 73
73 using BluetoothConnection::status; 74 using BluetoothConnection::status;
74 using BluetoothConnection::Connect; 75 using BluetoothConnection::Connect;
75 using BluetoothConnection::DeviceRemoved; 76 using BluetoothConnection::DeviceRemoved;
76 using BluetoothConnection::Disconnect; 77 using BluetoothConnection::Disconnect;
77 78
78 private: 79 private:
79 RemoteDevice CreateRemoteDevice() { 80 RemoteDevice CreateRemoteDevice() {
80 return RemoteDevice(kDeviceName, kPublicKey, kBluetoothAddress, 81 return RemoteDevice(kDeviceUserId, kDeviceName, kPublicKey,
81 kPersistentSymmetricKey); 82 kBluetoothAddress, kPersistentSymmetricKey);
82 } 83 }
83 84
84 DISALLOW_COPY_AND_ASSIGN(MockBluetoothConnection); 85 DISALLOW_COPY_AND_ASSIGN(MockBluetoothConnection);
85 }; 86 };
86 87
87 class TestWireMessage : public WireMessage { 88 class TestWireMessage : public WireMessage {
88 public: 89 public:
89 TestWireMessage() : WireMessage("permit id", "payload") {} 90 TestWireMessage() : WireMessage("permit id", "payload") {}
90 ~TestWireMessage() override {} 91 ~TestWireMessage() override {}
91 92
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 450
450 ASSERT_FALSE(error_callback.is_null()); 451 ASSERT_FALSE(error_callback.is_null());
451 EXPECT_CALL(connection, OnDidSendMessage(Ref(*expected_wire_message), false)); 452 EXPECT_CALL(connection, OnDidSendMessage(Ref(*expected_wire_message), false));
452 EXPECT_CALL(connection, SetStatusProxy(Connection::DISCONNECTED)); 453 EXPECT_CALL(connection, SetStatusProxy(Connection::DISCONNECTED));
453 EXPECT_CALL(*socket_, Disconnect(_)); 454 EXPECT_CALL(*socket_, Disconnect(_));
454 EXPECT_CALL(*adapter_, RemoveObserver(&connection)); 455 EXPECT_CALL(*adapter_, RemoveObserver(&connection));
455 error_callback.Run("The most helpful of error messages"); 456 error_callback.Run("The most helpful of error messages");
456 } 457 }
457 458
458 } // namespace proximity_auth 459 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698