Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 3635e07b authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix KisKraSaverTest to check patterns correctly

parent 89bedcd4
......@@ -340,6 +340,7 @@ macro(macro_add_unittest_definitions)
add_definitions(-DFILES_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/")
add_definitions(-DFILES_OUTPUT_DIR="${CMAKE_CURRENT_BINARY_DIR}")
add_definitions(-DFILES_DEFAULT_DATA_DIR="${KRITA_DEFAULT_TEST_DATA_DIR}")
add_definitions(-DSYSTEM_RESOURCES_DATA_DIR="${CMAKE_SOURCE_DIR}/krita/data/")
endmacro()
......
......@@ -425,9 +425,14 @@ QStringList KoResourcePaths::findAllResourcesInternal(const QString &type,
debugWidgetUtils << "\t\talias:" << alias;
QStringList dirs;
dirs << QStandardPaths::locateAll(d->mapTypeToQStandardPaths(type), alias, QStandardPaths::LocateDirectory)
<< getInstallationPrefix() + "share/" + alias + "/"
<< getInstallationPrefix() + "share/krita/" + alias + "/";
QFileInfo dirInfo(alias);
if (dirInfo.exists() && dirInfo.isDir() && dirInfo.isAbsolute()) {
dirs << alias;
} else {
dirs << QStandardPaths::locateAll(d->mapTypeToQStandardPaths(type), alias, QStandardPaths::LocateDirectory)
<< getInstallationPrefix() + "share/" + alias + "/"
<< getInstallationPrefix() + "share/krita/" + alias + "/";
}
Q_FOREACH (const QString &dir, dirs) {
appendResources(&resources,
......
......@@ -55,8 +55,12 @@
#include <filter/kis_filter_registry.h>
#include <generator/kis_generator_registry.h>
#include <KoResourcePaths.h>
void KisKraSaverTest::initTestCase()
{
KoResourcePaths::addResourceDir("ko_patterns", QString(SYSTEM_RESOURCES_DATA_DIR) + "/patterns");
KisFilterRegistry::instance();
KisGeneratorRegistry::instance();
}
......@@ -139,6 +143,7 @@ void KisKraSaverTest::testSaveEmpty()
void testRoundTripFillLayerImpl(const QString &testName, KisFilterConfigurationSP config)
{
TestUtil::ExternalImageChecker chk(testName, "fill_layer");
chk.setFuzzy(2);
QScopedPointer<KisDocument> doc(KisPart::instance()->createDocument());
......@@ -190,11 +195,11 @@ void KisKraSaverTest::testRoundTripFillLayerColor()
void KisKraSaverTest::testRoundTripFillLayerPattern()
{
KisGeneratorSP generator = KisGeneratorRegistry::instance()->get("pattern");
Q_ASSERT(generator);
QVERIFY(generator);
// warning: we pass null paint device to the default constructed value
KisFilterConfigurationSP config = generator->factoryConfiguration(0);
Q_ASSERT(config);
QVERIFY(config);
QVariant v;
v.setValue(QString("11_drawed_furry.png"));
......
......@@ -399,7 +399,8 @@ struct ExternalImageChecker
: m_prefix(prefix),
m_testName(testName),
m_success(true),
m_maxFailingPixels(100)
m_maxFailingPixels(100),
m_fuzzy(1)
{
}
......@@ -408,6 +409,10 @@ struct ExternalImageChecker
m_maxFailingPixels = value;
}
void setFuzzy(int fuzzy){
m_fuzzy = fuzzy;
}
bool testPassed() const {
return m_success;
}
......@@ -417,7 +422,7 @@ struct ExternalImageChecker
checkQImageExternal(device->convertToQImage(0, image->bounds()),
m_testName,
m_prefix,
caseName, 1, 1, m_maxFailingPixels);
caseName, m_fuzzy, m_fuzzy, m_maxFailingPixels);
m_success &= result;
return result;
......@@ -436,6 +441,7 @@ private:
bool m_success;
int m_maxFailingPixels;
int m_fuzzy;
};
......
Markdown is supported
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