diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-22 08:06:40 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-22 08:06:40 (GMT) |
commit | 0b6fd8966972616232054c5194243c52ca360bf8 (patch) | |
tree | 06dc40958aefc6f5e118dccfa192ff77528a014d /tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp | |
parent | 1c47be7174ca1e9ed393a12461742975079710d7 (diff) | |
parent | e9da512e321c6ea7795a4abc0b9d24bf4d3d2527 (diff) | |
download | Qt-0b6fd8966972616232054c5194243c52ca360bf8.zip Qt-0b6fd8966972616232054c5194243c52ca360bf8.tar.gz Qt-0b6fd8966972616232054c5194243c52ca360bf8.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (135 commits)
Do not treat images in qml examples differently.
Replace Flickable overshoot property with boundsBehavior
Autotests and doc
Give error on attempt to import types from too-early version number.
Remove (undocumented) QML bindings for effects.
De-straighten them lines.
Doc: fix QStringList model doc (really).
Doc: fix QStringList model docs
Change return type to match value().
Add duration and easing properties to AnchorAnimation.
Autotest
Remove dead code
Compile on Windows (export decl fix).
Fix versioning of Qt Declarative's in-built types
Fixed declarative/parserstress autotest.
Fix parsing of regular expression literals.
Fill out QGraphicsLayout bindings
Update test files to new syntax
Compile without Qt3 support.
Ensure workerscript.qml works (autotested).
...
Diffstat (limited to 'tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp new file mode 100644 index 0000000..7de15a3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <qtest.h> +#include <QtTest/QSignalSpy> +#include <QStandardItemModel> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtDeclarative/qdeclarativecontext.h> +#include <private/qdeclarativevisualitemmodel_p.h> +#include <private/qdeclarativevaluetype_p.h> +#include <math.h> + +static void initStandardTreeModel(QStandardItemModel *model) +{ + QStandardItem *item; + item = new QStandardItem(QLatin1String("Row 1 Item")); + model->insertRow(0, item); + + item = new QStandardItem(QLatin1String("Row 2 Item")); + item->setCheckable(true); + model->insertRow(1, item); + + QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item")); + item->setChild(0, childItem); + + item = new QStandardItem(QLatin1String("Row 3 Item")); + item->setIcon(QIcon()); + model->insertRow(2, item); +} + +class tst_qdeclarativevisualdatamodel : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativevisualdatamodel(); + +private slots: + void rootIndex(); + +private: + QDeclarativeEngine engine; +}; + +tst_qdeclarativevisualdatamodel::tst_qdeclarativevisualdatamodel() +{ +} + +void tst_qdeclarativevisualdatamodel::rootIndex() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/visualdatamodel.qml")); + + QStandardItemModel model; + initStandardTreeModel(&model); + + engine.rootContext()->setContextProperty("myModel", &model); + + QDeclarativeVisualDataModel *obj = qobject_cast<QDeclarativeVisualDataModel*>(c.create()); + QVERIFY(obj != 0); + + QMetaObject::invokeMethod(obj, "setRoot"); + QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0)); + + QMetaObject::invokeMethod(obj, "setRootToParent"); + QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex()); + + delete obj; +} + + +QTEST_MAIN(tst_qdeclarativevisualdatamodel) + +#include "tst_qdeclarativevisualdatamodel.moc" |