summaryrefslogtreecommitdiffstats
path: root/tests/auto/other/sessionmanagement_macos/tst_sessionmanagement_macos.mm
blob: 02a3464ec76385753c139a0c97b7672b3a6a622c (plain)
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
36
// Copyright (C) 2019 Samuel Gaist <samuel.gaist@idiap.ch>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only


#include <QTest>
#include <QSignalSpy>
#include <QSessionManager>
#include <AppKit/AppKit.h>

// Q_DECLARE_METATYPE(QSessionManager)

class tst_SessionManagement_macOS : public QObject
{
    Q_OBJECT

private slots:
    void stopApplication();
};

/*
    Test that session handling code is properly called
*/
void tst_SessionManagement_macOS::stopApplication()
{
    int argc = 0;
    QGuiApplication app(argc, nullptr);
    QSignalSpy spy(&app, &QGuiApplication::commitDataRequest);
    QTimer::singleShot(1000, []() {
         [NSApp terminate:nil];
    });
    app.exec();
    QCOMPARE(spy.count(), 1);
}

QTEST_APPLESS_MAIN(tst_SessionManagement_macOS)
#include "tst_sessionmanagement_macos.moc"