diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2014-02-27 00:36:51 -0500 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-02-28 12:38:15 +0100 |
commit | e6ac15cf7a29265bb9b4ca11fdd97ff277d6d433 (patch) | |
tree | 7b1c5b5687005536038f39a0c57587d7f78c7d23 /tests/auto/blackbox | |
parent | 5c01bb69986801bd717639a2612bf48c5701ebb3 (diff) |
Add test coverage for new PropertyList extension features.
Change-Id: If31fd181c30b61f8f02915408520e85b34d5fc11
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto/blackbox')
-rw-r--r-- | tests/auto/blackbox/testdata/jsextensions/propertylist.qbs | 65 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 13 |
2 files changed, 77 insertions, 1 deletions
diff --git a/tests/auto/blackbox/testdata/jsextensions/propertylist.qbs b/tests/auto/blackbox/testdata/jsextensions/propertylist.qbs index 5b80eeafb..8790629c2 100644 --- a/tests/auto/blackbox/testdata/jsextensions/propertylist.qbs +++ b/tests/auto/blackbox/testdata/jsextensions/propertylist.qbs @@ -55,10 +55,75 @@ Product { jsontextfile.write(propertyList.toJSONString()); jsontextfile.close(); + propertyList.writeToFile("test2.json", "json-compact"); + propertyList.writeToFile("test3.json", "json-pretty"); + process = new Process(); process.exec("plutil", ["-convert", "json", "test.xml"]); process.close(); + propertyList = new PropertyList(); + propertyList.readFromFile("test.xml"); + if (propertyList.format() !== "json") { // yes, JSON -- ignore the file extension + throw "expected property list format json but got " + propertyList.format(); + } + + if (propertyList.isEmpty()) { + throw "PropertyList was 'empty' after being loaded with data"; + } + + var opensteptextfile = new TextFile("test.openstep.plist", TextFile.WriteOnly); + opensteptextfile.write('{ rootObject = ( "val1", "val3", "val5", /* comment */ "val7", "val9", ); }'); + opensteptextfile.close(); + + propertyList = new PropertyList(); + propertyList.readFromFile("test.openstep.plist"); + if (propertyList.format() !== "openstep") { + throw "expected property list format openstep but got " + propertyList.format(); + } + + var jsonObj = JSON.parse(propertyList.toJSONString()); + if (jsonObj["rootObject"].length != 5) { + throw "going from OpenStep to a JSON string to a JSON object somehow broke"; + } + + propertyList.clear(); + propertyList.readFromString('<dict><key>foo</key><string>barz</string></dict>'); + jsonObj = JSON.parse(propertyList.toJSONString()); + if (jsonObj["foo"] !== "barz") { + throw "the XML plist did not get parsed properly"; + } + + propertyList.writeToFile("woof.xml", "xml1"); + propertyList.readFromFile("woof.xml"); + if (propertyList.format() !== "xml1") { + throw "round trip writing and reading XML failed"; + } + + propertyList.writeToFile("woof.plist", "binary1"); + propertyList.readFromFile("woof.plist"); + if (propertyList.format() !== "binary1") { + throw "round trip writing and reading binary failed"; + } + + if (jsonObj["foo"] !== "barz") { + throw "the binary plist did not get parsed properly"; + } + + if (propertyList.toString("json") !== propertyList.toString("json-compact") || + propertyList.toJSONString() !== propertyList.toJSONString("compact")) { + throw "json and json-compact formats were not equivalent"; + } + + if (propertyList.toString("json") === propertyList.toString("json-pretty") || + propertyList.toJSONString() === propertyList.toJSONString("pretty")) { + throw "json and json-pretty formats were not different"; + } + + if (propertyList.toString("xml1") !== propertyList.toXMLString()) { + throw 'toString("xml1") and toXMLString() were not equivalent'; + } + return "Pineapple Steve"; } } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 394557390..db0928e4d 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -1597,7 +1597,18 @@ void TestBlackbox::jsExtensionsPropertyList() QFile file2("test.xml"); QVERIFY(file2.exists()); QVERIFY(file2.open(QIODevice::ReadOnly)); - QCOMPARE(file1.readAll(), file2.readAll()); + QFile file3("test2.json"); + QVERIFY(file3.exists()); + QVERIFY(file3.open(QIODevice::ReadOnly)); + QByteArray file1Contents = file1.readAll(); + QCOMPARE(file3.readAll(), file1Contents); + QCOMPARE(file1Contents, file2.readAll()); + QFile file4("test.openstep.plist"); + QVERIFY(file4.exists()); + QFile file5("test3.json"); + QVERIFY(file5.exists()); + QVERIFY(file5.open(QIODevice::ReadOnly)); + QVERIFY(file1Contents != file5.readAll()); } void TestBlackbox::jsExtensionsTextFile() |