Skip to content

Commit

Permalink
Add simple TileService test
Browse files Browse the repository at this point in the history
  • Loading branch information
gue-ni committed Feb 19, 2024
1 parent 73de25f commit c1e7701
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ add_executable(tests
test-terrain.cpp
)

if(CMAKE_COMPILER_IS_GNUCC)
target_link_options(tests PRIVATE -fsanitize=thread)
target_compile_options(tests PRIVATE -fsanitize=thread)
endif()

target_link_libraries(tests PRIVATE Catch2::Catch2WithMain collision terrain)

if(WIN32)
Expand Down
34 changes: 34 additions & 0 deletions test/test-terrain.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <catch2/catch_test_macros.hpp>
#include <filesystem>
#include <iostream>

#include "Common.h"
Expand All @@ -7,3 +8,36 @@

#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/io.hpp>

TEST_CASE("TileService")
{
const std::string cache = "tiles/ortho-cache-test";
const std::string url = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile";
const UrlPattern pattern = UrlPattern::ZYX_Y_SOUTH;

try {
std::filesystem::remove_all(cache);
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}

TileService tile_service(url, pattern, "", cache);

std::vector tiles = {
TileId(0u, 0u, 0u),
TileId(1u, 0u, 0u),
TileId(2u, 0u, 0u),
TileId(3u, 0u, 0u),
};

for (auto& tile : tiles) {
Image* image = tile_service.get_tile(tile);
}

std::this_thread::sleep_for(std::chrono::milliseconds(3000));

for (auto& tile : tiles) {
Image* image = tile_service.get_tile_cached(tile);
// CHECK(image != nullptr);
}
}

0 comments on commit c1e7701

Please sign in to comment.