Browse Source

Expand data-alias test

Michael Ragazzon 2 years ago
parent
commit
34d81625e3

+ 0 - 19
Samples/assets/data-window.rml

@@ -1,19 +0,0 @@
-<template name="data-window" content="content">
-<head>
-	<link type="text/rcss" href="rml.rcss"/>
-	<link type="text/rcss" href="invader.rcss"/>
-</head>
-<body class="window">
-	<div id="title_bar">
-		<handle move_target="#document">
-			<div id="icon"></div>
-			<span class="title">{{ title }}</span>
-		</handle>
-	</div>
-	<div id="window">
-		<div id="content">
-		</div>
-	</div>
-	<handle size_target="#document" style="position: absolute; width: 16dp; height: 16dp; bottom: 0px; right: 0px; cursor: resize;"></handle>
-</body>
-</template>

+ 11 - 0
Tests/Data/UnitTests/data-title.rml

@@ -0,0 +1,11 @@
+<template name="data-title">
+<head></head>
+<body>
+<div class="title-wrapper">
+	<handle move_target="#document">
+		<div class="icon" data-attr-icon="icon"></div>
+		<span class="title">{{ title }}</span>
+	</handle>
+</div>
+</body>
+</template>

+ 21 - 20
Tests/Source/UnitTests/DataBinding.cpp

@@ -43,7 +43,6 @@ static const String document_rml = R"(
 <rml>
 <rml>
 <head>
 <head>
 	<title>Test</title>
 	<title>Test</title>
-	<link type="text/rcss" href="/assets/rml.rcss"/>
 	<link type="text/template" href="/assets/window.rml"/>
 	<link type="text/template" href="/assets/window.rml"/>
 	<style>
 	<style>
 		body.window
 		body.window
@@ -118,7 +117,6 @@ static const String inside_string_rml = R"(
 <rml>
 <rml>
 <head>
 <head>
 	<title>Test</title>
 	<title>Test</title>
-	<link type="text/rcss" href="/assets/rml.rcss"/>
 	<link type="text/template" href="/assets/window.rml"/>
 	<link type="text/template" href="/assets/window.rml"/>
 	<style>
 	<style>
 		body.window
 		body.window
@@ -153,21 +151,33 @@ static const String aliasing_rml = R"(
 <head>
 <head>
 	<title>Test</title>
 	<title>Test</title>
 	<link type="text/rcss" href="/assets/rml.rcss"/>
 	<link type="text/rcss" href="/assets/rml.rcss"/>
-	<link type="text/template" href="/assets/data-window.rml"/>
+	<link type="text/rcss" href="/assets/invader.rcss"/>
+	<link type="text/template" href="/../Tests/Data/UnitTests/data-title.rml"/>
+	<style>
+		body {
+			width: 600px;
+			height: 400px;
+			background: #ccc;
+			color: #333;
+		}
+		.title-wrapper { border: 1dp red; }
+		.icon { width: 64dp; height: 64dp; display: inline-block; }
+		.icon[icon="a"] { decorator: image("/assets/high_scores_alien_1.tga"); }
+		.icon[icon="b"] { decorator: image("/assets/high_scores_alien_2.tga"); }
+	</style>
 </head>
 </head>
 
 
 <body data-model="basics">
 <body data-model="basics">
 <p>{{ i0 }}</p>
 <p>{{ i0 }}</p>
 <p data-alias-differentname="i0">{{ differentname }}</p>
 <p data-alias-differentname="i0">{{ differentname }}</p>
-<div data-alias-title="s0" id="w1">
-	<template src="data-window"></template>
+<div data-alias-title="s0" data-alias-icon="wrapped.a.val" id="w1">
+	<template src="data-title"/>
 </div>
 </div>
-
-<div data-alias-title="s1" id="w2">
-	<template src="data-window"></template>
+<div data-alias-title="s1" data-alias-icon="wrapped.b.val" id="w2">
+	<template src="data-title"/>
 </div>
 </div>
 </body>
 </body>
-</rml>	
+</rml>
 )";
 )";
 
 
 struct StringWrap
 struct StringWrap
@@ -439,9 +449,6 @@ TEST_CASE("databinding")
 	REQUIRE(document);
 	REQUIRE(document);
 	document->Show();
 	document->Show();
 
 
-	context->Update();
-	context->Render();
-
 	TestsShell::RenderLoop();
 	TestsShell::RenderLoop();
 
 
 	document->Close();
 	document->Close();
@@ -460,9 +467,6 @@ TEST_CASE("databinding.inside_string")
 	REQUIRE(document);
 	REQUIRE(document);
 	document->Show();
 	document->Show();
 
 
-	context->Update();
-	context->Render();
-
 	TestsShell::RenderLoop();
 	TestsShell::RenderLoop();
 
 
 	CHECK(document->QuerySelector("p:nth-child(4)")->GetInnerRML() == "before i{{test}}23 test");
 	CHECK(document->QuerySelector("p:nth-child(4)")->GetInnerRML() == "before i{{test}}23 test");
@@ -483,16 +487,13 @@ TEST_CASE("databinding.aliasing")
 	REQUIRE(document);
 	REQUIRE(document);
 	document->Show();
 	document->Show();
 
 
-	context->Update();
-	context->Render();
-
 	TestsShell::RenderLoop();
 	TestsShell::RenderLoop();
 
 
 	CHECK(document->QuerySelector("p:nth-child(1)")->GetInnerRML() == document->QuerySelector("p:nth-child(2)")->GetInnerRML());
 	CHECK(document->QuerySelector("p:nth-child(1)")->GetInnerRML() == document->QuerySelector("p:nth-child(2)")->GetInnerRML());
-	REQUIRE(document->QuerySelector("#w1 .title"));
-	REQUIRE(document->QuerySelector("#w2 .title"));
 	CHECK(document->QuerySelector("#w1 .title")->GetInnerRML() == "s0");
 	CHECK(document->QuerySelector("#w1 .title")->GetInnerRML() == "s0");
+	CHECK(document->QuerySelector("#w1 .icon")->GetAttribute("icon", String()) == "a");
 	CHECK(document->QuerySelector("#w2 .title")->GetInnerRML() == "s1");
 	CHECK(document->QuerySelector("#w2 .title")->GetInnerRML() == "s1");
+	CHECK(document->QuerySelector("#w2 .icon")->GetAttribute("icon", String()) == "b");
 
 
 	document->Close();
 	document->Close();