ui::testing::TestLauncher¶
Header: winui/testing/TestLauncher.hpp.
Derives from ui::Launcher.
Launcher test double: launches nothing and records every URI and file it was handed.
Install it with set_launcher(); ui::launch_uri(), ui::launch_file() and a hyperlink Button's or a Hyperlink inline's navigate_uri then reach it. It uninstalls itself when destroyed.
Example:
ui::testing::HeadlessTextMeasurer measurer;
ui::testing::TestLauncher launcher;
ui::testing::set_launcher(&launcher);
ui::Window window;
auto button = std::make_unique<ui::ButtonControl>("Docs");
button->set_variant(ui::ButtonVariant::Hyperlink);
button->set_navigate_uri("https://example.com/docs");
ui::ButtonControl* b = window.set_content(std::move(button));
window.layout({400.0f, 400.0f}, measurer);
const ui::Point p = b->bounds().center();
ui::testing::seams(window).handle_pointer({p, ui::PointerButton::Left, ui::PointerAction::Down});
ui::testing::seams(window).handle_pointer({p, ui::PointerButton::Left, ui::PointerAction::Up});
REQUIRE(launcher.launched == std::vector<std::string>{"https://example.com/docs"});
launched¶
Every URI launched so far, oldest first.
launched_files¶
Every file launched so far, oldest first.
TestLauncher¶
~TestLauncher¶
Uninstalls it if it is still the installed launcher.
TestLauncher¶
operator=¶
launch_uri¶
Appends uri to launched.
launch_file¶
Appends file to launched_files.