diff --git a/tests/Engine/Utility/ImageLoading.cpp b/tests/Engine/Utility/ImageLoading.cpp new file mode 100644 index 000000000..9c7143d5c --- /dev/null +++ b/tests/Engine/Utility/ImageLoading.cpp @@ -0,0 +1,40 @@ +#include +#include +#include + +std::filesystem::path GetResourceDir(); + +SCENARIO("Images", "[Utility][Image]") +{ + WHEN("Loading PNG files") + { + GIVEN("Logo.png") + { + std::shared_ptr logo = Nz::Image::LoadFromFile(GetResourceDir() / "Logo.png"); + REQUIRE(logo); + + CHECK(logo->GetWidth() == 765); + CHECK(logo->GetHeight() == 212); + CHECK(logo->GetLevelCount() == 1); + CHECK(logo->GetPixelColor(165, 139) == Nz::Color(51, 58, 100)); + CHECK(logo->GetFormat() == Nz::PixelFormat::RGBA8); + CHECK(logo->HasAlpha()); + } + } + + WHEN("Loading JPG files") + { + GIVEN("stars-background.jpg") + { + std::shared_ptr background = Nz::Image::LoadFromFile(GetResourceDir() / "stars-background.jpg"); + REQUIRE(background); + + CHECK(background->GetWidth() == 1920); + CHECK(background->GetHeight() == 1200); + CHECK(background->GetLevelCount() == 1); + CHECK(background->GetPixelColor(1377, 372) == Nz::Color(171, 152, 233)); + CHECK(background->GetFormat() == Nz::PixelFormat::RGBA8); + CHECK(!background->HasAlpha()); + } + } +} diff --git a/tests/Engine/Utility/MeshLoading.cpp b/tests/Engine/Utility/MeshLoading.cpp new file mode 100644 index 000000000..1238b9d85 --- /dev/null +++ b/tests/Engine/Utility/MeshLoading.cpp @@ -0,0 +1,50 @@ +#include +#include +#include + +std::filesystem::path GetResourceDir(); + +SCENARIO("Meshes", "[Utility][Mesh]") +{ + WHEN("Loading OJB files") + { + GIVEN("Spaceship/spaceship.obj") + { + std::shared_ptr spaceship = Nz::Mesh::LoadFromFile(GetResourceDir() / "Spaceship/spaceship.obj"); + REQUIRE(spaceship); + + CHECK(!spaceship->IsAnimable()); + CHECK(spaceship->GetSubMeshCount() == 2); + CHECK(spaceship->GetMaterialCount() == 2); + CHECK(spaceship->GetTriangleCount() == 6814); + CHECK(spaceship->GetVertexCount() == 8713); + } + + GIVEN("SpaceStation/space_station.obj") + { + std::shared_ptr spacestation = Nz::Mesh::LoadFromFile(GetResourceDir() / "SpaceStation/space_station.obj"); + REQUIRE(spacestation); + + CHECK(!spacestation->IsAnimable()); + CHECK(spacestation->GetSubMeshCount() == 1); + CHECK(spacestation->GetMaterialCount() == 1); + CHECK(spacestation->GetTriangleCount() == 422); + CHECK(spacestation->GetVertexCount() == 516); + } + } + + WHEN("Loading MD2 files") + { + GIVEN("drfreak.md2") + { + std::shared_ptr drfreak = Nz::Mesh::LoadFromFile(GetResourceDir() / "drfreak.md2"); + CHECK(drfreak); + + CHECK(!drfreak->IsAnimable()); //< non-skeletal animations are not supported + CHECK(drfreak->GetSubMeshCount() == 1); + CHECK(drfreak->GetMaterialCount() == 1); + CHECK(drfreak->GetTriangleCount() == 593); + CHECK(drfreak->GetVertexCount() == 496); + } + } +} diff --git a/tests/main.cpp b/tests/main.cpp index 15d36ca8c..38e3ef663 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -7,11 +7,12 @@ #include #include #include +#include #include int main(int argc, char* argv[]) { - Nz::Modules nazaza; + Nz::Modules nazaza; if (!glslang::InitializeProcess()) return EXIT_FAILURE;