feat: start loading some stuff async
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <destrum/Serialization/SceneSerializer.h>
|
||||
#include <destrum/Threading/JobSystem.h>
|
||||
|
||||
#include "TestUtils.h"
|
||||
@@ -143,6 +146,21 @@ namespace {
|
||||
check(!Jobs().IsRunning(), "job system should be stopped");
|
||||
}
|
||||
|
||||
void testLoadSceneFileAsync()
|
||||
{
|
||||
Jobs().Init(2);
|
||||
const auto path = std::filesystem::temp_directory_path() / "destrum_async_scene.json";
|
||||
std::ofstream{path} << R"({"version":2,"name":"async","objects":[]})";
|
||||
|
||||
auto good = SceneSerializer::LoadSceneFileAsync(path);
|
||||
auto missing = SceneSerializer::LoadSceneFileAsync(path.parent_path() / "destrum_no_such_scene.json");
|
||||
check(good.get().success, "async scene load should parse a valid file");
|
||||
check(!missing.get().success, "async scene load should report a missing file");
|
||||
|
||||
std::filesystem::remove(path);
|
||||
Jobs().Shutdown();
|
||||
}
|
||||
|
||||
void testRunsInlineWhenStopped()
|
||||
{
|
||||
check(!Jobs().IsRunning(), "job system should start stopped");
|
||||
@@ -164,4 +182,5 @@ void RunJobsTests()
|
||||
testAsyncRethrows();
|
||||
testMainThreadQueue();
|
||||
testShutdownDrainsPendingJobs();
|
||||
testLoadSceneFileAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user