diff options
Diffstat (limited to 'tests/auto/qquickxmllistmodel/data')
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/empty.xml | 0 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/get.qml | 61 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/groups.qml | 10 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/groups.xml | 18 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/model.qml | 11 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/model.xml | 54 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/model2.xml | 14 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/propertychanges.qml | 11 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/proxyCrash.qml | 9 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/recipes.qml | 11 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/recipes.xml | 90 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/roleCrash.qml | 8 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/roleErrors.qml | 11 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/roleKeys.qml | 13 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/testtypes.qml | 8 | ||||
-rw-r--r-- | tests/auto/qquickxmllistmodel/data/unique.qml | 9 |
16 files changed, 338 insertions, 0 deletions
diff --git a/tests/auto/qquickxmllistmodel/data/empty.xml b/tests/auto/qquickxmllistmodel/data/empty.xml new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/empty.xml diff --git a/tests/auto/qquickxmllistmodel/data/get.qml b/tests/auto/qquickxmllistmodel/data/get.qml new file mode 100644 index 0000000..509da71 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/get.qml @@ -0,0 +1,61 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } + + id: root + + property bool preTest: false + property bool postTest: false + + function runPreTest() { + if (root.get(0) != undefined) + return; + + preTest = true; + } + + function runPostTest() { + if (root.get(-1) != undefined) + return; + + var row = root.get(0); + if (row.name != "Polly" || + row.type != "Parrot" || + row.age != 12 || + row.size != "Small") + return; + + row = root.get(1); + if (row.name != "Penny" || + row.type != "Turtle" || + row.age != 4 || + row.size != "Small") + return; + + row = root.get(7); + if (row.name != "Rover" || + row.type != "Dog" || + row.age != 0 || + row.size != "Large") + return; + + row = root.get(8); + if (row.name != "Tiny" || + row.type != "Elephant" || + row.age != 15 || + row.size != "Large") + return; + + if (root.get(9) != undefined) + return; + + postTest = true; + } +} diff --git a/tests/auto/qquickxmllistmodel/data/groups.qml b/tests/auto/qquickxmllistmodel/data/groups.qml new file mode 100644 index 0000000..c1b574a --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/groups.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "groups.xml" + query: "//animal[@name='Garfield']/parent::group" + + XmlRole { name: "id"; query: "@id/string()" } + XmlRole { name: "name"; query: "@name/string()" } +} diff --git a/tests/auto/qquickxmllistmodel/data/groups.xml b/tests/auto/qquickxmllistmodel/data/groups.xml new file mode 100644 index 0000000..5de4d2e --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/groups.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<groups version="2.0"> + <group id="1" name="Animals" type="root"> + <group id="11" name="dogs"> + <animal id="111" name="Lassie"/> + <animal id="112" name="Laika"/> + <animal id="113" name="Wile E. Coyote" type="fictional"/> + </group> + <group id="12" name="cats"> + <animal id="121" name="Garfield" type="fictional"/> + <animal id="122" name="Sylvester" type="fictional"/> + </group> + <group id="13" name="birds"> + <animal id="131" name="Donald Duck" type="fictional"/> + <animal id="132" name="Phoenix" type="fictional"/> + </group> + </group> +</groups> diff --git a/tests/auto/qquickxmllistmodel/data/model.qml b/tests/auto/qquickxmllistmodel/data/model.qml new file mode 100644 index 0000000..2df3927 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/model.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } +} diff --git a/tests/auto/qquickxmllistmodel/data/model.xml b/tests/auto/qquickxmllistmodel/data/model.xml new file mode 100644 index 0000000..40cd6d0 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/model.xml @@ -0,0 +1,54 @@ +<Pets> + <Pet> + <name>Polly</name> + <type>Parrot</type> + <age>12</age> + <size>Small</size> + </Pet> + <Pet> + <name>Penny</name> + <type>Turtle</type> + <age>4</age> + <size>Small</size> + </Pet> + <Pet> + <name>Warren</name> + <type>Rabbit</type> + <age>2</age> + <size>Small</size> + </Pet> + <Pet> + <name>Spot</name> + <type>Dog</type> + <age>9</age> + <size>Medium</size> + </Pet> + <Pet> + <name>Whiskers</name> + <type>Cat</type> + <age>2</age> + <size>Medium</size> + </Pet> + <Pet> + <name>Joey</name> + <type>Kangaroo</type> + <age>1</age> + </Pet> + <Pet> + <name>Kimba</name> + <type>Bunny</type> + <age>65</age> + <size>Large</size> + </Pet> + <Pet> + <name>Rover</name> + <type>Dog</type> + <size>Large</size> + </Pet> + <Pet> + <name>Tiny</name> + <type>Elephant</type> + <age>15</age> + <size>Large</size> + </Pet> +</Pets> diff --git a/tests/auto/qquickxmllistmodel/data/model2.xml b/tests/auto/qquickxmllistmodel/data/model2.xml new file mode 100644 index 0000000..dab2ec6 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/model2.xml @@ -0,0 +1,14 @@ +<Pets> + <Pet> + <name>Polly</name> + <type>Parrot</type> + <age>12</age> + <size>Small</size> + </Pet> + <Pet> + <name>Penny</name> + <type>Turtle</type> + <age>4</age> + <size>Small</size> + </Pet> +</Pets> diff --git a/tests/auto/qquickxmllistmodel/data/propertychanges.qml b/tests/auto/qquickxmllistmodel/data/propertychanges.qml new file mode 100644 index 0000000..f8a97bf --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/propertychanges.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { objectName: "role"; name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } +} diff --git a/tests/auto/qquickxmllistmodel/data/proxyCrash.qml b/tests/auto/qquickxmllistmodel/data/proxyCrash.qml new file mode 100644 index 0000000..c0c5a25 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/proxyCrash.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 +import SortFilterProxyModel 1.0 + +SortFilterProxyModel { + source: XmlListModel { + XmlRole { } + } +} diff --git a/tests/auto/qquickxmllistmodel/data/recipes.qml b/tests/auto/qquickxmllistmodel/data/recipes.qml new file mode 100644 index 0000000..dc609e9 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/recipes.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "recipes.xml" + query: "/recipes/recipe" + XmlRole { name: "title"; query: "@title/string()" } + XmlRole { name: "picture"; query: "picture/string()" } + XmlRole { name: "ingredients"; query: "ingredients/string()" } + XmlRole { name: "preparation"; query: "method/string()" } +} diff --git a/tests/auto/qquickxmllistmodel/data/recipes.xml b/tests/auto/qquickxmllistmodel/data/recipes.xml new file mode 100644 index 0000000..d71de60 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/recipes.xml @@ -0,0 +1,90 @@ +<recipes> + <recipe title="Pancakes"> + <picture>content/pics/pancakes.jpg</picture> + <ingredients><![CDATA[<html> + <ul> + <li> 1 cup (150g) self-raising flour + <li> 1 tbs caster sugar + <li> 3/4 cup (185ml) milk + <li> 1 egg + </ul> + </html> + ]]></ingredients> + <method><![CDATA[<html> + <ol> + <li> Sift flour and sugar together into a bowl. Add a pinch of salt. + <li> Beat milk and egg together, then add to dry ingredients. Beat until smooth. + <li> Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. + <li> Turn over and cook other side until golden. + </ol> + </html> + ]]></method> + </recipe> + <recipe title="Fruit Salad"> + <picture>content/pics/fruit-salad.jpg</picture> + <ingredients><![CDATA[* Seasonal Fruit]]></ingredients> + <method><![CDATA[* Chop fruit and place in a bowl.]]></method> + </recipe> + <recipe title="Vegetable Soup"> + <picture>content/pics/vegetable-soup.jpg</picture> + <ingredients><![CDATA[<html> + <ul> + <li> 1 onion + <li> 1 turnip + <li> 1 potato + <li> 1 carrot + <li> 1 head of celery + <li> 1 1/2 litres of water + </ul> + </html> + ]]></ingredients> + <method><![CDATA[<html> + <ol> + <li> Chop vegetables. + <li> Boil in water until vegetables soften. + <li> Season with salt and pepper to taste. + </ol> + </html> + ]]></method> + </recipe> + <recipe title="Hamburger"> + <picture>content/pics/hamburger.jpg</picture> + <ingredients><![CDATA[<html> + <ul> + <li> 500g minced beef + <li> Seasoning + <li> lettuce, tomato, onion, cheese + <li> 1 hamburger bun for each burger + </ul> + </html> + ]]></ingredients> + <method><![CDATA[<html> + <ol> + <li> Mix the beef, together with seasoning, in a food processor. + <li> Shape the beef into burgers. + <li> Grill the burgers for about 5 mins on each side (until cooked through) + <li> Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. + </ol> + </html> + ]]></method> + </recipe> + <recipe title="Lemonade"> + <picture>content/pics/lemonade.jpg</picture> + <ingredients><![CDATA[<html> + <ul> + <li> 1 cup Lemon Juice + <li> 1 cup Sugar + <li> 6 Cups of Water (2 cups warm water, 4 cups cold water) + </ul> + </html> + ]]></ingredients> + <method><![CDATA[<html> + <ol> + <li> Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. + <li> Pour in lemon juice, stir again, and add 4 cups of cold water. + <li> Chill or serve over ice cubes. + </ol> + </html> + ]]></method> + </recipe> +</recipes> diff --git a/tests/auto/qquickxmllistmodel/data/roleCrash.qml b/tests/auto/qquickxmllistmodel/data/roleCrash.qml new file mode 100644 index 0000000..6a7059b --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/roleCrash.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + id: model + XmlRole {} + Component.onCompleted: model.roles = 0 +} diff --git a/tests/auto/qquickxmllistmodel/data/roleErrors.qml b/tests/auto/qquickxmllistmodel/data/roleErrors.qml new file mode 100644 index 0000000..91664b6 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/roleErrors.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "/name/string()" } //starts with '/' + XmlRole { name: "type"; query: "type" } //no type + XmlRole { name: "age"; query: "age/" } //ends with '/' + XmlRole { name: "size"; query: "size/number()" } //wrong type +} diff --git a/tests/auto/qquickxmllistmodel/data/roleKeys.qml b/tests/auto/qquickxmllistmodel/data/roleKeys.qml new file mode 100644 index 0000000..9f667d8 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/roleKeys.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + query: "/data/item" + XmlRole { id: nameRole; name: "name"; query: "name/string()"; isKey: true } + XmlRole { name: "age"; query: "age/number()"; isKey: true } + XmlRole { name: "sport"; query: "sport/string()" } + + function disableNameKey() { + nameRole.isKey = false; + } +} diff --git a/tests/auto/qquickxmllistmodel/data/testtypes.qml b/tests/auto/qquickxmllistmodel/data/testtypes.qml new file mode 100644 index 0000000..5ec1ffa --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/testtypes.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + query: "/data" + XmlRole { name: "stringValue"; query: "a-string/string()" } + XmlRole { name: "numberValue"; query: "a-number/number()" } +} diff --git a/tests/auto/qquickxmllistmodel/data/unique.qml b/tests/auto/qquickxmllistmodel/data/unique.qml new file mode 100644 index 0000000..322a2e4 --- /dev/null +++ b/tests/auto/qquickxmllistmodel/data/unique.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "name"; query: "type/string()" } +} |