┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/dolphinmainwindowtest.cpp21
-rw-r--r--src/tests/kfileitemmodeltest.cpp33
-rw-r--r--src/tests/kitemlistcontrollertest.cpp1
-rw-r--r--src/tests/placesitemmodeltest.cpp68
4 files changed, 73 insertions, 50 deletions
diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp
index 0dc330124..673bccd44 100644
--- a/src/tests/dolphinmainwindowtest.cpp
+++ b/src/tests/dolphinmainwindowtest.cpp
@@ -40,9 +40,11 @@ private slots:
void testActiveViewAfterClosingSplitView_data();
void testActiveViewAfterClosingSplitView();
void testUpdateWindowTitleAfterClosingSplitView();
+ void testOpenInNewTabTitle();
void testNewFileMenuEnabled_data();
void testNewFileMenuEnabled();
+
private:
QScopedPointer<DolphinMainWindow> m_mainWindow;
};
@@ -173,6 +175,25 @@ void DolphinMainWindowTest::testUpdateWindowTitleAfterClosingSplitView()
QCOMPARE(currentUrlChangedSpy.count(), 1);
}
+// Test case for bug #397910
+void DolphinMainWindowTest::testOpenInNewTabTitle()
+{
+ 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);
+
+ tabWidget->openNewTab(QUrl::fromLocalFile(QDir::tempPath()));
+ QCOMPARE(tabWidget->count(), 2);
+ 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");
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index b455c521d..2f258d17d 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -1551,25 +1551,26 @@ void KFileItemModelTest::testChangeSortRoleWhileFiltering()
{
KFileItemList items;
- KIO::UDSEntry entry;
- entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, 0100000); // S_IFREG might not be defined on non-Unix platforms.
- entry.insert(KIO::UDSEntry::UDS_ACCESS, 07777);
- entry.insert(KIO::UDSEntry::UDS_SIZE, 0);
- entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, 0);
- entry.insert(KIO::UDSEntry::UDS_GROUP, "group");
- entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, 0);
+ KIO::UDSEntry entry[3];
- entry.insert(KIO::UDSEntry::UDS_NAME, "a.txt");
- entry.insert(KIO::UDSEntry::UDS_USER, "user-b");
- items.append(KFileItem(entry, m_testDir->url(), false, true));
+ entry[0].insert(KIO::UDSEntry::UDS_NAME, "a.txt");
+ entry[0].insert(KIO::UDSEntry::UDS_USER, "user-b");
- entry.insert(KIO::UDSEntry::UDS_NAME, "b.txt");
- entry.insert(KIO::UDSEntry::UDS_USER, "user-c");
- items.append(KFileItem(entry, m_testDir->url(), false, true));
+ entry[1].insert(KIO::UDSEntry::UDS_NAME, "b.txt");
+ entry[1].insert(KIO::UDSEntry::UDS_USER, "user-c");
- entry.insert(KIO::UDSEntry::UDS_NAME, "c.txt");
- entry.insert(KIO::UDSEntry::UDS_USER, "user-a");
- items.append(KFileItem(entry, m_testDir->url(), false, true));
+ entry[2].insert(KIO::UDSEntry::UDS_NAME, "c.txt");
+ entry[2].insert(KIO::UDSEntry::UDS_USER, "user-a");
+
+ for (int i = 0; i < 3; ++i) {
+ entry[i].insert(KIO::UDSEntry::UDS_FILE_TYPE, 0100000); // S_IFREG might not be defined on non-Unix platforms.
+ entry[i].insert(KIO::UDSEntry::UDS_ACCESS, 07777);
+ entry[i].insert(KIO::UDSEntry::UDS_SIZE, 0);
+ entry[i].insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, 0);
+ entry[i].insert(KIO::UDSEntry::UDS_GROUP, "group");
+ entry[i].insert(KIO::UDSEntry::UDS_ACCESS_TIME, 0);
+ items.append(KFileItem(entry[i], m_testDir->url(), false, true));
+ }
m_model->slotItemsAdded(m_testDir->url(), items);
m_model->slotCompleted();
diff --git a/src/tests/kitemlistcontrollertest.cpp b/src/tests/kitemlistcontrollertest.cpp
index a468ca6dc..c472f128f 100644
--- a/src/tests/kitemlistcontrollertest.cpp
+++ b/src/tests/kitemlistcontrollertest.cpp
@@ -545,6 +545,7 @@ void KItemListControllerTest::testKeyboardNavigation()
}
// No items are selected. Therefore, the current item should be activated.
// This is handled by falling through to the NoSelection/SingleSelection case.
+ Q_FALLTHROUGH();
case KItemListController::NoSelection:
case KItemListController::SingleSelection:
// In NoSelection and SingleSelection mode, the current item should be activated.
diff --git a/src/tests/placesitemmodeltest.cpp b/src/tests/placesitemmodeltest.cpp
index 545bba89c..40ee47cbc 100644
--- a/src/tests/placesitemmodeltest.cpp
+++ b/src/tests/placesitemmodeltest.cpp
@@ -96,7 +96,7 @@ private:
QStringList placesUrls(PlacesItemModel *model = nullptr) const;
QStringList initialUrls() const;
void createPlaceItem(const QString &text, const QUrl &url, const QString &icon);
- void removePlaceAfter(int index);
+ void schedulePlaceRemoval(int index);
void cancelPlaceRemoval(int index);
void removeTestUserData();
QMimeData *createMimeData(const QList<int> &indexes) const;
@@ -190,7 +190,7 @@ void PlacesItemModelTest::createPlaceItem(const QString &text, const QUrl &url,
m_model->createPlacesItem(text, url, icon);
}
-void PlacesItemModelTest::removePlaceAfter(int index)
+void PlacesItemModelTest::schedulePlaceRemoval(int index)
{
m_tobeRemoved.insert(index);
}
@@ -235,7 +235,7 @@ QMimeData *PlacesItemModelTest::createMimeData(const QList<int> &indexes) const
void PlacesItemModelTest::init()
{
m_model = new PlacesItemModel();
- // WORKAROUND: need to wait for bookmark to load, check: PlacesItemModel::updateBookmarks
+ // WORKAROUND: need to wait for bookmark to load
QTest::qWait(300);
QCOMPARE(m_model->count(), m_expectedModelCount);
}
@@ -563,7 +563,7 @@ void PlacesItemModelTest::testSystemItems()
QTRY_COMPARE(itemsInsertedSpy.count(), 1);
// make sure the new place get removed
- removePlaceAfter(tempDirIndex);
+ schedulePlaceRemoval(tempDirIndex);
QList<QVariant> args = itemsInsertedSpy.takeFirst();
KItemRangeList range = args.at(0).value<KItemRangeList>();
@@ -589,7 +589,7 @@ void PlacesItemModelTest::testSystemItems()
void PlacesItemModelTest::testEditBookmark()
{
- int tempDirIndex = 3;
+ int tempDirIndex = 1;
if (m_hasDesktopFolder) {
tempDirIndex++;
}
@@ -602,32 +602,32 @@ void PlacesItemModelTest::testEditBookmark()
createPlaceItem(QStringLiteral("Temporary Dir"), QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation)), QString());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex);
+ schedulePlaceRemoval(tempDirIndex + 2);
QSignalSpy itemsChangedSply(m_model, &PlacesItemModel::itemsChanged);
// modify place text
- m_model->item(3)->setText(QStringLiteral("Renamed place"));
+ m_model->item(tempDirIndex)->setText(QStringLiteral("Renamed place"));
m_model->refresh();
// check if the correct signal was fired
QTRY_COMPARE(itemsChangedSply.count(), 1);
QList<QVariant> args = itemsChangedSply.takeFirst();
KItemRangeList range = args.at(0).value<KItemRangeList>();
- QCOMPARE(range.first().index, 3);
+ QCOMPARE(range.first().index, tempDirIndex);
QCOMPARE(range.first().count, 1);
QSet<QByteArray> roles = args.at(1).value<QSet<QByteArray> >();
QCOMPARE(roles.size(), 1);
QCOMPARE(*roles.begin(), QByteArrayLiteral("text"));
- QCOMPARE(m_model->item(3)->text(), QStringLiteral("Renamed place"));
+ QCOMPARE(m_model->item(tempDirIndex)->text(), QStringLiteral("Renamed place"));
// check if the item was updated in the other model
- QTRY_COMPARE(other->item(3)->text(), QStringLiteral("Renamed place"));
+ QTRY_COMPARE(other->item(tempDirIndex)->text(), QStringLiteral("Renamed place"));
}
void PlacesItemModelTest::testEditAfterCreation()
{
- int tempDirIndex = 3;
+ int tempDirIndex = 1;
if (m_hasDesktopFolder) {
tempDirIndex++;
}
@@ -646,25 +646,25 @@ void PlacesItemModelTest::testEditAfterCreation()
QTRY_COMPARE(model->count(), m_model->count());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex);
+ schedulePlaceRemoval(tempDirIndex + 2);
// modify place text
- PlacesItem *item = m_model->placesItem(3);
+ PlacesItem *item = m_model->placesItem(tempDirIndex);
item->setText(QStringLiteral("Renamed place"));
m_model->refresh();
// check if the second model got the changes
QTRY_COMPARE(model->count(), m_model->count());
- QTRY_COMPARE(model->placesItem(3)->text(), m_model->placesItem(3)->text());
- QTRY_COMPARE(model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")),
- m_model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")));
- QTRY_COMPARE(model->placesItem(3)->icon(), m_model->placesItem(3)->icon());
- QTRY_COMPARE(model->placesItem(3)->url(), m_model->placesItem(3)->url());
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->text(), m_model->placesItem(tempDirIndex)->text());
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")),
+ m_model->placesItem(tempDirIndex)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")));
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->icon(), m_model->placesItem(tempDirIndex)->icon());
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->url(), m_model->placesItem(tempDirIndex)->url());
}
void PlacesItemModelTest::testEditMetadata()
{
- int tempDirIndex = 3;
+ int tempDirIndex = 1;
if (m_hasDesktopFolder) {
tempDirIndex++;
}
@@ -684,21 +684,21 @@ void PlacesItemModelTest::testEditMetadata()
QTRY_COMPARE(model->count(), m_model->count());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex);
+ schedulePlaceRemoval(tempDirIndex + 2);
// modify place metadata
- PlacesItem *item = m_model->placesItem(3);
+ PlacesItem *item = m_model->placesItem(tempDirIndex);
item->bookmark().setMetaDataItem(QStringLiteral("OnlyInApp"), KAboutData::applicationData().componentName());
m_model->refresh();
// check if the place was modified in both models
- QTRY_COMPARE(model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")),
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")),
KAboutData::applicationData().componentName());
- QTRY_COMPARE(model->placesItem(3)->text(), m_model->placesItem(3)->text());
- QTRY_COMPARE(model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")),
- m_model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")));
- QTRY_COMPARE(model->placesItem(3)->icon(), m_model->placesItem(3)->icon());
- QTRY_COMPARE(model->placesItem(3)->url(), m_model->placesItem(3)->url());
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->text(), m_model->placesItem(tempDirIndex)->text());
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")),
+ m_model->placesItem(tempDirIndex)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")));
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->icon(), m_model->placesItem(tempDirIndex)->icon());
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->url(), m_model->placesItem(tempDirIndex)->url());
}
void PlacesItemModelTest::testRefresh()
@@ -722,7 +722,7 @@ void PlacesItemModelTest::testRefresh()
QTRY_COMPARE(model->count(), m_model->count());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex);
+ schedulePlaceRemoval(tempDirIndex);
PlacesItem *item = m_model->placesItem(tempDirIndex);
PlacesItem *sameItem = model->placesItem(tempDirIndex);
@@ -893,7 +893,7 @@ void PlacesItemModelTest::testDuplicatedEntries()
void PlacesItemModelTest::renameAfterCreation()
{
- int tempDirIndex = 3;
+ int tempDirIndex = 1;
if (m_hasDesktopFolder) {
tempDirIndex++;
}
@@ -910,10 +910,10 @@ void PlacesItemModelTest::renameAfterCreation()
// create a new place
createPlaceItem(QStringLiteral("Temporary Dir"), tempUrl, QString());
- urls.insert(tempDirIndex, tempUrl.toLocalFile());
+ urls.insert(tempDirIndex + 2, tempUrl.toLocalFile());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex);
+ schedulePlaceRemoval(tempDirIndex + 2);
CHECK_PLACES_URLS(urls);
QCOMPARE(model->count(), m_model->count());
@@ -922,7 +922,7 @@ void PlacesItemModelTest::renameAfterCreation()
// modify place text
QSignalSpy changedSpy(m_model, &PlacesItemModel::itemsChanged);
- PlacesItem *item = m_model->placesItem(3);
+ PlacesItem *item = m_model->placesItem(tempDirIndex);
item->setText(QStringLiteral("New Temporary Dir"));
item->setUrl(item->url());
item->setIcon(item->icon());
@@ -931,8 +931,8 @@ void PlacesItemModelTest::renameAfterCreation()
QTRY_COMPARE(changedSpy.count(), 1);
// check if the place was modified in both models
- QTRY_COMPARE(m_model->placesItem(3)->text(), QStringLiteral("New Temporary Dir"));
- QTRY_COMPARE(model->placesItem(3)->text(), QStringLiteral("New Temporary Dir"));
+ QTRY_COMPARE(m_model->placesItem(tempDirIndex)->text(), QStringLiteral("New Temporary Dir"));
+ QTRY_COMPARE(model->placesItem(tempDirIndex)->text(), QStringLiteral("New Temporary Dir"));
}
QTEST_MAIN(PlacesItemModelTest)