3.7 KiB
test_chat_menu
Type: Harness API (may include self-tests).
Source contract: test_chat_menu.h.
Use when
Attribute chat-list context menus to the exact message. Read the contract below and the source header before use.
Contract and usage
The chat-list context-menu reader, OpenChatListContextMenu(list, target, point) (input helpers), in a module of its own because it depends on history
view types, which test_menu.h does not: ChatListMenuReading (the
underlying ContextMenuReading, with its menu pointer cleared on every
refusal; the requested message and the list's own view of it; the four
ChatListResolutions; enterSent, leaveSent, menuRead, observed,
listMenu, menuHidden and attributed; built(), never true on default
state), the fourteen refusals ChatListMenuRefusalName names, and
ChatListMenuDetails, which prints recorded values only. The private state it
reads - _mouseActive, _dragStateItem, _overElement, _overItemExact,
the visible message area, _menu and HistoryInner::hasPendingResizedItems()
- goes through the test-only explicit-instantiation accessor
test_notify_override.cppuses, confined totest_chat_menu.cpp: no production accessor, no pixel scan, no registry. Its own self-test,AppendChatListMenuSelfTest, in twelve stages, needs a logged-in session and a Saved Messages history whose folder is known. It injects two fixed plain-text outgoing messages A and B there, a private fixture added withHistory::addNewMessageand ids fromData::Session::nextNonHistoryEntryId() - regular and so selectable, nothing sent, "Select" the only entry ever
triggered - and keeps the main window minimized with
KeepMainWindowNotMarkingReadfrom before the injection until both are destroyed. On the legacyHistoryInner, and then on theHistoryView::ListWidgetof aHistoryView::ChatWidgetopened through theuse-modern-chat-viewoption: a premise arm (A resolved last, the mouse outside the list, the window inactive throughClearWindowActive, and an unprotectedOpenContextMenuat B's point that the list resolved to A or to none, never to B, read at build through the observer); the protected reading for B under the same conditions, built and attributed to B; "Select" from it leaving exactly B selected (HistoryInner::getSelectedItems(),ListWidget::getSelectedIds()); B requested at A's point refusedwrong-targetwith A in its details, its menu hidden, and "Select" through it refusedmenu-gonewith the selection unchanged;no-list,not-a-chat-listandoutside-viewportcontrols; and an active control throughForceWindowActive, the window still minimized and not marking read, that resolves B. EveryClearWindowActiveandForceWindowActiveis undone in the same turn, back to the activation captured at the start. The teardown destroys A and B first and proves that neither id resolves to a message or to aListWidgetview, then restores the option, the chat, the window state and the Qt activation, and the same idempotent release runs fromRunner::onFinish. TheHistory::messages()index theChatWidgetleg seeds may stay allocated and keep listing both ids: an id aboveServerMaxMsgIdlies above every slice'srange.till, whereSparseIdsList::removeOnecannot reach it, and every reader of the index looks ids up throughData::Session::message()and skips one with no message behind it; itsFIXTURE_INDEXrow reports what it lists. Confirm withAppendChatListMenuSelfTest.