Skip to content

ui::testing::TestJumpListHost

Header: winui/testing/TestJumpListHost.hpp.

Derives from ui::JumpListHost.

JumpListHost test double: touches no jump list, and keeps the tasks it was handed and every recent file.

Install it with set_jump_list_host(); ui::set_jump_list() and ui::add_recent_file() then reach it. It uninstalls itself when destroyed.

Example:

ui::testing::TestJumpListHost jump_list;
ui::testing::set_jump_list_host(&jump_list);

ui::set_jump_list({ui::JumpTask{.title = "New window", .arguments = "--new-window"}});
ui::add_recent_file("notes.txt");
REQUIRE(jump_list.tasks.size() == 1);
REQUIRE(jump_list.recent_files.size() == 1);

tasks

std::vector<JumpTask> tasks

The tasks of the last ui::set_jump_list().

recent_files

std::vector<std::filesystem::path> recent_files

Every file ui::add_recent_file() was given, oldest first.

set_count

int set_count = 0

How many times ui::set_jump_list() was called.

TestJumpListHost

TestJumpListHost() = default

~TestJumpListHost

~TestJumpListHost() override

Uninstalls it if it is still the installed host.

TestJumpListHost

TestJumpListHost(const TestJumpListHost&) = delete

operator=

TestJumpListHost& operator=(const TestJumpListHost&) = delete

set_tasks

void set_tasks(std::vector<JumpTask> new_tasks) override

Replaces tasks and counts the call.

add_recent_file

void add_recent_file(const std::filesystem::path& path) override

Appends path to recent_files.