summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-06-17 05:00:54 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-06-17 05:00:54 (GMT)
commitefc8b0c9c97a84097bc7f62a109e455caa8b2279 (patch)
treec2db4a844ba39a96125d4eba2f56b1c51a46badb /tests
parentdc5543f5595870209e8122d13d070694b5e0eb39 (diff)
parenta6b0458c5ab5bc8ad6c868425820e0bf0e932336 (diff)
downloadQt-efc8b0c9c97a84097bc7f62a109e455caa8b2279.zip
Qt-efc8b0c9c97a84097bc7f62a109e455caa8b2279.tar.gz
Qt-efc8b0c9c97a84097bc7f62a109e455caa8b2279.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: doc: add note that items with width or height of 0 are not positioned. Add test for model data changes. clearFocus() shouldn't mess with focus if it doesn't have focus Fix the N900 device orientation backend Micro cleanup Write TextInput.positionToRectangle docs. Minor demo fixes Fix autoScroll implementation Move knowledge of QGraphicsObject out of qml engine Stopping a flick resulted in the next click being consumed. Enhance docs Slight addition to the docs.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml5
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp44
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp1
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml9
4 files changed, 52 insertions, 7 deletions
diff --git a/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml
index c8b863c..7f2f85a 100644
--- a/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml
@@ -9,12 +9,13 @@ Rectangle {
Item {
objectName: "myDelegate"
height: 20
+ width: 240
Text {
- y: index*20
+ objectName: "myName"
text: name
}
Text {
- y: index*20
+ objectName: "myNumber"
x: 100
text: number
}
diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
index 3cc68f4..7299a43 100644
--- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
+++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
@@ -45,6 +45,7 @@
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativeexpression.h>
#include <private/qdeclarativerepeater_p.h>
#include <private/qdeclarativetext_p.h>
@@ -75,6 +76,8 @@ private slots:
private:
QDeclarativeView *createView();
template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &objectName, int index);
+ template<typename T>
T *findItem(QGraphicsObject *parent, const QString &id);
};
@@ -312,6 +315,20 @@ void tst_QDeclarativeRepeater::dataModel()
testModel.removeItem(2);
QCOMPARE(container->childItems().count(), 4);
+ // Check that model changes are propagated
+ QDeclarativeText *text = findItem<QDeclarativeText>(canvas->rootObject(), "myName", 1);
+ QVERIFY(text);
+ QCOMPARE(text->text(), QString("two"));
+
+ testModel.modifyItem(1, "Item two", "_2");
+ text = findItem<QDeclarativeText>(canvas->rootObject(), "myName", 1);
+ QVERIFY(text);
+ QCOMPARE(text->text(), QString("Item two"));
+
+ text = findItem<QDeclarativeText>(canvas->rootObject(), "myNumber", 1);
+ QVERIFY(text);
+ QCOMPARE(text->text(), QString("_2"));
+
delete testObject;
delete canvas;
}
@@ -387,6 +404,33 @@ QDeclarativeView *tst_QDeclarativeRepeater::createView()
}
template<typename T>
+T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QDeclarativeExpression e(qmlContext(item), item, "index");
+ if (e.evaluate().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, objectName, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+template<typename T>
T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName)
{
const QMetaObject &mo = T::staticMetaObject;
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 3143580..a55b42e 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -396,7 +396,6 @@ void tst_qdeclarativetextinput::positionAt()
#endif
// Check without autoscroll...
- QEXPECT_FAIL("", "QTBUG-11127", Abort);
textinputObject->setAutoScroll(false);
pos = textinputObject->positionAt(textinputObject->width()/2);
diff = abs(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2);
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml b/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml
index 69f57c6..e863262 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml
@@ -30,13 +30,14 @@ Item {
y: 5
//Below function implements all scrolling logic
onCursorPositionChanged: {
- if(cursorRect.x < leftMargin - textInp.x){//Cursor went off the front
- textInp.x = leftMargin - Math.max(0, cursorRect.x);
- }else if(cursorRect.x > parent.width - leftMargin - rightMargin - textInp.x){//Cusor went off the end
- textInp.x = leftMargin - Math.max(0, cursorRect.x - (parent.width - leftMargin - rightMargin));
+ if(cursorRectangle.x < leftMargin - textInp.x){//Cursor went off the front
+ textInp.x = leftMargin - Math.max(0, cursorRectangle.x);
+ }else if(cursorRectangle.x > parent.width - leftMargin - rightMargin - textInp.x){//Cusor went off the end
+ textInp.x = leftMargin - Math.max(0, cursorRectangle.x - (parent.width - leftMargin - rightMargin));
}
}
+ autoScroll: false //It is preferable to implement your own scrolling
text:""
horizontalAlignment: TextInput.AlignLeft
font.pixelSize:15