Add failing test case for bug #385111

Will be fixed by D12446.

CCBUG: 385111
This commit is contained in:
Elvis Angelaccio 2018-04-25 12:34:02 +02:00
parent e15d9f266b
commit 74c2d4ea2d

View file

@ -22,6 +22,9 @@
#include "dolphintabwidget.h" #include "dolphintabwidget.h"
#include "dolphinviewcontainer.h" #include "dolphinviewcontainer.h"
#include <KActionCollection>
#include <QSignalSpy>
#include <QTest> #include <QTest>
class DolphinMainWindowTest : public QObject class DolphinMainWindowTest : public QObject
@ -31,6 +34,7 @@ class DolphinMainWindowTest : public QObject
private slots: private slots:
void init(); void init();
void testClosingTabsWithSearchBoxVisible(); void testClosingTabsWithSearchBoxVisible();
void testUpdateWindowTitleAfterClosingSplitView();
private: private:
QScopedPointer<DolphinMainWindow> m_mainWindow; QScopedPointer<DolphinMainWindow> m_mainWindow;
@ -64,6 +68,46 @@ void DolphinMainWindowTest::testClosingTabsWithSearchBoxVisible()
QCOMPARE(tabWidget->count(), 1); QCOMPARE(tabWidget->count(), 1);
} }
// Test case for bug #385111
void DolphinMainWindowTest::testUpdateWindowTitleAfterClosingSplitView()
{
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);
QVERIFY(tabWidget->currentTabPage()->primaryViewContainer());
QVERIFY(!tabWidget->currentTabPage()->secondaryViewContainer());
// Open split view.
m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
QVERIFY(tabWidget->currentTabPage()->splitViewEnabled());
QVERIFY(tabWidget->currentTabPage()->secondaryViewContainer());
// Make sure the right view is the active one.
auto leftViewContainer = tabWidget->currentTabPage()->primaryViewContainer();
auto rightViewContainer = tabWidget->currentTabPage()->secondaryViewContainer();
QVERIFY(!leftViewContainer->isActive());
QVERIFY(rightViewContainer->isActive());
// Activate left view.
leftViewContainer->setActive(true);
QVERIFY(leftViewContainer->isActive());
QVERIFY(!rightViewContainer->isActive());
// Close split view. The secondary view (which was on the right) will become the primary one and must be active.
m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
QVERIFY(rightViewContainer->isActive());
QCOMPARE(rightViewContainer, tabWidget->currentTabPage()->activeViewContainer());
// Change URL and make sure we emit the currentUrlChanged signal (which triggers the window title update).
QSignalSpy currentUrlChangedSpy(tabWidget, &DolphinTabWidget::currentUrlChanged);
tabWidget->currentTabPage()->activeViewContainer()->setUrl(QUrl::fromLocalFile(QDir::rootPath()));
QCOMPARE(currentUrlChangedSpy.count(), 1);
}
QTEST_MAIN(DolphinMainWindowTest) QTEST_MAIN(DolphinMainWindowTest)
#include "dolphinmainwindowtest.moc" #include "dolphinmainwindowtest.moc"