summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Richardson <arichardson.kde@gmail.com>2015-08-14 00:21:11 (GMT)
committerAlex Richardson <arichardson.kde@gmail.com>2015-08-14 00:30:32 (GMT)
commit824a35ced051842a1518b95146042d3567a89ba1 (patch)
tree57165eef05d240153272135f0c3631b30fb06eca
parent1dd033d91450cc8708d3b4b42cbaea23bdb90cbc (diff)
Ensure KImageIO test always finds the currently built generator
REVIEW: 123895
-rw-r--r--generators/kimgio/CMakeLists.txt2
-rw-r--r--generators/kimgio/tests/kimgiotest.cpp24
2 files changed, 23 insertions, 3 deletions
diff --git a/generators/kimgio/CMakeLists.txt b/generators/kimgio/CMakeLists.txt
index ab06445..5d9011b 100644
--- a/generators/kimgio/CMakeLists.txt
+++ b/generators/kimgio/CMakeLists.txt
@@ -14,6 +14,8 @@ install(TARGETS okularGenerator_kimgio DESTINATION ${KDE_INSTALL_PLUGINDIR})
add_definitions( -DKDESRCDIR="${CMAKE_CURRENT_SOURCE_DIR}/" )
set( kimgiotest_SRCS tests/kimgiotest.cpp ${CMAKE_SOURCE_DIR}/ui/pagepainter.cpp ${CMAKE_SOURCE_DIR}/ui/guiutils.cpp )
ecm_add_test(${kimgiotest_SRCS} TEST_NAME "kimgiotest" LINK_LIBRARIES okularcore okularpart Qt5::Svg Qt5::Test)
+target_compile_definitions(kimgiotest PRIVATE -DGENERATOR_PATH="$<TARGET_FILE:okularGenerator_kimgio>")
+
########### install files ###############
diff --git a/generators/kimgio/tests/kimgiotest.cpp b/generators/kimgio/tests/kimgiotest.cpp
index f819724..56f2047 100644
--- a/generators/kimgio/tests/kimgiotest.cpp
+++ b/generators/kimgio/tests/kimgiotest.cpp
@@ -19,7 +19,9 @@
#include <QImage>
#include <QPainter>
+#include <QImageReader>
#include <QTemporaryFile>
+#include <KPluginLoader>
class KIMGIOTest
: public QObject
@@ -27,10 +29,26 @@ class KIMGIOTest
Q_OBJECT
private slots:
+ void initTestCase();
void testExifOrientation_data();
void testExifOrientation();
};
+void KIMGIOTest::initTestCase()
+{
+ // Make sure we find the okularGenerator_kimgio that we build just now and not the system one
+ QFileInfo lib( GENERATOR_PATH );
+ QVERIFY2( lib.exists(), GENERATOR_PATH );
+ QStringList libPaths = QCoreApplication::libraryPaths();
+ libPaths.prepend( lib.absolutePath() );
+ QCoreApplication::setLibraryPaths( libPaths );
+ QVERIFY( !KPluginLoader::findPlugin( "okularGenerator_kimgio" ).isEmpty() );
+ // make sure we didn't break the search path for image formats:
+ auto availableFormats = QImageReader::supportedImageFormats();
+ QVERIFY2(availableFormats.contains( "jpeg" ), availableFormats.join( ", " ).data() );
+}
+
+
// The following images have different Exif orientation tags, but they all
// are a 3x2 rectangle whose top-left pixel is black, and whose other pixels are
// white. Note that, due to JPEG lossy compression, some pixels are not pure
@@ -60,8 +78,8 @@ void KIMGIOTest::testExifOrientation_data()
void KIMGIOTest::testExifOrientation()
{
QFETCH( QString, imgPath );
- QMimeDatabase db;
-
+ QMimeDatabase db;
+
Okular::SettingsCore::instance( "kimgiotest" );
Okular::Document *m_document = new Okular::Document( 0 );
const QMimeType mime = db.mimeTypeForFile( imgPath );
@@ -70,7 +88,7 @@ void KIMGIOTest::testExifOrientation()
m_document->addObserver( dummyDocumentObserver );
// Load image
- m_document->openDocument( imgPath, QUrl(), mime );
+ QCOMPARE((int)m_document->openDocument( imgPath, QUrl(), mime ), (int)Okular::Document::OpenSuccess);
m_document->setRotation( 0 ); // Test the default rotation
QCOMPARE( m_document->pages(), 1u );