|
|
@@ -32,6 +32,7 @@
|
|
|
#include <RmlUi/Core/Core.h>
|
|
|
#include <RmlUi/Core/Element.h>
|
|
|
#include <RmlUi/Core/ElementDocument.h>
|
|
|
+#include <Shell.h>
|
|
|
#include <algorithm>
|
|
|
#include <doctest.h>
|
|
|
|
|
|
@@ -82,6 +83,39 @@ static const String document_textures_rml = R"(
|
|
|
</rml>
|
|
|
)";
|
|
|
|
|
|
+static const String document_basic_rml = R"(
|
|
|
+<rml>
|
|
|
+<head>
|
|
|
+ <title>Test</title>
|
|
|
+ <link type="text/rcss" href="/assets/rml.rcss"/>
|
|
|
+ <style>
|
|
|
+ body {
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ font-family: LatoLatin;
|
|
|
+ font-size: 16px;
|
|
|
+ }
|
|
|
+ @spritesheet aliens {
|
|
|
+ src: /assets/high_scores_alien_3.tga;
|
|
|
+ alien3: 0px 0px 64px 64px;
|
|
|
+ }
|
|
|
+ div.sprite {
|
|
|
+ height: 100px;
|
|
|
+ decorator: image(alien3);
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <img src="/assets/high_scores_alien_1.tga"/>
|
|
|
+ <div class="sprite"/>
|
|
|
+ abc
|
|
|
+</body>
|
|
|
+</rml>
|
|
|
+)";
|
|
|
+
|
|
|
static inline StringList GetSortedTextureSourceList()
|
|
|
{
|
|
|
StringList list = Rml::GetTextureSourceList();
|
|
|
@@ -281,3 +315,52 @@ TEST_CASE("core.observer_ptr")
|
|
|
|
|
|
TestsShell::ShutdownShell();
|
|
|
}
|
|
|
+
|
|
|
+TEST_CASE("core.RemoveContext")
|
|
|
+{
|
|
|
+ TestsSystemInterface* system_interface = TestsShell::GetTestsSystemInterface();
|
|
|
+ TestsRenderInterface* render_interface = TestsShell::GetTestsRenderInterface();
|
|
|
+ // This test only works with the dummy renderer.
|
|
|
+ if (!render_interface)
|
|
|
+ return;
|
|
|
+
|
|
|
+ const Vector2i window_size = {1280, 720};
|
|
|
+
|
|
|
+ Shell::Initialize();
|
|
|
+ Rml::SetSystemInterface(system_interface);
|
|
|
+ REQUIRE(Rml::GetRenderInterface() == nullptr);
|
|
|
+ REQUIRE(Rml::Initialise());
|
|
|
+ Shell::LoadFonts();
|
|
|
+
|
|
|
+ Context* context = Rml::CreateContext("main", window_size, render_interface);
|
|
|
+ REQUIRE(context);
|
|
|
+
|
|
|
+ ElementDocument* document = context->LoadDocumentFromMemory(document_basic_rml);
|
|
|
+ document->Show();
|
|
|
+
|
|
|
+ context->Update();
|
|
|
+ context->Render();
|
|
|
+
|
|
|
+ REQUIRE(Rml::RemoveContext(context->GetName()));
|
|
|
+
|
|
|
+ SUBCASE("Normal shutdown")
|
|
|
+ {
|
|
|
+ Rml::Shutdown();
|
|
|
+ TestsShell::ResetTestsRenderInterface();
|
|
|
+ }
|
|
|
+
|
|
|
+ SUBCASE("Destroy render interface before shutdown")
|
|
|
+ {
|
|
|
+ ReleaseRenderManagers();
|
|
|
+
|
|
|
+ const auto counters = render_interface->GetCounters();
|
|
|
+ CHECK(counters.release_texture == counters.generate_texture + counters.load_texture);
|
|
|
+ CHECK(counters.release_geometry == counters.compile_geometry);
|
|
|
+
|
|
|
+ TestsShell::ResetTestsRenderInterface();
|
|
|
+
|
|
|
+ Rml::Shutdown();
|
|
|
+ }
|
|
|
+
|
|
|
+ Shell::Shutdown();
|
|
|
+}
|