using System.IO; using NUnit.Framework; using Robust.Client.Interfaces.UserInterface; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.Utility; using Robust.Shared.Interfaces.Resources; using Robust.Shared.IoC; using Robust.Shared.Utility; using Robust.Shared.Maths; namespace Robust.UnitTesting.Client.UserInterface { [TestFixture] [TestOf(typeof(Control))] public class ControlTest : RobustUnitTest { public override UnitTestProject Project => UnitTestProject.Client; private const string Data = @"[gd_scene format=2] [node name=""Root"" type=""Control"" index=""0""] [node name=""Child1"" type=""Panel"" parent=""."" index=""0""] [node name=""Child2"" type=""Label"" parent=""."" index=""1""] [node name=""Child11"" type=""VBoxContainer"" parent=""Child1"" index=""0""] [node name=""Child12"" type=""LineEdit"" parent=""Child1"" index=""1""] [node name=""Child21"" type=""Button"" parent=""Child2"" index=""0""] "; [OneTimeSetUp] public void Setup() { var cache = IoCManager.Resolve(); var data = EncodingHelpers.UTF8.GetBytes(Data); var stream = new MemoryStream(data); cache.MountStreamAt(stream, new ResourcePath("/Scenes/Test/TestScene.tscn")); IoCManager.Resolve().InitializeTesting(); } [Test] public void TestManualSpawn() { var asset = (GodotAssetScene) GodotParser.Parse(new StringReader(Data)); var control = Control.ManualSpawnFromScene(asset); Assert.That(control.Name, Is.EqualTo("Root")); var child1 = control.GetChild("Child1"); var child11 = child1.GetChild("Child11"); var child12 = child1.GetChild("Child12"); var child2 = control.GetChild