X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/05d389c56eb2b628c518b221d9ff8477227c64f0..502a5c86feb0015c42f052d242c8115de320a38e:/src/tests/dolphinmainwindowtest.cpp diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index 70ec8dba0..0dc330124 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" @@ -25,6 +26,7 @@ #include #include +#include #include class DolphinMainWindowTest : public QObject @@ -32,16 +34,24 @@ class DolphinMainWindowTest : public QObject Q_OBJECT private slots: + void initTestCase(); void init(); void testClosingTabsWithSearchBoxVisible(); void testActiveViewAfterClosingSplitView_data(); void testActiveViewAfterClosingSplitView(); void testUpdateWindowTitleAfterClosingSplitView(); + void testNewFileMenuEnabled_data(); + void testNewFileMenuEnabled(); private: QScopedPointer m_mainWindow; }; +void DolphinMainWindowTest::initTestCase() +{ + QStandardPaths::setTestModeEnabled(true); +} + void DolphinMainWindowTest::init() { m_mainWindow.reset(new DolphinMainWindow()); @@ -163,6 +173,31 @@ void DolphinMainWindowTest::testUpdateWindowTitleAfterClosingSplitView() QCOMPARE(currentUrlChangedSpy.count(), 1); } +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) #include "dolphinmainwindowtest.moc"