Verified Commit 79e55866 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

wallpapers/image: update tests

A new image is added to the default folder.

CCBUG: 454692
parent 9a265766
Pipeline #184160 passed with stage
in 6 minutes and 12 seconds
/*
SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QString>
namespace ImageBackendTestData
{
constexpr const int defaultImageCount = 2;
constexpr const int defaultPackageCount = 1;
constexpr const int defaultTotalCount = defaultImageCount + defaultPackageCount;
constexpr const int alternateImageCount = 1;
constexpr const int alternatePackageCount = 1;
constexpr const int alternateTotalCount = alternateImageCount + alternatePackageCount;
inline const QString defaultImageFileName1 = QStringLiteral("wallpaper.jpg.jpg");
inline const QString defaultImageFileName2 = QStringLiteral("# BUG454692 file name with hash char.png");
inline const QString defaultPackageFolderName1 = QStringLiteral("package");
inline const QString alternateImageFileName1 = QStringLiteral("dummy.jpg");
inline const QString alternatePackageFolderName1 = QStringLiteral("dummy");
}
......@@ -7,6 +7,7 @@
#include <QDir>
#include <QtTest>
#include "commontestdata.h"
#include "finder/imagefinder.h"
class ImageFinderTest : public QObject
......@@ -41,17 +42,19 @@ void ImageFinderTest::testImageFinderCanFindImages()
* Expected result:
*
* - wallpaper.jpg.jpg is found.
* - "# BUG454692 file name with hash char.png" is found.
* - symlinkshouldnotbefoundbythefinder.jpg is ignored.
* - screenshot.png is ignored.
* - All images in package/contents/images/ are ignored.
*
* So the total number of images found by ImageFinder is 1.
* So the total number of images found by ImageFinder is 2.
*/
const auto paths = spy.takeFirst().at(0).toStringList();
qInfo() << "Found images:" << paths;
QCOMPARE(paths.size(), 1);
QCOMPARE(paths.at(0), m_dataDir.absoluteFilePath(QStringLiteral("wallpaper.jpg.jpg")));
QCOMPARE(paths.size(), ImageBackendTestData::defaultImageCount);
QTRY_COMPARE(paths.count(m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName1)), 1);
QTRY_COMPARE(paths.count(m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName2)), 1);
}
QTEST_MAIN(ImageFinderTest)
......
......@@ -9,6 +9,7 @@
#include <KIO/PreviewJob>
#include "../model/imagelistmodel.h"
#include "commontestdata.h"
class ImageListModelTest : public QObject
{
......@@ -34,7 +35,7 @@ private:
QDir m_dataDir;
QDir m_alternateDir;
QString m_wallpaperPath;
QStringList m_wallpaperPaths;
QString m_dummyWallpaperPath;
QSize m_targetSize;
};
......@@ -46,8 +47,9 @@ void ImageListModelTest::initTestCase()
QVERIFY(!m_dataDir.isEmpty());
QVERIFY(!m_alternateDir.isEmpty());
m_wallpaperPath = m_dataDir.absoluteFilePath(QStringLiteral("wallpaper.jpg.jpg"));
m_dummyWallpaperPath = m_alternateDir.absoluteFilePath(QStringLiteral("dummy.jpg"));
m_wallpaperPaths << m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName1);
m_wallpaperPaths << m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName2);
m_dummyWallpaperPath = m_alternateDir.absoluteFilePath(ImageBackendTestData::alternateImageFileName1);
m_targetSize = QSize(1920, 1080);
......@@ -65,7 +67,7 @@ void ImageListModelTest::init()
m_countSpy->wait(10 * 1000);
QCOMPARE(m_countSpy->size(), 1);
m_countSpy->clear();
QCOMPARE(m_model->rowCount(), 1);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultImageCount);
}
void ImageListModelTest::cleanup()
......@@ -84,7 +86,8 @@ void ImageListModelTest::cleanupTestCase()
void ImageListModelTest::testImageListModelData()
{
QPersistentModelIndex idx = m_model->index(0, 0);
const int row = m_model->indexOf(m_wallpaperPaths.at(0));
QPersistentModelIndex idx = m_model->index(row, 0);
QVERIFY(idx.isValid());
// Should return the complete base name for wallpaper.jpg.jpg
......@@ -106,8 +109,8 @@ void ImageListModelTest::testImageListModelData()
QCOMPARE(m_dataSpy->takeFirst().at(2).value<QVector<int>>().at(0), ImageRoles::ResolutionRole);
QCOMPARE(idx.data(ImageRoles::ResolutionRole).toString(), QStringLiteral("15x16"));
QCOMPARE(idx.data(ImageRoles::PathRole).toUrl(), QUrl::fromLocalFile(m_wallpaperPath));
QCOMPARE(idx.data(ImageRoles::PackageNameRole).toString(), m_wallpaperPath);
QCOMPARE(idx.data(ImageRoles::PathRole).toUrl(), QUrl::fromLocalFile(m_wallpaperPaths.at(0)));
QCOMPARE(idx.data(ImageRoles::PackageNameRole).toString(), m_wallpaperPaths.at(0));
QCOMPARE(idx.data(ImageRoles::RemovableRole).toBool(), false);
QCOMPARE(idx.data(ImageRoles::PendingDeletionRole).toBool(), false);
......@@ -115,8 +118,9 @@ void ImageListModelTest::testImageListModelData()
void ImageListModelTest::testImageListModelIndexOf()
{
QCOMPARE(m_model->indexOf(m_wallpaperPath), 0);
QCOMPARE(m_model->indexOf(QUrl::fromLocalFile(m_wallpaperPath).toString()), 0);
QTRY_VERIFY(m_model->indexOf(m_wallpaperPaths.at(0)) >= 0);
QTRY_VERIFY(m_model->indexOf(m_wallpaperPaths.at(1)) >= 0);
QTRY_VERIFY(m_model->indexOf(QUrl::fromLocalFile(m_wallpaperPaths.at(0)).toString()) >= 0);
QCOMPARE(m_model->indexOf(m_dataDir.absoluteFilePath(QStringLiteral(".wallpaper.jpg"))), -1);
}
......@@ -126,7 +130,7 @@ void ImageListModelTest::testImageListModelLoad()
m_countSpy->wait(10 * 1000);
QCOMPARE(m_countSpy->size(), 1);
m_countSpy->clear();
QCOMPARE(m_model->rowCount(), 1);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::alternateImageCount);
QCOMPARE(m_model->index(0, 0).data(Qt::DisplayRole), QStringLiteral("dummy"));
}
......@@ -138,7 +142,7 @@ void ImageListModelTest::testImageListModelAddBackground()
m_countSpy->clear();
QCOMPARE(results.size(), 1);
QCOMPARE(results.at(0), m_dummyWallpaperPath);
QCOMPARE(m_model->rowCount(), 2);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultImageCount + 1);
QPersistentModelIndex idx = m_model->index(0, 0); // This is the newly added item.
QVERIFY(idx.isValid());
......@@ -206,14 +210,14 @@ void ImageListModelTest::testImageListModelRemoveBackground()
m_countSpy->clear();
QCOMPARE(results.size(), 1);
QCOMPARE(results.at(0), m_dummyWallpaperPath);
QCOMPARE(m_model->rowCount(), 1);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultImageCount);
QCOMPARE(m_model->m_removableWallpapers.size(), 0);
}
void ImageListModelTest::testImageListModelRemoveLocalBackground()
{
const QString standardPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/wallpapers/");
QFile imageFile(m_wallpaperPath);
QFile imageFile(m_wallpaperPaths.at(0));
QVERIFY(QDir(standardPath).mkpath(standardPath));
QVERIFY(imageFile.copy(standardPath + QStringLiteral("wallpaper.jpg.jpg")));
......
......@@ -12,6 +12,7 @@
#include "../model/imagelistmodel.h"
#include "../model/imageproxymodel.h"
#include "../model/packagelistmodel.h"
#include "commontestdata.h"
class ImageProxyModelTest : public QObject
{
......@@ -36,7 +37,7 @@ private:
QDir m_dataDir;
QDir m_alternateDir;
QString m_wallpaperPath;
QStringList m_wallpaperPaths;
QString m_dummyWallpaperPath;
QString m_packagePath;
QString m_dummyPackagePath;
......@@ -51,11 +52,12 @@ void ImageProxyModelTest::initTestCase()
QVERIFY(!m_dataDir.isEmpty());
QVERIFY(!m_alternateDir.isEmpty());
m_wallpaperPath = m_dataDir.absoluteFilePath(QStringLiteral("wallpaper.jpg.jpg"));
m_dummyWallpaperPath = m_alternateDir.absoluteFilePath(QStringLiteral("dummy.jpg"));
m_wallpaperPaths << m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName1);
m_wallpaperPaths << m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName2);
m_dummyWallpaperPath = m_alternateDir.absoluteFilePath(ImageBackendTestData::alternateImageFileName1);
m_packagePath = m_dataDir.absoluteFilePath(QStringLiteral("package"));
m_dummyPackagePath = m_alternateDir.absoluteFilePath(QStringLiteral("dummy"));
m_packagePath = m_dataDir.absoluteFilePath(ImageBackendTestData::defaultPackageFolderName1);
m_dummyPackagePath = m_alternateDir.absoluteFilePath(ImageBackendTestData::alternatePackageFolderName1);
m_modelNum = 2;
m_targetSize = QSize(1920, 1080);
......@@ -85,11 +87,11 @@ void ImageProxyModelTest::init()
QVERIFY(!m_model->loading());
QCOMPARE(m_model->rowCount(), 2); // wallpaper.jpg.jpg, package
QCOMPARE(m_model->count(), 2);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultTotalCount);
QCOMPARE(m_model->count(), m_model->rowCount());
QCOMPARE(m_model->m_imageModel->count(), 1);
QCOMPARE(m_model->m_packageModel->count(), 1);
QCOMPARE(m_model->m_imageModel->count(), ImageBackendTestData::defaultImageCount);
QCOMPARE(m_model->m_packageModel->count(), ImageBackendTestData::defaultPackageCount);
}
void ImageProxyModelTest::cleanup()
......@@ -108,7 +110,8 @@ void ImageProxyModelTest::cleanupTestCase()
void ImageProxyModelTest::testImageProxyModelIndexOf()
{
QVERIFY(m_model->indexOf(m_wallpaperPath) >= 0);
QVERIFY(m_model->indexOf(m_wallpaperPaths.at(0)) >= 0);
QVERIFY(m_model->indexOf(m_wallpaperPaths.at(1)) >= 0);
QVERIFY(m_model->indexOf(m_packagePath) >= 0);
QVERIFY(m_model->indexOf(m_packagePath + QDir::separator()) >= 0);
QCOMPARE(m_model->indexOf(m_dataDir.absoluteFilePath(QStringLiteral("brokenpackage") + QDir::separator())), -1);
......@@ -124,9 +127,9 @@ void ImageProxyModelTest::testImageProxyModelReload()
QCOMPARE(m_countSpy->size(), m_modelNum);
m_countSpy->clear();
QCOMPARE(m_model->rowCount(), 2);
QCOMPARE(m_model->m_imageModel->rowCount(), 1);
QCOMPARE(m_model->m_packageModel->rowCount(), 1);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultTotalCount);
QCOMPARE(m_model->m_imageModel->rowCount(), ImageBackendTestData::defaultImageCount);
QCOMPARE(m_model->m_packageModel->rowCount(), ImageBackendTestData::defaultPackageCount);
}
void ImageProxyModelTest::testImageProxyModelAddBackground()
......@@ -134,7 +137,7 @@ void ImageProxyModelTest::testImageProxyModelAddBackground()
int count = m_model->count();
// Case 1: add an existing wallpaper
auto results = m_model->addBackground(m_wallpaperPath);
auto results = m_model->addBackground(m_wallpaperPaths.at(0));
QCOMPARE(m_countSpy->size(), 0);
QCOMPARE(results.size(), 0);
......@@ -149,8 +152,8 @@ void ImageProxyModelTest::testImageProxyModelAddBackground()
m_countSpy->clear();
QCOMPARE(results.size(), 1);
QCOMPARE(m_model->count(), ++count);
QCOMPARE(m_model->m_imageModel->count(), 2);
QCOMPARE(m_model->m_packageModel->count(), 1);
QCOMPARE(m_model->m_imageModel->count(), ImageBackendTestData::defaultImageCount + 1);
QCOMPARE(m_model->m_packageModel->count(), ImageBackendTestData::defaultPackageCount);
// Case 4: add a new package
results = m_model->addBackground(m_dummyPackagePath);
......@@ -158,8 +161,8 @@ void ImageProxyModelTest::testImageProxyModelAddBackground()
m_countSpy->clear();
QCOMPARE(results.size(), 1);
QCOMPARE(m_model->count(), ++count);
QCOMPARE(m_model->m_imageModel->count(), 2);
QCOMPARE(m_model->m_packageModel->count(), 2);
QCOMPARE(m_model->m_imageModel->count(), ImageBackendTestData::defaultImageCount + 1);
QCOMPARE(m_model->m_packageModel->count(), ImageBackendTestData::defaultPackageCount + 1);
// Test KDirWatch
QVERIFY(m_model->m_dirWatch.contains(m_dummyWallpaperPath));
......@@ -184,16 +187,16 @@ void ImageProxyModelTest::testImageProxyModelRemoveBackground()
m_model->removeBackground(QUrl::fromLocalFile(m_dummyWallpaperPath).toString());
QCOMPARE(m_countSpy->size(), 1);
m_countSpy->clear();
QCOMPARE(m_model->m_imageModel->count(), 1);
QCOMPARE(m_model->m_packageModel->count(), 2);
QCOMPARE(m_model->m_imageModel->count(), ImageBackendTestData::defaultImageCount);
QCOMPARE(m_model->m_packageModel->count(), ImageBackendTestData::defaultPackageCount + 1);
QCOMPARE(m_model->count(), --count);
QVERIFY(!m_model->m_dirWatch.contains(m_dummyWallpaperPath));
m_model->removeBackground(m_dummyPackagePath);
QCOMPARE(m_countSpy->size(), 1);
m_countSpy->clear();
QCOMPARE(m_model->m_imageModel->count(), 1);
QCOMPARE(m_model->m_packageModel->count(), 1);
QCOMPARE(m_model->m_imageModel->count(), ImageBackendTestData::defaultImageCount);
QCOMPARE(m_model->m_packageModel->count(), ImageBackendTestData::defaultPackageCount);
QCOMPARE(m_model->count(), --count);
QVERIFY(!m_model->m_dirWatch.contains(m_dummyPackagePath));
......@@ -208,7 +211,8 @@ void ImageProxyModelTest::testImageProxyModelRemoveBackground()
void ImageProxyModelTest::testImageProxyModelDirWatch()
{
QVERIFY(m_model->m_dirWatch.contains(m_dataDir.absolutePath()));
QVERIFY(m_model->m_dirWatch.contains(m_wallpaperPath));
QVERIFY(m_model->m_dirWatch.contains(m_wallpaperPaths.at(0)));
QVERIFY(m_model->m_dirWatch.contains(m_wallpaperPaths.at(1)));
QVERIFY(m_model->m_dirWatch.contains(m_packagePath));
m_model->deleteLater();
......@@ -230,7 +234,7 @@ void ImageProxyModelTest::testImageProxyModelDirWatch()
QVERIFY(m_model->m_dirWatch.contains(standardPath));
// Copy an image to the folder
QFile imageFile(m_wallpaperPath);
QFile imageFile(m_wallpaperPaths.at(0));
QVERIFY(imageFile.copy(standardPath + QStringLiteral("image.jpg")));
m_countSpy->wait();
QCOMPARE(m_countSpy->size(), 1);
......
......@@ -7,6 +7,7 @@
#include <QDir>
#include <QtTest>
#include "commontestdata.h"
#include "finder/imagesizefinder.h"
class ImageSizeFinderTest : public QObject
......@@ -29,7 +30,7 @@ void ImageSizeFinderTest::initTestCase()
void ImageSizeFinderTest::testImageSizeFinder()
{
const QString path = m_dataDir.absoluteFilePath(QStringLiteral("wallpaper.jpg.jpg"));
const QString path = m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName1);
ImageSizeFinder *finder = new ImageSizeFinder(path);
QSignalSpy spy(finder, &ImageSizeFinder::sizeFound);
......
......@@ -10,6 +10,7 @@
#include <KPackage/PackageLoader>
#include "commontestdata.h"
#include "finder/packagefinder.h"
class PackageFinderTest : public QObject
......@@ -72,7 +73,7 @@ void PackageFinderTest::testFindPreferredSizeInPackage()
QFETCH(QString, expected);
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Wallpaper/Images"));
package.setPath(m_dataDir.absoluteFilePath(QStringLiteral("package")));
package.setPath(m_dataDir.absoluteFilePath(ImageBackendTestData::defaultPackageFolderName1));
QVERIFY(package.isValid());
QVERIFY(package.metadata().isValid());
......@@ -84,7 +85,8 @@ void PackageFinderTest::testFindPreferredSizeInPackage()
void PackageFinderTest::testPackageFinderCanFindPackages()
{
PackageFinder *finder = new PackageFinder({m_dataDir.absolutePath(), m_dataDir.absoluteFilePath(QStringLiteral("package"))}, QSize(1920, 1080));
PackageFinder *finder =
new PackageFinder({m_dataDir.absolutePath(), m_dataDir.absoluteFilePath(ImageBackendTestData::defaultPackageFolderName1)}, QSize(1920, 1080));
QSignalSpy spy(finder, &PackageFinder::packageFound);
QThreadPool::globalInstance()->start(finder);
......@@ -95,7 +97,8 @@ void PackageFinderTest::testPackageFinderCanFindPackages()
const auto items = spy.takeFirst().at(0).value<QList<KPackage::Package>>();
// Total 2 packages in the directory, but one package is broken and should not be added to the list.
QCOMPARE(items.size(), 1);
QCOMPARE(items.at(0).filePath("preferred"), m_dataDir.absoluteFilePath(QStringLiteral("package/contents/images/1920x1080.jpg")));
QCOMPARE(items.at(0).filePath("preferred"),
m_dataDir.absoluteFilePath(QStringLiteral("%1/contents/images/1920x1080.jpg").arg(ImageBackendTestData::defaultPackageFolderName1)));
}
QTEST_MAIN(PackageFinderTest)
......
......@@ -10,6 +10,7 @@
#include <KIO/PreviewJob>
#include "../model/packagelistmodel.h"
#include "commontestdata.h"
class PackageListModelTest : public QObject
{
......@@ -47,8 +48,8 @@ void PackageListModelTest::initTestCase()
QVERIFY(!m_dataDir.isEmpty());
QVERIFY(!m_alternateDir.isEmpty());
m_packagePath = m_dataDir.absoluteFilePath(QStringLiteral("package"));
m_dummyPackagePath = m_alternateDir.absoluteFilePath(QStringLiteral("dummy"));
m_packagePath = m_dataDir.absoluteFilePath(ImageBackendTestData::defaultPackageFolderName1);
m_dummyPackagePath = m_alternateDir.absoluteFilePath(ImageBackendTestData::alternatePackageFolderName1);
m_targetSize = QSize(1920, 1080);
......@@ -66,7 +67,7 @@ void PackageListModelTest::init()
m_countSpy->wait(10 * 1000);
QCOMPARE(m_countSpy->size(), 1);
m_countSpy->clear();
QCOMPARE(m_model->rowCount(), 1);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultPackageCount);
}
void PackageListModelTest::cleanup()
......@@ -140,7 +141,7 @@ void PackageListModelTest::testPackageListModelAddBackground()
m_countSpy->clear();
QCOMPARE(results.size(), 1);
QCOMPARE(results.at(0), m_dummyPackagePath + QDir::separator());
QCOMPARE(m_model->rowCount(), 2);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultPackageCount + 1);
QPersistentModelIndex idx = m_model->index(0, 0); // This is the newly added item.
QVERIFY(idx.isValid());
......@@ -154,7 +155,7 @@ void PackageListModelTest::testPackageListModelAddBackground()
QCOMPARE(m_countSpy->size(), 0);
// Case 3: add an image
results = m_model->addBackground(m_alternateDir.absoluteFilePath(QStringLiteral("dummy.jpg")));
results = m_model->addBackground(m_alternateDir.absoluteFilePath(ImageBackendTestData::alternateImageFileName1));
QCOMPARE(results.size(), 0);
QCOMPARE(m_countSpy->size(), 0);
......@@ -200,7 +201,7 @@ void PackageListModelTest::testPackageListModelRemoveBackground()
results = m_model->removeBackground(m_dummyPackagePath);
QCOMPARE(m_countSpy->size(), 1);
m_countSpy->clear();
QCOMPARE(m_model->rowCount(), 1);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultPackageCount);
QCOMPARE(results.size(), 1);
QCOMPARE(results.at(0), m_dummyPackagePath + QDir::separator());
QCOMPARE(m_model->m_removableWallpapers.size(), 0);
......
......@@ -8,6 +8,7 @@
#include "../slidefiltermodel.h"
#include "../slidemodel.h"
#include "commontestdata.h"
class SlideFilterModelTest : public QObject
{
......@@ -40,7 +41,7 @@ void SlideFilterModelTest::initTestCase()
m_dataDir = QDir(QFINDTESTDATA("testdata/default"));
QVERIFY(!m_dataDir.isEmpty());
m_wallpaperPath = m_dataDir.absoluteFilePath(QStringLiteral("wallpaper.jpg.jpg"));
m_wallpaperPath = m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName1);
m_targetSize = QSize(1920, 1080);
......
......@@ -9,6 +9,7 @@
#include "../model/imageproxymodel.h"
#include "../slidemodel.h"
#include "commontestdata.h"
class SlideModelTest : public QObject
{
......@@ -34,7 +35,7 @@ private:
QDir m_dataDir;
QDir m_alternateDir;
QString m_wallpaperPath;
QStringList m_wallpaperPaths;
QString m_dummyWallpaperPath;
QString m_packagePath;
QString m_dummyPackagePath;
......@@ -48,7 +49,8 @@ void SlideModelTest::initTestCase()
QVERIFY(!m_dataDir.isEmpty());
QVERIFY(!m_alternateDir.isEmpty());
m_wallpaperPath = m_dataDir.absoluteFilePath(QStringLiteral("wallpaper.jpg.jpg"));
m_wallpaperPaths << m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName1);
m_wallpaperPaths << m_dataDir.absoluteFilePath(ImageBackendTestData::defaultImageFileName2);
m_dummyWallpaperPath = m_alternateDir.absoluteFilePath(QStringLiteral("dummy.jpg"));
m_packagePath = m_dataDir.absoluteFilePath(QStringLiteral("package"));
......@@ -73,10 +75,10 @@ void SlideModelTest::init()
m_doneSpy->clear();
QCOMPARE(m_model->sourceModels().size(), 1);
QCOMPARE(m_model->m_models.size(), 1);
QCOMPARE(m_model->rowCount(), 2); // wallpaper.jpg.jpg, package
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultTotalCount);
QVERIFY(m_model->m_models.contains(m_dataDir.absolutePath() + QDir::separator()));
QCOMPARE(m_model->m_models.value(m_dataDir.absolutePath() + QDir::separator())->count(), 2);
QCOMPARE(m_model->m_models.value(m_dataDir.absolutePath() + QDir::separator())->count(), ImageBackendTestData::defaultTotalCount);
}
void SlideModelTest::cleanup()
......@@ -107,7 +109,8 @@ void SlideModelTest::testSlideModelData()
void SlideModelTest::testSlideModelIndexOf()
{
QVERIFY(m_model->indexOf(m_wallpaperPath) >= 0);
QVERIFY(m_model->indexOf(m_wallpaperPaths.at(0)) >= 0);
QVERIFY(m_model->indexOf(m_wallpaperPaths.at(1)) >= 0);
QVERIFY(m_model->indexOf(m_packagePath) >= 0);
QVERIFY(m_model->indexOf(m_packagePath + QDir::separator()) >= 0);
QCOMPARE(m_model->indexOf(m_dummyWallpaperPath), -1);
......@@ -119,7 +122,7 @@ void SlideModelTest::testSlideModelAddDirs()
int count = m_model->rowCount();
// Case 1: add an image file
auto results = m_model->addDirs({m_wallpaperPath});
auto results = m_model->addDirs({m_wallpaperPaths.at(0)});
QCOMPARE(m_model->m_models.size(), 1);
QCOMPARE(results.size(), 0);
......@@ -135,7 +138,7 @@ void SlideModelTest::testSlideModelAddDirs()
QVERIFY(m_doneSpy->wait());
QCOMPARE(m_doneSpy->size(), 1);
m_doneSpy->clear();
QCOMPARE(m_model->rowCount(), ++ ++count);
QCOMPARE(m_model->rowCount(), count + ImageBackendTestData::alternateTotalCount);
}
void SlideModelTest::testSlideModelRemoveDir()
......@@ -144,7 +147,7 @@ void SlideModelTest::testSlideModelRemoveDir()
m_model->removeDir(m_alternateDir.absolutePath());
QCOMPARE(m_model->m_models.size(), 1);
QCOMPARE(m_model->m_loaded, 1);
QCOMPARE(m_model->rowCount(), 2);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::defaultTotalCount);
// Case 2: remove an existing dir
m_model->removeDir(m_dataDir.absolutePath());
......@@ -173,7 +176,7 @@ void SlideModelTest::testSlideModelSetSlidePaths()
m_doneSpy->clear();
QCOMPARE(m_model->sourceModels().size(), 1);
QCOMPARE(m_model->m_models.size(), 1);
QCOMPARE(m_model->rowCount(), 2);
QCOMPARE(m_model->rowCount(), ImageBackendTestData::alternateTotalCount);
}
void SlideModelTest::testSlideModelSetUncheckedSlides()
......
......@@ -117,12 +117,13 @@ TestCase {
imageWallpaper.renderingMode = Wallpaper.ImageBackend.SlideShow;
wait(1000); // &SlideModel::done
const image1 = imageWallpaper.modelImage;
let image = imageWallpaper.modelImage;
imageWallpaper.nextSlide();
verify(image1 != imageWallpaper.modelImage);
verify(image != imageWallpaper.modelImage);
image = imageWallpaper.modelImage;
imageWallpaper.nextSlide();
compare(image1, imageWallpaper.modelImage);
verify(image != imageWallpaper.modelImage);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment