summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-11-05 03:31:48 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-11-05 03:31:48 (GMT)
commit541d800f6b6597712cb705d30e1f4060a1536843 (patch)
tree7469593c4a4eceb4cadac517345303116c37ae12
parent5ff952242ca7c2a5ae64c3fc4c904fd121fdf74b (diff)
parent6dcc1c24400d5d86257125f3ee7ad45f75a5a8a8 (diff)
downloadQt-541d800f6b6597712cb705d30e1f4060a1536843.zip
Qt-541d800f6b6597712cb705d30e1f4060a1536843.tar.gz
Qt-541d800f6b6597712cb705d30e1f4060a1536843.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--src/declarative/extra/extra.pri2
-rw-r--r--src/declarative/extra/qmlgraphicsintegermodel.cpp126
-rw-r--r--tests/auto/declarative/declarative.pro1
-rw-r--r--tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp12
-rw-r--r--tests/auto/declarative/valuetypes/data/font_read.qml18
-rw-r--r--tests/auto/declarative/valuetypes/data/font_write.2.qml6
-rw-r--r--tests/auto/declarative/valuetypes/data/font_write.3.qml7
-rw-r--r--tests/auto/declarative/valuetypes/data/font_write.qml16
-rw-r--r--tests/auto/declarative/valuetypes/data/point_read.qml7
-rw-r--r--tests/auto/declarative/valuetypes/data/point_write.qml6
-rw-r--r--tests/auto/declarative/valuetypes/data/pointf_read.qml8
-rw-r--r--tests/auto/declarative/valuetypes/data/pointf_write.qml6
-rw-r--r--tests/auto/declarative/valuetypes/data/rect_read.qml10
-rw-r--r--tests/auto/declarative/valuetypes/data/rect_write.qml9
-rw-r--r--tests/auto/declarative/valuetypes/data/rectf_read.qml10
-rw-r--r--tests/auto/declarative/valuetypes/data/rectf_write.qml9
-rw-r--r--tests/auto/declarative/valuetypes/data/size_read.qml8
-rw-r--r--tests/auto/declarative/valuetypes/data/size_write.qml7
-rw-r--r--tests/auto/declarative/valuetypes/data/sizef_read.qml9
-rw-r--r--tests/auto/declarative/valuetypes/data/sizef_write.qml6
-rw-r--r--tests/auto/declarative/valuetypes/data/vector3d_read.qml9
-rw-r--r--tests/auto/declarative/valuetypes/data/vector3d_write.qml8
-rw-r--r--tests/auto/declarative/valuetypes/testtypes.cpp (renamed from src/declarative/extra/qmlgraphicsintegermodel_p.h)49
-rw-r--r--tests/auto/declarative/valuetypes/testtypes.h128
-rw-r--r--tests/auto/declarative/valuetypes/tst_valuetypes.cpp330
-rw-r--r--tests/auto/declarative/valuetypes/valuetypes.pro10
26 files changed, 638 insertions, 179 deletions
diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri
index 9d0e760..a84dfca 100644
--- a/src/declarative/extra/extra.pri
+++ b/src/declarative/extra/extra.pri
@@ -2,7 +2,6 @@ SOURCES += \
extra/qnumberformat.cpp \
extra/qmlnumberformatter.cpp \
extra/qmldatetimeformatter.cpp \
- extra/qmlgraphicsintegermodel.cpp \
extra/qmlgraphicsanimatedimageitem.cpp \
extra/qmlgraphicsparticles.cpp \
extra/qmlbehavior.cpp \
@@ -12,7 +11,6 @@ HEADERS += \
extra/qnumberformat_p.h \
extra/qmlnumberformatter_p.h \
extra/qmldatetimeformatter_p.h \
- extra/qmlgraphicsintegermodel_p.h \
extra/qmlgraphicsanimatedimageitem_p.h \
extra/qmlgraphicsanimatedimageitem_p_p.h \
extra/qmlgraphicsparticles_p.h \
diff --git a/src/declarative/extra/qmlgraphicsintegermodel.cpp b/src/declarative/extra/qmlgraphicsintegermodel.cpp
deleted file mode 100644
index bcd00e6..0000000
--- a/src/declarative/extra/qmlgraphicsintegermodel.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module 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 "qmlgraphicsintegermodel_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,IntegerModel,QmlGraphicsIntegerModel)
-
-class QmlGraphicsIntegerModelPrivate
-{
-public:
- QmlGraphicsIntegerModelPrivate() : minimum(0), maximum(0) {}
- int minimum;
- int maximum;
-};
-
-QmlGraphicsIntegerModel::QmlGraphicsIntegerModel(QObject *parent)
- : QListModelInterface(parent)
-{
- d = new QmlGraphicsIntegerModelPrivate;
-}
-
-QmlGraphicsIntegerModel::~QmlGraphicsIntegerModel()
-{
- delete d;
-}
-
-int QmlGraphicsIntegerModel::minimum() const
-{
- return d->minimum;
-}
-
-void QmlGraphicsIntegerModel::setMinimum(int minimum)
-{
- d->minimum = minimum;
-}
-
-int QmlGraphicsIntegerModel::maximum() const
-{
- return d->maximum;
-}
-
-void QmlGraphicsIntegerModel::setMaximum(int maximum)
-{
- d->maximum = maximum;
-}
-
-int QmlGraphicsIntegerModel::count() const
-{
- return qMax(0, d->maximum - d->minimum + 1);
-}
-
-QHash<int,QVariant> QmlGraphicsIntegerModel::data(int index, const QList<int> &roles) const
-{
- QHash<int,QVariant> returnHash;
-
- for (int i = 0; i < roles.size(); ++i) {
- int role = roles.at(i);
- QVariant info;
- switch(role) {
- case Qt::DisplayRole:
- info = QVariant(QString::number(d->minimum+index));
- break;
- default:
- break;
- }
- returnHash.insert(role, info);
- }
- return returnHash;
-}
-
-QString QmlGraphicsIntegerModel::toString(int role) const
-{
- switch(role) {
- case Qt::DisplayRole:
- return QLatin1String("display");
- default:
- return QLatin1String("");
- }
-}
-
-QList<int> QmlGraphicsIntegerModel::roles() const
-{
- return QList<int>() << Qt::DisplayRole;
-}
-
-QT_END_NAMESPACE
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 1be38a8..b9f59d6 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -35,6 +35,7 @@ SUBDIRS += \
repeater \ # Cover
sql \ # Cover
states \ # Cover
+ valuetypes \ # Cover
visual # Cover
# Tests which should run in Pulse
diff --git a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp b/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp
index 9be77e8..ece6030 100644
--- a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp
+++ b/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp
@@ -95,13 +95,15 @@ void tst_QmlPropertyMap::operatorValue()
QmlPropertyMap map;
map.insert(QLatin1String("key1"),100);
map.insert(QLatin1String("key2"),200);
- QVERIFY(map.keys().count() == 2);
+ QVERIFY(map.count() == 2);
QVERIFY(map.contains(QLatin1String("key1")));
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
- QCOMPARE(map[QLatin1String("key1")], map.value(QLatin1String("key1")));
- QCOMPARE(map[QLatin1String("key2")], map.value(QLatin1String("key2")));
+ const QmlPropertyMap &constMap = map;
+
+ QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200));
+ QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1")));
+ QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2")));
}
void tst_QmlPropertyMap::clear()
diff --git a/tests/auto/declarative/valuetypes/data/font_read.qml b/tests/auto/declarative/valuetypes/data/font_read.qml
new file mode 100644
index 0000000..e1d1ce0
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/font_read.qml
@@ -0,0 +1,18 @@
+import Test 1.0
+
+MyTypeObject {
+ property string f_family: font.family
+ property bool f_bold: font.bold
+ property int f_weight: font.weight
+ property bool f_italic: font.italic
+ property bool f_underline: font.underline
+ property bool f_overline: font.overline
+ property bool f_strikeout: font.strikeout
+ property real f_pointSize: font.pointSize
+ property int f_pixelSize: font.pixelSize
+ property int f_capitalization: font.capitalization
+ property real f_letterSpacing: font.letterSpacing
+ property real f_wordSpacing: font.wordSpacing;
+ property var copy: font
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/font_write.2.qml b/tests/auto/declarative/valuetypes/data/font_write.2.qml
new file mode 100644
index 0000000..b559389
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/font_write.2.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ font.pixelSize: 10
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/font_write.3.qml b/tests/auto/declarative/valuetypes/data/font_write.3.qml
new file mode 100644
index 0000000..913ac50
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/font_write.3.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ font.pixelSize: 10
+ font.pointSize: 19
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/font_write.qml b/tests/auto/declarative/valuetypes/data/font_write.qml
new file mode 100644
index 0000000..ff4d0a1
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/font_write.qml
@@ -0,0 +1,16 @@
+import Test 1.0
+
+MyTypeObject {
+ font.family: if(1) "Helvetica"
+ font.bold: if(1) false
+ font.weight: "Normal"
+ font.italic: if(1) false
+ font.underline: if(1) false
+ font.overline: if(1) false
+ font.strikeout: if(1) false
+ font.pointSize: if(1) 15
+ font.capitalization: "AllLowercase"
+ font.letterSpacing: if(1) 9.7
+ font.wordSpacing: if(1) 11.2
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/point_read.qml b/tests/auto/declarative/valuetypes/data/point_read.qml
new file mode 100644
index 0000000..3e67de6
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/point_read.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ property int p_x: point.x
+ property int p_y: point.y
+ property var copy: point
+}
diff --git a/tests/auto/declarative/valuetypes/data/point_write.qml b/tests/auto/declarative/valuetypes/data/point_write.qml
new file mode 100644
index 0000000..063525a
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/point_write.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ point.x: if (true) 11
+ point.y: if (true) 12
+}
diff --git a/tests/auto/declarative/valuetypes/data/pointf_read.qml b/tests/auto/declarative/valuetypes/data/pointf_read.qml
new file mode 100644
index 0000000..d845a5b
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/pointf_read.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property real p_x: pointf.x
+ property real p_y: pointf.y
+ property var copy: pointf
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/pointf_write.qml b/tests/auto/declarative/valuetypes/data/pointf_write.qml
new file mode 100644
index 0000000..9ee3fc1
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/pointf_write.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ pointf.x: if (true) 6.8
+ pointf.y: if (true) 9.3
+}
diff --git a/tests/auto/declarative/valuetypes/data/rect_read.qml b/tests/auto/declarative/valuetypes/data/rect_read.qml
new file mode 100644
index 0000000..5364431
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/rect_read.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+
+MyTypeObject {
+ property int r_x: rect.x
+ property int r_y: rect.y
+ property int r_width: rect.width
+ property int r_height: rect.height
+ property var copy: rect
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/rect_write.qml b/tests/auto/declarative/valuetypes/data/rect_write.qml
new file mode 100644
index 0000000..8add453
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/rect_write.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ rect.x: if (true) 1234
+ rect.y: if (true) 7
+ rect.width: if (true) 56
+ rect.height: if (true) 63
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/rectf_read.qml b/tests/auto/declarative/valuetypes/data/rectf_read.qml
new file mode 100644
index 0000000..aeb9f41
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/rectf_read.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+
+MyTypeObject {
+ property real r_x: rectf.x
+ property real r_y: rectf.y
+ property real r_width: rectf.width
+ property real r_height: rectf.height
+ property var copy: rectf
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/rectf_write.qml b/tests/auto/declarative/valuetypes/data/rectf_write.qml
new file mode 100644
index 0000000..1e6ff4f
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/rectf_write.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ rectf.x: if (true) 70.1
+ rectf.y: if (true) -113.2
+ rectf.width: if (true) 80924.8
+ rectf.height: if (true) 99.2
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/size_read.qml b/tests/auto/declarative/valuetypes/data/size_read.qml
new file mode 100644
index 0000000..86dba03
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/size_read.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property int s_width: size.width
+ property int s_height: size.height
+ property var copy: size
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/size_write.qml b/tests/auto/declarative/valuetypes/data/size_write.qml
new file mode 100644
index 0000000..2f9d10e
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/size_write.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ size.width: if (true) 13
+ size.height: if (true) 88
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/sizef_read.qml b/tests/auto/declarative/valuetypes/data/sizef_read.qml
new file mode 100644
index 0000000..c6f34e4
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/sizef_read.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ property real s_width: sizef.width
+ property real s_height: sizef.height
+ property var copy: sizef
+}
+
+
diff --git a/tests/auto/declarative/valuetypes/data/sizef_write.qml b/tests/auto/declarative/valuetypes/data/sizef_write.qml
new file mode 100644
index 0000000..f16f0bd
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/sizef_write.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ sizef.width: if (true) 44.3
+ sizef.height: if (true) 92.8
+}
diff --git a/tests/auto/declarative/valuetypes/data/vector3d_read.qml b/tests/auto/declarative/valuetypes/data/vector3d_read.qml
new file mode 100644
index 0000000..abdf9f0
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/vector3d_read.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_x: vector.x
+ property real v_y: vector.y
+ property real v_z: vector.z
+ property var copy: vector
+}
+
diff --git a/tests/auto/declarative/valuetypes/data/vector3d_write.qml b/tests/auto/declarative/valuetypes/data/vector3d_write.qml
new file mode 100644
index 0000000..9c1bf76
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/data/vector3d_write.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ vector.x: if (true) -0.3
+ vector.y: if (true) -12.9
+ vector.z: if (true) 907.4
+}
+
diff --git a/src/declarative/extra/qmlgraphicsintegermodel_p.h b/tests/auto/declarative/valuetypes/testtypes.cpp
index 4055e01..d57afaf 100644
--- a/src/declarative/extra/qmlgraphicsintegermodel_p.h
+++ b/tests/auto/declarative/valuetypes/testtypes.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -38,49 +38,6 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "testtypes.h"
-#ifndef QMLGRAPHICSINTMODEL_H
-#define QMLGRAPHICSINTMODEL_H
-
-#include <QtCore/QObject>
-#include <QtDeclarative/qml.h>
-#include <private/qlistmodelinterface_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlGraphicsIntegerModelPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsIntegerModel : public QListModelInterface
-{
- Q_OBJECT
-public:
- QmlGraphicsIntegerModel(QObject *parent=0);
- ~QmlGraphicsIntegerModel();
-
- Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
- int minimum() const;
- void setMinimum(int);
-
- Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
- int maximum() const;
- void setMaximum(int);
-
- int count() const;
- QHash<int, QVariant> data(int index, const QList<int> &roles) const;
- QList<int> roles() const;
- QString toString(int role) const;
-
-private:
- QmlGraphicsIntegerModelPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsIntegerModel)
-
-QT_END_HEADER
-
-#endif
+QML_DEFINE_TYPE(Test, 1, 0, 0, MyTypeObject, MyTypeObject);
diff --git a/tests/auto/declarative/valuetypes/testtypes.h b/tests/auto/declarative/valuetypes/testtypes.h
new file mode 100644
index 0000000..cc98d7c
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/testtypes.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QObject>
+#include <QPoint>
+#include <QPointF>
+#include <QSize>
+#include <QSizeF>
+#include <QRect>
+#include <QRectF>
+#include <QVector3D>
+#include <QFont>
+#include <qml.h>
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed);
+ Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed);
+ Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed);
+ Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed);
+ Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed);
+ Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed);
+ Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed);
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed);
+
+public:
+ MyTypeObject() :
+ m_point(10, 4),
+ m_pointf(11.3, -10.9),
+ m_size(1912, 1913),
+ m_sizef(0.1, 100923.2),
+ m_rect(2, 3, 109, 102),
+ m_rectf(103.8, 99.2, 88.1, 77.6),
+ m_vector(23.88, 3.1, 4.3)
+ {
+ m_font.setFamily("Arial");
+ m_font.setBold(true);
+ m_font.setWeight(QFont::DemiBold);
+ m_font.setItalic(true);
+ m_font.setUnderline(true);
+ m_font.setOverline(true);
+ m_font.setStrikeOut(true);
+ m_font.setPointSize(29);
+ m_font.setCapitalization(QFont::AllUppercase);
+ m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
+ m_font.setWordSpacing(19.7);
+ }
+
+ QPoint m_point;
+ QPoint point() const { return m_point; }
+ void setPoint(const QPoint &v) { m_point = v; }
+
+ QPointF m_pointf;
+ QPointF pointf() const { return m_pointf; }
+ void setPointf(const QPointF &v) { m_pointf = v; }
+
+ QSize m_size;
+ QSize size() const { return m_size; }
+ void setSize(const QSize &v) { m_size = v; }
+
+ QSizeF m_sizef;
+ QSizeF sizef() const { return m_sizef; }
+ void setSizef(const QSizeF &v) { m_sizef = v; }
+
+ QRect m_rect;
+ QRect rect() const { return m_rect; }
+ void setRect(const QRect &v) { m_rect = v; }
+
+ QRectF m_rectf;
+ QRectF rectf() const { return m_rectf; }
+ void setRectf(const QRectF &v) { m_rectf = v; }
+
+ QVector3D m_vector;
+ QVector3D vector() const { return m_vector; }
+ void setVector(const QVector3D &v) { m_vector = v; }
+
+ QFont m_font;
+ QFont font() const { return m_font; }
+ void setFont(const QFont &v) { m_font = v; }
+
+signals:
+ void changed();
+};
+QML_DECLARE_TYPE(MyTypeObject);
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/valuetypes/tst_valuetypes.cpp b/tests/auto/declarative/valuetypes/tst_valuetypes.cpp
new file mode 100644
index 0000000..a338e47
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/tst_valuetypes.cpp
@@ -0,0 +1,330 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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 <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "testtypes.h"
+
+class tst_valuetypes : public QObject
+{
+ Q_OBJECT
+public:
+ tst_valuetypes() {}
+
+private slots:
+ void point();
+ void pointf();
+ void size();
+ void sizef();
+ void rect();
+ void rectf();
+ void vector3d();
+ void font();
+
+ // ###
+ // Test binding assignment
+ // Test static assignment
+ // Test JS assignment
+ // Test "font.x: blah; font: blah2;" conflict
+ // Test constant binding removal
+ // Test value sources
+ // Test behaviours
+private:
+ QmlEngine engine;
+};
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_valuetypes::point()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("point_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("p_x").toInt(), 10);
+ QCOMPARE(object->property("p_y").toInt(), 4);
+ QCOMPARE(object->property("copy"), QVariant(QPoint(10, 4)));
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("point_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->point(), QPoint(11, 12));
+
+ delete object;
+ }
+}
+
+void tst_valuetypes::pointf()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("pointf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("p_x").toDouble(), 11.3);
+ QCOMPARE(object->property("p_y").toDouble(), -10.9);
+ QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9)));
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("pointf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
+
+ delete object;
+ }
+}
+
+void tst_valuetypes::size()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("size_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toInt(), 1912);
+ QCOMPARE(object->property("s_height").toInt(), 1913);
+ QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("size_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->size(), QSize(13, 88));
+
+ delete object;
+ }
+}
+
+void tst_valuetypes::sizef()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("sizef_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toDouble(), 0.1);
+ QCOMPARE(object->property("s_height").toDouble(), 100923.2);
+ QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("sizef_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
+
+ delete object;
+ }
+}
+
+void tst_valuetypes::rect()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("rect_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("r_x").toInt(), 2);
+ QCOMPARE(object->property("r_y").toInt(), 3);
+ QCOMPARE(object->property("r_width").toInt(), 109);
+ QCOMPARE(object->property("r_height").toInt(), 102);
+ QCOMPARE(object->property("copy"), QVariant(QRect(2, 3, 109, 102)));
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("rect_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
+
+ delete object;
+ }
+}
+
+void tst_valuetypes::rectf()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("rectf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("r_x").toDouble(), 103.8);
+ QCOMPARE(object->property("r_y").toDouble(), 99.2);
+ QCOMPARE(object->property("r_width").toDouble(), 88.1);
+ QCOMPARE(object->property("r_height").toDouble(), 77.6);
+ QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6)));
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("rectf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2));
+
+ delete object;
+ }
+}
+
+void tst_valuetypes::vector3d()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("vector3d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)3.1);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)4.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector3D(23.88, 3.1, 4.3)));
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("vector3d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4));
+
+ delete object;
+ }
+}
+
+void tst_valuetypes::font()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("font_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("f_family").toString(), object->font().family());
+ QCOMPARE(object->property("f_bold").toBool(), object->font().bold());
+ QCOMPARE(object->property("f_weight").toInt(), object->font().weight());
+ QCOMPARE(object->property("f_italic").toBool(), object->font().italic());
+ QCOMPARE(object->property("f_underline").toBool(), object->font().underline());
+ QCOMPARE(object->property("f_overline").toBool(), object->font().overline());
+ QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut());
+ QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF());
+ QCOMPARE(object->property("f_pixelSize").toInt(), object->font().pixelSize());
+ QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization());
+ QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing());
+ QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing());
+
+ QCOMPARE(object->property("copy"), QVariant(object->font()));
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("font_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QFont font;
+ font.setFamily("Helvetica");
+ font.setBold(false);
+ font.setWeight(QFont::Normal);
+ font.setItalic(false);
+ font.setUnderline(false);
+ font.setStrikeOut(false);
+ font.setPointSize(15);
+ font.setCapitalization(QFont::AllLowercase);
+ font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7);
+ font.setWordSpacing(11.2);
+
+ QCOMPARE(object->font(), font);
+
+ delete object;
+ }
+
+ // Test pixelSize
+ {
+ QmlComponent component(&engine, TEST_FILE("font_write.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+ }
+
+ // Test pixelSize and pointSize
+ {
+ QmlComponent component(&engine, TEST_FILE("font_write.3.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+ }
+}
+
+QTEST_MAIN(tst_valuetypes)
+
+#include "tst_valuetypes.moc"
diff --git a/tests/auto/declarative/valuetypes/valuetypes.pro b/tests/auto/declarative/valuetypes/valuetypes.pro
new file mode 100644
index 0000000..ae7c731
--- /dev/null
+++ b/tests/auto/declarative/valuetypes/valuetypes.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+HEADERS += testtypes.h
+
+SOURCES += tst_valuetypes.cpp \
+ testtypes.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"