Add tests and SDK

This commit is contained in:
Jérôme Leclercq
2021-05-17 23:08:37 +02:00
parent 26de5872eb
commit e716b44aa3
52 changed files with 539 additions and 276 deletions

View File

@@ -4,6 +4,8 @@
#include <chrono>
#include <thread>
std::filesystem::path GetResourceDir();
SCENARIO("Music", "[AUDIO][MUSIC]")
{
GIVEN("A music")
@@ -12,7 +14,7 @@ SCENARIO("Music", "[AUDIO][MUSIC]")
WHEN("We load our music")
{
REQUIRE(music.OpenFromFile("resources/Engine/Audio/The_Brabanconne.ogg"));
REQUIRE(music.OpenFromFile(GetResourceDir() / "Engine/Audio/The_Brabanconne.ogg"));
THEN("We can ask the informations of the file")
{

View File

@@ -4,6 +4,8 @@
#include <chrono>
#include <thread>
std::filesystem::path GetResourceDir();
SCENARIO("Sound", "[AUDIO][SOUND]")
{
GIVEN("A sound")
@@ -12,7 +14,7 @@ SCENARIO("Sound", "[AUDIO][SOUND]")
WHEN("We load our sound")
{
REQUIRE(sound.LoadFromFile("resources/Engine/Audio/Cat.flac"));
REQUIRE(sound.LoadFromFile(GetResourceDir() / "Engine/Audio/Cat.flac"));
THEN("We can ask the informations of the file")
{

View File

@@ -1,13 +1,15 @@
#include <Nazara/Audio/SoundBuffer.hpp>
#include <Catch/catch.hpp>
std::filesystem::path GetResourceDir();
SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]")
{
GIVEN("A sound buffer")
{
WHEN("We load our sound")
{
Nz::SoundBufferRef soundBuffer = Nz::SoundBuffer::LoadFromFile("resources/Engine/Audio/Cat.flac");
Nz::SoundBufferRef soundBuffer = Nz::SoundBuffer::LoadFromFile(GetResourceDir() / "Engine/Audio/Cat.flac");
REQUIRE(soundBuffer.IsValid());
THEN("We can ask the informations of the file")

View File

@@ -1,6 +1,8 @@
#include <Nazara/Audio/Sound.hpp>
#include <Catch/catch.hpp>
std::filesystem::path GetResourceDir();
SCENARIO("SoundEmitter", "[AUDIO][SOUNDEMITTER]")
{
GIVEN("A sound emitter")
@@ -9,7 +11,7 @@ SCENARIO("SoundEmitter", "[AUDIO][SOUNDEMITTER]")
WHEN("We load our sound")
{
REQUIRE(sound.LoadFromFile("resources/Engine/Audio/Cat.flac"));
REQUIRE(sound.LoadFromFile(GetResourceDir() / "Engine/Audio/Cat.flac"));
THEN("We can ask information about position and velocity")
{

View File

@@ -1,6 +1,8 @@
#include <Nazara/Core/File.hpp>
#include <Catch/catch.hpp>
std::filesystem::path GetResourceDir();
SCENARIO("File", "[CORE][FILE]")
{
GIVEN("One file")
@@ -63,9 +65,9 @@ SCENARIO("File", "[CORE][FILE]")
GIVEN("The test file")
{
REQUIRE(std::filesystem::exists("resources/Engine/Core/FileTest.txt"));
REQUIRE(std::filesystem::exists(GetResourceDir() / "Engine/Core/FileTest.txt"));
Nz::File fileTest("resources/Engine/Core/FileTest.txt", Nz::OpenMode_ReadOnly | Nz::OpenMode_Text);
Nz::File fileTest(GetResourceDir() / "Engine/Core/FileTest.txt", Nz::OpenMode_ReadOnly | Nz::OpenMode_Text);
WHEN("We read the first line of the file")
{

View File

@@ -1,11 +1,11 @@
#include <NazaraSDK/Application.hpp>
#include <NazaraSDK/ClientApplication.hpp>
#include <Catch/catch.hpp>
SCENARIO("Application", "[NDK][APPLICATION]")
{
GIVEN("An application")
{
Nz::Window& window = Ndk::Application::Instance()->AddWindow<Nz::Window>();
Nz::Window& window = Ndk::ClientApplication::Instance()->AddWindow<Nz::Window>();
WHEN("We open a window")
{
@@ -22,4 +22,4 @@ SCENARIO("Application", "[NDK][APPLICATION]")
}
}
}
}
}

View File

@@ -32,7 +32,7 @@ SCENARIO("BaseSystem", "[NDK][BASESYSTEM]")
{
GIVEN("Our TestSystem")
{
Ndk::World world(false);
Ndk::World world;
Ndk::BaseSystem& system = world.AddSystem<TestSystem>();
REQUIRE(&system.GetWorld() == &world);
@@ -62,4 +62,4 @@ SCENARIO("BaseSystem", "[NDK][BASESYSTEM]")
}
}
}
}
}

View File

@@ -55,7 +55,7 @@ SCENARIO("Entity", "[NDK][ENTITY]")
{
GIVEN("A world & an entity")
{
Ndk::World world(false);
Ndk::World world;
Ndk::BaseSystem& system = world.AddSystem<UpdateSystem>();
Ndk::EntityHandle entity = world.CreateEntity();
@@ -99,4 +99,4 @@ SCENARIO("Entity", "[NDK][ENTITY]")
}
}
}
}
}

View File

@@ -6,7 +6,7 @@ SCENARIO("EntityList", "[NDK][ENTITYLIST]")
{
GIVEN("A world & a set of entities")
{
Ndk::World world(false);
Ndk::World world;
const Ndk::EntityHandle& entity = world.CreateEntity();
Ndk::EntityList entityList;
@@ -39,4 +39,4 @@ SCENARIO("EntityList", "[NDK][ENTITYLIST]")
}
}
}
}
}

View File

@@ -6,7 +6,7 @@ SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]")
{
GIVEN("A world & an entity")
{
Ndk::World world(false);
Ndk::World world;
Ndk::EntityHandle entity = world.CreateEntity();
WHEN("We set the ownership of the entity to our owner")
@@ -108,7 +108,7 @@ SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]")
GIVEN("A vector of EntityOwner")
{
Ndk::World world(false);
Ndk::World world;
std::vector<Ndk::EntityOwner> entityOwners;
for (std::size_t i = 1; i <= 10; ++i)

View File

@@ -3,6 +3,7 @@
#include <NazaraSDK/Components/CollisionComponent2D.hpp>
#include <NazaraSDK/Components/NodeComponent.hpp>
#include <NazaraSDK/Components/PhysicsComponent2D.hpp>
#include <NazaraSDK/Systems/PhysicsSystem2D.hpp>
#include <Catch/catch.hpp>
#include <limits>
@@ -13,6 +14,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
GIVEN("A world and an entity")
{
Ndk::World world;
world.AddSystem<Ndk::PhysicsSystem2D>();
Nz::Vector2f position(2.f, 3.f);
Nz::Rectf movingAABB(0.f, 0.f, 16.f, 18.f);
@@ -74,6 +76,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
GIVEN("A world and a simple entity")
{
Ndk::World world;
world.AddSystem<Ndk::PhysicsSystem2D>();
Nz::Vector2f position(0.f, 0.f);
Nz::Rectf movingAABB(0.f, 0.f, 1.f, 2.f);
@@ -120,6 +123,7 @@ SCENARIO("PhysicsSystem2D", "[NDK][PHYSICSSYSTEM2D]")
GIVEN("A world and a simple entity not at the origin")
{
Ndk::World world;
world.AddSystem<Ndk::PhysicsSystem2D>();
Nz::Vector2f position(3.f, 4.f);
Nz::Rectf movingAABB(0.f, 0.f, 1.f, 2.f);

View File

@@ -3,6 +3,7 @@
#include <NazaraSDK/Components/CollisionComponent3D.hpp>
#include <NazaraSDK/Components/NodeComponent.hpp>
#include <NazaraSDK/Components/PhysicsComponent3D.hpp>
#include <NazaraSDK/Systems/PhysicsSystem3D.hpp>
#include <Catch/catch.hpp>
SCENARIO("PhysicsSystem3D", "[NDK][PHYSICSSYSTEM3D]")
@@ -10,6 +11,8 @@ SCENARIO("PhysicsSystem3D", "[NDK][PHYSICSSYSTEM3D]")
GIVEN("A world and a static entity & a dynamic entity")
{
Ndk::World world;
world.AddSystem<Ndk::PhysicsSystem3D>();
const Ndk::EntityHandle& staticEntity = world.CreateEntity();
Ndk::CollisionComponent3D& collisionComponentStatic = staticEntity->AddComponent<Ndk::CollisionComponent3D>();
Ndk::NodeComponent& nodeComponentStatic = staticEntity->AddComponent<Ndk::NodeComponent>();
@@ -31,4 +34,4 @@ SCENARIO("PhysicsSystem3D", "[NDK][PHYSICSSYSTEM3D]")
}
}
}
}
}

View File

@@ -13,7 +13,7 @@ SCENARIO("VelocitySystem", "[NDK][VELOCITYSYSTEM]")
Ndk::VelocityComponent& velocityComponent = entity->AddComponent<Ndk::VelocityComponent>();
Ndk::NodeComponent& nodeComponent = entity->AddComponent<Ndk::NodeComponent>();
world.GetSystem<Ndk::VelocitySystem>().SetFixedUpdateRate(30.f);
world.AddSystem<Ndk::VelocitySystem>().SetFixedUpdateRate(30.f);
WHEN("We give a speed to our entity")
{
@@ -27,4 +27,4 @@ SCENARIO("VelocitySystem", "[NDK][VELOCITYSYSTEM]")
}
}
}
}
}

View File

@@ -55,7 +55,7 @@ SCENARIO("World", "[NDK][WORLD]")
{
GIVEN("A brave new world and the update system")
{
Ndk::World world(false);
Ndk::World world;
Ndk::BaseSystem& system = world.AddSystem<UpdateSystem>();
WHEN("We had a new entity with an updatable component and a system")
@@ -103,7 +103,7 @@ SCENARIO("World", "[NDK][WORLD]")
GIVEN("A newly created entity")
{
Ndk::World world(false);
Ndk::World world;
Ndk::EntityHandle entity = world.CreateEntity();
REQUIRE(entity.IsValid());
@@ -129,7 +129,7 @@ SCENARIO("World", "[NDK][WORLD]")
GIVEN("An empty world")
{
Ndk::World world(false);
Ndk::World world;
WHEN("We create two entities")
{

20
tests/main_client.cpp Normal file
View File

@@ -0,0 +1,20 @@
#define CATCH_CONFIG_RUNNER
#include <Catch/catch.hpp>
#include <Nazara/Core/Log.hpp>
#include <Nazara/Core/AbstractLogger.hpp>
#include <Nazara/Core/Modules.hpp>
#include <NazaraSDK/ClientApplication.hpp>
#include <NazaraSDK/ClientSdk.hpp>
int main(int argc, char* argv[])
{
Nz::Modules<Ndk::ClientSdk> nazaza;
Ndk::ClientApplication app(argc, argv);
Nz::Log::GetLogger()->EnableStdReplication(false);
int result = Catch::Session().run(argc, argv);
return result;
}

15
tests/resources.cpp Normal file
View File

@@ -0,0 +1,15 @@
#include <filesystem>
std::filesystem::path GetResourceDir()
{
static std::filesystem::path resourceDir = []
{
std::filesystem::path resourceDir = "resources";
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir))
return ".." / resourceDir;
else
return resourceDir;
}();
return resourceDir;
}

View File

@@ -1 +0,0 @@
6993cbcca9ac596667135cb0f30bea4841178d3b

View File

@@ -1 +0,0 @@
94b2c47c9143adbac0fb7e81df5cc87f969f7150

View File

@@ -1,54 +0,0 @@
The_Brabanconne.ogg
https://en.wikipedia.org/wiki/File:The_Brabanconne.ogg
Original file:
The_Brabanconne.ogg (Ogg Vorbis sound file, length 1 min 3 s, 378 kbps)
Summary:
Description: The Belgian national anthem (instrumental version) performed by the United States Navy Band. Direct link is at http://www.navyband.navy.mil/anthems/ANTHEMS/Belgium.mp3.
Date: 19 October 2004
Source: http://www.navyband.navy.mil/anthems/national_anthems.htm
Author: United States Navy Band (rendition), uploaded to Wikimedia by Keith Lehwald
Licencing:
This file is a work of a sailor or employee of the U.S. Navy, taken or made as part of that person's official duties. As a work of the U.S. federal government, the image is in the public domain.
This file has been identified as being free of known restrictions under copyright law, including all related and neighboring rights.
-------------------------------------------------------------------------------------------------
Cat.flac:
http://www.freesound.org/people/EARR/sounds/148013/
Original file:
148013__earr__angry-cat.flac (Flac sound file, length 8 s, 96000 Hz, 24 bit depth)
Author:
EARR
Description:
Slightly angry cat. She is a beautiful Siamese cat called Agostina. She is angry for the recording because i pressed his tail.
Information about the recording and equipment:
-Location: Living room.
-Type of acoustic environment: Small, diffuse, moderately reflective.
-Distance from sound source to microphones: Approx a few centimeters.
-Miking technique: Jecklin disk.
-Microphones: 2 Brüel & Kjaer type 4190 capsules with type 2669L head amplifier.
-Microphone preamps: Modified Brüel & Kjaer type 5935L.
-ADC: Echo Audiofire 4. (line inputs 3 & 4).
-Recorder: Echo Audiofire 4 and Dell D630C running Samplitude 10.
Eq: Compensation only for the response of the microphones (In this case for flat response at 60º. See Brüel & Kjaer type 4190 datasheet).
No reverb, no compression, no fx.
Licencing:
Creative commons

View File

@@ -1 +0,0 @@
Test

View File

@@ -1,24 +0,0 @@
#############################
MD5 sample mesh and animation
#############################
INFORMATION & USAGE
===================
File includes *.blend source files and TGA format textures for MD5 animated mesh testing.
For extensive information and usage instructions visit http://www.katsbits.com/smforum/index.php?topic=178.0
- bob_lamp_update.blend contain mesh and armature as would be prior to preparation for export.
- bob_lamp_update_export contains triangulated mesh ready for export.
NOTES
=====
Included files are for use in **Blender 2.69** or above; opening files in older versions may result in errors dues to internal differences between Blender versions.
Files and media are provided "as is" without any warranties of functionality.
COPYRIGHT & DISTRIBUTION
========================
Copyright © 2014 KatsBits. All Rights Reserved.
For more information visit http://www.katsbits.com/ or email info@katsbits.com
For NON-COMMERCIAL USE ONLY. This file and/or its contents and/or associated materials may not be reproduced, duplicated, distributed or otherwise 'monetised' without prior consent.
Contact info@katsbits.com or visit http://copyright.katsbits.com/ for further details regarding this material and/or distribution/copyright.

View File

@@ -1,82 +0,0 @@
skybox.png
https://commons.wikimedia.org/wiki/File:Skybox_example.png
Original file:
Skybox example.ogg (Ogg Vorbis sound file, length 1 min 3 s, 378 kbps)
Summary:
Description: English: An example of a skybox and how the faces can be aligned
Date: 8 June 2011
Source: Own work
Author: Creator:Arieee
Description: The Belgian national anthem (instrumental version) performed by the United States Navy Band. Direct link is at http://www.navyband.navy.mil/anthems/ANTHEMS/Belgium.mp3.
Date: 19 October 2004
Source: http://www.navyband.navy.mil/anthems/national_anthems.htm
Author: United States Navy Band (rendition), uploaded to Wikimedia by Keith Lehwald
Licencing:
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
to share to copy, distribute and transmit the work
to remix to adapt the work
Under the following conditions:
attribution You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
share alike If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
-------------------------------------------------------------------------------------------------
Bob lamp
http://www.katsbits.com/download/models/md5-example.php
Original file:
bob_lamp_update.zip (Animated MD5 sample file)
Summary:
Description: Updated version of "Bob", a low-poly character mesh for general export and testing of MD5 mesh and animation - "*.md5mesh" and "*.md5anim". File and it's contents should be opened in Blender 2.69 or above to avoid compatibility issues with older versions of Blender and/or resulting MD5 exports (md5mesh & md5anim).
File includes two versions of the source file, one 'working' - mesh is intact with surfaces in 'quad' form; and one 'prepped' (exported) - mesh has been tessilated (triangulated) for export.
Date: Januari 2014
Source: http://www.katsbits.com/download/models/md5-example.php
Author: KatsBits
Licencing:
Please, refer to "Bob lamp/Readme.txt" file.
-------------------------------------------------------------------------------------------------
Standford dragon
http://graphics.stanford.edu/data/3Dscanrep/
Original file:
dragon_recon.tar.gz (PLY files)
Summary:
Dragon
Source: Stanford University Computer Graphics Laboratory
Scanner: Cyberware 3030 MS + spacetime analysis
Number of scans: ~70
Total size of scans: 2,748,318 points (about 5,500,000 triangles)
Reconstruction: vrip (conservatively decimated)
Size of reconstruction: 566,098 vertices, 1,132,830 triangles
Comments: contains numerous small holes
Date: 1996
Source: http://graphics.stanford.edu/data/3Dscanrep/
Author: Stanford University Computer Graphics Laboratory
Licencing:
Please be sure to acknowledge the source of the data and models you take from this repository. In each of the listings below, we have cited the source of the range data and reconstructed models. You are welcome to use the data and models for research purposes. You are also welcome to mirror or redistribute them for free. Finally, you may publish images made using these models, or the images on this web site, in a scholarly article or book - as long as credit is given to the Stanford Computer Graphics Laboratory. However, such models or images are not to be used for commercial purposes, nor should they appear in a product for sale (with the exception of scholarly journals or books), without our permission.
Please, refer to "dragon_recon/README" file.

View File

@@ -1,27 +0,0 @@
Surface Reconstructions
Stanford Range Repository
Computer Graphics Laboratory
Stanford University
August 4, 1996
These files are the result of reconstructing a set of range images
using the "vrip" program. The first file is the high resolution
result, while the "_res*" files are decimated versions. Note that
these decimations were performed using a crude algorithm that does not
necessarily preserve mesh topology. While they are not beautiful,
they are suitable for interactive rendering.
Note that this model is a decimated version of the original which was
constructed at the voxel resolution of 0.35 mm. The original model
has no holes in it, however, the decimated model has some holes that
we detected with software, but not by inspection. Apparently, the
decimation software introduced these holes.
For more information, consult the web pages of the Stanford Graphics
Laboratory:
http://www-graphics.stanford.edu

View File

@@ -1,24 +0,0 @@
function test_Test()
local test = Test(1)
local i = test:GetI()
local result = Test.StaticMethodWithArguments(i, i)
local finalTest = Test(result + test:GetDefault(), true)
CheckTest(test)
CheckStatic(result)
CheckFinalTest(finalTest)
end
function test_InheritTest()
local test = InheritTest()
CheckInheritTest(test)
end
function test_TestHandle()
local test = TestHandle()
CheckTestHandle()
end

View File

@@ -1,15 +0,0 @@
function even (x)
coroutine.yield(1)
end
function odd (x)
coroutine.yield(0)
end
function infinite (x)
for i=1,x do
if i==3 then coroutine.yield(-1) end
if i % 2 == 0 then even(i) else odd(i) end
end
end

22
tests/xmake.lua Normal file
View File

@@ -0,0 +1,22 @@
target("NazaraClientUnitTests")
set_group("Tests")
set_kind("binary")
add_deps("NazaraClientSDK")
add_files("main_client.cpp")
add_files("resources.cpp")
add_files("Engine/**.cpp")
target("NazaraUnitTests")
set_group("Tests")
set_kind("binary")
add_deps("NazaraSDK")
add_files("main.cpp")
add_files("resources.cpp")
add_files("Engine/**.cpp")
add_files("SDK/**.cpp")
del_files("Engine/Audio/**")
del_files("SDK/NDK/Application.cpp")
del_files("SDK/NDK/Systems/ListenerSystem.cpp")