mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-19 18:26:34 +01:00
Autotests: Fi QmlTabsApiTest
GIT_SILENT Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
922681c1cb
commit
8f766f7576
@ -31,11 +31,14 @@ void QmlTabsApiTest::cleanupTestCase()
|
|||||||
void QmlTabsApiTest::testInitWindowCount()
|
void QmlTabsApiTest::testInitWindowCount()
|
||||||
{
|
{
|
||||||
QCOMPARE(mApp->windowCount(), 1);
|
QCOMPARE(mApp->windowCount(), 1);
|
||||||
QCOMPARE(mApp->getWindow()->tabCount(), 0);
|
QTRY_COMPARE(mApp->getWindow()->tabCount(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlTabsApiTest::testTabsAPI()
|
void QmlTabsApiTest::testTabsAPI()
|
||||||
{
|
{
|
||||||
|
/* Wait until the initial tab (at index 0) in the window is created */
|
||||||
|
QTRY_COMPARE(mApp->getWindow()->tabCount(), 1);
|
||||||
|
|
||||||
// Tab Insertion
|
// Tab Insertion
|
||||||
QObject *qmlTabsObject = m_testHelper.evaluateQObject(QSL("Falkon.Tabs"));
|
QObject *qmlTabsObject = m_testHelper.evaluateQObject(QSL("Falkon.Tabs"));
|
||||||
QVERIFY(qmlTabsObject);
|
QVERIFY(qmlTabsObject);
|
||||||
@ -47,26 +50,26 @@ void QmlTabsApiTest::testTabsAPI()
|
|||||||
QVariantMap retMap1 = QVariant(qmlTabsInsertedSpy.at(0).at(0)).toMap();
|
QVariantMap retMap1 = QVariant(qmlTabsInsertedSpy.at(0).at(0)).toMap();
|
||||||
int index1 = retMap1.value(QSL("index"), -1).toInt();
|
int index1 = retMap1.value(QSL("index"), -1).toInt();
|
||||||
int windowId1 = retMap1.value(QSL("windowId"), -1).toInt();
|
int windowId1 = retMap1.value(QSL("windowId"), -1).toInt();
|
||||||
QCOMPARE(index1, 0);
|
QCOMPARE(index1, 1);
|
||||||
QCOMPARE(windowId1, 0);
|
QCOMPARE(windowId1, 0);
|
||||||
|
|
||||||
QObject *qmlTabObject1 = m_testHelper.evaluateQObject(QSL("Falkon.Tabs.get({index: 0})"));
|
QObject *qmlTabObject1 = m_testHelper.evaluateQObject(QSL("Falkon.Tabs.get({index: 1})"));
|
||||||
QVERIFY(qmlTabObject1);
|
QVERIFY(qmlTabObject1);
|
||||||
QCOMPARE(qmlTabObject1->property("index").toInt(), 0);
|
QCOMPARE(qmlTabObject1->property("index").toInt(), 1);
|
||||||
QCOMPARE(qmlTabObject1->property("pinned").toBool(), false);
|
QCOMPARE(qmlTabObject1->property("pinned").toBool(), false);
|
||||||
QTRY_COMPARE(qmlTabObject1->property("url").toString(), QSL("https://example.com/"));
|
QTRY_COMPARE(qmlTabObject1->property("url").toString(), QSL("https://example.com/"));
|
||||||
|
|
||||||
m_testHelper.evaluate(QL1S("Falkon.Tabs.addTab({"
|
m_testHelper.evaluate(QL1S("Falkon.Tabs.addTab({"
|
||||||
" url: 'https://another-example.com/',"
|
" url: 'https://another-example.com/'"
|
||||||
"})"));
|
"})"));
|
||||||
QCOMPARE(qmlTabsInsertedSpy.count(), 2);
|
QCOMPARE(qmlTabsInsertedSpy.count(), 2);
|
||||||
QVariantMap retMap2 = QVariant(qmlTabsInsertedSpy.at(1).at(0)).toMap();
|
QVariantMap retMap2 = QVariant(qmlTabsInsertedSpy.at(1).at(0)).toMap();
|
||||||
int index2 = retMap2.value(QSL("index"), -1).toInt();
|
int index2 = retMap2.value(QSL("index"), -1).toInt();
|
||||||
int windowId2 = retMap2.value(QSL("windowId"), -1).toInt();
|
int windowId2 = retMap2.value(QSL("windowId"), -1).toInt();
|
||||||
QCOMPARE(index2, 1);
|
QCOMPARE(index2, 2);
|
||||||
QCOMPARE(windowId2, 0);
|
QCOMPARE(windowId2, 0);
|
||||||
|
|
||||||
bool pinnedTab = m_testHelper.evaluate(QSL("Falkon.Tabs.pinTab({index: 1})")).toBool();
|
bool pinnedTab = m_testHelper.evaluate(QSL("Falkon.Tabs.pinTab({index: 2})")).toBool();
|
||||||
QVERIFY(pinnedTab);
|
QVERIFY(pinnedTab);
|
||||||
QObject *qmlTabObject2 = m_testHelper.evaluateQObject(QSL("Falkon.Tabs.get({index: 0})"));
|
QObject *qmlTabObject2 = m_testHelper.evaluateQObject(QSL("Falkon.Tabs.get({index: 0})"));
|
||||||
QVERIFY(qmlTabObject2);
|
QVERIFY(qmlTabObject2);
|
||||||
@ -87,11 +90,17 @@ void QmlTabsApiTest::testTabsAPI()
|
|||||||
m_testHelper.evaluate(QSL("Falkon.Tabs.nextTab()"));
|
m_testHelper.evaluate(QSL("Falkon.Tabs.nextTab()"));
|
||||||
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 1);
|
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 1);
|
||||||
m_testHelper.evaluate(QSL("Falkon.Tabs.nextTab()"));
|
m_testHelper.evaluate(QSL("Falkon.Tabs.nextTab()"));
|
||||||
|
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 2);
|
||||||
|
m_testHelper.evaluate(QSL("Falkon.Tabs.nextTab()"));
|
||||||
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 0);
|
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 0);
|
||||||
m_testHelper.evaluate(QSL("Falkon.Tabs.previousTab()"));
|
m_testHelper.evaluate(QSL("Falkon.Tabs.previousTab()"));
|
||||||
|
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 2);
|
||||||
|
m_testHelper.evaluate(QSL("Falkon.Tabs.previousTab()"));
|
||||||
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 1);
|
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 1);
|
||||||
m_testHelper.evaluate(QSL("Falkon.Tabs.previousTab()"));
|
m_testHelper.evaluate(QSL("Falkon.Tabs.previousTab()"));
|
||||||
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 0);
|
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 0);
|
||||||
|
m_testHelper.evaluate(QSL("Falkon.Tabs.setCurrentIndex({index: 2})"));
|
||||||
|
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 2);
|
||||||
m_testHelper.evaluate(QSL("Falkon.Tabs.setCurrentIndex({index: 1})"));
|
m_testHelper.evaluate(QSL("Falkon.Tabs.setCurrentIndex({index: 1})"));
|
||||||
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 1);
|
QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 1);
|
||||||
m_testHelper.evaluate(QSL("Falkon.Tabs.setCurrentIndex({index: 0})"));
|
m_testHelper.evaluate(QSL("Falkon.Tabs.setCurrentIndex({index: 0})"));
|
||||||
@ -103,11 +112,11 @@ void QmlTabsApiTest::testTabsAPI()
|
|||||||
QCOMPARE(qmlTabsMovedSpy.count(), 1);
|
QCOMPARE(qmlTabsMovedSpy.count(), 1);
|
||||||
|
|
||||||
// Tab Removal
|
// Tab Removal
|
||||||
QCOMPARE(mApp->getWindow()->tabCount(), 2);
|
QCOMPARE(mApp->getWindow()->tabCount(), 3);
|
||||||
QSignalSpy qmlTabsRemovedSpy(qmlTabsObject, SIGNAL(tabRemoved(QVariantMap)));
|
QSignalSpy qmlTabsRemovedSpy(qmlTabsObject, SIGNAL(tabRemoved(QVariantMap)));
|
||||||
m_testHelper.evaluate(QSL("Falkon.Tabs.closeTab({index: 0})"));
|
m_testHelper.evaluate(QSL("Falkon.Tabs.closeTab({index: 0})"));
|
||||||
QCOMPARE(qmlTabsRemovedSpy.count(), 1);
|
QCOMPARE(qmlTabsRemovedSpy.count(), 1);
|
||||||
QCOMPARE(mApp->getWindow()->tabCount(), 1);
|
QCOMPARE(mApp->getWindow()->tabCount(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
FALKONTEST_MAIN(QmlTabsApiTest)
|
FALKONTEST_MAIN(QmlTabsApiTest)
|
||||||
|
Loading…
Reference in New Issue
Block a user