From ad47e8dea16509ad7fca93661669e61ada10ce84 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Thu, 14 Mar 2024 10:50:48 +0000 Subject: [PATCH] Adapt testOpenInNewTabTitle() to upstream change 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index 6b4b0f71b7..f5ece564d3 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -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("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()