Skip to content

Commit a7aeda6

Browse files
committed
more tests
1 parent 12e6ef4 commit a7aeda6

File tree

4 files changed

+122
-24
lines changed

4 files changed

+122
-24
lines changed
Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
11
{
22
"UserEvents": {
3-
"vchel": [
3+
"vchel": [],
4+
"Owner": [],
5+
"d1638316d18f4a1e23a287aaaa12b6c540f704e257a6549bc9a672497ccc934e": [
46
{
5-
"NewName": "FormsScreenGum.ListBoxInstance",
7+
"NewName": "TestScreen.TextWrappingSetInGumRelativeToChildren1",
68
"OldName": null,
79
"ElementType": "Screens",
810
"EventType": 5,
9-
"TimestampUtc": "2025-02-01T11:51:39.9152236Z"
11+
"TimestampUtc": "2025-02-16T18:22:43.5936725Z"
1012
},
1113
{
12-
"NewName": "FormsScreenGum.PreFilledListBox",
13-
"OldName": "FormsScreenGum.ListBoxInstance",
14+
"NewName": "TestScreen.TruncateVerticalTextInstance",
15+
"OldName": "TestScreen.TextWrappingSetInGumRelativeToChildren1",
1416
"ElementType": "Screens",
1517
"EventType": 7,
16-
"TimestampUtc": "2025-02-01T11:51:46.4248279Z"
18+
"TimestampUtc": "2025-02-16T18:22:58.8773212Z"
1719
},
1820
{
19-
"NewName": "FormsScreenGum.ListBoxItemInstance",
20-
"OldName": null,
21-
"ElementType": "Screens",
22-
"EventType": 5,
23-
"TimestampUtc": "2025-02-01T11:52:11.0317194Z"
24-
},
25-
{
26-
"NewName": "FormsScreenGum.ListBoxItemInstance1",
27-
"OldName": null,
21+
"NewName": "TestScreen.TruncateVerticalTextInstance",
22+
"OldName": "TestScreen.TextWrappingSetInGumRelativeToChildren1",
2823
"ElementType": "Screens",
29-
"EventType": 5,
30-
"TimestampUtc": "2025-02-01T11:52:15.2735895Z"
24+
"EventType": 7,
25+
"TimestampUtc": "2025-02-16T18:22:58.8783221Z"
3126
},
3227
{
33-
"NewName": "FormsScreenGum.ListBoxItemInstance2",
34-
"OldName": null,
28+
"NewName": "TestScreen.TruncateVerticalTextInstance",
29+
"OldName": "TestScreen.TextWrappingSetInGumRelativeToChildren1",
3530
"ElementType": "Screens",
36-
"EventType": 5,
37-
"TimestampUtc": "2025-02-01T11:52:16.8730004Z"
31+
"EventType": 7,
32+
"TimestampUtc": "2025-02-16T18:22:58.8793235Z"
3833
}
39-
],
40-
"Owner": []
34+
]
4135
}
4236
}

Tests/TestProjectDesktopNet6/TestProjectDesktopNet6/Content/GumProject/Screens/TestScreen.gusx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,59 @@ wrap the text.</Value>
13411341
<Value xsi:type="xsd:float">4</Value>
13421342
<SetsValue>true</SetsValue>
13431343
</Variable>
1344+
<Variable>
1345+
<Type>int</Type>
1346+
<Name>TruncateVerticalTextInstance.FontSize</Name>
1347+
<Value xsi:type="xsd:int">14</Value>
1348+
<SetsValue>true</SetsValue>
1349+
</Variable>
1350+
<Variable>
1351+
<Type>float</Type>
1352+
<Name>TruncateVerticalTextInstance.Height</Name>
1353+
<Value xsi:type="xsd:float">33</Value>
1354+
<SetsValue>true</SetsValue>
1355+
</Variable>
1356+
<Variable>
1357+
<Type>string</Type>
1358+
<Name>TruncateVerticalTextInstance.Parent</Name>
1359+
<SetsValue>true</SetsValue>
1360+
</Variable>
1361+
<Variable>
1362+
<Type>string</Type>
1363+
<Name>TruncateVerticalTextInstance.Text</Name>
1364+
<Value xsi:type="xsd:string">This text has multiple lines. They should truncate after a few.</Value>
1365+
<SetsValue>true</SetsValue>
1366+
</Variable>
1367+
<Variable>
1368+
<Type>TextOverflowVerticalMode</Type>
1369+
<Name>TruncateVerticalTextInstance.TextOverflowVerticalMode</Name>
1370+
<Value xsi:type="xsd:int">1</Value>
1371+
<SetsValue>true</SetsValue>
1372+
</Variable>
1373+
<Variable>
1374+
<Type>float</Type>
1375+
<Name>TruncateVerticalTextInstance.Width</Name>
1376+
<Value xsi:type="xsd:float">90</Value>
1377+
<SetsValue>true</SetsValue>
1378+
</Variable>
1379+
<Variable>
1380+
<Type>DimensionUnitType</Type>
1381+
<Name>TruncateVerticalTextInstance.WidthUnits</Name>
1382+
<Value xsi:type="xsd:int">0</Value>
1383+
<SetsValue>true</SetsValue>
1384+
</Variable>
1385+
<Variable>
1386+
<Type>float</Type>
1387+
<Name>TruncateVerticalTextInstance.X</Name>
1388+
<Value xsi:type="xsd:float">627</Value>
1389+
<SetsValue>true</SetsValue>
1390+
</Variable>
1391+
<Variable>
1392+
<Type>float</Type>
1393+
<Name>TruncateVerticalTextInstance.Y</Name>
1394+
<Value xsi:type="xsd:float">793</Value>
1395+
<SetsValue>true</SetsValue>
1396+
</Variable>
13441397
<Variable>
13451398
<Type>string</Type>
13461399
<Name>TypedContainer.ContainedType</Name>
@@ -1377,6 +1430,11 @@ wrap the text.</Value>
13771430
<Value xsi:type="xsd:float">440.5</Value>
13781431
<SetsValue>true</SetsValue>
13791432
</Variable>
1433+
<Variable>
1434+
<Type>VerticalTruncationState</Type>
1435+
<Name>VerticalTruncationStateState</Name>
1436+
<SetsValue>true</SetsValue>
1437+
</Variable>
13801438
</State>
13811439
<Category>
13821440
<Name>StateCategory1</Name>
@@ -1399,6 +1457,27 @@ wrap the text.</Value>
13991457
</Variable>
14001458
</State>
14011459
</Category>
1460+
<Category>
1461+
<Name>VerticalTruncationState</Name>
1462+
<State>
1463+
<Name>YesTruncate</Name>
1464+
<Variable>
1465+
<Type>TextOverflowVerticalMode</Type>
1466+
<Name>TruncateVerticalTextInstance.TextOverflowVerticalMode</Name>
1467+
<Value xsi:type="xsd:int">1</Value>
1468+
<SetsValue>true</SetsValue>
1469+
</Variable>
1470+
</State>
1471+
<State>
1472+
<Name>NoTruncate</Name>
1473+
<Variable>
1474+
<Type>TextOverflowVerticalMode</Type>
1475+
<Name>TruncateVerticalTextInstance.TextOverflowVerticalMode</Name>
1476+
<Value xsi:type="xsd:int">0</Value>
1477+
<SetsValue>true</SetsValue>
1478+
</Variable>
1479+
</State>
1480+
</Category>
14021481
<Instance>
14031482
<Name>TextWithDefaultBitmapFont</Name>
14041483
<BaseType>Text</BaseType>
@@ -1624,6 +1703,11 @@ wrap the text.</Value>
16241703
<BaseType>Text</BaseType>
16251704
<DefinedByBase>false</DefinedByBase>
16261705
</Instance>
1706+
<Instance>
1707+
<Name>TruncateVerticalTextInstance</Name>
1708+
<BaseType>Text</BaseType>
1709+
<DefinedByBase>false</DefinedByBase>
1710+
</Instance>
16271711
<Instance>
16281712
<Name>NewlineWidthTest</Name>
16291713
<BaseType>Text</BaseType>

Tests/TestProjectDesktopNet6/TestProjectDesktopNet6/Screens/FormsScreen.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ public partial class FormsScreen
7272

7373
void CustomInitialize()
7474
{
75+
DialogBox_ShouldHaveMultiplePages_WhenEnteringLongText();
7576
Forms_ShouldRemoveInternalBinding_WhenBindingContextChanges();
7677

7778
Binding_ShouldCascadeToChildren_WhenChildrenAreAddedToParent();
7879

7980
DerivedControls_ShouldHaveVisualCreated_WhenInstantiated();
8081

81-
DialogBox_ShouldHaveMultiplePages_WhenEnteringLongText();
8282
DialogBox_ShouldWrapTextProperly_WhenShowingMultiplePages();
8383

8484
ListBox_ShouldRaiseSelectectionChanged_WhenSelectedObjectIsSet();
@@ -156,6 +156,10 @@ private void DialogBox_ShouldHaveMultiplePages_WhenEnteringLongText()
156156
dialogBoxString += "This is a long string.\n";
157157
}
158158

159+
var textInstance = dialogBox.Visual.GetGraphicalUiElementByName("TextInstance");
160+
textInstance.HeightUnits.ShouldNotBe(Gum.DataTypes.DimensionUnitType.RelativeToChildren);
161+
textInstance.TextOverflowVerticalMode.ShouldBe(RenderingLibrary.Graphics.TextOverflowVerticalMode.TruncateLine);
162+
159163
dialogBox.Show(dialogBoxString);
160164
dialogBox.PagesRemaining.ShouldNotBe(0, "because this text should be long enough to require multiple pages");
161165

Tests/TestProjectDesktopNet6/TestProjectDesktopNet6/Screens/GumScreen.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ void CustomInitialize()
8585
TextGue_ShouldMatchInternalText_WhenMismatchOccursOnAssignment();
8686

8787
TextGue_ShouldMatchInternalText_WhenAssigignedOnTextRuntime();
88+
89+
TextGue_ShouldTruncate_WhenSetToTruncate();
90+
}
91+
92+
private void TextGue_ShouldTruncate_WhenSetToTruncate()
93+
{
94+
var text = this.GumScreen_.GetGraphicalUiElementByName("TruncateVerticalTextInstance") as TextRuntime;
95+
96+
text.TextOverflowVerticalMode.ShouldBe(TextOverflowVerticalMode.TruncateLine);
97+
98+
EntireGumScreen.CurrentVerticalTruncationStateState = TestScreenRuntime.VerticalTruncationState.NoTruncate;
99+
text.TextOverflowVerticalMode.ShouldBe(TextOverflowVerticalMode.SpillOver);
100+
101+
EntireGumScreen.CurrentVerticalTruncationStateState = TestScreenRuntime.VerticalTruncationState.YesTruncate;
102+
text.TextOverflowVerticalMode.ShouldBe(TextOverflowVerticalMode.TruncateLine);
103+
88104
}
89105

90106
private void TextGue_ShouldMatchInternalText_WhenMismatchOccursOnAssignment()

0 commit comments

Comments
 (0)