1 // Copyright 2014 The Chromium OS 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 #ifndef LIBBRILLO_BRILLO_HTTP_MOCK_CONNECTION_H_ 6 #define LIBBRILLO_BRILLO_HTTP_MOCK_CONNECTION_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include <base/macros.h> 12 #include <brillo/http/http_connection.h> 13 #include <gmock/gmock.h> 14 15 namespace brillo { 16 namespace http { 17 18 class MockConnection : public Connection { 19 public: 20 using Connection::Connection; 21 22 MOCK_METHOD2(SendHeaders, bool(const HeaderList&, ErrorPtr*)); 23 MOCK_METHOD2(MockSetRequestData, bool(Stream*, ErrorPtr*)); 24 MOCK_METHOD1(MockSetResponseData, void(Stream*)); 25 MOCK_METHOD1(FinishRequest, bool(ErrorPtr*)); 26 MOCK_METHOD2(FinishRequestAsync, 27 RequestID(const SuccessCallback&, const ErrorCallback&)); 28 MOCK_CONST_METHOD0(GetResponseStatusCode, int()); 29 MOCK_CONST_METHOD0(GetResponseStatusText, std::string()); 30 MOCK_CONST_METHOD0(GetProtocolVersion, std::string()); 31 MOCK_CONST_METHOD1(GetResponseHeader, std::string(const std::string&)); 32 MOCK_CONST_METHOD1(MockExtractDataStream, Stream*(brillo::ErrorPtr*)); 33 34 private: SetRequestData(StreamPtr stream,brillo::ErrorPtr * error)35 bool SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) override { 36 return MockSetRequestData(stream.get(), error); 37 } SetResponseData(StreamPtr stream)38 void SetResponseData(StreamPtr stream) override { 39 MockSetResponseData(stream.get()); 40 } ExtractDataStream(brillo::ErrorPtr * error)41 StreamPtr ExtractDataStream(brillo::ErrorPtr* error) override { 42 return StreamPtr{MockExtractDataStream(error)}; 43 } 44 45 DISALLOW_COPY_AND_ASSIGN(MockConnection); 46 }; 47 48 } // namespace http 49 } // namespace brillo 50 51 #endif // LIBBRILLO_BRILLO_HTTP_MOCK_CONNECTION_H_ 52