]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Adapt testOpenInNewTabTitle() to upstream change
authorFelix Ernst <felixernst@kde.org>
Thu, 14 Mar 2024 10:50:48 +0000 (10:50 +0000)
committerMéven Car <meven.car@kdemail.net>
Thu, 14 Mar 2024 10:50:48 +0000 (10:50 +0000)
Prior to this commit the test failed because it expected a generic "inode-directory" icon for directories like "home" or "tmp" even though we have more specialised and nicer icons for these directories. I assume the test only used to pass because we were actually always using generic and therefore unhelpful icons for tabs.

This commit removes the hard-coded expectation of the "inode-directory" icon and instead compares the tab icon with the return value of KIO::iconNameForUrl(tabUrl).

src/tests/dolphinmainwindowtest.cpp

index 6b4b0f71b759e51f61fcb5bd5b41e5b66774e8ba..f5ece564d33e32f725c6c369746878fd2e3d4125 100644 (file)
@@ -212,7 +212,8 @@ void DolphinMainWindowTest::testUpdateWindowTitleAfterChangingSplitView()
 // Test case for bug #397910
 void DolphinMainWindowTest::testOpenInNewTabTitle()
 {
-    m_mainWindow->openDirectories({QUrl::fromLocalFile(QDir::homePath())}, false);
+    const QUrl homePathUrl{QUrl::fromLocalFile(QDir::homePath())};
+    m_mainWindow->openDirectories({homePathUrl}, false);
     m_mainWindow->show();
     QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data()));
     QVERIFY(m_mainWindow->isVisible());
@@ -220,13 +221,14 @@ void DolphinMainWindowTest::testOpenInNewTabTitle()
     auto tabWidget = m_mainWindow->findChild<DolphinTabWidget *>("tabWidget");
     QVERIFY(tabWidget);
 
-    tabWidget->openNewTab(QUrl::fromLocalFile(QDir::tempPath()));
+    const QUrl tempPathUrl{QUrl::fromLocalFile(QDir::tempPath())};
+    tabWidget->openNewTab(tempPathUrl);
     QCOMPARE(tabWidget->count(), 2);
     QVERIFY(tabWidget->tabText(0) != tabWidget->tabText(1));
-    if (!tabWidget->tabIcon(0).isNull() && !tabWidget->tabIcon(1).isNull()) {
-        QCOMPARE(QStringLiteral("inode-directory"), tabWidget->tabIcon(0).name());
-        QCOMPARE(QStringLiteral("inode-directory"), tabWidget->tabIcon(1).name());
-    }
+
+    QVERIFY2(!tabWidget->tabIcon(0).isNull() && !tabWidget->tabIcon(1).isNull(), "Tabs are supposed to have icons.");
+    QCOMPARE(KIO::iconNameForUrl(homePathUrl), tabWidget->tabIcon(0).name());
+    QCOMPARE(KIO::iconNameForUrl(tempPathUrl), tabWidget->tabIcon(1).name());
 }
 
 void DolphinMainWindowTest::testNewFileMenuEnabled_data()