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 EditorWindow to create with this test fixture. |
Remarks
Use this class as a base when the UI is defined in the CreateGUI method or
if the window explicitly contains IMGUI content that needs a GUIView to run properly.
If an EditorWindow is not strictly required and an Editor Panel (UI Toolkit panel) is sufficient, use UITestFixture instead.
Constructors
EditorWindowUITestFixture()
Instantiates an empty EditorWindow test fixture.
Declaration
protected EditorWindowUITestFixture()
Remarks
Use the simulate property to access the UIToolkit 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
By default, if this function is not set, the EditorWindow instance will be created using CreateInstance(Type).
Use this function to designate an alternate window creation function.
This function will be called at the beginning of the test fixture,
or at the beginning of a test if the window is null.
debugMode
Property which determines whether the window should remain open at the end of a failed test for debugging purposes. Default is false (off).
Declaration
public bool debugMode { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Set this property to true if you want the window to remain open for manual debugging after a test failure.
Should be set to false when running tests in batch mode.
needsImprovedIMGUISupport
Property which determines whether the EditorWindowPanelSimulator.FrameUpdate()
should be called within an IMGUI context. Default is false.
Declaration
public bool needsImprovedIMGUISupport { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
panelSize
The size of the root VisualElement 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 will be Closed() and destroyed.
Use this function to designate an alternate window release function.
This function will be 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)
Execute 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 or 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()