docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Create multi-window tests

    The test fixtures instantiate one panel and manage its lifetime for you. However, some tests require multiple panels or windows to simulate complex UI interactions. You can create and manage multiple PanelSimulator instances in your tests to achieve this. Each PanelSimulator can represent a different panel or window, allowing you to test interactions between them.

    PanelSimulator types

    There are different types of PanelSimulator, each designed to work in specific environments or scenarios. The test fixture you select determines what type of UI the test fixture initializes.

    The following table summarizes the different PanelSimulator types used by each test fixture:

    Test fixture Simulator Type Description
    UITestFixture RuntimePanelSimulator or EditorPanelSimulator Simulates a panel in either the runtime or Editor environment.
    DebugUITestFixture EditorWindowPanelSimulator Simulates a panel within an Editor window.
    EditorWindowUITestFixture EditorWindowPanelSimulator Simulates a panel within an Editor window.
    RuntimeUITestFixture RuntimePanelSimulator Simulates a panel in the runtime environment.

    Example

    The following example shows how to create multiple EditorWindowPanelSimulator instances in a test:

    public class SimulateMultipleWindows : EditorWindowUITestFixture<UITestFrameworkDocSampleWindow>
    {
        [Test]
        public void MultipleWindowsExampleTest()
        {
            // Use the CleanupUtil UITestComponent to manage the ScriptableObject cleanup.
            CleanupUtil cleanupUtil = AddTestComponent<CleanupUtil>();
    
            // Ensure the main test UI is updated.
            simulate.FrameUpdate();
    
            // Create a new EditorWindow for testing.
            EditorWindow window = ScriptableObject.CreateInstance<EditorWindow>();
            window.Show();
    
            // Ensure the new window will be properly destroyed.
            cleanupUtil.AddDestructible(window);
    
            // Hook up the EditorWindow as a simulator.
            EditorWindowPanelSimulator secondEditorWindow =
                new EditorWindowPanelSimulator(window);
    
            // Ensure the UI for the second window is updated.
            secondEditorWindow.FrameUpdate();
    
            // Test steps.
            // ...
        }
    }
    

    Additional resources

    • Trigger and update UI
    • PanelSimulator
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)