Refactor singleton type registration code
[profile/ivi/qtdeclarative.git] / tests / auto / qml / qqmlecmascript / data / singletontype / qobjectSingletonTypeWriting.qml
1 import QtQuick 2.0
2 import Qt.test 1.0 as QtTest     // qobject singleton Type installed into existing uri
3
4 QtObject {
5     property int firstProperty: 1
6     property int secondProperty: 2
7     property int readOnlyProperty: QtTest.QObject.qobjectTestProperty
8     property int writableProperty: QtTest.QObject.qobjectTestWritableProperty
9     property int writableFinalProperty: QtTest.QObject.qobjectTestWritableFinalProperty
10
11     onFirstPropertyChanged: {
12         // In this case, we want to attempt to set the singleton Type property.
13         // This should fail, as the singleton Type property is read only.
14         if (firstProperty != QtTest.QObject.qobjectTestProperty) {
15             QtTest.QObject.qobjectTestProperty = firstProperty; // should silently fail.
16         }
17     }
18
19     onSecondPropertyChanged: {
20         // In this case, we want to attempt to set the singleton Type properties.
21         // This should succeed, as the singleton Type properties are writable.
22         if (secondProperty != QtTest.QObject.qobjectTestWritableProperty) {
23             QtTest.QObject.qobjectTestWritableProperty = secondProperty; // should succeed.
24         }
25         if (secondProperty != QtTest.QObject.qobjectTestWritableFinalProperty) {
26             QtTest.QObject.qobjectTestWritableFinalProperty = secondProperty; // should succeed.
27         }
28     }
29 }
30