Ensure KImageIO test always finds the currently built generator

REVIEW: 123895
frameworks
Alex Richardson 11 years ago
parent 1dd033d914
commit 824a35ced0
  1. 2
      generators/kimgio/CMakeLists.txt
  2. 24
      generators/kimgio/tests/kimgiotest.cpp

@ -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 ###############

@ -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 );

Loading…
Cancel
Save