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_METHOD(bool, SendHeaders, (const HeaderList&, ErrorPtr*), (override)); 23 MOCK_METHOD(bool, MockSetRequestData, (Stream*, ErrorPtr*)); 24 MOCK_METHOD(void, MockSetResponseData, (Stream*)); 25 MOCK_METHOD(bool, FinishRequest, (ErrorPtr*), (override)); 26 MOCK_METHOD(RequestID, 27 FinishRequestAsync, 28 (const SuccessCallback&, const ErrorCallback&), 29 (override)); 30 MOCK_METHOD(int, GetResponseStatusCode, (), (const, override)); 31 MOCK_METHOD(std::string, GetResponseStatusText, (), (const, override)); 32 MOCK_METHOD(std::string, GetProtocolVersion, (), (const, override)); 33 MOCK_METHOD(std::string, 34 GetResponseHeader, 35 (const std::string&), 36 (const, override)); 37 MOCK_METHOD(Stream*, MockExtractDataStream, (brillo::ErrorPtr*), (const)); 38 39 private: SetRequestData(StreamPtr stream,brillo::ErrorPtr * error)40 bool SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) override { 41 return MockSetRequestData(stream.get(), error); 42 } SetResponseData(StreamPtr stream)43 void SetResponseData(StreamPtr stream) override { 44 MockSetResponseData(stream.get()); 45 } ExtractDataStream(brillo::ErrorPtr * error)46 StreamPtr ExtractDataStream(brillo::ErrorPtr* error) override { 47 return StreamPtr{MockExtractDataStream(error)}; 48 } 49 50 DISALLOW_COPY_AND_ASSIGN(MockConnection); 51 }; 52 53 } // namespace http 54 } // namespace brillo 55 56 #endif // LIBBRILLO_BRILLO_HTTP_MOCK_CONNECTION_H_ 57