xref: /aosp_15_r20/external/libbrillo/brillo/http/mock_connection.h (revision 1a96fba65179ea7d3f56207137718607415c5953)
1*1a96fba6SXin Li // Copyright 2014 The Chromium OS Authors. All rights reserved.
2*1a96fba6SXin Li // Use of this source code is governed by a BSD-style license that can be
3*1a96fba6SXin Li // found in the LICENSE file.
4*1a96fba6SXin Li 
5*1a96fba6SXin Li #ifndef LIBBRILLO_BRILLO_HTTP_MOCK_CONNECTION_H_
6*1a96fba6SXin Li #define LIBBRILLO_BRILLO_HTTP_MOCK_CONNECTION_H_
7*1a96fba6SXin Li 
8*1a96fba6SXin Li #include <memory>
9*1a96fba6SXin Li #include <string>
10*1a96fba6SXin Li 
11*1a96fba6SXin Li #include <base/macros.h>
12*1a96fba6SXin Li #include <brillo/http/http_connection.h>
13*1a96fba6SXin Li #include <gmock/gmock.h>
14*1a96fba6SXin Li 
15*1a96fba6SXin Li namespace brillo {
16*1a96fba6SXin Li namespace http {
17*1a96fba6SXin Li 
18*1a96fba6SXin Li class MockConnection : public Connection {
19*1a96fba6SXin Li  public:
20*1a96fba6SXin Li   using Connection::Connection;
21*1a96fba6SXin Li 
22*1a96fba6SXin Li   MOCK_METHOD(bool, SendHeaders, (const HeaderList&, ErrorPtr*), (override));
23*1a96fba6SXin Li   MOCK_METHOD(bool, MockSetRequestData, (Stream*, ErrorPtr*));
24*1a96fba6SXin Li   MOCK_METHOD(void, MockSetResponseData, (Stream*));
25*1a96fba6SXin Li   MOCK_METHOD(bool, FinishRequest, (ErrorPtr*), (override));
26*1a96fba6SXin Li   MOCK_METHOD(RequestID,
27*1a96fba6SXin Li               FinishRequestAsync,
28*1a96fba6SXin Li               (const SuccessCallback&, const ErrorCallback&),
29*1a96fba6SXin Li               (override));
30*1a96fba6SXin Li   MOCK_METHOD(int, GetResponseStatusCode, (), (const, override));
31*1a96fba6SXin Li   MOCK_METHOD(std::string, GetResponseStatusText, (), (const, override));
32*1a96fba6SXin Li   MOCK_METHOD(std::string, GetProtocolVersion, (), (const, override));
33*1a96fba6SXin Li   MOCK_METHOD(std::string,
34*1a96fba6SXin Li               GetResponseHeader,
35*1a96fba6SXin Li               (const std::string&),
36*1a96fba6SXin Li               (const, override));
37*1a96fba6SXin Li   MOCK_METHOD(Stream*, MockExtractDataStream, (brillo::ErrorPtr*), (const));
38*1a96fba6SXin Li 
39*1a96fba6SXin Li  private:
SetRequestData(StreamPtr stream,brillo::ErrorPtr * error)40*1a96fba6SXin Li   bool SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) override {
41*1a96fba6SXin Li     return MockSetRequestData(stream.get(), error);
42*1a96fba6SXin Li   }
SetResponseData(StreamPtr stream)43*1a96fba6SXin Li   void SetResponseData(StreamPtr stream) override {
44*1a96fba6SXin Li     MockSetResponseData(stream.get());
45*1a96fba6SXin Li   }
ExtractDataStream(brillo::ErrorPtr * error)46*1a96fba6SXin Li   StreamPtr ExtractDataStream(brillo::ErrorPtr* error) override {
47*1a96fba6SXin Li     return StreamPtr{MockExtractDataStream(error)};
48*1a96fba6SXin Li   }
49*1a96fba6SXin Li 
50*1a96fba6SXin Li   DISALLOW_COPY_AND_ASSIGN(MockConnection);
51*1a96fba6SXin Li };
52*1a96fba6SXin Li 
53*1a96fba6SXin Li }  // namespace http
54*1a96fba6SXin Li }  // namespace brillo
55*1a96fba6SXin Li 
56*1a96fba6SXin Li #endif  // LIBBRILLO_BRILLO_HTTP_MOCK_CONNECTION_H_
57