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

Side by Side Diff: components/proximity_auth/fake_connection.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, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/proximity_auth/fake_connection.h"
6
7 #include "components/proximity_auth/wire_message.h"
8
9 namespace proximity_auth {
10
11 FakeConnection::FakeConnection(const RemoteDevice& remote_device)
12 : Connection(RemoteDevice()) {
13 Connect();
14 }
15
16 FakeConnection::~FakeConnection() {
17 Disconnect();
18 }
19
20 void FakeConnection::Connect() {
21 SetStatus(CONNECTED);
22 }
23
24 void FakeConnection::Disconnect() {
25 SetStatus(DISCONNECTED);
26 }
27
28 void FakeConnection::FinishSendingMessageWithSuccess(bool success) {
29 CHECK(current_message_);
30 // Capture a copy of the message, as OnDidSendMessage() might reentrantly
31 // call SendMessage().
32 scoped_ptr<WireMessage> sent_message = current_message_.Pass();
33 OnDidSendMessage(*sent_message, success);
34 }
35
36 void FakeConnection::ReceiveMessageWithPayload(const std::string& payload) {
37 pending_payload_ = payload;
38 OnBytesReceived(std::string());
39 pending_payload_.clear();
40 }
41
42 void FakeConnection::SendMessageImpl(scoped_ptr<WireMessage> message) {
43 CHECK(!current_message_);
44 current_message_ = message.Pass();
45 }
46
47 scoped_ptr<WireMessage> FakeConnection::DeserializeWireMessage(
48 bool* is_incomplete_message) {
49 *is_incomplete_message = false;
50 return make_scoped_ptr(new WireMessage(pending_payload_));
51 }
52
53 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/fake_connection.h ('k') | components/proximity_auth/messenger_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698