diff options
| author | Elvis Angelaccio <[email protected]> | 2019-05-05 16:52:16 +0200 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2019-05-05 16:52:16 +0200 |
| commit | d41d3be348e76feab3d31f5eec875f6a392ff40f (patch) | |
| tree | fba904662f32c6cca2622136ca1ba58c6f9ada76 /src/tests | |
| parent | 33a0d17ea8d4de81322ca51a5acc1356f37798ed (diff) | |
[PlacesItemModelTest] Ignore user tag places
Instead of listing the user tags (as tried in D21017), the test should not have
access to the user's baloo DB in the first place.
To do so, we use a QTemporaryDir as $HOME for the test process and for
its ioslave children (by setting KDE_FORK_SLAVES=yes).
While at it, drop the no-op removeTestUserData() function.
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/placesitemmodeltest.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/tests/placesitemmodeltest.cpp b/src/tests/placesitemmodeltest.cpp index 4ed4945b2..7f0d498a7 100644 --- a/src/tests/placesitemmodeltest.cpp +++ b/src/tests/placesitemmodeltest.cpp @@ -99,8 +99,8 @@ private: void createPlaceItem(const QString &text, const QUrl &url, const QString &icon); void schedulePlaceRemoval(int index); void cancelPlaceRemoval(int index); - void removeTestUserData(); QMimeData *createMimeData(const QList<int> &indexes) const; + QTemporaryDir m_tempHomeDir; }; #define CHECK_PLACES_URLS(urls) \ @@ -201,15 +201,6 @@ void PlacesItemModelTest::cancelPlaceRemoval(int index) m_tobeRemoved.remove(index); } -void PlacesItemModelTest::removeTestUserData() -{ - // user hardcoded path to avoid removal of any user personal data - QDir dir(QStringLiteral("/home/renato/.qttest/share/placesitemmodeltest")); - if (dir.exists()) { - QVERIFY(dir.removeRecursively()); - } -} - QMimeData *PlacesItemModelTest::createMimeData(const QList<int> &indexes) const { QByteArray itemData; @@ -252,14 +243,15 @@ void PlacesItemModelTest::cleanup() m_tobeRemoved.clear(); delete m_model; m_model = nullptr; - removeTestUserData(); } void PlacesItemModelTest::initTestCase() { + QVERIFY(m_tempHomeDir.isValid()); + QVERIFY(qputenv("HOME", m_tempHomeDir.path().toUtf8())); + QVERIFY(qputenv("KDE_FORK_SLAVES", "yes")); + QStandardPaths::setTestModeEnabled(true); - // remove test user data - removeTestUserData(); const QString fakeHw = QFINDTESTDATA("data/fakecomputer.xml"); QVERIFY(!fakeHw.isEmpty()); @@ -290,9 +282,6 @@ void PlacesItemModelTest::cleanupTestCase() { qDeleteAll(m_interfacesMap); QFile::remove(bookmarksFile()); - - // Remove any previous properties file - removeTestUserData(); } void PlacesItemModelTest::testModelSort() |
