Test for basic image handling

This tests adding image files to dives including hashing and evaluating
exif data.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2017-02-21 10:27:31 +01:00 committed by Dirk Hohndel
parent dbd99f706e
commit c4976b505a
4 changed files with 87 additions and 0 deletions

View file

@ -20,6 +20,8 @@ TEST(TestDiveSiteDuplication testdivesiteduplication.cpp)
TEST(TestRenumber testrenumber.cpp)
TEST(TestGitStorage testgitstorage.cpp)
TEST(TestPreferences testpreferences.cpp)
TEST(TestPicture testpicture.cpp)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS
@ -32,4 +34,5 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
TestDiveSiteDuplication
TestPreferences
TestRenumber
TestPicture
)

43
tests/testpicture.cpp Normal file
View file

@ -0,0 +1,43 @@
#include "testpicture.h"
#include "core/dive.h"
#include "core/file.h"
#include "core/divelist.h"
#include <QString>
#include <core/qthelper.h>
void TestPicture::initTestCase()
{
/* we need to manually tell that the resource exists, because we are using it as library. */
Q_INIT_RESOURCE(subsurface);
}
void TestPicture::addPicture()
{
struct dive *dive;
struct picture *pic;
verbose = 1;
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test44.xml"), 0);
dive = get_dive(0);
QVERIFY(dive != NULL);
pic = dive->picture_list;
// So far no picture in dive
QVERIFY(pic == NULL);
dive_create_picture(dive, SUBSURFACE_SOURCE "/wreck.jpg", 0, false);
pic = dive->picture_list;
// Now there is a picture
QVERIFY(pic != NULL);
// Appearing at time 21:01
QVERIFY(pic->offset.seconds == 1261);
QVERIFY(pic->latitude.udeg == 47934500);
QVERIFY(pic->longitude.udeg == 11334500);
QVERIFY(pic->hash == NULL);
learnHash(pic, hashFile(localFilePath(pic->filename)));
QCOMPARE(pic->hash, "929ad9499b7ae7a9e39ef63eb6c239604ac2adfa");
}
QTEST_GUILESS_MAIN(TestPicture)

13
tests/testpicture.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef TESTPICTURE_H
#define TESTPICTURE_H
#include <QtTest>
class TestPicture : public QObject{
Q_OBJECT
private slots:
void initTestCase();
void addPicture();
};
#endif