mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-07-31 07:48:52 -04:00
* Move all unit tests to Engine/Tests * Fix Margin.EdgeSubtract * Fix Capsule.Contains * EnvironmentVariables.Remove if it's null * Fixed ray trace never returning startedsolid * Fix HistoryList.Navigate on empty list * Fix GameObject.WorldPosition accepting NaNs * Fix flex: initial expanding to the wrong grow/shrink * Translation.TryConvert shouldn't throw on invalid enum strings * Skip sound file tests on machines with no audio device
69 lines
1.6 KiB
C#
69 lines
1.6 KiB
C#
using Sandbox.UI;
|
|
namespace UITests.Panels;
|
|
|
|
[TestClass]
|
|
[DoNotParallelize] // Modfiies UI System Global
|
|
public partial class DisplayNoneTest
|
|
{
|
|
[TestMethod]
|
|
public void BasicNone()
|
|
{
|
|
var root = new RootPanel();
|
|
root.PanelBounds = new Rect( 0, 0, 1000, 1000 );
|
|
|
|
var panela = root.Add.Panel();
|
|
panela.Style.Set( "display: none;" );
|
|
|
|
var panelb = root.Add.Panel();
|
|
panelb.Style.Set( "width: 100px; height: 100px;" );
|
|
|
|
root.Layout();
|
|
|
|
// Should be flowing downwards by default
|
|
|
|
Assert.AreEqual( 0, panela.Box.Left );
|
|
Assert.AreEqual( 0, panela.Box.Top );
|
|
Assert.AreEqual( false, panela.IsVisible );
|
|
|
|
Assert.AreEqual( 0, panelb.Box.Left );
|
|
Assert.AreEqual( 0, panelb.Box.Top );
|
|
}
|
|
|
|
[TestMethod]
|
|
public void BasicSwitch()
|
|
{
|
|
var root = new RootPanel();
|
|
root.PanelBounds = new Rect( 0, 0, 1000, 1000 );
|
|
|
|
var panela = root.Add.Panel();
|
|
panela.Style.Set( "display: flex; width: 100px; height: 100px;" );
|
|
|
|
var panelb = root.Add.Panel();
|
|
panelb.Style.Set( "width: 100px; height: 100px;" );
|
|
|
|
root.Layout();
|
|
|
|
// Should be flowing downwards by default
|
|
|
|
Assert.AreEqual( 0, panela.Box.Left );
|
|
Assert.AreEqual( 0, panela.Box.Top );
|
|
Assert.AreEqual( true, panela.IsVisible );
|
|
|
|
Assert.AreEqual( 100, panelb.Box.Left );
|
|
Assert.AreEqual( 0, panelb.Box.Top );
|
|
|
|
|
|
panela.Style.Set( "display: none;" );
|
|
root.Layout();
|
|
|
|
Assert.AreEqual( DisplayMode.None, panela.ComputedStyle.Display );
|
|
Assert.AreEqual( 0, panela.Box.Left );
|
|
Assert.AreEqual( 0, panela.Box.Top );
|
|
Assert.AreEqual( false, panela.IsVisible );
|
|
|
|
Assert.AreEqual( 0, panelb.Box.Left );
|
|
Assert.AreEqual( 0, panelb.Box.Top );
|
|
}
|
|
|
|
}
|