File: main.cpp

package info (click to toggle)
dtkdeclarative 5.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 29,848 kB
  • sloc: cpp: 20,566; ansic: 66; makefile: 29; sh: 25
file content (35 lines) | stat: -rw-r--r-- 803 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include <gtest/gtest.h>

#include <QGuiApplication>
#include <QQuickStyle>
#include <QTimer>

int runTest(QGuiApplication &app)
{
    int ret = 0;
    QTimer::singleShot(0, &app, [&app, &ret]() {
        ret = RUN_ALL_TESTS();
        app.quit();
    });
    app.exec();
    return ret;
}

int main(int argc, char *argv[])
{
    // 编译时没有显示器,需要指定环境变量
    if (qEnvironmentVariable("DISPLAY").isEmpty())
        qputenv("QT_QPA_PLATFORM", "offscreen");

    QQuickStyle::setStyle("Chameleon");

    QGuiApplication app(argc, argv);
    app.setApplicationName(BIN_NAME);
    ::testing::InitGoogleTest(&argc, argv);

    return runTest(app);
}