summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/offscreen/tst_offscreen.cpp
blob: 553dc653bc9e90e4328e1e0d7f44f1d3cccdb871 (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
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include <QTest>
#include <QSignalSpy>
#include <QWebEngineProfile>
#include <QWebEnginePage>
#include <QWebEngineView>

class tst_OffScreen : public QObject {
    Q_OBJECT
public:
    tst_OffScreen(){}

private slots:
    void offscreen();
};

void tst_OffScreen::offscreen()
{
    QWebEngineProfile profile;
    QWebEnginePage page(&profile);
    QWebEngineView view;
    QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool)));
    view.setPage(&page);
    page.load(QUrl("qrc:/test.html"));
    view.show();
    QTRY_COMPARE(view.isVisible(), true);
    QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size() > 0, true, 20000);
    QCOMPARE(loadFinishedSpy.takeFirst().at(0).toBool(), true);
}

#include "tst_offscreen.moc"
QTEST_MAIN(tst_OffScreen)