diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2014-01-16 13:02:56 -0500 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-01-20 17:01:23 +0100 |
commit | 98a76fc281a5968b188150580ce27f19c568fd29 (patch) | |
tree | b9ac68f4e26a79a10b962d6a70eb573ab4eadb93 /tests/auto/blackbox/testdata/jsextensions | |
parent | fe3941568f11ea02996af489453bc5606b6988fd (diff) |
Add a JS extension for working with property lists.
Change-Id: Ib9413501f647f52b60507daf85bdfe8e560d7e08
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto/blackbox/testdata/jsextensions')
-rw-r--r-- | tests/auto/blackbox/testdata/jsextensions/propertylist.qbs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/jsextensions/propertylist.qbs b/tests/auto/blackbox/testdata/jsextensions/propertylist.qbs new file mode 100644 index 000000000..94a1e1b31 --- /dev/null +++ b/tests/auto/blackbox/testdata/jsextensions/propertylist.qbs @@ -0,0 +1,38 @@ +import qbs +import qbs.Process +import qbs.PropertyList +import qbs.TextFile + +Product { + type: { + var obj = { + "Array": ["ListItem1", "ListItem2", "ListItem3"], + "Integer": 1, + "Boolean": true, + "String": "otherString" + }; + + var infoplist = new TextFile("test.xml", TextFile.WriteOnly); + infoplist.write(JSON.stringify(obj)); + infoplist.close(); + + var process = new Process(); + process.exec("plutil", ["-convert", "xml1", "test.xml"]); + process.close(); + + var xmlfile = new TextFile("test.xml", TextFile.ReadOnly); + var propertyList = new PropertyList(); + propertyList.read(xmlfile.readAll()); + xmlfile.close(); + + var jsontextfile = new TextFile("test.json", TextFile.WriteOnly); + jsontextfile.write(propertyList.toJSON()); + jsontextfile.close(); + + process = new Process(); + process.exec("plutil", ["-convert", "json", "test.xml"]); + process.close(); + + return "Pineapple Steve"; + } +} |