summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-12-23 15:37:09 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-12-23 15:37:09 (GMT)
commite2ff3adad12ad10363a19d2c49d0ed3bdfe20d68 (patch)
tree1b688135c560b44b0398627f09b0fc5af26f6a8c /tests/auto/declarative
parentdb2cef1df7fe3e9068d95acd1227a4585373be59 (diff)
parenta315c693d0f3dd64711b8459d86b89ddc48e8c1a (diff)
downloadQt-e2ff3adad12ad10363a19d2c49d0ed3bdfe20d68.zip
Qt-e2ff3adad12ad10363a19d2c49d0ed3bdfe20d68.tar.gz
Qt-e2ff3adad12ad10363a19d2c49d0ed3bdfe20d68.tar.bz2
Merge branch 'qt-master-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration into master-integration
* 'qt-master-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration: (46 commits) Fix crash in indeterminate progressbars on windows Fix infinite loop in qmake when reading malformed .ts files. Fix timer regression for indeterminate progressbars Improve performance of bilinear upscaling of images with neon. Fix libinfixed usage in Symbian when def files are used Made documentation of QPixmap::createMaskFromColor match behaviour. Improve performance of bilinear downscaling of images with neon. Document the 'variant' basic type Add double type to QML Basic Types docs Remove redundant docs Doc: Added a missing license header. More testing for KeyNavigation attached properties. Add tests for ListView.indexAt() and GridView.IndexAt() runonphone: Only print the modprobe instructions on linux reword: Make the USB serial device enumeration work on OS X, too runonphone: Check that the device->config is valid before dereferencing it Remove few compile warnings Fix using QFileDialog statics in Symbian. doc: Replaced some \raw and \endraw uses with \table and \endtable doc: Replaced some \raw and \endraw uses with \table and \endtable ...
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp37
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keynavigationtest.qml40
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp5
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp33
4 files changed, 115 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index fd5d140..a2dcf1c 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -84,6 +84,7 @@ private slots:
void manualHighlight();
void footer();
void header();
+ void indexAt();
private:
QDeclarativeView *createView();
@@ -1299,6 +1300,42 @@ void tst_QDeclarativeGridView::header()
QTRY_COMPARE(header->y(), 0.0);
}
+void tst_QDeclarativeGridView::indexAt()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(gridview->count(), model.count());
+
+ QCOMPARE(gridview->indexAt(0, 0), 0);
+ QCOMPARE(gridview->indexAt(79, 59), 0);
+ QCOMPARE(gridview->indexAt(80, 0), 1);
+ QCOMPARE(gridview->indexAt(0, 60), 3);
+ QCOMPARE(gridview->indexAt(240, 0), -1);
+
+ delete canvas;
+}
QDeclarativeView *tst_QDeclarativeGridView::createView()
{
diff --git a/tests/auto/declarative/qdeclarativeitem/data/keynavigationtest.qml b/tests/auto/declarative/qdeclarativeitem/data/keynavigationtest.qml
index 229f969..f614a12 100644
--- a/tests/auto/declarative/qdeclarativeitem/data/keynavigationtest.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keynavigationtest.qml
@@ -3,6 +3,46 @@ import QtQuick 1.0
Grid {
columns: 2
width: 100; height: 100
+ function verify() {
+ if (item1.KeyNavigation.right != item2)
+ return false;
+ if (item1.KeyNavigation.down != item3)
+ return false;
+ if (item1.KeyNavigation.tab != item2)
+ return false;
+ if (item1.KeyNavigation.backtab != item4)
+ return false;
+
+ if (item2.KeyNavigation.left != item1)
+ return false;
+ if (item2.KeyNavigation.down != item4)
+ return false;
+ if (item2.KeyNavigation.tab != item3)
+ return false;
+ if (item2.KeyNavigation.backtab != item1)
+ return false;
+
+ if (item3.KeyNavigation.right != item4)
+ return false;
+ if (item3.KeyNavigation.up != item1)
+ return false;
+ if (item3.KeyNavigation.tab != item4)
+ return false;
+ if (item3.KeyNavigation.backtab != item2)
+ return false;
+
+ if (item4.KeyNavigation.left != item3)
+ return false;
+ if (item4.KeyNavigation.up != item2)
+ return false;
+ if (item4.KeyNavigation.tab != item1)
+ return false;
+ if (item4.KeyNavigation.backtab != item3)
+ return false;
+
+ return true;
+ }
+
Rectangle {
id: item1
objectName: "item1"
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index 711bf00..0ebb8b7 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -393,6 +393,11 @@ void tst_QDeclarativeItem::keyNavigation()
QVERIFY(item);
QVERIFY(item->hasActiveFocus());
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
+ Q_RETURN_ARG(QVariant, result)));
+ QVERIFY(result.toBool());
+
// right
QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
QApplication::sendEvent(canvas, &key);
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index b834d46..3df10a9 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -105,6 +105,7 @@ private slots:
void QTBUG_14821();
void resizeDelegate();
void QTBUG_16037();
+ void indexAt();
private:
template <class T> void items();
@@ -1964,6 +1965,38 @@ void tst_QDeclarativeListView::QTBUG_16037()
delete canvas;
}
+void tst_QDeclarativeListView::indexAt()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; 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);
+
+ QCOMPARE(listview->indexAt(0,0), 0);
+ QCOMPARE(listview->indexAt(0,19), 0);
+ QCOMPARE(listview->indexAt(239,19), 0);
+ QCOMPARE(listview->indexAt(0,20), 1);
+ QCOMPARE(listview->indexAt(240,20), -1);
+
+ delete canvas;
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();