cesium-native/CesiumAsync/test/MockAssetResponse.h

45 lines
1.2 KiB
C
Raw Permalink Normal View History

2021-01-21 04:23:54 +08:00
#pragma once
2024-12-21 01:00:09 +08:00
#include <CesiumAsync/IAssetResponse.h>
2021-03-05 00:22:38 +08:00
#include <cstddef>
2021-03-09 08:37:45 +08:00
#include <vector>
2021-01-21 04:23:54 +08:00
class MockAssetResponse : public CesiumAsync::IAssetResponse {
public:
2025-06-27 05:17:27 +08:00
MockAssetResponse() = default;
2021-03-09 08:37:45 +08:00
MockAssetResponse(
uint16_t statusCode,
const std::string& contentType,
const CesiumAsync::HttpHeaders& headers,
const std::vector<std::byte>& data)
: _statusCode{statusCode},
_contentType{contentType},
_headers{headers},
_data{data} {}
2025-06-27 05:17:27 +08:00
MockAssetResponse(MockAssetResponse&&) = default;
MockAssetResponse(const MockAssetResponse& rhs) = default;
MockAssetResponse& operator=(MockAssetResponse&&) = default;
MockAssetResponse& operator=(const MockAssetResponse&) = default;
2021-03-09 08:37:45 +08:00
virtual uint16_t statusCode() const override { return this->_statusCode; }
virtual std::string contentType() const override {
return this->_contentType;
}
virtual const CesiumAsync::HttpHeaders& headers() const override {
return this->_headers;
}
virtual std::span<const std::byte> data() const override {
return std::span<const std::byte>(_data.data(), _data.size());
2021-03-09 08:37:45 +08:00
}
2021-01-21 04:23:54 +08:00
private:
2021-03-09 08:37:45 +08:00
uint16_t _statusCode;
std::string _contentType;
CesiumAsync::HttpHeaders _headers;
std::vector<std::byte> _data;
2021-01-21 04:23:54 +08:00
};