summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-04-18 18:31:19 +0200
committerOlivier Goffart <olivier.goffart@nokia.com>2011-04-18 18:31:19 +0200
commitfda9cc1d8a0e49817d1c6192c52d18dffcecf327 (patch)
treeaa9a3209339af6882eb496ab827f5ac297452d66 /tests/auto/declarative
parent6814998ab4d9c6b0990b0bf01119ace69363ce3e (diff)
parentc8aafe9a63b13a4af3049c43fcd5e8cce27db829 (diff)
Merge remote-tracking branch 'origin/4.7' into qt-master-from-4.7
Conflicts: qmake/generators/makefile.cpp qmake/generators/win32/msbuild_objectmodel.cpp qmake/generators/win32/msvc_vcxproj.cpp src/corelib/global/qnamespace.h src/gui/text/qtextcontrol.cpp
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/attached.qml2
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml25
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp18
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml22
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h5
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp51
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/orientchange.qml7
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp103
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml1
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp21
11 files changed, 261 insertions, 4 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/attached.qml b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
index 5da4a69441..c5d5535bb7 100644
--- a/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
@@ -17,7 +17,7 @@ Rectangle {
transitions: Transition {
PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
- ScriptAction { script: console.log(ListView.delayRemove ? "on" : "off") }
+ ScriptAction { script: console.log(wrapper.ListView.delayRemove ? "on" : "off") }
}
Component.onCompleted: {
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml b/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml
new file mode 100644
index 0000000000..aa384c335f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml
@@ -0,0 +1,25 @@
+import QtQuick 1.0
+
+Rectangle {
+ id: container
+
+ width: 400; height: 400;
+ property Item myItem
+
+ function doCreate() {
+ myItem = myComponent.createObject(container)
+ myItem.x = 100
+ }
+
+ Component {
+ id: myComponent
+ Rectangle {
+ width: 100
+ height: 100
+ color: "green"
+ Behavior on x { NumberAnimation { duration: 500 } }
+ }
+ }
+
+ Component.onCompleted: doCreate()
+}
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index 80ba907d20..4536d9ef27 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -81,6 +81,7 @@ private slots:
void groupedPropertyCrash();
void runningTrue();
void sameValue();
+ void delayedRegistration();
};
void tst_qdeclarativebehaviors::simpleBehavior()
@@ -412,6 +413,23 @@ void tst_qdeclarativebehaviors::sameValue()
QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
}
+//QTBUG-18362
+void tst_qdeclarativebehaviors::delayedRegistration()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/delayedRegistration.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeItem *innerRect = rect->property("myItem").value<QDeclarativeItem*>();
+ QVERIFY(innerRect != 0);
+
+ QCOMPARE(innerRect->property("x").toInt(), int(0));
+
+ QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
+}
+
QTEST_MAIN(tst_qdeclarativebehaviors)
#include "tst_qdeclarativebehaviors.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml
new file mode 100644
index 0000000000..a7184c9200
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml
@@ -0,0 +1,22 @@
+import Qt.test 1.0
+import Qt.test 1.0 as Namespace
+
+MyQmlObject {
+ property alias a: me.a
+ property alias b: me.a
+ property alias c: me.a
+ property alias d: me.a
+
+ property MyQmlObject obj
+ obj: MyQmlObject {
+ MyQmlObject.value2: 13
+
+ id: me
+ property int a: MyQmlObject.value2 * 2
+ property int b: Namespace.MyQmlObject.value2 * 2
+ property int c: me.Namespace.MyQmlObject.value * 2
+ property int d: me.Namespace.MyQmlObject.value * 2
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index 94cec3fb18..ad38d279bb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -60,17 +60,18 @@ class MyQmlAttachedObject : public QObject
{
Q_OBJECT
Q_PROPERTY(int value READ value CONSTANT)
- Q_PROPERTY(int value2 READ value2 WRITE setValue2)
+ Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed)
public:
MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
int value() const { return 19; }
int value2() const { return m_value2; }
- void setValue2(int v) { m_value2 = v; }
+ void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); }
void emitMySignal() { emit mySignal(); }
signals:
+ void value2Changed();
void mySignal();
private:
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 78766712b8..1ec12fec01 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -650,6 +650,16 @@ void tst_qdeclarativeecmascript::attachedProperties()
}
{
+ QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 26);
+ QCOMPARE(object->property("b").toInt(), 26);
+ QCOMPARE(object->property("c").toInt(), 26);
+ QCOMPARE(object->property("d").toInt(), 26);
+ }
+
+ {
QDeclarativeComponent component(&engine, TEST_FILE("writeAttachedProperty.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index c18393429f..c8e7817adc 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -97,6 +97,7 @@ private slots:
void onRemove_data();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
+ void contentPosJump();
private:
QDeclarativeView *createView();
@@ -2077,6 +2078,56 @@ void tst_QDeclarativeGridView::testQtQuick11Attributes_data()
<< "";
}
+void tst_QDeclarativeGridView::contentPosJump()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 100; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ // Test jumping more than a page of items.
+ gridview->setContentY(500);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ gridview->setContentY(-100);
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ QVERIFY(itemCount < 15);
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ delete canvas;
+}
+
QDeclarativeView *tst_QDeclarativeGridView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);
diff --git a/tests/auto/declarative/qdeclarativelistview/data/orientchange.qml b/tests/auto/declarative/qdeclarativelistview/data/orientchange.qml
new file mode 100644
index 0000000000..c7aa0cd1d3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/orientchange.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+
+ListView {
+ width: 240; height: 320
+ delegate: Rectangle { objectName: "wrapper"; width: 80; height: 80 }
+ model: 100
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 2267a894b2..0c96587b30 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -119,6 +119,8 @@ private slots:
void testQtQuick11Attributes_data();
void rightToLeft();
void test_mirroring();
+ void orientationChange();
+ void contentPosJump();
private:
template <class T> void items();
@@ -2583,6 +2585,107 @@ void tst_QDeclarativeListView::test_mirroring()
delete canvasB;
}
+void tst_QDeclarativeListView::orientationChange()
+{
+ QDeclarativeView *canvas = createView();
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/orientchange.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(canvas->rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ listview->positionViewAtIndex(50, QDeclarativeListView::Beginning);
+
+ // Confirm items positioned correctly
+ for (int i = 50; i < 54; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*80.0);
+ }
+
+ listview->setOrientation(QDeclarativeListView::Horizontal);
+ QCOMPARE(listview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 3; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QCOMPARE(item->x(), i*80.0);
+ }
+
+ listview->positionViewAtIndex(50, QDeclarativeListView::Beginning);
+ listview->setOrientation(QDeclarativeListView::Vertical);
+ QCOMPARE(listview->contentX(), 0.);
+ //
+ // Confirm items positioned correctly
+ for (int i = 0; i < 4; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*80.0);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::contentPosJump()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 50; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ // Test jumping more than a page of items.
+ listview->setContentY(500);
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 25; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ listview->setContentY(-100);
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ QVERIFY(itemCount < 20);
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ delete canvas;
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml b/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
index c7c21fc8b2..f7fb3e7ced 100644
--- a/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
@@ -2,6 +2,7 @@ import QtQuick 1.0
Rectangle { width: 300; height: 300; color: "white"
TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject"
+ anchors.fill: parent
resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance" } } ]
cursorDelegate: cursor
}
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 8f1be6f8bc..574d2d5e71 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -1539,6 +1539,19 @@ void tst_qdeclarativetextedit::cursorDelegate()
textEditObject->setCursorPosition(0);
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QVERIFY(textEditObject->cursorRectangle().y() >= 0);
+ QVERIFY(textEditObject->cursorRectangle().y() < textEditObject->cursorRectangle().height());
+ textEditObject->setVAlign(QDeclarativeTextEdit::AlignVCenter);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QVERIFY(textEditObject->cursorRectangle().y() > (textEditObject->height() / 2) - textEditObject->cursorRectangle().height());
+ QVERIFY(textEditObject->cursorRectangle().y() < (textEditObject->height() / 2) + textEditObject->cursorRectangle().height());
+ textEditObject->setVAlign(QDeclarativeTextEdit::AlignBottom);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QVERIFY(textEditObject->cursorRectangle().y() > textEditObject->height() - (textEditObject->cursorRectangle().height() * 2));
+ QVERIFY(textEditObject->cursorRectangle().y() < textEditObject->height());
+
//Test Delegate gets deleted
textEditObject->setCursorDelegate(0);
QVERIFY(!textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
@@ -2227,6 +2240,8 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+ QSignalSpy cursorRectangleSpy(&edit, SIGNAL(cursorRectangleChanged()));
+
QRect currentRect;
QRect previousRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
@@ -2237,8 +2252,9 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
QCOMPARE(currentRect, previousRect);
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
- QCOMPARE(ic.updateReceived, true);
+ QCOMPARE(ic.updateReceived, false); // The cursor position hasn't changed.
#endif
+ QCOMPARE(cursorRectangleSpy.count(), 0);
// Verify that the micro focus rect moves to the left as the cursor position
// is incremented.
@@ -2250,6 +2266,8 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
QCOMPARE(ic.updateReceived, true);
#endif
+ QVERIFY(cursorRectangleSpy.count() > 0);
+ cursorRectangleSpy.clear();
previousRect = currentRect;
}
@@ -2263,6 +2281,7 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
QCOMPARE(ic.updateReceived, true);
#endif
+ QVERIFY(cursorRectangleSpy.count() > 0);
}
void tst_qdeclarativetextedit::inputContextMouseHandler()