summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-11-30 15:06:38 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-11-30 15:06:38 (GMT)
commitbb1a6cd1e9d6d00e8d70f665ca223261e9eda06e (patch)
treeb65be7919d3eb5e0b6fd63c6127234a79bd9e262 /tests/auto/declarative
parente42d95d4e9d0dc547c604939f88de95180e74fa0 (diff)
parent840ffbd6187fe2573d8c00481120d4cf30aed351 (diff)
downloadQt-bb1a6cd1e9d6d00e8d70f665ca223261e9eda06e.zip
Qt-bb1a6cd1e9d6d00e8d70f665ca223261e9eda06e.tar.gz
Qt-bb1a6cd1e9d6d00e8d70f665ca223261e9eda06e.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: Ensure header is considered when positioning content with snapping. Fix integer overflow in QDeclarativeItemPrivate::origin enumeration Correct ownership semantics for QObject derived types Correctly handle CppOwnership even when a QDeclarativeData doesn't exist Fix Browser.qml warnings Document which header to include for qmlRegister functions. Don't draw null pixmap in QDeclarativeImage paint function Fix id documentation Link to List Properties docs from QML Intro page
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp83
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp30
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/header.qml31
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp31
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp12
6 files changed, 188 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 14755f32..77fab91 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -135,6 +135,8 @@ private slots:
void scriptConnect();
void scriptDisconnect();
void ownership();
+ void cppOwnershipReturnValue();
+ void ownershipCustomReturnValue();
void qlistqobjectMethods();
void strictlyEquals();
void compiled();
@@ -2100,6 +2102,87 @@ void tst_qdeclarativeecmascript::ownership()
}
}
+class CppOwnershipReturnValue : public QObject
+{
+ Q_OBJECT
+public:
+ CppOwnershipReturnValue() : value(0) {}
+ ~CppOwnershipReturnValue() { delete value; }
+
+ Q_INVOKABLE QObject *create() {
+ Q_ASSERT(value == 0);
+
+ value = new QObject;
+ QDeclarativeEngine::setObjectOwnership(value, QDeclarativeEngine::CppOwnership);
+ return value;
+ }
+
+ Q_INVOKABLE MyQmlObject *createQmlObject() {
+ Q_ASSERT(value == 0);
+
+ MyQmlObject *rv = new MyQmlObject;
+ value = rv;
+ return rv;
+ }
+
+ QPointer<QObject> value;
+};
+
+// QTBUG-15695.
+// Test setObjectOwnership(CppOwnership) works even when there is no QDeclarativeData
+void tst_qdeclarativeecmascript::cppOwnershipReturnValue()
+{
+ CppOwnershipReturnValue source;
+
+ {
+ QDeclarativeEngine engine;
+ engine.rootContext()->setContextProperty("source", &source);
+
+ QVERIFY(source.value == 0);
+
+ QDeclarativeComponent component(&engine);
+ component.setData("import QtQuick 1.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl());
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(source.value != 0);
+
+ delete object;
+ }
+
+ QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
+
+ QVERIFY(source.value != 0);
+}
+
+// QTBUG-15697
+void tst_qdeclarativeecmascript::ownershipCustomReturnValue()
+{
+ CppOwnershipReturnValue source;
+
+ {
+ QDeclarativeEngine engine;
+ engine.rootContext()->setContextProperty("source", &source);
+
+ QVERIFY(source.value == 0);
+
+ QDeclarativeComponent component(&engine);
+ component.setData("import QtQuick 1.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl());
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(source.value != 0);
+
+ delete object;
+ }
+
+ QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
+
+ QVERIFY(source.value == 0);
+}
+
class QListQObjectMethodsObject : public QObject
{
Q_OBJECT
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 327bba2..7998e30 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -1263,7 +1263,7 @@ void tst_QDeclarativeGridView::header()
QDeclarativeView *canvas = createView();
TestModel model;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < 30; i++)
model.addItem("Item" + QString::number(i), "");
QDeclarativeContext *ctxt = canvas->rootContext();
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index bf779ad..447210d 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -87,6 +87,7 @@ private slots:
void noLoading();
void paintedWidthHeight();
void sourceSize_QTBUG_14303();
+ void nullPixmapPaint();
private:
template<typename T>
@@ -540,6 +541,35 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_14303()
QTRY_COMPARE(sourceSizeSpy.count(), 2);
}
+static int numberOfWarnings = 0;
+static void checkWarnings(QtMsgType, const char *)
+{
+ numberOfWarnings++;
+}
+
+// QTBUG-15690
+void tst_qdeclarativeimage::nullPixmapPaint()
+{
+ QString componentStr = QString("import QtQuick 1.0\nImage { width: 10; height:10; fillMode: Image.PreserveAspectFit; source: \"")
+ + SERVER_ADDR + QString("/no-such-file.png\" }");
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *image = qobject_cast<QDeclarativeImage*>(component.create());
+
+ QTRY_VERIFY(image != 0);
+
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
+
+ QPixmap pm(100, 100);
+ QPainter p(&pm);
+
+ // used to print "QTransform::translate with NaN called"
+ image->paint(&p, 0, 0);
+ qInstallMsgHandler(previousMsgHandler);
+ QVERIFY(numberOfWarnings == 0);
+ delete image;
+}
+
/*
Find an item with the specified objectName. If index is supplied then the
item must also evaluate the {index} expression equal to index
diff --git a/tests/auto/declarative/qdeclarativelistview/data/header.qml b/tests/auto/declarative/qdeclarativelistview/data/header.qml
new file mode 100644
index 0000000..6da996e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/header.qml
@@ -0,0 +1,31 @@
+import QtQuick 1.0
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 30
+ width: 240
+ Text {
+ text: index
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ }
+ ListView {
+ id: list
+ objectName: "list"
+ focus: true
+ width: 240
+ height: 320
+ snapMode: ListView.SnapToItem
+ model: testModel
+ delegate: myDelegate
+ header: Text { objectName: "header"; text: "Header"; height: 10 }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 37d836d..295a75d 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -98,6 +98,7 @@ private slots:
void QTBUG_9791();
void manualHighlight();
void QTBUG_11105();
+ void header();
void footer();
void resizeView();
void sizeLessThan1();
@@ -1661,6 +1662,36 @@ void tst_QDeclarativeListView::QTBUG_11105()
delete canvas;
}
+void tst_QDeclarativeListView::header()
+{
+ 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);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QDeclarativeText *header = findItem<QDeclarativeText>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->y(), 0.0);
+
+ QCOMPARE(listview->contentY(), 0.0);
+
+ model.clear();
+ QTRY_COMPARE(header->y(), 0.0);
+}
+
void tst_QDeclarativeListView::footer()
{
QDeclarativeView *canvas = createView();
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
index 21c7197..f19eb03 100644
--- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -238,13 +238,25 @@ void tst_QDeclarativeViewer::loading()
delete viewer;
}
+static int numberOfWarnings = 0;
+static void checkWarnings(QtMsgType, const char *)
+{
+ numberOfWarnings++;
+}
+
void tst_QDeclarativeViewer::fileBrowser()
{
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
QDeclarativeViewer *viewer = new QDeclarativeViewer();
QVERIFY(viewer);
viewer->setUseNativeFileBrowser(false);
viewer->openFile();
viewer->show();
+ QCoreApplication::processEvents();
+ qInstallMsgHandler(previousMsgHandler);
+
+ // QTBUG-15720
+ QVERIFY(numberOfWarnings == 0);
QApplication::setActiveWindow(viewer);
QTest::qWaitForWindowShown(viewer);