Skip to content

Commit

Permalink
Profile flag serialization tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hrobeers committed Dec 12, 2017
1 parent a116789 commit 8703cea
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Makefile
*.cbp
CMakeFiles
build/
*_autogen

# Emacs
*~
Expand Down
4 changes: 2 additions & 2 deletions src/version_autogen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 24 additions & 0 deletions tests/unittests/patheditor-tests/serializationtests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ void SerializationTests::testPathSerialization()
QVERIFY(!deserialized->pathItems().last()->constStartPoint()->continuous());
}

void SerializationTests::testFlagSerialization()
{
qunique_ptr<Profile> profile(new Profile());
QVERIFY(profile->editable());

QJsonObject serialized = JenSON::serialize(profile.get());
qunique_ptr<Profile> deserialized = JenSON::deserialize<Profile>(&serialized);
QVERIFY(deserialized->editable());

profile->setEditable(false);
QJsonObject serialized2 = JenSON::serialize(profile.get());
qunique_ptr<Profile> deserialized2 = JenSON::deserialize<Profile>(&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;
Expand All @@ -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)
1 change: 1 addition & 0 deletions tests/unittests/patheditor-tests/serializationtests.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class SerializationTests : public QObject
private slots:
void testFoilSerialization();
void testPathSerialization();
void testFlagSerialization();

// Test backwards compatibility
void testDeserializing_v_1_0();
Expand Down

0 comments on commit 8703cea

Please sign in to comment.