25void QmlWindowsApiTest::initTestCase()
29void QmlWindowsApiTest::cleanupTestCase()
33void QmlWindowsApiTest::testWindowsAPI()
35 QObject *currentWindowObject = m_testHelper.
evaluateQObject(
QSL(
"Falkon.Windows.getCurrent()"));
36 QVERIFY(currentWindowObject);
37 QCOMPARE(currentWindowObject->property(
"title").toString(),
mApp->getWindow()->windowTitle());
38 QCOMPARE(currentWindowObject->property(
"type").toInt(), (
int)
mApp->getWindow()->windowType());
39 QCOMPARE(currentWindowObject->property(
"tabs").toList().length(),
mApp->getWindow()->tabCount());
42 QVERIFY(windowObject);
43 QSignalSpy qmlWindowCreatedSignal(windowObject, SIGNAL(created(
QmlWindow*)));
44 qRegisterMetaType<BrowserWindow*>();
45 QSignalSpy windowCreatedSingal(
mApp->plugins(), SIGNAL(mainWindowCreated(
BrowserWindow*)));
48 QTRY_COMPARE(qmlWindowCreatedSignal.count(), 1);
49 QTRY_COMPARE(windowCreatedSingal.count(), 1);
51 QObject *newQmlWindow = m_testHelper.
evaluateQObject(
QSL(
"Falkon.Windows.create({})"));
52 QVERIFY(newQmlWindow);
53 QCOMPARE(
mApp->windowCount(), 2);
56 QTRY_COMPARE(qmlWindowCreatedSignal.count(), 2);
57 QTRY_COMPARE(windowCreatedSingal.count(), 2);
59 auto *newQmlSignalWindow = qvariant_cast<QObject*>(qmlWindowCreatedSignal.at(1).at(0));
60 QVERIFY(newQmlSignalWindow);
61 QCOMPARE(newQmlWindow->property(
"id").toInt(), newQmlSignalWindow->property(
"id").toInt());
63 int qmlWindowCount = m_testHelper.
evaluate(
QSL(
"Falkon.Windows.getAll().length")).toInt();
64 QCOMPARE(qmlWindowCount,
mApp->windowCount());
66 QSignalSpy qmlWindowRemovedSignal(windowObject, SIGNAL(removed(
QmlWindow*)));
67 int newQmlWindowId = newQmlSignalWindow->property(
"id").toInt();
68 m_testHelper.
evaluate(QString(
QSL(
"Falkon.Windows.remove(%1)")).arg(newQmlWindowId));
69 QTRY_COMPARE(qmlWindowRemovedSignal.count(), 1);
#define FALKONTEST_MAIN(Test)
QObject * evaluateQObject(const QString &source)
QJSValue evaluate(const QString &source)
The class exposing Browser window to QML.