Skip to content

Commit 34d8162

Browse files
committed
Expand data-alias test
1 parent 801b239 commit 34d8162

File tree

3 files changed

+32
-39
lines changed

3 files changed

+32
-39
lines changed

Samples/assets/data-window.rml

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template name="data-title">
2+
<head></head>
3+
<body>
4+
<div class="title-wrapper">
5+
<handle move_target="#document">
6+
<div class="icon" data-attr-icon="icon"></div>
7+
<span class="title">{{ title }}</span>
8+
</handle>
9+
</div>
10+
</body>
11+
</template>

Tests/Source/UnitTests/DataBinding.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ static const String document_rml = R"(
4343
<rml>
4444
<head>
4545
<title>Test</title>
46-
<link type="text/rcss" href="/assets/rml.rcss"/>
4746
<link type="text/template" href="/assets/window.rml"/>
4847
<style>
4948
body.window
@@ -118,7 +117,6 @@ static const String inside_string_rml = R"(
118117
<rml>
119118
<head>
120119
<title>Test</title>
121-
<link type="text/rcss" href="/assets/rml.rcss"/>
122120
<link type="text/template" href="/assets/window.rml"/>
123121
<style>
124122
body.window
@@ -153,21 +151,33 @@ static const String aliasing_rml = R"(
153151
<head>
154152
<title>Test</title>
155153
<link type="text/rcss" href="/assets/rml.rcss"/>
156-
<link type="text/template" href="/assets/data-window.rml"/>
154+
<link type="text/rcss" href="/assets/invader.rcss"/>
155+
<link type="text/template" href="/../Tests/Data/UnitTests/data-title.rml"/>
156+
<style>
157+
body {
158+
width: 600px;
159+
height: 400px;
160+
background: #ccc;
161+
color: #333;
162+
}
163+
.title-wrapper { border: 1dp red; }
164+
.icon { width: 64dp; height: 64dp; display: inline-block; }
165+
.icon[icon="a"] { decorator: image("/assets/high_scores_alien_1.tga"); }
166+
.icon[icon="b"] { decorator: image("/assets/high_scores_alien_2.tga"); }
167+
</style>
157168
</head>
158169
159170
<body data-model="basics">
160171
<p>{{ i0 }}</p>
161172
<p data-alias-differentname="i0">{{ differentname }}</p>
162-
<div data-alias-title="s0" id="w1">
163-
<template src="data-window"></template>
173+
<div data-alias-title="s0" data-alias-icon="wrapped.a.val" id="w1">
174+
<template src="data-title"/>
164175
</div>
165-
166-
<div data-alias-title="s1" id="w2">
167-
<template src="data-window"></template>
176+
<div data-alias-title="s1" data-alias-icon="wrapped.b.val" id="w2">
177+
<template src="data-title"/>
168178
</div>
169179
</body>
170-
</rml>
180+
</rml>
171181
)";
172182

173183
struct StringWrap
@@ -439,9 +449,6 @@ TEST_CASE("databinding")
439449
REQUIRE(document);
440450
document->Show();
441451

442-
context->Update();
443-
context->Render();
444-
445452
TestsShell::RenderLoop();
446453

447454
document->Close();
@@ -460,9 +467,6 @@ TEST_CASE("databinding.inside_string")
460467
REQUIRE(document);
461468
document->Show();
462469

463-
context->Update();
464-
context->Render();
465-
466470
TestsShell::RenderLoop();
467471

468472
CHECK(document->QuerySelector("p:nth-child(4)")->GetInnerRML() == "before i{{test}}23 test");
@@ -483,16 +487,13 @@ TEST_CASE("databinding.aliasing")
483487
REQUIRE(document);
484488
document->Show();
485489

486-
context->Update();
487-
context->Render();
488-
489490
TestsShell::RenderLoop();
490491

491492
CHECK(document->QuerySelector("p:nth-child(1)")->GetInnerRML() == document->QuerySelector("p:nth-child(2)")->GetInnerRML());
492-
REQUIRE(document->QuerySelector("#w1 .title"));
493-
REQUIRE(document->QuerySelector("#w2 .title"));
494493
CHECK(document->QuerySelector("#w1 .title")->GetInnerRML() == "s0");
494+
CHECK(document->QuerySelector("#w1 .icon")->GetAttribute("icon", String()) == "a");
495495
CHECK(document->QuerySelector("#w2 .title")->GetInnerRML() == "s1");
496+
CHECK(document->QuerySelector("#w2 .icon")->GetAttribute("icon", String()) == "b");
496497

497498
document->Close();
498499

0 commit comments

Comments
 (0)