diff options
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/tests/dolphinmainwindowtest.cpp | 26 | ||||
| -rw-r--r-- | src/tests/kfileitemmodeltest.cpp | 2 | ||||
| -rw-r--r-- | src/tests/kitemsettest.cpp | 6 | ||||
| -rw-r--r-- | src/tests/placesitemmodeltest.cpp | 21 |
5 files changed, 47 insertions, 10 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 44a413bd9..6ecac1f1e 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -71,7 +71,7 @@ LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test) ecm_add_test(draganddrophelpertest.cpp LINK_LIBRARIES dolphinprivate Qt5::Test) # PlacesItemModelTest -if (KF5_VERSION VERSION_GREATER_EQUAL "5.60.0") +if (KF5_VERSION VERSION_GREATER_EQUAL 5.63.0) ecm_add_test(placesitemmodeltest.cpp TEST_NAME placesitemmodeltest LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test) diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index 3d09699fe..e57c79b02 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -44,6 +44,9 @@ private slots: void testOpenInNewTabTitle(); void testNewFileMenuEnabled_data(); void testNewFileMenuEnabled(); + void testWindowTitle_data(); + void testWindowTitle(); + private: @@ -250,6 +253,29 @@ void DolphinMainWindowTest::testNewFileMenuEnabled() QTRY_COMPARE(newFileMenu->isEnabled(), expectedEnabled); } +void DolphinMainWindowTest::testWindowTitle_data() +{ + QTest::addColumn<QUrl>("activeViewUrl"); + QTest::addColumn<QString>("expectedWindowTitle"); + + // TODO: this test should enforce the english locale. + QTest::newRow("home") << QUrl::fromLocalFile(QDir::homePath()) << QStringLiteral("Home"); + QTest::newRow("home with trailing slash") << QUrl::fromLocalFile(QStringLiteral("%1/").arg(QDir::homePath())) << QStringLiteral("Home"); + QTest::newRow("trash") << QUrl::fromUserInput(QStringLiteral("trash:/")) << QStringLiteral("Trash"); +} + +void DolphinMainWindowTest::testWindowTitle() +{ + QFETCH(QUrl, activeViewUrl); + m_mainWindow->openDirectories({ activeViewUrl }, false); + m_mainWindow->show(); + QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data())); + QVERIFY(m_mainWindow->isVisible()); + + QFETCH(QString, expectedWindowTitle); + QCOMPARE(m_mainWindow->windowTitle(), expectedWindowTitle); +} + QTEST_MAIN(DolphinMainWindowTest) #include "dolphinmainwindowtest.moc" diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index c53979970..f081eba86 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -460,7 +460,7 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems() } m_model->m_dirLister->updateDirectory(m_testDir->url()); - if (itemsInsertedSpy.count() == 0) { + if (itemsInsertedSpy.isEmpty()) { QVERIFY(itemsInsertedSpy.wait()); } diff --git a/src/tests/kitemsettest.cpp b/src/tests/kitemsettest.cpp index 27f8413a7..ca2c16b27 100644 --- a/src/tests/kitemsettest.cpp +++ b/src/tests/kitemsettest.cpp @@ -203,7 +203,7 @@ void KItemSetTest::testIterators() QVERIFY(itemSet.isValid()); QVERIFY(itemSet.count() == itemsQVector.count()); - if (itemSet.count() == 0) { + if (itemSet.isEmpty()) { QVERIFY(itemSet.isEmpty()); QVERIFY(itemSet.begin() == itemSet.end()); QVERIFY(itemSet.constBegin() == itemSet.constEnd()); @@ -342,7 +342,7 @@ void KItemSetTest::testFind() int min; int max; - if (itemSet.count() == 0) { + if (itemSet.isEmpty()) { // Use some arbitrary values for the upcoming tests. min = 0; max = 5; @@ -401,7 +401,7 @@ void KItemSetTest::testChangingOneItem() int min; int max; - if (itemSet.count() == 0) { + if (itemSet.isEmpty()) { // Use some arbitrary values for the upcoming tests. min = 0; max = 5; diff --git a/src/tests/placesitemmodeltest.cpp b/src/tests/placesitemmodeltest.cpp index cc66c5aa0..d066b2ec9 100644 --- a/src/tests/placesitemmodeltest.cpp +++ b/src/tests/placesitemmodeltest.cpp @@ -28,6 +28,7 @@ #include <KConfigGroup> #include <KAboutData> #include <KFilePlacesModel> +#include <KProtocolInfo> #include "dolphin_generalsettings.h" #include "panels/places/placesitemmodel.h" @@ -79,7 +80,7 @@ private: PlacesItemModel* m_model; QSet<int> m_tobeRemoved; QMap<QString, QDBusInterface *> m_interfacesMap; - int m_expectedModelCount = 14; + int m_expectedModelCount = qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused")) ? 16 : 14; bool m_hasDesktopFolder = false; bool m_hasDocumentsFolder = false; bool m_hasDownloadsFolder = false; @@ -175,8 +176,14 @@ QStringList PlacesItemModelTest::initialUrls() const urls << QStringLiteral("trash:/") << QStringLiteral("remote:/") - << QStringLiteral("/media/nfs") - << QStringLiteral("timeline:/today") << QStringLiteral("timeline:/yesterday") + << QStringLiteral("/media/nfs"); + + if (qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))) { + urls << QStringLiteral("recentlyused:/files"); + urls << QStringLiteral("recentlyused:/locations"); + } + + urls << QStringLiteral("timeline:/today") << QStringLiteral("timeline:/yesterday") << QStringLiteral("search:/documents") << QStringLiteral("search:/images") << QStringLiteral("search:/audio") << QStringLiteral("search:/videos") << QStringLiteral("/foreign") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); @@ -315,7 +322,11 @@ void PlacesItemModelTest::testGroups() QCOMPARE(groups.at(1).second.toString(), QStringLiteral("Remote")); QCOMPARE(groups.at(2).first, expectedRemoteIndex + 2); - QCOMPARE(groups.at(2).second.toString(), QStringLiteral("Recently Saved")); + QCOMPARE(groups.at(2).second.toString(), QStringLiteral("Recent")); + + if (qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))) { + expectedRemoteIndex += 2; + } QCOMPARE(groups.at(3).first, expectedRemoteIndex + 4); QCOMPARE(groups.at(3).second.toString(), QStringLiteral("Search For")); @@ -342,7 +353,7 @@ void PlacesItemModelTest::testPlaceItem_data() QTest::newRow("Baloo - Documents") << QUrl("search:/documents") << false << true << QStringLiteral("Search For") << false; // baloo - timeline - QTest::newRow("Baloo - Today") << QUrl("timeline:/today") << false << true << QStringLiteral("Recently Saved") << false; + QTest::newRow("Baloo - Today") << QUrl("timeline:/today") << false << true << QStringLiteral("Recent") << false; // devices QTest::newRow("Devices - Floppy") << QUrl("file:///media/floppy0") << false << false << QStringLiteral("Removable Devices") << false; |
