***************************************************************************/
#include "dolphinmainwindow.h"
+#include "dolphinnewfilemenu.h"
#include "dolphintabpage.h"
#include "dolphintabwidget.h"
#include "dolphinviewcontainer.h"
void testActiveViewAfterClosingSplitView_data();
void testActiveViewAfterClosingSplitView();
void testUpdateWindowTitleAfterClosingSplitView();
+ void testUpdateWindowTitleAfterChangingSplitView();
void testOpenInNewTabTitle();
+ void testNewFileMenuEnabled_data();
+ void testNewFileMenuEnabled();
+
private:
QScopedPointer<DolphinMainWindow> m_mainWindow;
QCOMPARE(currentUrlChangedSpy.count(), 1);
}
+// Test case for bug #402641
+void DolphinMainWindowTest::testUpdateWindowTitleAfterChangingSplitView()
+{
+ m_mainWindow->openDirectories({ QUrl::fromLocalFile(QDir::homePath()) }, false);
+ m_mainWindow->show();
+ QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data()));
+ QVERIFY(m_mainWindow->isVisible());
+
+ auto tabWidget = m_mainWindow->findChild<DolphinTabWidget*>("tabWidget");
+ QVERIFY(tabWidget);
+
+ // Open split view.
+ m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(tabWidget->currentTabPage()->splitViewEnabled());
+
+ auto leftViewContainer = tabWidget->currentTabPage()->primaryViewContainer();
+ auto rightViewContainer = tabWidget->currentTabPage()->secondaryViewContainer();
+
+ // Store old window title.
+ const auto oldTitle = m_mainWindow->windowTitle();
+
+ // Change URL in the right view and make sure the title gets updated.
+ rightViewContainer->setUrl(QUrl::fromLocalFile(QDir::rootPath()));
+ QVERIFY(m_mainWindow->windowTitle() != oldTitle);
+
+ // Activate back the left view and check whether the old title gets restored.
+ leftViewContainer->setActive(true);
+ QEXPECT_FAIL("", "Bug #402641", Continue);
+ QCOMPARE(m_mainWindow->windowTitle(), oldTitle);
+}
+
// Test case for bug #397910
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<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)