mock_stream_socket.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2016 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. #include "chromecast/net/mock_stream_socket.h"
  5. #include "net/base/io_buffer.h"
  6. #include "net/base/net_errors.h"
  7. #include "net/socket/next_proto.h"
  8. #include "net/socket/socket_tag.h"
  9. #include "net/traffic_annotation/network_traffic_annotation.h"
  10. using ::testing::Invoke;
  11. using ::testing::Return;
  12. using ::testing::ReturnRef;
  13. using ::testing::_;
  14. namespace chromecast {
  15. MockStreamSocket::MockStreamSocket() {
  16. // Set default return values.
  17. ON_CALL(*this, Read(_, _, _)).WillByDefault(Return(net::ERR_IO_PENDING));
  18. ON_CALL(*this, Write(_, _, _, _))
  19. .WillByDefault(Invoke(
  20. [](net::IOBuffer* buf, int buf_len,
  21. net::CompletionOnceCallback callback,
  22. const net::NetworkTrafficAnnotationTag& traffic_annotation) {
  23. return buf_len;
  24. }));
  25. ON_CALL(*this, NetLog()).WillByDefault(ReturnRef(net_log_));
  26. ON_CALL(*this, GetNegotiatedProtocol())
  27. .WillByDefault(Return(net::NextProto()));
  28. }
  29. MockStreamSocket::~MockStreamSocket() {}
  30. } // namespace chromecast