Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
blockingtestdialogs.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef BLOCKINGTESTDIALOGS_H
5#define BLOCKINGTESTDIALOGS_H
6
7#include "hdc.h"
8
9#include <QtCore/qjsonobject.h>
10#include <QtCore/qlist.h>
11#include <QtCore/qrect.h>
12#include <QtCore/qregularexpression.h>
13#include <QtCore/qstring.h>
14
15#include <optional>
16
17QT_BEGIN_NAMESPACE
18
19class BlockingTestDialogs
20{
21public:
22 BlockingTestDialogs(const QString &testConfigPath, Hdc hdc);
23
24 bool isEmpty() const;
25
26 bool answerVisibleDialog();
27
28private:
29 struct Dialog
30 {
31 QString name;
32 QRegularExpression prompt;
33 QList<QRegularExpression> buttons;
34 QString position;
35 };
36
37 struct ScreenText
38 {
39 QString text;
40 QRect bounds;
41 };
42
43 void loadDeclarations(const QString &testConfigPath);
44 static std::optional<Dialog> parseDialog(const QJsonObject &declaration);
45
46 QList<ScreenText> dumpScreenTexts() const;
47 static void collectTexts(const QJsonObject &node, QList<ScreenText> &texts);
48
49 static bool anyTextMatches(
50 const QList<ScreenText> &texts, const QRegularExpression &pattern);
51 static std::optional<ScreenText> findButton(
52 const QList<ScreenText> &texts, const QRegularExpression &pattern,
53 const QString &position);
54 bool pressButtons(const Dialog &dialog, const QList<ScreenText> &texts) const;
55 void reportUnmatchedDialog(const QList<ScreenText> &texts);
56
57 QList<Dialog> m_dialogs;
58 Hdc m_hdc;
59 QString m_lastReportedUnknownDialog;
60};
61
62QT_END_NAMESPACE
63
64#endif // BLOCKINGTESTDIALOGS_H
static constexpr int EXIT_NOEXITCODE
Definition main.cpp:42
static constexpr int EXIT_ERROR
Definition main.cpp:40
static bool waitForProcessStart(const Hdc &hdc, const QString &bundleName, const QString &shellExitCodePath, int timeoutSecs=30)
Definition main.cpp:137
static void waitForProcessDeath(const Hdc &hdc, const QString &bundleName, int timeoutSecs=15)
Definition main.cpp:121
static constexpr auto quietBeforeDialogCheck
Definition main.cpp:50
static QString shellSingleQuote(const QString &value)
Definition main.cpp:43
static constexpr int EXIT_CRASH
Definition main.cpp:40
static std::atomic< bool > g_interrupted
Definition main.cpp:105
static constexpr auto quietBeforeDialogCheckWhileStarting
Definition main.cpp:51
static void sigHandler(int sig)
Definition main.cpp:107
static constexpr auto dialogsExpectedWhileStarting
Definition main.cpp:52
static bool waitForStdoutFile(const Hdc &hdc, const QString &shellStdoutPath, int timeoutSecs=10)
Definition main.cpp:158
static constexpr int EXIT_TIMEOUT
Definition main.cpp:41
static void answerBlockingDialogsIfStalled(BlockingTestDialogs &blockingTestDialogs, const QElapsedTimer &elapsed, std::chrono::nanoseconds lastOutputAt)
Definition main.cpp:174
int main(int argc, char *argv[])
[ctor_close]