2017-04-27 18:21:27 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-02-21 09:27:31 +00:00
|
|
|
#include "testpicture.h"
|
|
|
|
#include "core/dive.h"
|
|
|
|
#include "core/divelist.h"
|
2018-07-25 19:39:04 +00:00
|
|
|
#include "core/file.h"
|
2017-02-21 09:27:31 +00:00
|
|
|
#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);
|
|
|
|
}
|
|
|
|
|
2018-02-18 13:57:42 +00:00
|
|
|
#define PIC1_NAME "/dives/images/wreck.jpg"
|
|
|
|
#define PIC2_NAME "/dives/images/data_after_EOI.jpg"
|
|
|
|
#define PIC1_HASH "929ad9499b7ae7a9e39ef63eb6c239604ac2adfa"
|
|
|
|
#define PIC2_HASH "fa8bd48f8f24017a81e1204f52300bd98b43d4a7"
|
|
|
|
|
2017-02-21 09:27:31 +00:00
|
|
|
void TestPicture::addPicture()
|
|
|
|
{
|
|
|
|
struct dive *dive;
|
2017-05-06 13:36:29 +00:00
|
|
|
struct picture *pic1, *pic2;
|
2017-02-21 09:27:31 +00:00
|
|
|
verbose = 1;
|
|
|
|
|
2019-02-28 21:45:17 +00:00
|
|
|
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test44.xml", &dive_table, &trip_table, &dive_site_table), 0);
|
2017-02-21 09:27:31 +00:00
|
|
|
dive = get_dive(0);
|
2018-12-11 21:30:57 +00:00
|
|
|
// Pictures will be added to selected dives
|
|
|
|
dive->selected = true;
|
2017-02-21 09:27:31 +00:00
|
|
|
QVERIFY(dive != NULL);
|
2017-05-06 13:36:29 +00:00
|
|
|
pic1 = dive->picture_list;
|
2017-02-21 09:27:31 +00:00
|
|
|
// So far no picture in dive
|
2017-05-06 13:36:29 +00:00
|
|
|
QVERIFY(pic1 == NULL);
|
|
|
|
|
2018-12-11 21:30:57 +00:00
|
|
|
create_picture(SUBSURFACE_TEST_DATA "/dives/images/wreck.jpg", 0, false);
|
|
|
|
create_picture(SUBSURFACE_TEST_DATA "/dives/images/data_after_EOI.jpg", 0, false);
|
2017-05-06 13:36:29 +00:00
|
|
|
pic1 = dive->picture_list;
|
|
|
|
pic2 = pic1->next;
|
|
|
|
// Now there are two picture2
|
|
|
|
QVERIFY(pic1 != NULL);
|
|
|
|
QVERIFY(pic2 != NULL);
|
|
|
|
// 1st appearing at time 21:01
|
|
|
|
// 2nd appearing at time 22:01
|
|
|
|
QVERIFY(pic1->offset.seconds == 1261);
|
2018-10-20 18:12:15 +00:00
|
|
|
QVERIFY(pic1->location.lat.udeg == 47934500);
|
|
|
|
QVERIFY(pic1->location.lon.udeg == 11334500);
|
2017-05-06 13:36:29 +00:00
|
|
|
QVERIFY(pic2->offset.seconds == 1321);
|
|
|
|
|
2018-06-02 16:03:03 +00:00
|
|
|
learnPictureFilename(pic1->filename, PIC1_NAME);
|
|
|
|
learnPictureFilename(pic2->filename, PIC2_NAME);
|
2018-02-18 15:22:34 +00:00
|
|
|
QCOMPARE(localFilePath(pic1->filename), QString(PIC1_NAME));
|
|
|
|
QCOMPARE(localFilePath(pic2->filename), QString(PIC2_NAME));
|
2017-02-21 09:27:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(TestPicture)
|