Files
comaps/storage/storage_tests/fake_map_files_downloader.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

62 lines
1.5 KiB
C++

#pragma once
#include "storage/downloader_queue_universal.hpp"
#include "storage/map_files_downloader.hpp"
#include "storage/queued_country.hpp"
#include "platform/downloader_defines.hpp"
#include "coding/file_writer.hpp"
#include "base/thread_checker.hpp"
#include <cstdint>
#include <memory>
#include <vector>
namespace storage
{
class TaskRunner;
// This class can be used in tests to mimic a real downloader. It
// always returns a single URL for map files downloading and when
// asked for a file, creates a file with zero-bytes content on a disk.
// Because all callbacks must be invoked asynchronously, it needs a
// single-thread message loop runner to run callbacks.
//
// *NOTE*, this class is not thread-safe.
class FakeMapFilesDownloader : public MapFilesDownloader
{
public:
static int64_t const kBlockSize = 1024 * 1024;
FakeMapFilesDownloader(TaskRunner & taskRunner);
~FakeMapFilesDownloader();
// MapFilesDownloader overrides:
void Remove(CountryId const & id) override;
void Clear() override;
QueueInterface const & GetQueue() const override;
private:
// MapFilesDownloader overrides:
void Download(QueuedCountry && queuedCountry) override;
void Download();
void DownloadNextChunk(uint64_t requestId);
void OnFileDownloaded(QueuedCountry const & queuedCountry,
downloader::DownloadStatus const & status);
downloader::Progress m_progress;
std::unique_ptr<FileWriter> m_writer;
uint64_t m_timestamp;
TaskRunner & m_taskRunner;
ThreadChecker m_checker;
Queue m_queue;
};
} // namespace storage