@@ -68,6 +68,7 @@ private Q_SLOTS:
68
68
void testInlineRename ();
69
69
void testThumbnailAfterRename ();
70
70
void testViewModeAfterDynamicView ();
71
+ void testActivationAndTabTitleAfterRenameOpeningFolder ();
71
72
void cleanupTestCase ();
72
73
73
74
private:
@@ -421,7 +422,7 @@ void DolphinMainWindowTest::testCreateFileAction()
421
422
QCOMPARE (file.size (), 0 );
422
423
}
423
424
424
- void DolphinMainWindowTest::testCreateFileActionRequiresWritePermission ()
425
+ void DolphinMainWindowTest::testCreateFileActionRequiresWritePermission ()
425
426
{
426
427
QScopedPointer<TestDir> testDir{new TestDir ()};
427
428
QString testDirUrl (QDir::cleanPath (testDir->url ().toString ()));
@@ -1145,6 +1146,85 @@ void DolphinMainWindowTest::testViewModeAfterDynamicView()
1145
1146
QVERIFY (ViewProperties (view->viewPropertiesUrl ()).dynamicViewPassed ());
1146
1147
}
1147
1148
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
+
1148
1228
void DolphinMainWindowTest::cleanupTestCase ()
1149
1229
{
1150
1230
m_mainWindow->showNormal ();
0 commit comments