Vixen
02b45cc4
csharp
public sealed class EditorSession

A whole editor under test: a project on disk, panels, and synthetic input into them.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The real application, not a rehearsal of one. Everything worth asserting about an editor — which panel a click landed in, what the inspector was handed, which of the several selections won, whether a saved scene comes back — is wiring that exists in the head and nowhere else. A harness that built its own shell and its own panels would be a harness for a copy of the thing that breaks.

⚠ The frame is EditorHost's four steps in EditorHost's order: the shell's tick, the layout, the application's update, the draw. The update has to sit between the layout and the draw because a viewport measures itself in render pixels from a box the layout pass produces — which is why Updated exists at all. A harness that ran it anywhere else would be one whose passing tests said nothing about the loop that ships.

⚠ No GPU, no window, no platform. The host's first four steps are all above the RHI, which is the same reason --frames N is a smoke test on a machine with no Vulkan. Everything up to and including the draw list runs here; only the submission does not.

Ui is the vocabulary and this type is the nouns. Selectors, waiting-in-frames, assertions and screenshots are all UiTest's and are not reimplemented; what is added here is everything that needs to know what an editor is — a panel id, a command id, a row in the outliner, a restart.

using var editor = EditorSession.Start(); editor.Step("select the crate") .Open("hierarchy") .ExpandAll(editor.Hierarchy) .ClickRow(editor.Hierarchy, "Crate") .Run("edit.delete") .Run("edit.undo"); editor.Ui.Contains("Crate").ShouldExist();

Fields and properties (20)

  • public UiTest Ui

    The document harness underneath: selectors, assertions, frames, pictures.

  • public string DataDirectory

    Where the user's layouts, keymap and theme live.

  • public string ProjectRoot

    The project's root on disk.

  • public IReadOnlyList<string> Trail

    The steps a scenario has announced, in order.

  • public EditorShell Shell

    The shell: commands, keymap, menus, docking, dialogs, notifications.

  • public UiDocument Document

    The interface tree, which is the shell's.

  • public EditorProject Project

    The project the editor has open.

  • public SceneDocument Scene

    The scene it is editing.

  • public SceneViewport? Viewport

    The focused pane, or while the scene panel is closed.

  • public IReadOnlyList<SceneViewport> Viewports

    Every pane of the scene panel, in reading order. Empty while it is closed.

  • public TreeView Hierarchy

    The outliner's tree.

  • public TreeView Assets

    The content browser's tree.

  • public IEditorRegistry Extensions

    What has been contributed to this editor, from every producer.

  • public PluginHost Plugins

    The plugin host, and through it what this editor publishes to a plugin.

  • public InspectorView Inspector

    The inspector.

  • public IReadOnlyList<DockPanel> Panels

    Every panel that is open, in document order.

  • public bool IsAsking

    Whether the editor is asking something.

  • public bool IsClosing

    Whether the editor has been asked to close and agreed to.

  • public string? PendingProject

    Where the editor has been asked to reopen, or .

  • public IReadOnlyList<(string Path, DateTime Opened)> RecentProjects

    The projects this editor has opened, newest first, as paths and times.

Methods (30)

  • public static EditorSession Start(EditorSessionOptions? options = null)

    Opens an editor.

  • public EditorSession Step(string what)

    Names what the next few commands are for, so a failure says where it was.

  • public void Frame()

    Runs one frame, the way the host does.

  • public void Frames(int count)

    Runs several.

  • public EditorSession Settle()

    Runs enough frames for whatever just happened to be visible.

  • public EditorSession Open(string id)

    Brings a panel forward, opening it if it is closed.

  • public EditorSession Close(string id)

    Closes a panel.

  • public DockPanel Panel(string id)

    The panel with an id, which must be open.

  • public TreeView Tree(string id)

    The tree inside a panel, by the id the arrangement knows the panel by.

  • public T Control<T>(string id) where T : UiElement

    The one control of a type inside a panel, opening the panel if it is closed.

  • public T Component<T>(string id) where T : Component

    The one VXML component of a type inside a panel, opening the panel if it is closed.

  • public UiSubject In(string id)

    Everything inside a panel, as a subject to select within.

  • public EditorSession Run(string command)

    Runs a command the way a menu line does, and waits for the consequences.

  • public bool CanRun(string command)

    Whether a command would run right now.

  • public EditorSession Menu(string menu, params string[] path)

    Opens a menu on the bar and chooses a line, by clicking both.

  • public TreeRow Row(TreeView tree, string text)

    The realised row showing some text.

  • public EditorSession ClickRow(TreeView tree, string text, ModifierKeys modifiers = None)

    Clicks the row showing some text.

  • public EditorSession DoubleClickRow(TreeView tree, string text)

    Double-clicks it, which renames in the outliner and opens in the browser.

  • public EditorSession RightClickRow(TreeView tree, string text)

    Right-clicks it, which is what opens a context menu on it.

  • public EditorSession ExpandAll(TreeView tree)

    Opens every node in a tree, so that a deep row is on screen to be clicked.

  • public static IEnumerable<TreeNode> NodesOf(TreeView tree)

    Every node in a tree, depth first.

  • public static IReadOnlyList<string> Labels(TreeView tree)

    What a tree is showing, top to bottom.

  • public EditorSession Answer(string label)

    Answers whatever dialog is on screen by pressing one of its buttons.

  • public EditorSession RequestProject(string root)

    Asks the editor to close this project and reopen over another.

  • public EditorSession RequestClose()

    Asks the editor to close, the way the window's close button does.

  • public EditorSession Click(UiElement element)

    Clicks the middle of an element.

  • public EditorSession Screenshot(string name)

    Takes a picture and compares it with the committed one.

  • public EditorSession Restart()

    Closes the editor and opens it again over the same directories.

  • public void Dispose()
  • public EditorSessionException Fail(string message)

    A failure that carries the scenario's trail and the interface it happened in.

Used by (44, showing 40)

  • AddComponentMenuTestsVixen.Editor.App.Tests
  • AnimationWiringTestsVixen.Editor.App.Tests
  • AssetPickerTestsVixen.Editor.App.Tests
  • AssetWatchTestsVixen.Editor.App.Tests
  • BehaviorAuthoringTestsVixen.Editor.App.Tests
  • BuildSettingsTestsVixen.Editor.App.Tests
  • ClosingTestsVixen.Editor.App.Tests
  • ComponentTestsVixen.Editor.App.Tests
  • ConsolePanelTestsVixen.Editor.App.Tests
  • CreateMenuTestsVixen.Editor.App.Tests
  • DeclaredContributionTestsVixen.Editor.App.Tests
  • DiagnosticsPanelTestsVixen.Editor.App.Tests
  • DropIntoFieldTestsVixen.Editor.App.Tests
  • DropIntoSceneTestsVixen.Editor.App.Tests
  • EditorAffordanceTestsVixen.Editor.App.Tests
  • EditorModeTestsVixen.Editor.App.Tests
  • EditorScriptWorkflowTestsVixen.Editor.App.Tests
  • GridViewTestsVixen.Editor.App.Tests
  • HarnessTestsVixen.Editor.App.Tests
  • IconContributionTestsVixen.Editor.App.Tests
  • InspectorPanelTestsVixen.Editor.App.Tests
  • KeyBindingsPanelTestsVixen.Editor.App.Tests
  • MenuBarTestsVixen.Editor.App.Tests
  • MilestoneE3TestsVixen.Editor.App.Tests
  • MilestoneE5TestsVixen.Editor.App.Tests
  • OneEditPathTestsVixen.Editor.App.Tests
  • OutOfTreePluginTestsVixen.Editor.App.Tests
  • OutlinerColumnTestsVixen.Editor.App.Tests
  • OutlinerTestsVixen.Editor.App.Tests
  • PanelBehaviourTestsVixen.Editor.App.Tests
  • ProjectBrowserTestsVixen.Editor.App.Tests
  • ProjectTreeStateTestsVixen.Editor.App.Tests
  • ScenarioTestsVixen.Editor.App.Tests
  • SceneMenuTestsVixen.Editor.App.Tests
  • SelectionTestsVixen.Editor.App.Tests
  • SettingsWindowTestsVixen.Editor.App.Tests
  • ShaderGraphSurfaceTestsVixen.Editor.App.Tests
  • SnapCommandTestsVixen.Editor.App.Tests
  • TerrainPanelTestsVixen.Editor.App.Tests
  • TerrainSessionTestsVixen.Editor.App.Tests