diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-19 16:48:53 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-06 13:58:09 -0700 |
commit | 74f03e3537ee530000d4b11013bb12de91cb21dd (patch) | |
tree | d534e7ee2718318b9ae0bba9578ec84001a5dff9 /tests | |
parent | 093551363602e723864467af0812f13f4525855f (diff) | |
download | subsurface-74f03e3537ee530000d4b11013bb12de91cb21dd.tar.gz |
media: move addition of pictures out of create_picture()
If we want to make addition of pictures undoable, then create_picture()
must not add directly to the dive. Instead, return the dive to which the
picture should be added and let the caller perform the addition.
This means that the picture-test has to be adapted.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testpicture.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/testpicture.cpp b/tests/testpicture.cpp index 7bd683523..b5c6ae22a 100644 --- a/tests/testpicture.cpp +++ b/tests/testpicture.cpp @@ -22,7 +22,7 @@ void TestPicture::initTestCase() void TestPicture::addPicture() { - struct dive *dive; + struct dive *dive, *dive1, *dive2; struct picture *pic1, *pic2; verbose = 1; @@ -34,9 +34,19 @@ void TestPicture::addPicture() // So far no picture in dive QVERIFY(dive->pictures.nr == 0); - create_picture(SUBSURFACE_TEST_DATA "/dives/images/wreck.jpg", 0, false); - create_picture(SUBSURFACE_TEST_DATA "/dives/images/data_after_EOI.jpg", 0, false); - // Now there are two picture2 + pic1 = create_picture(SUBSURFACE_TEST_DATA "/dives/images/wreck.jpg", 0, false, &dive1); + pic2 = create_picture(SUBSURFACE_TEST_DATA "/dives/images/data_after_EOI.jpg", 0, false, &dive2); + QVERIFY(pic1 != NULL); + QVERIFY(pic2 != NULL); + QVERIFY(dive1 == dive); + QVERIFY(dive2 == dive); + + add_picture(&dive->pictures, *pic1); + add_picture(&dive->pictures, *pic2); + free(pic1); + free(pic2); + + // Now there are two pictures QVERIFY(dive->pictures.nr == 2); pic1 = &dive->pictures.pictures[0]; pic2 = &dive->pictures.pictures[1]; |