testing::UITest#
Base class of UI test suites.
| Header: | #include <AUI/Test/UI/UITestCase.h> |
| CMake: | aui_link(my_target PUBLIC aui::uitests) |
Detailed Description#
Derive your suite from UITest and use TEST_F. Before each test, UITest replaces the window manager with a stub
one (windows are not shown on the screen, rendering goes to a software renderer). After each test, it closes all
windows and destroys the window manager.
class UIMyWindow : public testing::UITest {
protected:
void SetUp() override {
UITest::SetUp(); // do not forget to call the base
_new<MyWindow>()->show();
}
};
TEST_F(UIMyWindow, Hello) {
By::text("Say hello").perform(click());
}
Warning
If you override SetUp or TearDown, call UITest::SetUp() first and UITest::TearDown() last.
Release every window and view you own before calling UITest::TearDown().
Every failed assertion made via UIMatcher saves a screenshot to reports/<suite>/fail-<test>.png with the
matched views outlined in red; a screenshot of the final state of every test is saved as
reports/<suite>/finish-<test>.png.
For views to update (layout, styles, pending messages), the UI must be processed; actions and checks of
UIMatcher do that for you. In other cases, call uitest::frame().
Examples#
examples/ui/views/tests/LayoutManagerTest.cpp
Views Example — All-in-one views building example.
Public Methods#
saveScreenshot#
void UITest::saveScreenshot(const AString& name)
Saves a screenshot of the current state to reports/ (useful for inspecting a test by eye).
- Arguments
namesuffix of the file name; the file is named `. _ .png`.