111 lines
5.5 KiB
C++
111 lines
5.5 KiB
C++
#include "mainwindow.h"
|
|
#include "applicationstyle.h"
|
|
#include "urdfviewerwidget.h"
|
|
#include "taskorchestrationwidget.h"
|
|
#include <QApplication>
|
|
#include <QCheckBox>
|
|
#include <QComboBox>
|
|
#include <QAbstractItemView>
|
|
#include <QDialog>
|
|
#include <QPushButton>
|
|
#include <QTimer>
|
|
#include <QDebug>
|
|
#include <QFile>
|
|
#include <QLabel>
|
|
#include <QTextStream>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
QApplication application(argc, argv);
|
|
application.setApplicationName(QStringLiteral("CMVR Theme Verification"));
|
|
application.setOrganizationName(QStringLiteral("CMVR Tests"));
|
|
ApplicationStyle::install(application);
|
|
if (application.windowIcon().pixmap(32, 32).isNull()) return 1;
|
|
MainWindow window;
|
|
if (auto *demo = window.findChild<QCheckBox *>(QStringLiteral("demoCheck")))
|
|
demo->setChecked(false);
|
|
window.resize(1600, 1000);
|
|
window.show();
|
|
QTimer::singleShot(150, &window, [&]() {
|
|
int comboCount = 0;
|
|
QStringList audit;
|
|
for (QComboBox *combo : window.findChildren<QComboBox *>()) {
|
|
combo->ensurePolished();
|
|
if (!combo->view()->styleSheet().contains(QStringLiteral("#e8f1ff"))) {
|
|
qCritical() << "Unthemed combo:" << combo->objectName(); application.exit(6); return;
|
|
}
|
|
++comboCount;
|
|
audit.append(QStringLiteral("PASS %1 / %2").arg(combo->metaObject()->className(), combo->objectName()));
|
|
}
|
|
QFile report(QStringLiteral("combo-audit.txt"));
|
|
if (report.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
QTextStream stream(&report);
|
|
stream << "Main-window combos: " << comboCount << '\n' << audit.join('\n') << '\n';
|
|
}
|
|
report.close();
|
|
qInfo() << "Themed main-window combo count:" << comboCount;
|
|
window.grab().save(QStringLiteral("application-system.png"));
|
|
QMetaObject::invokeMethod(&window, "selectPage", Qt::DirectConnection, Q_ARG(int, 1));
|
|
application.processEvents();
|
|
const auto viewers = window.findChildren<UrdfViewerWidget *>();
|
|
for (const auto *viewer : viewers) if (viewer->modelPreviewEnabled()) { application.exit(2); return; }
|
|
window.grab().save(QStringLiteral("application-arm.png"));
|
|
QMetaObject::invokeMethod(&window, "selectPage", Qt::DirectConnection, Q_ARG(int, 16));
|
|
application.processEvents();
|
|
window.grab().save(QStringLiteral("application-tasks.png"));
|
|
if (auto *tasks = window.findChild<TaskOrchestrationWidget *>()) {
|
|
tasks->setAvailableDevices({QVariantMap{{"deviceId", "usb_cam1"}, {"type", 2}},
|
|
QVariantMap{{"deviceId", "mic1"}, {"type", 5}}});
|
|
QPushButton *add = nullptr;
|
|
for (auto *button : tasks->findChildren<QPushButton *>())
|
|
if (button->text().contains(QStringLiteral("任务节点"))) { add = button; break; }
|
|
if (!add) { application.exit(7); return; }
|
|
bool taskInspected = false;
|
|
QTimer::singleShot(100, &window, [&]() {
|
|
auto *dialog = qobject_cast<QDialog *>(QApplication::activeModalWidget());
|
|
if (!dialog) return;
|
|
auto *title = dialog->findChild<QLabel *>(QStringLiteral("jointFlowDialogTitle"));
|
|
taskInspected = title && title->text() == QStringLiteral("任务节点参数");
|
|
int count = 0;
|
|
for (QComboBox *combo : dialog->findChildren<QComboBox *>()) {
|
|
combo->ensurePolished();
|
|
taskInspected = taskInspected && combo->view()->styleSheet().contains(QStringLiteral("#e8f1ff"));
|
|
++count;
|
|
}
|
|
if (report.open(QIODevice::Append | QIODevice::Text)) {
|
|
QTextStream stream(&report);
|
|
stream << "Task-node dialog combos: " << count << " / " << (taskInspected ? "PASS" : "FAIL") << '\n';
|
|
report.close();
|
|
}
|
|
dialog->grab().save(QStringLiteral("task-node-dialog.png"));
|
|
dialog->reject();
|
|
});
|
|
add->click();
|
|
if (!taskInspected) { application.exit(8); return; }
|
|
}
|
|
QPushButton *settings = nullptr;
|
|
for (QPushButton *button : window.findChildren<QPushButton *>())
|
|
if (button->text() == QStringLiteral("软件设置")) settings = button;
|
|
if (!settings) { application.exit(3); return; }
|
|
bool inspected = false;
|
|
QTimer::singleShot(100, &window, [&]() {
|
|
auto *dialog = qobject_cast<QDialog *>(QApplication::activeModalWidget());
|
|
if (dialog && dialog->objectName() == QStringLiteral("applicationSettingsDialog")) {
|
|
inspected = dialog->property("applicationChrome").toBool()
|
|
&& !(dialog->windowFlags() & Qt::WindowStaysOnTopHint);
|
|
for (QComboBox *combo : dialog->findChildren<QComboBox *>()) {
|
|
combo->ensurePolished();
|
|
inspected = inspected && combo->view()->styleSheet().contains(QStringLiteral("#e8f1ff"));
|
|
}
|
|
dialog->grab().save(QStringLiteral("application-settings.png"));
|
|
dialog->reject();
|
|
}
|
|
});
|
|
settings->click();
|
|
qInfo() << "Theme shell: navigation, disabled model default, icon and settings verified";
|
|
application.exit(inspected ? 0 : 4);
|
|
});
|
|
QTimer::singleShot(12000, &application, [&]() { application.exit(5); });
|
|
return application.exec();
|
|
}
|