aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dives/test44.xml28
-rw-r--r--tests/CMakeLists.txt3
-rw-r--r--tests/testpicture.cpp43
-rw-r--r--tests/testpicture.h13
4 files changed, 87 insertions, 0 deletions
diff --git a/dives/test44.xml b/dives/test44.xml
new file mode 100644
index 000000000..a9e59d9c8
--- /dev/null
+++ b/dives/test44.xml
@@ -0,0 +1,28 @@
+<divelog program='subsurface' version='3'>
+<settings>
+<divecomputerid model='Suunto Vyper' deviceid='7fffffff' serial='00522075' firmware='0.0.33'/>
+<divecomputerid model='Suunto Vyper' deviceid='e9237b0a' nickname='Suunto Vyper (e9237b0a)'/>
+ <autogroup state='1' />
+</settings>
+<divesites>
+<site uuid='47b3e28c' gps='47.934500 11.334500'/>
+</divesites>
+<dives>
+<trip date='2012-01-08' time='15:30:03'>
+<dive number='1' divesiteid='47b3e28c' date='2012-01-08' time='15:30:03' duration='46:06 min'>
+ <notes>Loading the image wreck.jpg should result in a picutre at 21:01. </notes>
+ <cylinder size='24.0 l' workpressure='232.0 bar' description='D12 232 bar' />
+ <divecomputer model='manually added dive' date='2014-01-09' time='14:22:03'>
+ <depth max='15.0 m' mean='13.698 m' />
+ <sample time='0:00 min' depth='0.0 m' />
+ <sample time='0:50 min' depth='15.0 m' />
+ <sample time='1:00 min' depth='15.0 m' />
+ <sample time='40:00 min' depth='15.0 m' />
+ <sample time='42:00 min' depth='5.0 m' />
+ <sample time='45:00 min' depth='5.0 m' />
+ <sample time='46:06 min' depth='0.0 m' />
+ </divecomputer>
+</dive>
+</trip>
+</dives>
+</divelog>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 03f550ae0..5106588d0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -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
)
diff --git a/tests/testpicture.cpp b/tests/testpicture.cpp
new file mode 100644
index 000000000..6b59018c1
--- /dev/null
+++ b/tests/testpicture.cpp
@@ -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)
diff --git a/tests/testpicture.h b/tests/testpicture.h
new file mode 100644
index 000000000..e6b8e859e
--- /dev/null
+++ b/tests/testpicture.h
@@ -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