From dec7016c0d52129340a5b47f6de4df8af5115e21 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sun, 7 Oct 2018 13:05:55 +0200 Subject: Add test cases for enabled status of DolphinNewFileMenu Summary: Root and Trash test cases are currently failing because of commit e133c4557ecc37ed3f7e1b9418306aa8cc516865. Reviewers: #dolphin Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D16005 --- src/tests/dolphinmainwindowtest.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/tests/dolphinmainwindowtest.cpp') diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index eee387116..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" @@ -39,6 +40,8 @@ private slots: void testActiveViewAfterClosingSplitView_data(); void testActiveViewAfterClosingSplitView(); void testUpdateWindowTitleAfterClosingSplitView(); + void testNewFileMenuEnabled_data(); + void testNewFileMenuEnabled(); private: QScopedPointer m_mainWindow; @@ -170,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" -- cgit v1.3