the tool card counts, and a device run leaves a log

A tool that takes minutes -- a build, a wide search, a command nobody can
predict -- read as a window that had hung: the card said "running" and
nothing else, forever. The chip now counts from the point the card starts
running (from five seconds on, before that it is noise), which is where a
person looks when a call seems stuck; the status line and the Stop button
were already there. A card that appears already running (a replayed
transcript) starts its clock too.

--uitest: two checks for it (a card four minutes eighteen in says
"running · 4:18"; a finished one stops counting).

And the run now writes uitest.log in its workspace, every line and the
verdict. That is the only way to read a run *on a phone*: stdout reaches
nobody there, an app started from adb cannot be handed CST_APP_SHOT or any
other environment (so the shots a desktop run can take are out), and logcat
does not carry this build's Qt messages at all -- checked: a plain
`qInfo` from the app is not in the buffer.

First device run (NX789J, 105 checks): 88 ok, 17 FAIL, every failure
pre-existing and unrelated to this work -- the settings dialog does not
open from the gear (so nothing in it is reachable: the five dialog checks,
the two provider-form ones and the four clicks that follow), Open/Share
leave no status line on the device, and the clipboard-image checks have no
clipboard. All the md_to_pdf and card checks pass on the phone, including
"black ink on paper (darkest pixel 0)" from 4c69ef3.
This commit is contained in:
WHC
2026-10-11 20:41:58 +08:00
parent 9d7ad9433e
commit a34c74e453
3 changed files with 117 additions and 3 deletions
+59
View File
@@ -11,6 +11,7 @@
#include <QGuiApplication>
#include <QClipboard>
#include <QBuffer>
#include <QDateTime>
#include <QFile>
#include <QImage>
#include <QPalette>
@@ -42,9 +43,23 @@ namespace {
int g_fail;
/* The run's own log file, opened once the workspace is known (see the top of
* the run below): every line stdout gets is written here as well. On a phone
* stdout reaches nobody, and an app started from adb cannot be handed
* CST_APP_SHOT or any other environment -- so `--uitest --workspace DIR` plus
* `adb pull DIR/uitest.log` is how a device run is read back. Empty when the
* file could not be made, in which case the run only prints. */
QFile g_runLog;
void check(bool ok, const QString &what) {
std::printf("%s %s\n", ok ? "ok " : "FAIL", qPrintable(what));
std::fflush(stdout);
if (g_runLog.isOpen()) {
g_runLog.write(ok ? "ok " : "FAIL");
g_runLog.write(what.toUtf8());
g_runLog.write("\n");
g_runLog.flush();
}
if (!ok)
g_fail++;
}
@@ -243,6 +258,10 @@ int runUiTest(AgentCore &core, const QString &size) {
/* A file card hands its file to the system: in a test run nothing may open
* for real, and the platform layer itself honours this (see ToolProvider.h). */
qputenv("CST_APP_NO_OPEN", "1");
/* From here on the run leaves a log in the workspace next to the files it
* makes, so a device run can be read back without logcat (see g_runLog). */
g_runLog.setFileName(core.workspace() + QStringLiteral("/uitest.log"));
g_runLog.open(QIODevice::WriteOnly | QIODevice::Truncate);
const QString resumed =
writeFixtureSession(core.workspace(), QStringLiteral("20260101-115959-on"));
check(!resumed.isEmpty() && core.switchSession(resumed),
@@ -516,6 +535,40 @@ int runUiTest(AgentCore &core, const QString &size) {
QGuiApplication::setPalette(was);
}
/* A tool that takes minutes -- a build, a wide search -- must not read as a
* window that has hung: while a card runs, its chip counts. */
{
QList<QQuickItem *> cards;
collectNamed(win->contentItem(), QStringLiteral("toolCard"), &cards);
check(!cards.isEmpty(),
QStringLiteral("the fixture session has a tool card to watch"));
if (!cards.isEmpty()) {
QQuickItem *card = cards.first();
card->setProperty("state", "running");
/* four minutes eighteen in, the point where "running" alone stopped
* being an answer */
card->setProperty(
"startedAt",
static_cast<double>(QDateTime::currentMSecsSinceEpoch()) - 258000.0);
card->setProperty("runningFor", 258);
QList<QQuickItem *> chips;
collectNamed(card, QStringLiteral("toolChip"), &chips);
const QString counting = chips.isEmpty()
? QString()
: chips.first()->property("text").toString();
check(counting.contains(QLatin1String("4:18")),
QStringLiteral("a running card says how long it has been going (%1)")
.arg(counting));
card->setProperty("state", "done");
const QString settled = chips.isEmpty()
? QString()
: chips.first()->property("text").toString();
check(!settled.contains(QLatin1String("4:18")),
QStringLiteral("and a finished card stops counting (%1)")
.arg(settled));
}
}
/* new sessions: the engine moves, the view empties, the store grows */
const int before = core.sessions().size();
clickMouse(win, QStringLiteral("newSessionButton"));
@@ -954,6 +1007,12 @@ int runUiTest(AgentCore &core, const QString &size) {
maybeShot(win, QString());
std::printf("--- %s\n", g_fail ? "FAILED" : "all UI checks passed");
if (g_runLog.isOpen()) {
g_runLog.write("--- ");
g_runLog.write(g_fail ? "FAILED" : "all UI checks passed");
g_runLog.write("\n");
g_runLog.close();
}
return g_fail ? 1 : 0;
}