Skip to content

Commit 051bc36

Browse files
GWDxMéven Car
authored andcommitted
Add integration test for split view activation and tab title update after renaming a folder
In a split-view tab, the child folder is opened in the left view and other tabs, while the parent folder is opened in the right view. After renaming the child folder from the right view: - The activated view should not switch to the left view. - All tab titles should be updated. CCBUG: 496414
1 parent eeb5251 commit 051bc36

File tree

1 file changed

+81
-1
lines changed

1 file changed

+81
-1
lines changed

src/tests/dolphinmainwindowtest.cpp

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private Q_SLOTS:
6868
void testInlineRename();
6969
void testThumbnailAfterRename();
7070
void testViewModeAfterDynamicView();
71+
void testActivationAndTabTitleAfterRenameOpeningFolder();
7172
void cleanupTestCase();
7273

7374
private:
@@ -421,7 +422,7 @@ void DolphinMainWindowTest::testCreateFileAction()
421422
QCOMPARE(file.size(), 0);
422423
}
423424

424-
void DolphinMainWindowTest::testCreateFileActionRequiresWritePermission()
425+
void DolphinMainWindowTest::testCreateFileActionRequiresWritePermission()
425426
{
426427
QScopedPointer<TestDir> testDir{new TestDir()};
427428
QString testDirUrl(QDir::cleanPath(testDir->url().toString()));
@@ -1145,6 +1146,85 @@ void DolphinMainWindowTest::testViewModeAfterDynamicView()
11451146
QVERIFY(ViewProperties(view->viewPropertiesUrl()).dynamicViewPassed());
11461147
}
11471148

1149+
void DolphinMainWindowTest::testActivationAndTabTitleAfterRenameOpeningFolder()
1150+
{
1151+
QScopedPointer<TestDir> testDir{new TestDir()};
1152+
testDir->createDir("a");
1153+
const QUrl parentDirUrl = QUrl::fromLocalFile(testDir->url().toLocalFile());
1154+
const QUrl childDirUrl = QUrl::fromLocalFile(testDir->url().toLocalFile() + "/a");
1155+
1156+
auto tabWidget = m_mainWindow->findChild<DolphinTabWidget *>("tabWidget");
1157+
QVERIFY(tabWidget);
1158+
1159+
// Tab 0: Open childDirUrl
1160+
m_mainWindow->openDirectories({childDirUrl}, false);
1161+
m_mainWindow->show();
1162+
QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data()));
1163+
QVERIFY(m_mainWindow->isVisible());
1164+
1165+
// Tab 0: Enable split view
1166+
m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->setChecked(true);
1167+
m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
1168+
QVERIFY(tabWidget->currentTabPage()->splitViewEnabled());
1169+
1170+
// Tab 1: Open childDirUrl
1171+
tabWidget->openNewActivatedTab(childDirUrl);
1172+
1173+
// Tab 1: Open parentDirUrl in right view
1174+
m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->setChecked(true);
1175+
m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
1176+
QVERIFY(tabWidget->currentTabPage()->splitViewEnabled());
1177+
1178+
DolphinView *view = m_mainWindow->activeViewContainer()->view();
1179+
view->m_model->loadDirectory(parentDirUrl);
1180+
view->setUrl(parentDirUrl);
1181+
1182+
// Check current view is right view
1183+
QVERIFY(tabWidget->currentTabPage()->secondaryViewContainer()->isActive());
1184+
1185+
// Check all tab titles are correct
1186+
// Tab 0: (a) | a
1187+
// Tab 1: (a) | parentDir
1188+
const QString parentDirName = QFileInfo(parentDirUrl.toString()).fileName();
1189+
const QString childDirName = QFileInfo(childDirUrl.toString()).fileName();
1190+
const QString expectedTab0Title = QStringLiteral("(%1) | %2").arg(childDirName, childDirName);
1191+
const QString expectedTab1Title = QStringLiteral("(%1) | %2").arg(childDirName, parentDirName);
1192+
QCOMPARE(tabWidget->tabText(0), expectedTab0Title);
1193+
QCOMPARE(tabWidget->tabText(1), expectedTab1Title);
1194+
1195+
// Prepare signal spies
1196+
QSignalSpy viewDirectoryLoadingCompletedSpy(view, &DolphinView::directoryLoadingCompleted);
1197+
QSignalSpy itemsChangedSpy(view->m_model, &KFileItemModel::itemsChanged);
1198+
1199+
QVERIFY(viewDirectoryLoadingCompletedSpy.wait());
1200+
QTest::qWait(0);
1201+
1202+
// Rename child dir to "b"
1203+
view->markUrlsAsSelected({childDirUrl});
1204+
view->updateViewState();
1205+
view->renameSelectedItems(); // Rename inline
1206+
1207+
QTest::keyClick(QApplication::focusWidget(), Qt::Key_B);
1208+
QTest::keyClick(QApplication::focusWidget(), Qt::Key_Enter);
1209+
QVERIFY(itemsChangedSpy.wait()); // Make sure that rename worked
1210+
1211+
// Check current view is right view
1212+
QVERIFY(tabWidget->currentTabPage()->secondaryViewContainer()->isActive());
1213+
1214+
// Check navigator in left view is inactive
1215+
auto leftViewNavigator = tabWidget->currentTabPage()->primaryViewContainer()->urlNavigator();
1216+
QVERIFY(!leftViewNavigator->isActive());
1217+
1218+
// Check all tab titles are correct after rename
1219+
// Tab 0: (b) | b
1220+
// Tab 1: (b) | parentDir
1221+
const QString newChildDirName = QStringLiteral("b");
1222+
const QString expectedNewTab0Title = QStringLiteral("(%1) | %2").arg(newChildDirName, newChildDirName);
1223+
const QString expectedNewTab1Title = QStringLiteral("(%1) | %2").arg(newChildDirName, parentDirName);
1224+
QCOMPARE(tabWidget->tabText(0), expectedNewTab0Title);
1225+
QCOMPARE(tabWidget->tabText(1), expectedNewTab1Title);
1226+
}
1227+
11481228
void DolphinMainWindowTest::cleanupTestCase()
11491229
{
11501230
m_mainWindow->showNormal();

0 commit comments

Comments
 (0)