From 8703cea39a9af67788a47628368daf20e378b352 Mon Sep 17 00:00:00 2001 From: hrobeers Date: Tue, 12 Dec 2017 09:01:06 +0100 Subject: [PATCH] Profile flag serialization tests --- .gitignore | 1 + src/version_autogen.hpp | 4 ++-- .../patheditor-tests/serializationtests.cpp | 24 +++++++++++++++++++ .../patheditor-tests/serializationtests.h | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 330c2c7..e1fb8f6 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ Makefile *.cbp CMakeFiles build/ +*_autogen # Emacs *~ diff --git a/src/version_autogen.hpp b/src/version_autogen.hpp index fa2954e..9abbe17 100644 --- a/src/version_autogen.hpp +++ b/src/version_autogen.hpp @@ -11,7 +11,7 @@ #define MINOR_VERSION 1 #define REVISION 1 -#define BUILD_NUMBER 503 -#define COMMIT_HASH "0c790aa172876158cfd1e5365652f420a0466e7c" +#define BUILD_NUMBER 504 +#define COMMIT_HASH "a1167896addf102911a3d9276490635a2324f238" #endif // VERSION_AUTOGEN_H diff --git a/tests/unittests/patheditor-tests/serializationtests.cpp b/tests/unittests/patheditor-tests/serializationtests.cpp index ab3dfb6..01d11c0 100644 --- a/tests/unittests/patheditor-tests/serializationtests.cpp +++ b/tests/unittests/patheditor-tests/serializationtests.cpp @@ -90,6 +90,27 @@ void SerializationTests::testPathSerialization() QVERIFY(!deserialized->pathItems().last()->constStartPoint()->continuous()); } +void SerializationTests::testFlagSerialization() +{ + qunique_ptr profile(new Profile()); + QVERIFY(profile->editable()); + + QJsonObject serialized = JenSON::serialize(profile.get()); + qunique_ptr deserialized = JenSON::deserialize(&serialized); + QVERIFY(deserialized->editable()); + + profile->setEditable(false); + QJsonObject serialized2 = JenSON::serialize(profile.get()); + qunique_ptr deserialized2 = JenSON::deserialize(&serialized2); + QVERIFY(!deserialized2->editable()); +} + +/// +/// \brief SerializationTests::testDeserializing_v_1_0 +/// +/// Paths received an added cont property to highlight continuity. +/// This change should be backwards compatible, meaning that old files should still load successfully. +/// void SerializationTests::testDeserializing_v_1_0() { QString errorMsg; @@ -113,6 +134,9 @@ void SerializationTests::testDeserializing_v_1_0() // Verify that the v1.0 thickness property is not present in the current serialization QByteArray serialized = QJsonDocument(JenSON::serialize(deserialized.get())).toJson(QJsonDocument::Compact); QVERIFY(!serialized.contains("\"thickness\":0")); + + // A flags property is added to v1.2, make sure flag properties are initialized correctly + QVERIFY(deserialized->profile()->editable()); } QTR_ADD_TEST(SerializationTests) diff --git a/tests/unittests/patheditor-tests/serializationtests.h b/tests/unittests/patheditor-tests/serializationtests.h index fc0ccc3..6f9e46b 100644 --- a/tests/unittests/patheditor-tests/serializationtests.h +++ b/tests/unittests/patheditor-tests/serializationtests.h @@ -33,6 +33,7 @@ class SerializationTests : public QObject private slots: void testFoilSerialization(); void testPathSerialization(); + void testFlagSerialization(); // Test backwards compatibility void testDeserializing_v_1_0();