pub trait EditorTestApi {
Show 38 methods
// Required methods
fn dispatch(&mut self, action: Action);
fn dispatch_seq(&mut self, actions: &[Action]);
fn buffer_text(&self) -> String;
fn primary_caret(&self) -> Caret;
fn carets(&self) -> Vec<Caret>;
fn selection_text(&mut self) -> String;
fn viewport_top_byte(&self) -> usize;
fn terminal_width(&self) -> u16;
fn terminal_height(&self) -> u16;
fn gutter_width(&self) -> u16;
fn hardware_cursor_position(&mut self) -> Option<(u16, u16)>;
fn visible_byte_range(&self) -> Option<(usize, usize)>;
fn modal_snapshot(&self) -> ModalSnapshot;
fn buffer_count(&self) -> usize;
fn active_buffer_path(&self) -> Option<String>;
fn buffer_paths(&self) -> Vec<String>;
fn dispatch_mouse_click(&mut self, col: u16, row: u16) -> bool;
fn is_modified(&self) -> bool;
fn take_full_redraw_request_for_tests(&mut self) -> bool;
fn seed_marker(&mut self, byte_offset: usize, symbol: &str, color: &str);
fn marker_positions(&self, symbol: &str) -> Vec<usize>;
fn active_event_log_len(&self) -> usize;
fn notify_file_changed(&mut self, path: &str);
fn create_side_by_side_diff(
&mut self,
name: &str,
mode: &str,
old_content: &str,
new_content: &str,
hunks: &[(usize, usize, usize, usize)],
) -> usize;
fn set_composite_initial_focus_hunk_on(
&mut self,
composite_handle: usize,
hunk_index: usize,
);
fn composite_initial_focus_hunk_on(
&self,
composite_handle: usize,
) -> Option<usize>;
fn composite_next_hunk_active_on(&mut self, composite_handle: usize) -> bool;
fn composite_prev_hunk_active_on(&mut self, composite_handle: usize) -> bool;
fn flush_layout_for_tests(&mut self);
fn status_message(&self) -> Option<String>;
fn seed_virtual_line(
&mut self,
byte_offset: usize,
text: &str,
fg: Option<(u8, u8, u8)>,
bg: Option<(u8, u8, u8)>,
placement: &str,
namespace: &str,
priority: i32,
);
fn virtual_text_count(&self) -> usize;
fn clear_virtual_text_namespace(&mut self, namespace: &str);
fn add_margin_annotation(
&mut self,
line: usize,
position: &str,
symbol: &str,
color: Option<(u8, u8, u8)>,
annotation_id: Option<&str>,
);
fn remove_margin_annotation(&mut self, annotation_id: &str);
fn margin_left_total_width(&self) -> usize;
fn top_line_number(&mut self) -> usize;
fn primary_scrollbar_geometry(&self) -> Option<(usize, usize, u16, u16)>;
}Expand description
The single observation surface for semantic theorem tests.
Implemented by crate::app::Editor. Tests obtain a
&mut dyn EditorTestApi from the test harness and never see the
underlying Editor type directly.
Required Methods§
Sourcefn dispatch(&mut self, action: Action)
fn dispatch(&mut self, action: Action)
Apply a single semantic action, then drain async messages.
Sourcefn dispatch_seq(&mut self, actions: &[Action])
fn dispatch_seq(&mut self, actions: &[Action])
Apply a sequence of actions in order, draining async messages once
at the end. Equivalent to calling dispatch per action but cheaper.
Sourcefn buffer_text(&self) -> String
fn buffer_text(&self) -> String
Full buffer text. Panics if the buffer has unloaded regions (large-file mode); semantic theorems are not the right tool for large-file scenarios — write a layout/E2E test instead.
Sourcefn primary_caret(&self) -> Caret
fn primary_caret(&self) -> Caret
Primary cursor projected to a Caret.
Sourcefn carets(&self) -> Vec<Caret>
fn carets(&self) -> Vec<Caret>
All cursors projected to Carets, sorted by ascending position.
The primary cursor is included. Use primary_caret() if you only
care about the primary; use carets() for multi-cursor theorems.
Sourcefn selection_text(&mut self) -> String
fn selection_text(&mut self) -> String
Concatenated selected text across all cursors, in ascending position
order, joined by \n. Returns the empty string if no cursor has a
selection.
Sourcefn viewport_top_byte(&self) -> usize
fn viewport_top_byte(&self) -> usize
Byte offset of the first line currently visible in the active viewport. After the renderer has run, this is the viewport’s scroll position. Without a render, this reflects the last reconciliation point.
Sourcefn terminal_width(&self) -> u16
fn terminal_width(&self) -> u16
Width of the active terminal in cells, as set at harness construction or via resize.
Sourcefn terminal_height(&self) -> u16
fn terminal_height(&self) -> u16
Height of the active terminal in cells.
Sourcefn gutter_width(&self) -> u16
fn gutter_width(&self) -> u16
Width of the line-number gutter in cells, computed from the active buffer’s line count. Includes the trailing separator if the renderer adds one.
Sourcefn hardware_cursor_position(&mut self) -> Option<(u16, u16)>
fn hardware_cursor_position(&mut self) -> Option<(u16, u16)>
Screen cell of the primary cursor, in (col, row). None ⇒
the cursor is off-screen (scrolled past). Requires a prior
render to be meaningful.
Sourcefn visible_byte_range(&self) -> Option<(usize, usize)>
fn visible_byte_range(&self) -> Option<(usize, usize)>
(start_byte, end_byte) of the currently-visible buffer
region. End is exclusive. None ⇒ unknown / not yet
reconciled.
Sourcefn modal_snapshot(&self) -> ModalSnapshot
fn modal_snapshot(&self) -> ModalSnapshot
Snapshot of the modal-popup stack visible to the user. Used
by ModalScenario to assert on palette / picker / menu /
completion state without screen scraping.
Sourcefn buffer_count(&self) -> usize
fn buffer_count(&self) -> usize
Number of buffers currently open across the workspace.
Sourcefn active_buffer_path(&self) -> Option<String>
fn active_buffer_path(&self) -> Option<String>
Display path of the active buffer. None for unnamed buffers.
Sourcefn buffer_paths(&self) -> Vec<String>
fn buffer_paths(&self) -> Vec<String>
Display paths of every open buffer in stable insertion
order. Unnamed buffers appear as "<unnamed:NNN>".
Sourcefn dispatch_mouse_click(&mut self, col: u16, row: u16) -> bool
fn dispatch_mouse_click(&mut self, col: u16, row: u16) -> bool
Dispatch a mouse click projected through the active
viewport. (col, row) are absolute screen coordinates;
gutter offset is applied internally. Returns true if the
editor consumed the event.
Sourcefn is_modified(&self) -> bool
fn is_modified(&self) -> bool
true if the active buffer has unsaved changes since it was
last loaded from / saved to disk. The “save point” is the
commit in the undo/redo log at which the buffer’s on-disk
representation matches its in-memory state. After loading a
fresh file (no edits applied), this is false. After any
edit it becomes true. Undoing back to the save point flips
it back to false — the property under test in
tests/semantic/undo_redo.rs::theorem_undo_to_save_point_*.
Sourcefn take_full_redraw_request_for_tests(&mut self) -> bool
fn take_full_redraw_request_for_tests(&mut self) -> bool
Consume the one-shot “full hardware redraw” flag the editor’s
event loop polls each frame: Action::RedrawScreen sets it,
the loop’s tick clears it. Returns the previous value and
resets the flag to false.
Exposed for LayoutScenario’s expected_full_redraw_requested
assertion — the only stable observation surface for the
“redraw screen” claim (issue #1070).
Sourcefn seed_marker(&mut self, byte_offset: usize, symbol: &str, color: &str)
fn seed_marker(&mut self, byte_offset: usize, symbol: &str, color: &str)
Seed a line indicator (margin marker) at byte_offset with the
given symbol (used as both the indicator glyph and the
namespace) and a color name ("red", "green", "blue",
"yellow"; anything else falls back to Color::Red).
Sourcefn marker_positions(&self, symbol: &str) -> Vec<usize>
fn marker_positions(&self, symbol: &str) -> Vec<usize>
Current byte positions of every marker whose namespace matches
symbol, in ascending order. Empty if no marker was seeded for
that namespace.
Sourcefn active_event_log_len(&self) -> usize
fn active_event_log_len(&self) -> usize
Length (in events) of the active buffer’s event log. Used by
PersistenceScenario save-point claims that check no undo
history is dropped on a no-op file-watcher notification.
Sourcefn notify_file_changed(&mut self, path: &str)
fn notify_file_changed(&mut self, path: &str)
Notify the editor that path on disk has changed. Triggers the
auto-revert path; the editor reads the file and updates its
buffer (or skips when on-disk content already matches).
Sourcefn create_side_by_side_diff(
&mut self,
name: &str,
mode: &str,
old_content: &str,
new_content: &str,
hunks: &[(usize, usize, usize, usize)],
) -> usize
fn create_side_by_side_diff( &mut self, name: &str, mode: &str, old_content: &str, new_content: &str, hunks: &[(usize, usize, usize, usize)], ) -> usize
Create a side-by-side composite diff view named name with
mode mode. Builds two virtual buffers (OLD, NEW), seeds them
with old_content / new_content, computes a line alignment
from hunks, and switches the active buffer to the composite.
Returns a 64-bit handle to the composite for follow-up calls
(composite_next_hunk_on, set_composite_initial_focus_hunk_on).
Sourcefn set_composite_initial_focus_hunk_on(
&mut self,
composite_handle: usize,
hunk_index: usize,
)
fn set_composite_initial_focus_hunk_on( &mut self, composite_handle: usize, hunk_index: usize, )
Set the composite buffer’s initial_focus_hunk field — the
one-shot “scroll to hunk N on first render” knob. The first
render consumes the value and resets the field to None.
Sourcefn composite_initial_focus_hunk_on(
&self,
composite_handle: usize,
) -> Option<usize>
fn composite_initial_focus_hunk_on( &self, composite_handle: usize, ) -> Option<usize>
Read the composite buffer’s current initial_focus_hunk
(after the first render this should be None, i.e. the field
was consumed). Returns None for missing or non-composite
buffers.
Sourcefn composite_next_hunk_active_on(&mut self, composite_handle: usize) -> bool
fn composite_next_hunk_active_on(&mut self, composite_handle: usize) -> bool
Jump the active split’s view of composite_handle to the next
hunk. Mirrors the n / ] keybinding semantics; returns
true iff a next hunk existed.
Sourcefn composite_prev_hunk_active_on(&mut self, composite_handle: usize) -> bool
fn composite_prev_hunk_active_on(&mut self, composite_handle: usize) -> bool
Jump back to the previous hunk; companion of
composite_next_hunk_active_on.
Sourcefn flush_layout_for_tests(&mut self)
fn flush_layout_for_tests(&mut self)
Force-materialize composite view state across visible splits without performing a render. Lets a scenario reach hunk-nav state before any frame paints.
Sourcefn status_message(&self) -> Option<String>
fn status_message(&self) -> Option<String>
Latest status message set by the editor (the same string the
status bar would display). None ⇒ no message has been set
since the last clear. Used by scrollbar-toggle scenarios that
assert on the “Vertical scrollbar hidden/shown” round-trip.
Sourcefn seed_virtual_line(
&mut self,
byte_offset: usize,
text: &str,
fg: Option<(u8, u8, u8)>,
bg: Option<(u8, u8, u8)>,
placement: &str,
namespace: &str,
priority: i32,
)
fn seed_virtual_line( &mut self, byte_offset: usize, text: &str, fg: Option<(u8, u8, u8)>, bg: Option<(u8, u8, u8)>, placement: &str, namespace: &str, priority: i32, )
Inject a virtual line at the marker for byte_offset with
text, fg/bg colors (each as Option<(r,g,b)>), placement
("above" or "below"), namespace, and priority.
Sourcefn virtual_text_count(&self) -> usize
fn virtual_text_count(&self) -> usize
Total count of virtual texts on the active state.
Sourcefn clear_virtual_text_namespace(&mut self, namespace: &str)
fn clear_virtual_text_namespace(&mut self, namespace: &str)
Clear every virtual text belonging to namespace.
Sourcefn add_margin_annotation(
&mut self,
line: usize,
position: &str,
symbol: &str,
color: Option<(u8, u8, u8)>,
annotation_id: Option<&str>,
)
fn add_margin_annotation( &mut self, line: usize, position: &str, symbol: &str, color: Option<(u8, u8, u8)>, annotation_id: Option<&str>, )
Inject a margin annotation (gutter symbol with optional color)
at line (0-indexed). position is "left" or "right".
Sourcefn remove_margin_annotation(&mut self, annotation_id: &str)
fn remove_margin_annotation(&mut self, annotation_id: &str)
Remove the previously-added margin annotation with this id.
Sourcefn margin_left_total_width(&self) -> usize
fn margin_left_total_width(&self) -> usize
margins.left_total_width() of the active state, in cells.
Sourcefn top_line_number(&mut self) -> usize
fn top_line_number(&mut self) -> usize
1-indexed logical line number of the viewport’s top byte —
the same observable the e2e scrollbar tests read via
harness.top_line_number(). Used to assert a scroll
position is (un)changed after a mouse interaction.
Sourcefn primary_scrollbar_geometry(&self) -> Option<(usize, usize, u16, u16)>
fn primary_scrollbar_geometry(&self) -> Option<(usize, usize, u16, u16)>
Cached scrollbar geometry of the primary (first) split:
(thumb_start, thumb_end, scrollbar_height, scrollbar_y) —
thumb extent in scrollbar-row offsets, the track’s height,
and the track’s top terminal row. None ⇒ no split areas
cached (no render yet). thumb_end > thumb_start indicates
a non-degenerate thumb; thumb_end - thumb_start < scrollbar_height indicates the content is scrollable (the
thumb does not fill the track) — the load-bearing claim of
test_scrollbar_shows_scrollable_content_with_wrapped_lines.
scrollbar_y lets a test resolve the thumb’s terminal row
for a click/drag at the thumb midpoint.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".