X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b610ce5913ef3172f3cf15c0a1d93c255ea0da4f..105fe62eeb3ec3258a35400a1e6cb2901e01ac2d:/src/tests/dolphinmainwindowtest.cpp diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index ca492215a..673bccd44 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -18,6 +18,7 @@ ***************************************************************************/ #include "dolphinmainwindow.h" +#include "dolphinnewfilemenu.h" #include "dolphintabpage.h" #include "dolphintabwidget.h" #include "dolphinviewcontainer.h" @@ -40,6 +41,9 @@ private slots: void testActiveViewAfterClosingSplitView(); void testUpdateWindowTitleAfterClosingSplitView(); void testOpenInNewTabTitle(); + void testNewFileMenuEnabled_data(); + void testNewFileMenuEnabled(); + private: QScopedPointer m_mainWindow; @@ -184,8 +188,35 @@ void DolphinMainWindowTest::testOpenInNewTabTitle() tabWidget->openNewTab(QUrl::fromLocalFile(QDir::tempPath())); QCOMPARE(tabWidget->count(), 2); - QVERIFY(tabWidget->tabIcon(0).name() != tabWidget->tabIcon(1).name()); QVERIFY(tabWidget->tabText(0) != tabWidget->tabText(1)); + if (!tabWidget->tabIcon(0).isNull() && !tabWidget->tabIcon(1).isNull()) { + QVERIFY(tabWidget->tabIcon(0).name() != tabWidget->tabIcon(1).name()); + } +} + +void DolphinMainWindowTest::testNewFileMenuEnabled_data() +{ + QTest::addColumn("activeViewUrl"); + QTest::addColumn("expectedEnabled"); + + QTest::newRow("home") << QUrl::fromLocalFile(QDir::homePath()) << true; + QTest::newRow("root") << QUrl::fromLocalFile(QDir::rootPath()) << false; + QTest::newRow("trash") << QUrl::fromUserInput(QStringLiteral("trash:/")) << false; +} + +void DolphinMainWindowTest::testNewFileMenuEnabled() +{ + QFETCH(QUrl, activeViewUrl); + m_mainWindow->openDirectories({ activeViewUrl }, false); + m_mainWindow->show(); + QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data())); + QVERIFY(m_mainWindow->isVisible()); + + auto newFileMenu = m_mainWindow->findChild("newFileMenu"); + QVERIFY(newFileMenu); + + QFETCH(bool, expectedEnabled); + QCOMPARE(newFileMenu->isEnabled(), expectedEnabled); } QTEST_MAIN(DolphinMainWindowTest)