| OLD | NEW |
| (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 "blimp/net/test_common.h" | |
| 6 | |
| 7 #include <string> | |
| 8 #include <utility> | |
| 9 | |
| 10 #include "base/memory/ptr_util.h" | |
| 11 #include "base/sys_byteorder.h" | |
| 12 #include "blimp/common/proto/blimp_message.pb.h" | |
| 13 #include "blimp/net/blimp_connection.h" | |
| 14 #include "blimp/net/common.h" | |
| 15 #include "blimp/net/message_port.h" | |
| 16 #include "net/base/io_buffer.h" | |
| 17 | |
| 18 namespace blimp { | |
| 19 | |
| 20 MockStreamSocket::MockStreamSocket() {} | |
| 21 | |
| 22 MockStreamSocket::~MockStreamSocket() {} | |
| 23 | |
| 24 MockTransport::MockTransport() {} | |
| 25 | |
| 26 std::unique_ptr<BlimpConnection> MockTransport::MakeConnection() { | |
| 27 return std::move(connection_); | |
| 28 } | |
| 29 | |
| 30 void MockTransport::SetMockConnection( | |
| 31 std::unique_ptr<MockBlimpConnection> connection) { | |
| 32 connection_ = std::move(connection); | |
| 33 } | |
| 34 | |
| 35 MockTransport::~MockTransport() {} | |
| 36 | |
| 37 const char* MockTransport::GetName() const { | |
| 38 return "mock"; | |
| 39 } | |
| 40 | |
| 41 MockConnectionHandler::MockConnectionHandler() {} | |
| 42 | |
| 43 MockConnectionHandler::~MockConnectionHandler() {} | |
| 44 | |
| 45 void MockConnectionHandler::HandleConnection( | |
| 46 std::unique_ptr<BlimpConnection> connection) { | |
| 47 HandleConnectionPtr(connection.get()); | |
| 48 } | |
| 49 | |
| 50 MockPacketReader::MockPacketReader() {} | |
| 51 | |
| 52 MockPacketReader::~MockPacketReader() {} | |
| 53 | |
| 54 MockPacketWriter::MockPacketWriter() {} | |
| 55 | |
| 56 MockPacketWriter::~MockPacketWriter() {} | |
| 57 | |
| 58 MockBlimpConnection::MockBlimpConnection() {} | |
| 59 | |
| 60 MockBlimpConnection::~MockBlimpConnection() {} | |
| 61 | |
| 62 MockConnectionErrorObserver::MockConnectionErrorObserver() {} | |
| 63 | |
| 64 MockConnectionErrorObserver::~MockConnectionErrorObserver() {} | |
| 65 | |
| 66 MockBlimpMessageProcessor::MockBlimpMessageProcessor() {} | |
| 67 | |
| 68 MockBlimpMessageProcessor::~MockBlimpMessageProcessor() {} | |
| 69 | |
| 70 void MockBlimpMessageProcessor::ProcessMessage( | |
| 71 std::unique_ptr<BlimpMessage> message, | |
| 72 const net::CompletionCallback& callback) { | |
| 73 MockableProcessMessage(*message, callback); | |
| 74 } | |
| 75 | |
| 76 std::string EncodeHeader(size_t size) { | |
| 77 std::unique_ptr<char[]> serialized(new char[kPacketHeaderSizeBytes]); | |
| 78 uint32_t net_size = base::HostToNet32(size); | |
| 79 memcpy(serialized.get(), &net_size, sizeof(net_size)); | |
| 80 return std::string(serialized.get(), kPacketHeaderSizeBytes); | |
| 81 } | |
| 82 | |
| 83 bool BufferStartsWith(net::GrowableIOBuffer* buf, | |
| 84 size_t buf_size, | |
| 85 const std::string& str) { | |
| 86 return (buf_size >= str.size() && | |
| 87 str == std::string(buf->data(), str.size())); | |
| 88 } | |
| 89 | |
| 90 } // namespace blimp | |
| OLD | NEW |