summaryrefslogtreecommitdiff
path: root/test/mock_transport.hh
blob: 7fe92354b097b719eda96f725dfbb4a56d6b3ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef MOCK_TRANSPORT_HH
#define MOCK_TRANSPORT_HH

#include "transport.hh"

#include <gmock/gmock.h>

class MockTransport : public Transport {
public:
  std::unique_ptr<Response> create_data(uint16_t code, std::string data)
    override {
    return std::unique_ptr<Response>(create_data_proxy(code, std::move(data)));
  }

  MOCK_METHOD(std::unique_ptr<Response>, create_file,
              (uint16_t, std::filesystem::path),
              (override));
  MOCK_METHOD(std::unique_ptr<Response>, create_exif_thumbnail,
              (uint16_t, std::filesystem::path),
              (override));
  MOCK_METHOD(void, add_client, (unique_fd&&), (override));

  MOCK_METHOD(Response*, create_data_proxy, (uint16_t, std::string));
};

class MockResponse : public Transport::Response {
public:
  MOCK_METHOD(uint16_t, code, (), (override, const));
  MOCK_METHOD((std::vector<std::pair<std::string, std::string>> const&),
              headers, (), (override, const));
  MOCK_METHOD(std::unique_ptr<Transport::Input>, open_content, (), (override));
  MOCK_METHOD(void, open_content_async, (
                  std::shared_ptr<TaskRunner>,
                  std::function<void(std::unique_ptr<Transport::Input>)>),
              (override));
  MOCK_METHOD(void, add_header, (std::string, std::string), (override));
};

#endif  // MOCK_TRANSPORT_HH