From 1d85d7b56400c3e42394e985c72f3a3e5b2069eb Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 20 Aug 2024 11:20:09 -0400 Subject: [PATCH] Start of test for shared images. --- .../Private/Tests/Cesium3DTileset.spec.cpp | 96 ++++++++++++++----- 1 file changed, 74 insertions(+), 22 deletions(-) diff --git a/Source/CesiumRuntime/Private/Tests/Cesium3DTileset.spec.cpp b/Source/CesiumRuntime/Private/Tests/Cesium3DTileset.spec.cpp index a9d3d53af..1813e8f4d 100644 --- a/Source/CesiumRuntime/Private/Tests/Cesium3DTileset.spec.cpp +++ b/Source/CesiumRuntime/Private/Tests/Cesium3DTileset.spec.cpp @@ -1,30 +1,82 @@ // Copyright 2020-2024 CesiumGS, Inc. and Contributors #include "Cesium3DTileset.h" +#include "CesiumGlobeAnchorComponent.h" +#include "CesiumLoadTestCore.h" +#include "CesiumSceneGeneration.h" +#include "CesiumSunSky.h" #include "CesiumTestHelpers.h" #include "Engine/World.h" +#include "GlobeAwareDefaultPawn.h" #include "Misc/AutomationTest.h" -BEGIN_DEFINE_SPEC( - FCesium3DTilesetSpec, - "Cesium.Unit.3DTileset", - EAutomationTestFlags::ApplicationContextMask | - EAutomationTestFlags::ProductFilter); -END_DEFINE_SPEC(FCesium3DTilesetSpec); - -void FCesium3DTilesetSpec::Define() { - Describe("SharedImages", [this]() { - It("should only load two textures", [this]() { - UWorld* World = GEditor->PlayWorld; - check(World); - - ACesium3DTileset* tileset = World->SpawnActor(); - tileset->SetTilesetSource(ETilesetSource::FromUrl); - tileset->SetUrl(FString::Printf( - TEXT( - "file:///%s/cesium-unreal/extern/cesium-native/Cesium3DTilesSelection/test/data/SharedImages"), - *FPaths::ProjectPluginsDir())); - tileset->SetActorLabel(TEXT("SharedImages")); - }); - }); +#define TEST_SCREEN_WIDTH 1280 +#define TEST_SCREEN_HEIGHT 720 + +namespace Cesium { + +IMPLEMENT_SIMPLE_AUTOMATION_TEST( + FCesium3DTilesetSharedImages, + "Cesium.Unit.3DTileset.SharedImages", + EAutomationTestFlags::EditorContext | EAutomationTestFlags::ProductFilter); + +static void setupForSharedImages(SceneGenerationContext& context) { + context.setCommonProperties( + FVector(21.16677692, -67.38013505, -6375355.1944), + FVector(-12, 5, -5), + FRotator(0, 90, 0), + 60.0f); + + context.georeference->SetOriginEarthCenteredEarthFixed(FVector(0, 0, 0)); + context.pawn->SetActorLocation(FVector(-12, 5, -5)); + + context.sunSky->TimeZone = 9.0f; + context.sunSky->UpdateSun(); + + ACesiumGeoreference* georeference = + context.world->SpawnActor(); + check(georeference != nullptr); + georeference->SetOriginPlacement(EOriginPlacement::TrueOrigin); + + ACesium3DTileset* tileset = context.world->SpawnActor(); + tileset->SetTilesetSource(ETilesetSource::FromUrl); + // Unreal returns the relative path of the plugins directory by default + FString FullPluginsPath = + IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead( + *FPaths::ProjectPluginsDir()); + tileset->SetUrl(FString::Printf( + TEXT( + "file:///%scesium-unreal/extern/cesium-native/Cesium3DTilesSelection/test/data/SharedImages/tileset.json"), + *FullPluginsPath)); + + tileset->SetActorLabel(TEXT("SharedImages")); + context.tilesets.push_back(tileset); + + UCesiumGlobeAnchorComponent* anchor = + NewObject(tileset); + anchor->SetGeoreference(georeference); + anchor->RegisterComponent(); + + anchor->MoveToEarthCenteredEarthFixedPosition(FVector::ZeroVector); +} + +void googleSetupRefreshTilesets( + SceneGenerationContext& context, + TestPass::TestingParameter parameter) { + context.refreshTilesets(); } + +bool FCesium3DTilesetSharedImages::RunTest(const FString& Parameters) { + std::vector testPasses; + testPasses.push_back( + TestPass{"Warm Cache", googleSetupRefreshTilesets, nullptr}); + + return RunLoadTest( + GetBeautifiedTestName(), + setupForSharedImages, + testPasses, + TEST_SCREEN_WIDTH, + TEST_SCREEN_HEIGHT); +} + +} // namespace Cesium