Class UITestFixture
Test fixture base class that creates a UIToolkit panel without the resources needed for an EditorWindow.
Inherited Members
Namespace: UnityEngine.UIElements.TestFramework
Assembly: Unity.UI.TestFramework.Runtime.dll
Syntax
public abstract class UITestFixture : AbstractUITestFixture
Remarks
Use this class when the UIToolkit content being tested can be decoupled from an actual EditorWindow.
If an EditorWindow is required for the test, use EditorWindowUITestFixture<EditorWindowType> instead.
To temporarily create an EditorWindow while developing or debugging tests that would otherwise use this class, see DebugUITestFixture.
From a playmode context, it will run as a RuntimeUITestFixture, using a default runtime theme.
UITestFrameworkRuntimeOptions to set a default runtime stylesheet."/>
Constructors
UITestFixture()
Instantiates a UITestFixture using the AutoDetect functionality.
Declaration
protected UITestFixture()
UITestFixture(bool)
Instantiates a UITestFixture using the AutoDetect functionality.
Declaration
protected UITestFixture(bool debugMode)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | debugMode | Enables debugging for Editor tests, functioning as |
UITestFixture(FixtureType, bool)
Instantiates a UITestFixture for the supplied fixtureType.
Declaration
protected UITestFixture(UITestFixture.FixtureType fixtureType, bool debugMode = false)
Parameters
| Type | Name | Description |
|---|---|---|
| UITestFixture.FixtureType | fixtureType | The type of test fixture to create. |
| bool | debugMode | Enables debugging for Editor tests, functioning as |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Throws when trying to create an Editor |
Properties
clearContentAfterTest
When set to true, the rootVisualElement will be cleared after each test.
Declaration
public override sealed bool clearContentAfterTest { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
panelSize
The size of the root VisualElement of the panel.
Declaration
public override sealed Vector2 panelSize { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Overrides
simulate
Returns the PanelSimulator used by the test fixture.
Declaration
public override sealed PanelSimulator simulate { get; set; }
Property Value
| Type | Description |
|---|---|
| PanelSimulator |
Overrides
Remarks
Use this property to interact with the simulated panel.
themeStyleSheet
Theme style sheet used by this test fixture.
Declaration
public override sealed ThemeStyleSheet themeStyleSheet { get; set; }
Property Value
| Type | Description |
|---|---|
| ThemeStyleSheet |
Overrides
Remarks
Defaults to null.
When the value is null, the style applied will be the default theme style sheet.
Methods
AddTestComponent(UITestComponent)
Adds the component to the test fixture.
Declaration
public override sealed void AddTestComponent(UITestComponent component)
Parameters
| Type | Name | Description |
|---|---|---|
| UITestComponent | component | The UITestComponent to add to the test fixture. |
Overrides
Remarks
Adding the component to the test fixture triggers relevant
UITestComponent virtual methods based on the current test state.
FindTestComponent<T>()
Returns the first component of type T attached to the test fixture.
Declaration
public override sealed T FindTestComponent<T>()
Returns
| Type | Description |
|---|---|
| T | The first component of type T. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of |
Overrides
FixtureOneTimeSetUp()
Sets up the test fixture.
Declaration
public override void FixtureOneTimeSetUp()
Overrides
FixtureOneTimeTearDown()
Tears down the test fixture.
Declaration
public override void FixtureOneTimeTearDown()
Overrides
FixtureSetUp()
Sets up the test.
Declaration
public override void FixtureSetUp()
Overrides
FixtureTearDown()
Tears down the test.
Declaration
public override void FixtureTearDown()
Overrides
RecreatePanel()
Recreates the simulated UIToolkit panel, providing a fresh instance.
Declaration
public override sealed void RecreatePanel()
Overrides
ReleasePanel()
Releases the currently simulated UIToolkit panel.
Declaration
public override sealed void ReleasePanel()
Overrides
RemoveTestComponent(UITestComponent)
Removes the component from the test fixture.
Declaration
public override sealed void RemoveTestComponent(UITestComponent component)
Parameters
| Type | Name | Description |
|---|---|---|
| UITestComponent | component | The UITestComponent to remove from the test fixture. |
Overrides
Remarks
Removing the component from the test fixture triggers relevant
UITestComponent virtual methods based on on the current test state.