23void QmlTabsApiTest::initTestCase()
27void QmlTabsApiTest::cleanupTestCase()
31void QmlTabsApiTest::testInitWindowCount()
33 QCOMPARE(
mApp->windowCount(), 1);
34 QTRY_COMPARE(
mApp->getWindow()->tabCount(), 1);
37void QmlTabsApiTest::testTabsAPI()
40 QTRY_COMPARE(
mApp->getWindow()->tabCount(), 1);
44 QVERIFY(qmlTabsObject);
45 QSignalSpy qmlTabsInsertedSpy(qmlTabsObject, SIGNAL(tabInserted(QVariantMap)));
47 " url: 'https://example.com/'"
49 QCOMPARE(qmlTabsInsertedSpy.count(), 1);
50 QVariantMap retMap1 = QVariant(qmlTabsInsertedSpy.at(0).at(0)).toMap();
51 int index1 = retMap1.value(
QSL(
"index"), -1).toInt();
52 int windowId1 = retMap1.value(
QSL(
"windowId"), -1).toInt();
54 QCOMPARE(windowId1, 0);
56 QObject *qmlTabObject1 = m_testHelper.
evaluateQObject(
QSL(
"Falkon.Tabs.get({index: 1})"));
57 QVERIFY(qmlTabObject1);
58 QCOMPARE(qmlTabObject1->property(
"index").toInt(), 1);
59 QCOMPARE(qmlTabObject1->property(
"pinned").toBool(),
false);
60 QTRY_COMPARE(qmlTabObject1->property(
"url").toString(),
QSL(
"https://example.com/"));
63 " url: 'https://another-example.com/'"
65 QCOMPARE(qmlTabsInsertedSpy.count(), 2);
66 QVariantMap retMap2 = QVariant(qmlTabsInsertedSpy.at(1).at(0)).toMap();
67 int index2 = retMap2.value(
QSL(
"index"), -1).toInt();
68 int windowId2 = retMap2.value(
QSL(
"windowId"), -1).toInt();
70 QCOMPARE(windowId2, 0);
72 bool pinnedTab = m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.pinTab({index: 2})")).toBool();
74 QObject *qmlTabObject2 = m_testHelper.
evaluateQObject(
QSL(
"Falkon.Tabs.get({index: 0})"));
75 QVERIFY(qmlTabObject2);
76 QCOMPARE(qmlTabObject2->property(
"index").toInt(), 0);
77 QCOMPARE(qmlTabObject2->property(
"pinned").toBool(),
true);
78 QTRY_COMPARE(qmlTabObject2->property(
"url").toString(),
QSL(
"https://another-example.com/"));
80 bool unpinnedTab = m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.unpinTab({index: 0})")).toBool();
82 QObject *qmlTabObject3 = m_testHelper.
evaluateQObject(
QSL(
"Falkon.Tabs.get({index: 0})"));
83 QVERIFY(qmlTabObject3);
84 QCOMPARE(qmlTabObject3->property(
"url").toString(),
QSL(
"https://another-example.com/"));
85 QCOMPARE(qmlTabObject3->property(
"index").toInt(), 0);
86 QCOMPARE(qmlTabObject3->property(
"pinned").toBool(),
false);
89 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 0);
90 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.nextTab()"));
91 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 1);
92 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.nextTab()"));
93 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 2);
94 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.nextTab()"));
95 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 0);
96 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.previousTab()"));
97 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 2);
98 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.previousTab()"));
99 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 1);
100 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.previousTab()"));
101 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 0);
102 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.setCurrentIndex({index: 2})"));
103 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 2);
104 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.setCurrentIndex({index: 1})"));
105 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 1);
106 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.setCurrentIndex({index: 0})"));
107 QCOMPARE(
mApp->getWindow()->tabWidget()->currentIndex(), 0);
110 QSignalSpy qmlTabsMovedSpy(qmlTabsObject, SIGNAL(tabMoved(QVariantMap)));
111 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.moveTab({from: 0, to:1, windowId: 0})"));
112 QCOMPARE(qmlTabsMovedSpy.count(), 1);
115 QCOMPARE(
mApp->getWindow()->tabCount(), 3);
116 QSignalSpy qmlTabsRemovedSpy(qmlTabsObject, SIGNAL(tabRemoved(QVariantMap)));
117 m_testHelper.
evaluate(
QSL(
"Falkon.Tabs.closeTab({index: 0})"));
118 QCOMPARE(qmlTabsRemovedSpy.count(), 1);
119 QCOMPARE(
mApp->getWindow()->tabCount(), 2);
#define FALKONTEST_MAIN(Test)
QObject * evaluateQObject(const QString &source)
QJSValue evaluate(const QString &source)