]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Add test cases for enabled status of DolphinNewFileMenu
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 7 Oct 2018 11:05:55 +0000 (13:05 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 7 Oct 2018 13:43:34 +0000 (15:43 +0200)
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/dolphinmainwindow.cpp
src/tests/dolphinmainwindowtest.cpp

index 3e3803d68e36e2f99b633bae6491d54d2e9e2005..a93405f537aa240db46f30f7d11ea2d61ac9aba2 100644 (file)
@@ -1066,6 +1066,7 @@ void DolphinMainWindow::setupActions()
 {
     // setup 'File' menu
     m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
+    m_newFileMenu->setObjectName("newFileMenu");
     QMenu* menu = m_newFileMenu->menu();
     menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
     menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
index eee3871167bb16dc39257b56cc48eed5473b4e48..0dc33012418f3aba196f0848c28f8fb22ae51ddb 100644 (file)
@@ -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<DolphinMainWindow> m_mainWindow;
@@ -170,6 +173,31 @@ void DolphinMainWindowTest::testUpdateWindowTitleAfterClosingSplitView()
     QCOMPARE(currentUrlChangedSpy.count(), 1);
 }
 
+void DolphinMainWindowTest::testNewFileMenuEnabled_data()
+{
+    QTest::addColumn<QUrl>("activeViewUrl");
+    QTest::addColumn<bool>("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<DolphinNewFileMenu*>("newFileMenu");
+    QVERIFY(newFileMenu);
+
+    QFETCH(bool, expectedEnabled);
+    QCOMPARE(newFileMenu->isEnabled(), expectedEnabled);
+}
+
 QTEST_MAIN(DolphinMainWindowTest)
 
 #include "dolphinmainwindowtest.moc"