diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-02-09 21:39:42 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-02-09 21:39:42 (GMT) |
commit | 4adf3144d79cf3affe2b83dabf5333134b6ec6f7 (patch) | |
tree | e6b0a817300eb4a195ee92e5c6c6a19ed4a36f60 /tests/auto | |
parent | 9a3b5988a089429e016334a434023bc5c992f0ed (diff) | |
parent | 969b61f508294d1f683e09e78641127d0f0def05 (diff) | |
download | Qt-4adf3144d79cf3affe2b83dabf5333134b6ec6f7.zip Qt-4adf3144d79cf3affe2b83dabf5333134b6ec6f7.tar.gz Qt-4adf3144d79cf3affe2b83dabf5333134b6ec6f7.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'tests/auto')
8 files changed, 77 insertions, 33 deletions
diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h index 09c850d..b307d9c 100644 --- a/tests/auto/declarative/qmlecmascript/testtypes.h +++ b/tests/auto/declarative/qmlecmascript/testtypes.h @@ -78,7 +78,7 @@ class MyQmlObject : public QObject Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) Q_PROPERTY(QmlList<QObject *> *objectQmlListProperty READ objectQmlListProperty CONSTANT) - Q_PROPERTY(QList<QObject *> *objectListProperty READ objectListProperty CONSTANT) + Q_PROPERTY(QmlListProperty<QObject> objectListProperty READ objectListProperty CONSTANT) Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) public: @@ -108,7 +108,7 @@ public: } QmlList<QObject *> *objectQmlListProperty() { return &m_objectQmlList; } - QList<QObject *> *objectListProperty() { return &m_objectQList; } + QmlListProperty<QObject> objectListProperty() { return QmlListProperty<QObject>(this, m_objectQList); } bool methodCalled() const { return m_methodCalled; } bool methodIntCalled() const { return m_methodIntCalled; } @@ -162,11 +162,11 @@ QML_DECLARE_TYPE(MyQmlObject); class MyQmlContainer : public QObject { Q_OBJECT - Q_PROPERTY(QList<MyQmlObject*>* children READ children CONSTANT) + Q_PROPERTY(QmlListProperty<MyQmlObject> children READ children CONSTANT) public: MyQmlContainer() {} - QList<MyQmlObject*> *children() { return &m_children; } + QmlListProperty<MyQmlObject> children() { return QmlListProperty<MyQmlObject>(this, m_children); } private: QList<MyQmlObject*> m_children; diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index 1ba9a52..cc5d7f2 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -1608,7 +1608,7 @@ void tst_qmlecmascript::listToVariant() QObject *object = component.create(&context); QVERIFY(object != 0); - QCOMPARE(object->property("test"), QVariant::fromValue(container.children())); + QVERIFY(qvariant_cast<QmlListProperty<MyQmlObject> >(object->property("test")) == container.children()); delete object; } diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp index c5a0e05..e60ac5c 100644 --- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp +++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp @@ -233,7 +233,7 @@ void tst_QmlGraphicsPathView::path() QCOMPARE(obj->startY(), 100.); QVERIFY(obj->path() != QPainterPath()); - QList<QmlGraphicsPathElement*> *list = obj->pathElements(); + QList<QmlGraphicsPathElement*> *list = static_cast<QList<QmlGraphicsPathElement*> *>(obj->pathElements().data); QCOMPARE(list->count(), 5); QmlGraphicsPathAttribute* attr = qobject_cast<QmlGraphicsPathAttribute*>(list->at(0)); diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml new file mode 100644 index 0000000..673790d --- /dev/null +++ b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +Item { + property var intInput: intInput + property var dblInput: dblInput + property var strInput: strInput + + width: 800; height: 600; + + Column{ + TextInput { id: intInput; + validator: QIntValidator{top: 11; bottom: 2} + } + TextInput { id: dblInput; + validator: QDoubleValidator{top: 12.12; bottom: 2.93; decimals: 2; notation: QDoubleValidator.StandardNotation} + } + TextInput { id: strInput; + //Requires QTBUG-8025 to be implemented first + //validator: QRegExpValidator { regExp: /[a-zA-z]{2,4}/;} + } + } + +} diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h index d6ca898..6cd4cb5 100644 --- a/tests/auto/declarative/qmllanguage/testtypes.h +++ b/tests/auto/declarative/qmllanguage/testtypes.h @@ -447,19 +447,20 @@ QML_DECLARE_TYPE(MyTypeObject); class MyContainer : public QObject { Q_OBJECT - Q_PROPERTY(QList<QObject*>* children READ children) - Q_PROPERTY(QList<MyInterface*>* qlistInterfaces READ qlistInterfaces) + Q_PROPERTY(QmlListProperty<QObject> children READ children) + Q_PROPERTY(QmlListProperty<MyInterface> qlistInterfaces READ qlistInterfaces) Q_PROPERTY(QmlList<MyInterface*>* qmllistInterfaces READ qmllistInterfaces) Q_CLASSINFO("DefaultProperty", "children"); public: MyContainer() {} - QList<QObject*> *children() { return &m_children; } - QList<MyInterface *> *qlistInterfaces() { return &m_interfaces; } + QmlListProperty<QObject> children() { return QmlListProperty<QObject>(this, m_children); } + QList<QObject *> *getChildren() { return &m_children; } + QmlListProperty<MyInterface> qlistInterfaces() { return QmlListProperty<MyInterface>(this, m_interfaces); } + QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; } QmlList<MyInterface *> *qmllistInterfaces() { return &m_qmlinterfaces; } const QmlConcreteList<MyInterface *> &qmllistAccessor() const { return m_qmlinterfaces; } -private: QList<QObject*> m_children; QList<MyInterface *> m_interfaces; QmlConcreteList<MyInterface *> m_qmlinterfaces; diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 357fc5f..7ccdd3d 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -351,7 +351,7 @@ void tst_qmllanguage::simpleContainer() VERIFY_ERRORS(0); MyContainer *container= qobject_cast<MyContainer*>(component.create()); QVERIFY(container != 0); - QCOMPARE(container->children()->count(),2); + QCOMPARE(container->getChildren()->count(),2); } void tst_qmllanguage::interfaceProperty() @@ -381,9 +381,9 @@ void tst_qmllanguage::interfaceQList() VERIFY_ERRORS(0); MyContainer *container= qobject_cast<MyContainer*>(component.create()); QVERIFY(container != 0); - QVERIFY(container->qlistInterfaces()->count() == 2); + QVERIFY(container->getQListInterfaces()->count() == 2); for(int ii = 0; ii < 2; ++ii) - QVERIFY(container->qlistInterfaces()->at(ii)->id == 913); + QVERIFY(container->getQListInterfaces()->at(ii)->id == 913); } void tst_qmllanguage::assignObjectToSignal() @@ -422,8 +422,8 @@ void tst_qmllanguage::assignQmlComponent() VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->children()->count() == 1); - QObject *child = object->children()->at(0); + QVERIFY(object->getChildren()->count() == 1); + QObject *child = object->getChildren()->at(0); QCOMPARE(child->property("x"), QVariant(10)); QCOMPARE(child->property("y"), QVariant(11)); } @@ -501,7 +501,7 @@ void tst_qmllanguage::rootAsQmlComponent() MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->property("x"), QVariant(11)); - QCOMPARE(object->children()->count(), 2); + QCOMPARE(object->getChildren()->count(), 2); } // Tests that components can be specified inline @@ -511,8 +511,8 @@ void tst_qmllanguage::inlineQmlComponents() VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); - QCOMPARE(object->children()->count(), 1); - QmlComponent *comp = qobject_cast<QmlComponent *>(object->children()->at(0)); + QCOMPARE(object->getChildren()->count(), 1); + QmlComponent *comp = qobject_cast<QmlComponent *>(object->getChildren()->at(0)); QVERIFY(comp != 0); MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create()); QVERIFY(compObject != 0); @@ -526,9 +526,9 @@ void tst_qmllanguage::idProperty() VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); - QCOMPARE(object->children()->count(), 1); + QCOMPARE(object->getChildren()->count(), 1); MyTypeObject *child = - qobject_cast<MyTypeObject *>(object->children()->at(0)); + qobject_cast<MyTypeObject *>(object->getChildren()->at(0)); QVERIFY(child != 0); QCOMPARE(child->id(), QString("myObjectId")); QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); @@ -1031,13 +1031,13 @@ void tst_qmllanguage::defaultPropertyListOrder() MyContainer *container = qobject_cast<MyContainer *>(component.create()); QVERIFY(container != 0); - QCOMPARE(container->children()->count(), 6); - QCOMPARE(container->children()->at(0)->property("index"), QVariant(0)); - QCOMPARE(container->children()->at(1)->property("index"), QVariant(1)); - QCOMPARE(container->children()->at(2)->property("index"), QVariant(2)); - QCOMPARE(container->children()->at(3)->property("index"), QVariant(3)); - QCOMPARE(container->children()->at(4)->property("index"), QVariant(4)); - QCOMPARE(container->children()->at(5)->property("index"), QVariant(5)); + QCOMPARE(container->getChildren()->count(), 6); + QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0)); + QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1)); + QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2)); + QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3)); + QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4)); + QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5)); } void tst_qmllanguage::declaredPropertyValues() diff --git a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp index ddf9a07..9bf47b6 100644 --- a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp +++ b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp @@ -52,7 +52,7 @@ public: private slots: void invalid(); void qmllist(); - void qlist(); + void listproperty(); void qstringlist(); void qvariantlist(); void qobject(); @@ -149,7 +149,7 @@ void tst_QmlListAccessor::qmllist() QCOMPARE(list.count(), 0); } -void tst_QmlListAccessor::qlist() +void tst_QmlListAccessor::listproperty() { QList<QObject*> list; QObject *obj = new QObject(this); @@ -161,11 +161,11 @@ void tst_QmlListAccessor::qlist() QCOMPARE(list.at(0), obj); QmlListAccessor accessor; - accessor.setList(qVariantFromValue((QList<QObject*>*)&list)); - QCOMPARE(accessor.list(), qVariantFromValue((QList<QObject*>*)&list)); + accessor.setList(qVariantFromValue(QmlListProperty<QObject>(this, list))); + QVERIFY(qvariant_cast<QmlListProperty<QObject> >(accessor.list()) == QmlListProperty<QObject>(this, list)); // type - QCOMPARE(accessor.type(), QmlListAccessor::QListPtr); + QCOMPARE(accessor.type(), QmlListAccessor::ListProperty); // isValid QVERIFY(accessor.isValid()); diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index 287f472..9f67a5e 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -236,6 +236,26 @@ void tst_QFileSystemModel::rootPath() QCOMPARE(model->rootPath(), QString(QDir::homePath())); QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? 0 : 1); QCOMPARE(model->rootDirectory().absolutePath(), QDir::homePath()); + + model->setRootPath(QDir::rootPath()); + int oldCount = rootChanged.count(); + oldRootPath = model->rootPath(); + root = model->setRootPath(QDir::homePath() + QLatin1String("/.")); + QTRY_VERIFY(model->rowCount(root) >= 0); + QCOMPARE(model->rootPath(), QDir::homePath()); + QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1); + QCOMPARE(model->rootDirectory().absolutePath(), QDir::homePath()); + + QDir newdir = QDir::home(); + if (newdir.cdUp()) { + oldCount = rootChanged.count(); + oldRootPath = model->rootPath(); + root = model->setRootPath(QDir::homePath() + QLatin1String("/..")); + QTRY_VERIFY(model->rowCount(root) >= 0); + QCOMPARE(model->rootPath(), newdir.path()); + QCOMPARE(rootChanged.count(), oldCount + 1); + QCOMPARE(model->rootDirectory().absolutePath(), newdir.path()); + } } void tst_QFileSystemModel::naturalCompare_data() |