From 74c2d4ea2d256183dc1f869a78ee5b1b79888330 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Wed, 25 Apr 2018 12:34:02 +0200 Subject: [PATCH 1/2] Add failing test case for bug #385111 Will be fixed by D12446. CCBUG: 385111 --- src/tests/dolphinmainwindowtest.cpp | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index 26036c9afa..a31237f3c5 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -22,6 +22,9 @@ #include "dolphintabwidget.h" #include "dolphinviewcontainer.h" +#include + +#include #include class DolphinMainWindowTest : public QObject @@ -31,6 +34,7 @@ class DolphinMainWindowTest : public QObject private slots: void init(); void testClosingTabsWithSearchBoxVisible(); + void testUpdateWindowTitleAfterClosingSplitView(); private: QScopedPointer m_mainWindow; @@ -64,6 +68,46 @@ void DolphinMainWindowTest::testClosingTabsWithSearchBoxVisible() 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("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) #include "dolphinmainwindowtest.moc" From 78c8b36dd84a94916835d702ea4a9e8eda65e8ef Mon Sep 17 00:00:00 2001 From: Robert Jennings Date: Wed, 25 Apr 2018 12:35:29 +0200 Subject: [PATCH 2/2] Update window title after closing split view Summary: In dolphintabpage.cpp: Through the connections set up in createViewContainer(), m_primaryViewContainer->setActive(true), at line 98, ends up triggering slotViewActivated(). Because m_primaryViewActive is true, oldActiveView is not set to the view needed in this particular situation. Both oldActiveView and newActiveView end up pointing to the same view and the connections are not set up. BUG: 385111 FIXED-IN: 18.04.1 Test Plan: 1. Open split view 2. Make left panel active 3. Close split view 4. Navigate to various directories Window title now updates to show current directory Also tried with multiple tabs/combinations Reviewers: #dolphin, ngraham Reviewed By: #dolphin, ngraham Subscribers: elvisangelaccio, ngraham Differential Revision: https://phabricator.kde.org/D12446 --- src/dolphintabpage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp index 342d6f6dee..a96c8b6a32 100644 --- a/src/dolphintabpage.cpp +++ b/src/dolphintabpage.cpp @@ -94,6 +94,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, const QUrl &secondaryUrl) // If the primary view is active, we have to swap the pointers // because the secondary view will be the new primary view. qSwap(m_primaryViewContainer, m_secondaryViewContainer); + m_primaryViewActive = false; } m_primaryViewContainer->setActive(true); view->close();