diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-05 03:25:56 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-05 03:25:56 (GMT) |
commit | 81f45fc6f1f84499a43f9cf1d838d611a07308e3 (patch) | |
tree | 1f5540398860750cc1c00b05e3a5c051fdc9cbed | |
parent | e68a0dafbff345eebb15cf6f1a5d88df37f0269a (diff) | |
download | Qt-81f45fc6f1f84499a43f9cf1d838d611a07308e3.zip Qt-81f45fc6f1f84499a43f9cf1d838d611a07308e3.tar.gz Qt-81f45fc6f1f84499a43f9cf1d838d611a07308e3.tar.bz2 |
Partial valuetypes test
23 files changed, 671 insertions, 0 deletions
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/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/tests/auto/declarative/valuetypes/testtypes.cpp b/tests/auto/declarative/valuetypes/testtypes.cpp new file mode 100644 index 0000000..d57afaf --- /dev/null +++ b/tests/auto/declarative/valuetypes/testtypes.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** 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 "testtypes.h" + +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\\\" |