Task: 2026/10/19/read-button-and-toast-states-painted-toasts-and-glyph-ink-in-the-harness
4.7 KiB
4.7 KiB
Overlay APIs and minimal scenario
test_runner.h— the staged scenario engine:Stage{name, run, until, then, timeout},waitEvent,waitForSessionReady, the normal bounded non-fatalwaitForChatsLoaded(), and explicit strictwaitForChatsLoadedStrict(); timing out an ordinaryStageends the whole scenario, while the wall-clock watchdog (default 120s;TDESKTOP_TEST_WATCHDOGoverride in seconds, 1..600, otherwise the default; the armed duration is logged at scenario start) guaranteesTEST_COMPLETE+ quit on every exit path including timeout.actOnWidgetwaits for and lifetime-guards the exact target before acting once.captureAndInspectsaves the accepted prepared frame and then runs numeric/raster assertions against that same widget and image.addGated(gate, compose)gives every stage appended whilecomposeruns, helper stages included, an inherited fixture gate whose first refusal the whole group keeps, andaddRecoveryappends a restoration stage that keeps only its ownskipReasoninside such a group (see gated groups).test_log.h— evidence dir fromTDESKTOP_TEST_EVIDENCE_DIR(the workspacetest-runhelper sets it), flushed absolute-path logging,Step/Pass/Fail/Check/Note,CheckNeartolerance assertions,LogGeometry, the standard markers.test_widgets.h—FindAll<T>/FindFirst<T>/FindVisible<T>(thedynamic_cast-based finders that avoid the guaranteedfindChildren<CustomWidget*>crash),Click,TypeText,CommitText,PressKey,Drag, andWheelvia real Qt events, plus generation-counted, lifetime-guardedPublishLiveWidget/PublishLiveActionseams for exact layer-owned objects, andReadButtonState/ButtonStateDetails, aUi::AbstractButton's own disabled flag read besideisEnabled()- the readiness of a button target, becausesetDisabled()leavesisEnabled()true (button state); each delivered event runs with postponed-call processing deferred and is followed by a drain of every pendingUi::PostponeCallto empty, so postponed input fix-ups AND their own change handling are settled when the helper returns; wrap programmaticsetTextinTest::Settle.test_capture.h—CaptureWidget/CaptureRect(visibility check,QWidget::grab()so floating elements and locked desktops cannot occlude, automatic blank-image FAIL, geometry log,SCREENSHOTmarker), plusPreparedWidgetCapture;Runner::captureWidgetpolls an exact target until it has a valid painted frame and saves that same accepted frame,Crop/Zoom/ContactSheetfor tight same-scale evidence.test_ink.h,test_style.h, andtest_panel.h— painted-ink/contrast measurement, settled palette baselines, and detection of aUi::SeparatePanelshow-animation cache.test_messages.h,test_transfer.h,test_open_handoff.h, andtest_launch_fuse.h— direct sent-message, document-transfer, document-open, and safely blocked OS-launch oracles. Prefer these established task-specific observers over reconstructing the same state in a scenario.test_agent.h—Test::Fire(name)/HasFired(name)named waitpoints;launch_finishedfires at the end ofApplication::run().TDESKTOP_TEST_SCALEis applied by the harness at startup, and on macOS the harness holds the App Nap opt-out for the whole run (TDESKTOP_TEST_APP_NAP=allowleaves it off; see launch behavior).test_scenario.cpp— the overlay-owned slot: it definesTest::SetupScenario(runner)and is a no-op in the repository.
A minimal scenario shape:
void SetupScenario(not_null<Runner*> runner) {
runner->waitEvent(u"launch_finished"_q);
runner->actOnWidget(
u"click the published button"_q,
[] { return Test::ReadLiveWidget(u"task.button"_q).widget; },
[](QWidget *widget) { Test::Click(widget); },
[](QWidget *widget) {
return Test::ReadButtonState(widget).usable();
},
Test::kDefaultStageTimeout,
[](QWidget *widget) {
return Test::ButtonStateDetails(Test::ReadButtonState(widget));
});
runner->captureAndInspect(
u"target_surface"_q,
[] { return Test::ReadLiveWidget(u"task.surface"_q).widget; },
[](QWidget *widget) {
return widget->property("contentGeneration").toInt() > 0;
},
[](QWidget *widget, const QImage &image) {
Test::LogGeometry(u"surface"_q, widget->geometry());
Test::Check(
image.width() >= widget->width(),
u"capture covers the surface width"_q,
u"image=%1 widget=%2"_q
.arg(image.width())
.arg(widget->width()));
});
}