morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::testing::ConformanceProbe Class Referenceabstract

How the conformance cases read and drive one backend under test. More...

#include <backend_conformance.hpp>

Public Member Functions

 ConformanceProbe (ConformanceProbe const &)=delete
ConformanceProbe & operator= (ConformanceProbe const &)=delete
 ConformanceProbe (ConformanceProbe &&)=delete
ConformanceProbe & operator= (ConformanceProbe &&)=delete
virtual IViewBackend & backend ()=0
 The backend under test.
virtual reactive::Runtime & runtime ()=0
 The runtime the cases' signals and mounts belong to.
virtual void settle ()=0
 Runs posted flushes and pending native events until nothing is left.
virtual std::string textOf (Widget const &widget)=0
 The text a widget shows: a Text's or TextInput's text, a Button's or Checkbox's label, and the label of the option a Select marks.
virtual bool visibleOf (Widget const &widget)=0
 The widget's own visibility flag, as its last setVisible left it.
virtual bool enabledOf (Widget const &widget)=0
 Whether a widget accepts input, by its own flag: a disabled ancestor does not make this false, which is what RecordingBackend records.
virtual std::size_t childCount (ContainerWidget const &container)=0
 How many children a container has.
virtual Widget * childAt (ContainerWidget const &container, std::size_t index)=0
 A container's child.
virtual void click (Widget &widget)=0
 Activates a button as a user would.
virtual void type (Widget &widget, std::string_view text)=0
 Replaces a text field's text as a user typing would: whatever the field held is cleared first (select all, or delete), so it ends up holding exactly text. onChange may see intermediate texts.
virtual void drag (Widget &source, Widget &target)=0
 Drags one widget onto another as a user would.
virtual void dismiss (Widget &dialog)=0
 Dismisses a dialog or drawer as a user would (Esc on the TUI), or a dismissible banner.
virtual void selectRows (Widget &table, std::vector< std::size_t > const &rows)=0
 Selects rows of a table as a user would, so that the user's selection is exactly these rows.
virtual std::vector< std::size_t > selectedRows (Widget const &table)=0
 The rows a table shows as selected.
virtual void moveCursor (Widget &field, std::size_t position)=0
 Moves a text field's cursor as a user would (the arrow keys, a click), without changing the text.
virtual std::size_t cursorOf (Widget const &field)=0
 Where a text field's cursor is.
virtual void press (Widget &focused, std::string_view chord)=0
 Presses a keyboard chord as a user would with focus on a widget.
virtual bool hasFocus (Widget const &widget)=0
 Whether a widget has keyboard focus.
virtual void chooseMenuEntry (Widget &menu, std::vector< std::size_t > const &path)=0
 Chooses a menu entry as a user would, opening each submenu on the path first.
virtual void expand (Widget &section, bool open)=0
 Opens or closes a collapsible section with its own control, as a user would.
virtual void dropFiles (Widget &zone, std::vector< std::string > const &paths)=0
 Drops files from the operating system onto a drop zone, as a user would.
virtual std::optional< WidgetBounds > boundsOf (Widget const &widget)
 Where a widget is drawn, for the layout cases (layoutConformanceCases). A backend that lays nothing out, such as RecordingBackend, answers none and runs only conformanceCases; a layout case run on it fails.

Detailed Description

How the conformance cases read and drive one backend under test.

The driving operations act as a user would, through the backend's own input path where it has one; each may run pending work before and after it. Reading operations report what the widget shows now.

Whether a handler can run after its widget was destroyed is observable only for a backend whose input can be delivered later than the driving call, such as a queued connection; a probe whose click delivers before it returns passes that case without exercising it.

Definition at line 54 of file backend_conformance.hpp.

Member Function Documentation

◆ backend()

virtual IViewBackend & morph::ui::testing::ConformanceProbe::backend ( )
pure virtual

The backend under test.

Returns
The backend every case mounts on.

◆ runtime()

virtual reactive::Runtime & morph::ui::testing::ConformanceProbe::runtime ( )
pure virtual

The runtime the cases' signals and mounts belong to.

Returns
The runtime, whose owner settle drives.

◆ textOf()

virtual std::string morph::ui::testing::ConformanceProbe::textOf ( Widget const & widget)
nodiscardpure virtual

The text a widget shows: a Text's or TextInput's text, a Button's or Checkbox's label, and the label of the option a Select marks.

Parameters
widgetThe widget.
Returns
The text, UTF-8; empty for a Select that marks no option.

◆ visibleOf()

virtual bool morph::ui::testing::ConformanceProbe::visibleOf ( Widget const & widget)
nodiscardpure virtual

The widget's own visibility flag, as its last setVisible left it.

Only the widget's own flag counts: a hidden ancestor, a collapsed panel or a closed dialog around it does not make this false. That is what RecordingBackend records, and it lets a case tell which Tabs page slot the mount hid.

Parameters
widgetThe widget.
Returns
True for a new widget; false once setVisible(false) reached it and until setVisible(true) does.

◆ enabledOf()

virtual bool morph::ui::testing::ConformanceProbe::enabledOf ( Widget const & widget)
nodiscardpure virtual

Whether a widget accepts input, by its own flag: a disabled ancestor does not make this false, which is what RecordingBackend records.

Parameters
widgetThe widget.
Returns
True for a new widget; false once setEnabled(false) reached it and until setEnabled(true) does.

◆ childCount()

virtual std::size_t morph::ui::testing::ConformanceProbe::childCount ( ContainerWidget const & container)
nodiscardpure virtual

How many children a container has.

Parameters
containerThe container.
Returns
The count.

◆ childAt()

virtual Widget * morph::ui::testing::ConformanceProbe::childAt ( ContainerWidget const & container,
std::size_t index )
nodiscardpure virtual

A container's child.

Parameters
containerThe container.
indexThe position.
Returns
The child, or null past the end. A case drives it as it drives a root.

◆ click()

virtual void morph::ui::testing::ConformanceProbe::click ( Widget & widget)
pure virtual

Activates a button as a user would.

Parameters
widgetThe button.

◆ type()

virtual void morph::ui::testing::ConformanceProbe::type ( Widget & widget,
std::string_view text )
pure virtual

Replaces a text field's text as a user typing would: whatever the field held is cleared first (select all, or delete), so it ends up holding exactly text. onChange may see intermediate texts.

Parameters
widgetThe field.
textThe text to end up with.

◆ drag()

virtual void morph::ui::testing::ConformanceProbe::drag ( Widget & source,
Widget & target )
pure virtual

Drags one widget onto another as a user would.

Parameters
sourceThe dragged widget.
targetThe widget it is dropped on.

◆ dismiss()

virtual void morph::ui::testing::ConformanceProbe::dismiss ( Widget & dialog)
pure virtual

Dismisses a dialog or drawer as a user would (Esc on the TUI), or a dismissible banner.

Parameters
dialogThe dialog, drawer or banner.

◆ selectRows()

virtual void morph::ui::testing::ConformanceProbe::selectRows ( Widget & table,
std::vector< std::size_t > const & rows )
pure virtual

Selects rows of a table as a user would, so that the user's selection is exactly these rows.

Parameters
tableThe table.
rowsPositions among the table's current rows, in the order the user picks them: at least one, and one only for a Single table.

◆ selectedRows()

virtual std::vector< std::size_t > morph::ui::testing::ConformanceProbe::selectedRows ( Widget const & table)
nodiscardpure virtual

The rows a table shows as selected.

Parameters
tableThe table.
Returns
Their positions among the table's current rows, ascending.

◆ moveCursor()

virtual void morph::ui::testing::ConformanceProbe::moveCursor ( Widget & field,
std::size_t position )
pure virtual

Moves a text field's cursor as a user would (the arrow keys, a click), without changing the text.

Parameters
fieldThe text field.
positionA byte offset into the text it shows.

◆ cursorOf()

virtual std::size_t morph::ui::testing::ConformanceProbe::cursorOf ( Widget const & field)
nodiscardpure virtual

Where a text field's cursor is.

Parameters
fieldThe text field.
Returns
A byte offset into the text it shows.

◆ press()

virtual void morph::ui::testing::ConformanceProbe::press ( Widget & focused,
std::string_view chord )
pure virtual

Presses a keyboard chord as a user would with focus on a widget.

Parameters
focusedThe widget focus is on; the probe moves focus there first if it must.
chordThe chord, as a document declares it, such as "Ctrl+S".

◆ hasFocus()

virtual bool morph::ui::testing::ConformanceProbe::hasFocus ( Widget const & widget)
nodiscardpure virtual

Whether a widget has keyboard focus.

Parameters
widgetThe widget.
Returns
True when it is the widget that has focus.

◆ chooseMenuEntry()

virtual void morph::ui::testing::ConformanceProbe::chooseMenuEntry ( Widget & menu,
std::vector< std::size_t > const & path )
pure virtual

Chooses a menu entry as a user would, opening each submenu on the path first.

Parameters
menuThe menu.
pathThe entry's index at each level, from the top.

◆ expand()

virtual void morph::ui::testing::ConformanceProbe::expand ( Widget & section,
bool open )
pure virtual

Opens or closes a collapsible section with its own control, as a user would.

Parameters
sectionThe section.
openThe state asked for.

◆ dropFiles()

virtual void morph::ui::testing::ConformanceProbe::dropFiles ( Widget & zone,
std::vector< std::string > const & paths )
pure virtual

Drops files from the operating system onto a drop zone, as a user would.

Parameters
zoneThe drop zone.
pathsThe files' paths, in the order dropped; not empty.

◆ boundsOf()

virtual std::optional< WidgetBounds > morph::ui::testing::ConformanceProbe::boundsOf ( Widget const & widget)
inlinenodiscardvirtual

Where a widget is drawn, for the layout cases (layoutConformanceCases). A backend that lays nothing out, such as RecordingBackend, answers none and runs only conformanceCases; a layout case run on it fails.

Parameters
widgetThe widget.
Returns
Its bounds, in the backend's own units; nullopt when the probe reads no geometry.

Definition at line 176 of file backend_conformance.hpp.


The documentation for this class was generated from the following file: