diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index 63a795e0b7..2ee8a9dbac 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -66,7 +66,6 @@ qt_env.Program("ui", qt_src + [asset_obj], LIBS=qt_libs) if GetOption('extras'): qt_src.remove("main.cc") # replaced by test_runner qt_env.Program('tests/test_translations', [asset_obj, 'tests/test_runner.cc', 'tests/test_translations.cc'] + qt_src, LIBS=qt_libs) - qt_env.Program('tests/ui_snapshot', [asset_obj, "tests/ui_snapshot.cc"] + qt_src, LIBS=qt_libs) if GetOption('extras') and arch != "Darwin": qt_env.SharedLibrary("qt/python_helpers", ["qt/qt_window.cc"], LIBS=qt_libs) diff --git a/selfdrive/ui/tests/.gitignore b/selfdrive/ui/tests/.gitignore index 8e0147f988..06dad47fea 100644 --- a/selfdrive/ui/tests/.gitignore +++ b/selfdrive/ui/tests/.gitignore @@ -1,4 +1,3 @@ test test_translations -ui_snapshot test_ui/report \ No newline at end of file diff --git a/selfdrive/ui/tests/ui_snapshot.cc b/selfdrive/ui/tests/ui_snapshot.cc deleted file mode 100644 index 14e0fab835..0000000000 --- a/selfdrive/ui/tests/ui_snapshot.cc +++ /dev/null @@ -1,66 +0,0 @@ -#include "selfdrive/ui/tests/ui_snapshot.h" - -#include -#include -#include -#include -#include - -#include "selfdrive/ui/qt/home.h" -#include "selfdrive/ui/qt/util.h" -#include "selfdrive/ui/qt/window.h" -#include "selfdrive/ui/ui.h" - -void saveWidgetAsImage(QWidget *widget, const QString &fileName) { - QImage image(widget->size(), QImage::Format_ARGB32); - QPainter painter(&image); - widget->render(&painter); - image.save(fileName); -} - -int main(int argc, char *argv[]) { - initApp(argc, argv); - - QApplication app(argc, argv); - - QCommandLineParser parser; - parser.setApplicationDescription("Take a snapshot of the UI."); - parser.addHelpOption(); - parser.addOption(QCommandLineOption(QStringList() << "o" - << "output", - "Output image file path. The file's suffix is used to " - "determine the format. Supports PNG and JPEG formats. " - "Defaults to \"snapshot.png\".", - "file", "snapshot.png")); - parser.process(app); - - const QString output = parser.value("output"); - if (output.isEmpty()) { - qCritical() << "No output file specified"; - return 1; - } - - auto current = QDir::current(); - - // change working directory to find assets - if (!QDir::setCurrent(QCoreApplication::applicationDirPath() + QDir::separator() + "..")) { - qCritical() << "Failed to set current directory"; - return 1; - } - - MainWindow w; - w.setFixedSize(2160, 1080); - w.show(); - app.installEventFilter(&w); - - // restore working directory - QDir::setCurrent(current.absolutePath()); - - // wait for the UI to update - QObject::connect(uiState(), &UIState::uiUpdate, [&](const UIState &s) { - saveWidgetAsImage(&w, output); - app.quit(); - }); - - return app.exec(); -} diff --git a/selfdrive/ui/tests/ui_snapshot.h b/selfdrive/ui/tests/ui_snapshot.h deleted file mode 100644 index b4699f6af5..0000000000 --- a/selfdrive/ui/tests/ui_snapshot.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -void saveWidgetAsImage(QWidget *widget, const QString &fileName);