diff --git a/.gitignore b/.gitignore index 0ba4716..19ba8bb 100644 --- a/.gitignore +++ b/.gitignore @@ -77,4 +77,5 @@ DerivedDataCache/* TestResults/* # VS Code -.vscode \ No newline at end of file +.vscode +*.code-workspace \ No newline at end of file diff --git a/BuildTests.bat b/BuildTests.bat index e041988..bab2a13 100644 --- a/BuildTests.bat +++ b/BuildTests.bat @@ -1,10 +1,11 @@ @echo off setlocal enableDelayedExpansion -set UEDir=C:\Users\bob\Documents\UE5 +set UEDir=..\..\UE5 set buildScript=!UEDir!\Engine\Build\BatchFiles\Build.bat set projectDir=%~dp0 set projectFile=ShapeArt.uproject -set build="!buildScript!" SketchTest Development Win64 "!projectDir!!projectFile!" -waitmutex +set testTarget=Tests +set build="!buildScript!" "!testTarget!" Development Win64 "!projectDir!!projectFile!" -waitmutex call !build! \ No newline at end of file diff --git a/BuildTests.sh b/BuildTests.sh new file mode 100644 index 0000000..bbb496d --- /dev/null +++ b/BuildTests.sh @@ -0,0 +1,10 @@ +#! /bin/bash + +UEDir=../../UE5 +buildScript=$UEDir/Engine/Build/BatchFiles/Linux/Build.sh +projectFile=ShapeArt.uproject +testTarget=Tests +build="$buildScript $testTarget Development Linux $PWD/$projectFile -waitmutex" + +echo $build +$build diff --git a/Config/DefaultGame.ini b/Config/DefaultGame.ini index 1f8634d..a483b21 100644 --- a/Config/DefaultGame.ini +++ b/Config/DefaultGame.ini @@ -2,4 +2,5 @@ [/Script/EngineSettings.GeneralProjectSettings] ProjectID=14B9EEC945525A1DE249B19C4218EF5F bShouldWindowPreserveAspectRatio=True +CopyrightNotice= diff --git a/Config/HoloLens/HoloLensEngine.ini b/Config/HoloLens/HoloLensEngine.ini new file mode 100644 index 0000000..7b8b53f --- /dev/null +++ b/Config/HoloLens/HoloLensEngine.ini @@ -0,0 +1,31 @@ + + +[/Script/HoloLensPlatformEditor.HoloLensTargetSettings] +bBuildForEmulation=False +bBuildForDevice=True +bUseNameForLogo=True +bBuildForRetailWindowsStore=False +bAutoIncrementVersion=False +bShouldCreateAppInstaller=False +AppInstallerInstallationURL= +HoursBetweenUpdateChecks=0 +bEnablePIXProfiling=False +TileBackgroundColor=(B=64,G=0,R=0,A=255) +SplashScreenBackgroundColor=(B=64,G=0,R=0,A=255) ++PerCultureResources=(CultureId="",Strings=(PackageDisplayName="",PublisherDisplayName="",PackageDescription="",ApplicationDisplayName="",ApplicationDescription=""),Images=()) +TargetDeviceFamily=Windows.Holographic +MinimumPlatformVersion= +MaximumPlatformVersionTested=10.0.18362.0 +MaxTrianglesPerCubicMeter=500.000000 +SpatialMeshingVolumeSize=20.000000 +CompilerVersion=Default +Windows10SDKVersion=10.0.18362.0 ++CapabilityList=internetClientServer ++CapabilityList=privateNetworkClientServer ++Uap2CapabilityList=spatialPerception +bSetDefaultCapabilities=False +SpatializationPlugin= +ReverbPlugin= +OcclusionPlugin= +SoundCueCookQualityIndex=-1 + diff --git a/README.md b/README.md index db19461..cbf4a54 100644 --- a/README.md +++ b/README.md @@ -6,76 +6,12 @@ Currently only supports VS Code for Windows, due to dead-end in getting GoogleTe ## VS Code -Open ShapeArt in UnrealEditor. Go to Tools > Refresh Visual Studio Code Project. Note that this wil overwrite any changes you have made to existing VS Code configuration files in the project. +Open ShapeArt in UnrealEditor. Go to `Tools > Refresh` Visual Studio Code Project. ## Tests -1. Install the GoogleTestAdapter extension -2. Add these tasks to .vscode/tasks.json: +1. Install the C++ TestMate extension. +2. In the TestMate extension setting, set "Test: Executables" to `Binaries/Win64/Tests.exe` or `Binaries/Linux/Tests`. +3. Copy the contents of the platform appropriate `code-workspace.example` file into `ShapeArt.code-workspace`. -``` -{ - "label": "SketchTest Build", - "group": "build", - "command": "Engine\\Build\\BatchFiles\\Build.bat", - "args": [ - "SketchTest", - "Development", - "Win64", - "${workspaceFolder}\\ShapeArt.uproject", - "-waitmutex" - ] - , - "options": { - "cwd": "C:\\Path\\To\\UE5" // Make sure you change this! - }, - "problemMatcher": "$msCompile", - "type": "shell" -}, -{ - "label": "SketchTest Clean", - "group": "build", - "command": "Engine\\Build\\BatchFiles\\Clean.bat", - "args": [ - "SketchTest", - "Development", - "Win64", - "${workspaceFolder}\\ShapeArt.uproject", - "-waitmutex" - ], - "problemMatcher": "$msCompile", - "type": "shell", - "options": { - "cwd": "C:\\Path\\To\\UE5" // Make sure you change this! - } -} -``` -3. Add this launch config to .vscode/launch.json: - -``` -{ - "name": "GoogleTest Sketch", - "request": "launch", - "program": "${workspaceFolder}\\Binaries\\Win64\\SketchTest.exe", - "preLaunchTask": "SketchTest Build", - "args": [], - "console": "integratedTerminal", - "type": "cppvsdbg", - "cwd": "C:\\Path\\To\\UE5" // Make sure you change this! -} -``` - -4. Open the GoogleTest tool, click the "Switch Test Configuration" button, and select "GoogleTest Sketch". This should run the tests, and also generate a .vscode/settings.json file. Add the following settings to that file: - -``` -"gtest-adapter.debugConfig": "GoogleTest Sketch", -// below are recommended settings -"gtest-adapter.showRunOutput": false, -"gtest-adapter.supportLocation": true, -"gtest-adapter.refreshAfterBuild": true, -"gtest-adapter.runAfterBuild": true, -"gtest-adapter.showCodeLens": true, -"gtest-adapter.clearRunOutput": true -``` - -5. Update includedir in CodeLens to include GoogleTest +You'll now have launch configuration called Run Tests. This will build and launch the test executable. \ No newline at end of file diff --git a/RunTests.bat b/RunTests.bat index 3eb71a1..113a22c 100644 --- a/RunTests.bat +++ b/RunTests.bat @@ -1,6 +1,6 @@ @echo off setlocal enableDelayedExpansion -set testExecutable="C:\Users\bob\Documents\Unreal Projects\ShapeArt\Binaries\Win64\SketchTest.exe" +set testExecutable=".\Binaries\Win64\Tests.exe" call !testExecutable! \ No newline at end of file diff --git a/RunTests.sh b/RunTests.sh new file mode 100644 index 0000000..b5e3917 --- /dev/null +++ b/RunTests.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +./Binaries/Linux/Tests \ No newline at end of file diff --git a/ShapeArt.Linux.code-workspace.example b/ShapeArt.Linux.code-workspace.example new file mode 100644 index 0000000..dabf82e --- /dev/null +++ b/ShapeArt.Linux.code-workspace.example @@ -0,0 +1,76 @@ +// Copy these contents to ShapeArt.code-workspace + +{ + "folders": [ + { + "name": "ShapeArt", + "path": "." + }, + { + "name": "UE5", + "path": "../../UE5" // Change this if needed + } + ], + "extensions": { + "recommendations": [ + "ms-vscode.cpptools", + "ms-dotnettools.csharp", + "matepek.vscode-catch2-test-adapter" + ] + }, + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "Run Tests", + "request": "launch", + "program": "${workspaceFolder:ShapeArt}/Binaries/Linux/Tests", + "preLaunchTask": "Tests Build", + "args": [], + "type": "cppdbg", + "cwd": "${workspaceFolder:UE5}" + } + ] + }, + "tasks": { + "version": "2.0.0", + "tasks": [ + { + "label": "Tests Build", + "group": "build", + "command": "Engine/Build/BatchFiles/Linux/Build.sh", + "args": [ + "Tests", + "Development", + "Linux", + "${workspaceFolder:ShapeArt}/ShapeArt.uproject", + "-waitmutex" + ] + , + "options": { + "cwd": "${workspaceFolder:UE5}" + }, + "problemMatcher": "$msCompile", + "type": "shell" + }, + { + "label": "Tests Clean", + "group": "build", + "command": "Engine/Build/BatchFiles/Linux/Build.sh", + "args": [ + "Tests", + "Development", + "Linux", + "${workspaceFolder:ShapeArt}/ShapeArt.uproject", + "-waitmutex", + "-clean" + ], + "problemMatcher": "$msCompile", + "type": "shell", + "options": { + "cwd": "${workspaceFolder:UE5}" + } + } + ] + } +} diff --git a/ShapeArt.Win64.code-workspace.example b/ShapeArt.Win64.code-workspace.example new file mode 100644 index 0000000..65ea42e --- /dev/null +++ b/ShapeArt.Win64.code-workspace.example @@ -0,0 +1,75 @@ +// Copy these contents to ShapeArt.code-workspace + +{ + "folders": [ + { + "name": "ShapeArt", + "path": "." + }, + { + "name": "UE5", + "path": "..\\..\\UE5" // Change this if needed + } + ], + "extensions": { + "recommendations": [ + "ms-vscode.cpptools", + "ms-dotnettools.csharp", + "matepek.vscode-catch2-test-adapter" + ] + }, + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "Run Tests", + "request": "launch", + "program": "${workspaceFolder:ShapeArt}\\Binaries\\Win64\\Tests.exe", + "preLaunchTask": "Tests Build", + "args": [], + "type": "cppvsdbg", + "cwd": "${workspaceFolder:UE5}" + } + ] + }, + "tasks": { + "version": "2.0.0", + "tasks": [ + { + "label": "Tests Build", + "group": "build", + "command": "Engine\\Build\\BatchFiles\\Build.bat", + "args": [ + "Tests", + "Development", + "Win64", + "${workspaceFolder:ShapeArt}\\ShapeArt.uproject", + "-waitmutex" + ] + , + "options": { + "cwd": "${workspaceFolder:UE5}" + }, + "problemMatcher": "$msCompile", + "type": "shell" + }, + { + "label": "Tests Clean", + "group": "build", + "command": "Engine\\Build\\BatchFiles\\Clean.bat", + "args": [ + "Tests", + "Development", + "Win64", + "${workspaceFolder:ShapeArt}\\ShapeArt.uproject", + "-waitmutex" + ], + "problemMatcher": "$msCompile", + "type": "shell", + "options": { + "cwd": "${workspaceFolder:UE5}" + } + } + ] + } +} diff --git a/ShapeArt.gta.runsettings b/ShapeArt.gta.runsettings deleted file mode 100644 index 87a6b2a..0000000 --- a/ShapeArt.gta.runsettings +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - false - true - false - Automatic - Automatic - Error - true - 4 - 1 - true - true - false - false - 0 - SketchTest.exe - 30 - $(SolutionDir) - - - - - \ No newline at end of file diff --git a/ShapeArt.uproject b/ShapeArt.uproject index f4a5071..6507928 100644 --- a/ShapeArt.uproject +++ b/ShapeArt.uproject @@ -16,7 +16,7 @@ }, { "Name": "Sketch", - "Type": "RuntimeAndProgram", + "Type": "Runtime", "LoadingPhase": "Default" } ], @@ -32,5 +32,8 @@ "Name": "FunctionalTestingEditor", "Enabled": true } + ], + "TargetPlatforms": [ + "Windows" ] } \ No newline at end of file diff --git a/Source/Sketch/Public/PolygonSketch.h b/Source/Sketch/Public/PolygonSketch.h index ff95699..b635afc 100644 --- a/Source/Sketch/Public/PolygonSketch.h +++ b/Source/Sketch/Public/PolygonSketch.h @@ -13,7 +13,7 @@ class SKETCH_API PolygonSketch : public Sketch { int GetSize() { return Size; } - FVector GetVertex(int Index) { return Vertices.GetData()[Index]; } + FVector GetVertex(int Index) { return Vertices[Index]; } void SetVertex(int Index, double X, double Y) { FVector& Vertex = Vertices[Index]; diff --git a/Source/Sketch/Sketch.Build.cs b/Source/Sketch/Sketch.Build.cs index fee0915..45b1d05 100644 --- a/Source/Sketch/Sketch.Build.cs +++ b/Source/Sketch/Sketch.Build.cs @@ -11,16 +11,6 @@ public Sketch(ReadOnlyTargetRules Target) : base(Target) bAddDefaultIncludePaths = true; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PublicDependencyModuleNames.AddRange(new string[] { "Core" }); - PrivateDependencyModuleNames.AddRange(new string[] { "GoogleTest" }); - - string googleTestBasePath = Path.Combine("$(ProjectDir)", "Source", "ThirdParty", "GoogleTest", "googletest-release-1.11.0"); - - PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googlemock")); - PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googlemock", "src")); - PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googlemock", "include")); - PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googletest")); - PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googletest", "src")); - PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googletest", "include")); } } } diff --git a/Source/SketchTest.Target.cs b/Source/SketchTest.Target.cs deleted file mode 100644 index 6669066..0000000 --- a/Source/SketchTest.Target.cs +++ /dev/null @@ -1,17 +0,0 @@ -using UnrealBuildTool; -using System.Collections.Generic; -using System.IO; - -public class SketchTestTarget : TargetRules -{ - public SketchTestTarget(TargetInfo Target) : base(Target) - { - Type = TargetType.Program; - DefaultBuildSettings = BuildSettingsVersion.V2; - LinkType = TargetLinkType.Modular; - LaunchModuleName = "Sketch"; - - bIsBuildingConsoleApplication = true; - - } -} diff --git a/Source/Tests.Target.cs b/Source/Tests.Target.cs new file mode 100644 index 0000000..033fc56 --- /dev/null +++ b/Source/Tests.Target.cs @@ -0,0 +1,23 @@ +using UnrealBuildTool; +using System.Collections.Generic; +using System.IO; + +public class TestsTarget : TargetRules +{ + public TestsTarget(TargetInfo Target) : base(Target) + { + Type = TargetType.Program; + DefaultBuildSettings = BuildSettingsVersion.V2; + LinkType = TargetLinkType.Modular; + LaunchModuleName = "Tests"; + bIsBuildingConsoleApplication = true; + bCompileAgainstEngine = false; + bCompileAgainstCoreUObject = false; + + // Keeps macro definitions in Tests.Build.cs from throwing errors. + // Note: The space at the beginning of the string is necessary, otherwise the first argument is ignored. + if(Platform == UnrealTargetPlatform.Linux) { + AdditionalCompilerArguments=" -Wno-error=macro-redefined -Wno-error=undef"; + } + } +} diff --git a/Source/Sketch/Tests/HistoryTest.cpp b/Source/Tests/Sketch/HistoryTest.cpp similarity index 74% rename from Source/Sketch/Tests/HistoryTest.cpp rename to Source/Tests/Sketch/HistoryTest.cpp index 4f8a112..2cec961 100644 --- a/Source/Sketch/Tests/HistoryTest.cpp +++ b/Source/Tests/Sketch/HistoryTest.cpp @@ -2,11 +2,12 @@ #include "gtest/gtest.h" #include + class HistoryTest : public ::testing::Test { protected: THistory* History = new THistory; - void PostTestValues(int Count) { + void PostValueSeries(int Count) { for(int i = 10; i <= Count * 10; i += 10) { History->Post(i); } @@ -24,7 +25,7 @@ class HistoryTest : public ::testing::Test { } } - void Post(int Value) { History->Post(Value); } + void PostValue(int Value) { History->Post(Value); } THistory::THistoryNode* GetCurrent() { return History->GetCurrent(); } @@ -35,20 +36,21 @@ class HistoryTest : public ::testing::Test { bool IsHead() { return History->IsHead(); } bool IsTail() { return History->IsTail(); } + }; TEST_F(HistoryTest, GetCurrent) { - Post(10); + PostValue(10); EXPECT_NE(GetCurrent(), nullptr); EXPECT_EQ(GetCurrentValue(), 10); - Post(25); + PostValue(25); EXPECT_NE(GetCurrent(), nullptr); EXPECT_EQ(GetCurrentValue(), 25); } TEST_F(HistoryTest, StepPrevious) { - PostTestValues(4); + PostValueSeries(4); for(int expected = 30; expected >= 10; expected -= 10) { StepPrevious(); @@ -57,16 +59,16 @@ TEST_F(HistoryTest, StepPrevious) { } TEST_F(HistoryTest, StepPreviousAndPost) { - PostTestValues(3); + PostValueSeries(3); StepPrevious(2); - Post(99); + PostValue(99); EXPECT_EQ(GetCurrentValue(), 99); } TEST_F(HistoryTest, StepNext) { - PostTestValues(4); + PostValueSeries(4); StepPrevious(4); @@ -76,9 +78,26 @@ TEST_F(HistoryTest, StepNext) { } } +TEST_F(HistoryTest, OverstepTail) { + PostValue(10); + EXPECT_THROW(StepNext(), std::out_of_range); +} + +TEST_F(HistoryTest, OverstepHead) { + PostValueSeries(10); + StepPrevious(10); + EXPECT_THROW(StepPrevious(), std::out_of_range); +} + +TEST_F(HistoryTest, GetCurrentOnHead) { + PostValueSeries(10); + StepPrevious(10); + EXPECT_THROW(GetCurrentValue(), std::out_of_range); +} + TEST_F(HistoryTest, IsHead) { EXPECT_TRUE(IsHead()); - Post(1); + PostValue(1); EXPECT_FALSE(IsHead()); StepPrevious(); EXPECT_TRUE(IsHead()); @@ -88,7 +107,7 @@ TEST_F(HistoryTest, IsHead) { TEST_F(HistoryTest, IsTail) { EXPECT_TRUE(IsTail()); - Post(1); + PostValue(1); EXPECT_TRUE(IsTail()); StepPrevious(); EXPECT_FALSE(IsTail()); @@ -97,6 +116,6 @@ TEST_F(HistoryTest, IsTail) { } TEST_F(HistoryTest, DeleteHistory) { - PostTestValues(100); + PostValueSeries(100); delete History; } \ No newline at end of file diff --git a/Source/Sketch/Tests/PolygonSketchTest.cpp b/Source/Tests/Sketch/PolygonSketchTest.cpp similarity index 99% rename from Source/Sketch/Tests/PolygonSketchTest.cpp rename to Source/Tests/Sketch/PolygonSketchTest.cpp index 6b47755..588f6f8 100644 --- a/Source/Sketch/Tests/PolygonSketchTest.cpp +++ b/Source/Tests/Sketch/PolygonSketchTest.cpp @@ -1,6 +1,7 @@ #include "PolygonSketch.h" #include "gtest/gtest.h" + class PolygonSketchTest : public ::testing::Test { protected: PolygonSketch Polygon {}; diff --git a/Source/Tests/Tests.Build.cs b/Source/Tests/Tests.Build.cs new file mode 100644 index 0000000..cd615cc --- /dev/null +++ b/Source/Tests/Tests.Build.cs @@ -0,0 +1,19 @@ +using UnrealBuildTool; +using System.IO; + +namespace UnrealBuildTool.Rules +{ + +public class Tests : ModuleRules +{ + public Tests(ReadOnlyTargetRules Target) : base(Target) + { + bAddDefaultIncludePaths = true; + bEnableExceptions = true; + + PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; + PublicDependencyModuleNames.AddRange(new string[] { "Core", "GoogleTestModule" }); + PrivateDependencyModuleNames.AddRange(new string[] { "Sketch" }); + } +} +} diff --git a/Source/Sketch/Tests/Tests.cpp b/Source/Tests/Tests.cpp similarity index 99% rename from Source/Sketch/Tests/Tests.cpp rename to Source/Tests/Tests.cpp index 2bfcf92..0d00a99 100644 --- a/Source/Sketch/Tests/Tests.cpp +++ b/Source/Tests/Tests.cpp @@ -1,4 +1,3 @@ // These two includes comprise the test program main(). - #include "gtest_main.cc" #include "gtest-all.cc" \ No newline at end of file diff --git a/Source/ThirdParty/GoogleTest/GoogleTest.Build.cs b/Source/ThirdParty/GoogleTest/GoogleTestModule.Build.cs similarity index 82% rename from Source/ThirdParty/GoogleTest/GoogleTest.Build.cs rename to Source/ThirdParty/GoogleTest/GoogleTestModule.Build.cs index 4644d1d..9b90768 100644 --- a/Source/ThirdParty/GoogleTest/GoogleTest.Build.cs +++ b/Source/ThirdParty/GoogleTest/GoogleTestModule.Build.cs @@ -4,14 +4,14 @@ namespace UnrealBuildTool.Rules { - public class GoogleTest : ModuleRules + public class GoogleTestModule : ModuleRules { - public GoogleTest(ReadOnlyTargetRules Target) : base(Target) + public GoogleTestModule(ReadOnlyTargetRules Target) : base(Target) { Type = ModuleType.External; PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; - string googleTestBasePath = Path.Combine(ModuleDirectory, "googletest-release-1.11.0"); + string googleTestBasePath = Path.Combine(ModuleDirectory, "googletest-release-1.11.0"); PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googlemock")); PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googlemock", "src")); PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googlemock", "include")); @@ -19,11 +19,27 @@ public GoogleTest(ReadOnlyTargetRules Target) : base(Target) PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googletest", "src")); PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googletest", "include")); - PublicDefinitions.Add("GTEST_OS_WINDOWS=1"); + if (Target.Platform == UnrealTargetPlatform.Win64) + { + PublicDefinitions.Add("GTEST_OS_WINDOWS=1"); + PublicDefinitions.Add("GTEST_OS_MAC=0"); + PublicDefinitions.Add("GTEST_OS_LINUX=0"); + } + else if (Target.Platform == UnrealTargetPlatform.Mac) + { + PublicDefinitions.Add("GTEST_OS_MAC=1"); + PublicDefinitions.Add("GTEST_OS_WINDOWS=0"); + PublicDefinitions.Add("GTEST_OS_LINUX=0"); + } + else if (Target.IsInPlatformGroup(UnrealPlatformGroup.Unix)) + { + PublicDefinitions.Add("GTEST_OS_LINUX=1"); + PublicDefinitions.Add("GTEST_OS_WINDOWS=0"); + PublicDefinitions.Add("GTEST_OS_MAC=0"); + } + PublicDefinitions.Add("GTEST_OS_WINDOWS_MOBILE=0"); PublicDefinitions.Add("GTEST_OS_LINUX_ANDROID=0"); - PublicDefinitions.Add("GTEST_OS_LINUX=0"); - PublicDefinitions.Add("GTEST_OS_MAC=0"); PublicDefinitions.Add("GTEST_OS_HPUX=0"); PublicDefinitions.Add("GTEST_OS_QNX=0"); PublicDefinitions.Add("GTEST_OS_FREEBSD=0");