Class EditorWindowUITestFixture<EditorWindowType>
Test fixture base class that creates an EditorWindow.
Inheritance
Inherited Members
Namespace: UnityEditor.UIElements.TestFramework
Assembly: Unity.UI.TestFramework.Editor.dll
Syntax
public abstract class EditorWindowUITestFixture<EditorWindowType> : CommonUITestFixture where EditorWindowType : EditorWindow
Type Parameters
| Name | Description |
|---|---|
| EditorWindowType | The type of |
Remarks
Inherit from this class when your UI is defined in the CreateGUI method,
or when your window contains IMGUI content that requires a GUIView context.
If you don't require an actual EditorWindow and an Editor panel is sufficient,
use UITestFixture instead.
Constructors
EditorWindowUITestFixture()
Instantiates an empty EditorWindowUITestFixture.
Declaration
protected EditorWindowUITestFixture()
Remarks
Use the simulate property to access the UI Toolkit panel. Use the window property to access the window.
Properties
createWindowFunction
Creates a new window.
Declaration
public Func<EditorWindowType> createWindowFunction { get; set; }
Property Value
| Type | Description |
|---|---|
| Func<EditorWindowType> |
Remarks
If not set, the EditorWindow instance is created using CreateInstance(Type).
Use it to designate an alternate window creation function.
Called when the test fixture starts or the window is null at test start.
needsImprovedIMGUISupport
Whether to call FrameUpdate(double)
within an IMGUI context. Defaults to false.
Declaration
public bool needsImprovedIMGUISupport { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
panelSize
The size of the rootVisualElement of the panel.
Declaration
public override sealed Vector2 panelSize { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Overrides
releaseWindowFunction
Releases the window.
Declaration
public Action<EditorWindowType> releaseWindowFunction { get; set; }
Property Value
| Type | Description |
|---|---|
| Action<EditorWindowType> |
Remarks
By default, if this function is not set, the EditorWindow instance is Closed() and destroyed.
Use this function to designate an alternate window release function.
This function is called at the end of the test fixture,
or at the end of a test if it has failed.
window
EditorWindow created by the test fixture. Null if no window is created.
Declaration
protected EditorWindowType window { get; }
Property Value
| Type | Description |
|---|---|
| EditorWindowType |
Remarks
The window is reused for the entire duration of the test fixture except if a test fails. In that case, the next test creates a new window.
Methods
ExecuteWithinIMGUIContext(Action)
Executes the given command within a valid IMGUI context.
Declaration
protected void ExecuteWithinIMGUIContext(Action command)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | command | The |
FixtureOneTimeSetUp()
Sets up the test fixture. Creates and sets up the window.
Declaration
public override void FixtureOneTimeSetUp()
Overrides
FixtureOneTimeTearDown()
Tears down the test fixture.
When a test fails and debugMode is set to true, windows are left open.
Declaration
public override void FixtureOneTimeTearDown()
Overrides
FixtureSetUp()
Sets up the test. Creates and initializes the window if it is null.
Declaration
public override void FixtureSetUp()
Overrides
FixtureTearDown()
Tears down the test.
When a test fails, closes and recreates the window from scratch.
When debugMode is set to true, windows of failed tests are left open.
Declaration
public override void FixtureTearDown()
Overrides
RecreatePanel()
Recreates the panel. Calls createWindowFunction if it's set; otherwise, creates the window using CreateInstance(Type).
Declaration
public override void RecreatePanel()
Overrides
ReleasePanel()
Releases the panel. Calls releaseWindowFunction if it's set; otherwise, closes and destroys the window.
Declaration
public override void ReleasePanel()