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

Side by Side Diff: components/cryptauth/secure_channel_unittest.cc

Issue 2697763002: [CrOS Tether]: Create BleConnectionManager, which manages secure connections between the current de… (Closed)
Patch Set: Add missing DEP. Created 3 years, 10 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
« no previous file with comments | « components/cryptauth/secure_channel.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/cryptauth/secure_channel.h" 5 #include "components/cryptauth/secure_channel.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 private: 112 private:
113 Authenticator* last_instance_; 113 Authenticator* last_instance_;
114 }; 114 };
115 115
116 RemoteDevice CreateTestRemoteDevice() { 116 RemoteDevice CreateTestRemoteDevice() {
117 RemoteDevice remote_device = GenerateTestRemoteDevices(1)[0]; 117 RemoteDevice remote_device = GenerateTestRemoteDevices(1)[0];
118 remote_device.user_id = test_user_id; 118 remote_device.user_id = test_user_id;
119 return remote_device; 119 return remote_device;
120 } 120 }
121 121
122 class TestSecureChannel : public SecureChannel {
123 public:
124 TestSecureChannel(std::unique_ptr<Connection> connection,
125 std::unique_ptr<Delegate> delegate)
126 : SecureChannel(std::move(connection), std::move(delegate)) {}
127 };
128
122 } // namespace 129 } // namespace
123 130
124 class CryptAuthSecureChannelTest : public testing::Test { 131 class CryptAuthSecureChannelTest : public testing::Test {
125 protected: 132 protected:
126 CryptAuthSecureChannelTest() 133 CryptAuthSecureChannelTest()
127 : test_device_(CreateTestRemoteDevice()), 134 : test_device_(CreateTestRemoteDevice()),
128 weak_ptr_factory_(this) {} 135 weak_ptr_factory_(this) {}
129 136
130 void SetUp() override { 137 void SetUp() override {
131 test_authenticator_factory_ = base::MakeUnique<TestAuthenticatorFactory>(); 138 test_authenticator_factory_ = base::MakeUnique<TestAuthenticatorFactory>();
132 DeviceToDeviceAuthenticator::Factory::SetInstanceForTesting( 139 DeviceToDeviceAuthenticator::Factory::SetInstanceForTesting(
133 test_authenticator_factory_.get()); 140 test_authenticator_factory_.get());
134 141
135 fake_secure_context_ = nullptr; 142 fake_secure_context_ = nullptr;
136 143
137 fake_secure_message_delegate_ = new FakeSecureMessageDelegate(); 144 fake_secure_message_delegate_ = new FakeSecureMessageDelegate();
138 145
139 test_delegate_ = 146 test_delegate_ =
140 new TestDelegate(base::WrapUnique(fake_secure_message_delegate_)); 147 new TestDelegate(base::WrapUnique(fake_secure_message_delegate_));
141 148
142 fake_connection_ = 149 fake_connection_ =
143 new FakeConnection(test_device_, /* should_auto_connect */ false); 150 new FakeConnection(test_device_, /* should_auto_connect */ false);
144 151
145 EXPECT_FALSE(fake_connection_->observers().size()); 152 EXPECT_FALSE(fake_connection_->observers().size());
146 secure_channel_ = base::MakeUnique<SecureChannel>( 153 secure_channel_ = base::MakeUnique<TestSecureChannel>(
147 base::WrapUnique(fake_connection_), base::WrapUnique(test_delegate_)); 154 base::WrapUnique(fake_connection_), base::WrapUnique(test_delegate_));
148 EXPECT_EQ(static_cast<size_t>(1), fake_connection_->observers().size()); 155 EXPECT_EQ(static_cast<size_t>(1), fake_connection_->observers().size());
149 EXPECT_EQ(secure_channel_.get(), fake_connection_->observers()[0]); 156 EXPECT_EQ(secure_channel_.get(), fake_connection_->observers()[0]);
150 157
151 test_observer_ = base::MakeUnique<TestObserver>(secure_channel_.get()); 158 test_observer_ = base::MakeUnique<TestObserver>(secure_channel_.get());
152 secure_channel_->AddObserver(test_observer_.get()); 159 secure_channel_->AddObserver(test_observer_.get());
153 } 160 }
154 161
155 void TearDown() override { 162 void TearDown() override {
156 // All state changes should have already been verified. This ensures that 163 // All state changes should have already been verified. This ensures that
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 546
540 StartAndFinishSendingMessage("feature", "request2", /* success */ true); 547 StartAndFinishSendingMessage("feature", "request2", /* success */ true);
541 548
542 fake_connection_->ReceiveMessage("feature", "response2, but encoded"); 549 fake_connection_->ReceiveMessage("feature", "response2, but encoded");
543 VerifyReceivedMessages(std::vector<ReceivedMessage> { 550 VerifyReceivedMessages(std::vector<ReceivedMessage> {
544 {"feature", "response2"} 551 {"feature", "response2"}
545 }); 552 });
546 } 553 }
547 554
548 } // namespace cryptauth 555 } // namespace cryptauth
OLDNEW
« no previous file with comments | « components/cryptauth/secure_channel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698