summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2011-03-16 17:25:47 +0100
committerThiago Macieira <thiago.macieira@nokia.com>2011-03-16 17:25:47 +0100
commit580e3d9968e12fb38348af503ef9ede50691c24c (patch)
tree2ae55db9989bd8147de9d25071cecbd279b847d7 /tests
parente318b0276c3d4a0db8660b4fa6d68f1784aee522 (diff)
parentb8ded0df9c85558b93ee5ec5abd5774c87c4deed (diff)
Merge remote-tracking branch 'origin/4.7' into HEAD
Conflicts: configure mkspecs/symbian-gcce/qmake.conf qmake/generators/metamakefile.cpp qmake/generators/win32/mingw_make.cpp src/corelib/global/global.pri src/corelib/global/qglobal.h src/opengl/qgl.cpp src/opengl/qwindowsurface_gl.cpp src/plugins/platforms/wayland/qwaylandbuffer.h tests/auto/qnetworkreply/tst_qnetworkreply.cpp tools/designer/src/components/formeditor/qdesigner_resource.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp39
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp39
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml7
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp12
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp7
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp14
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp24
-rw-r--r--tests/auto/qpainterpath/tst_qpainterpath.cpp5
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp17
12 files changed, 173 insertions, 10 deletions
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml b/tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml
new file mode 100644
index 0000000000..dcbb20bdd5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.0
+
+Flickable {
+ width: 100; height: 100
+ contentWidth: 200; contentHeight: 300
+
+ QGraphicsWidget { width: 200; height: 300; enabled: false }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index 65ba31681c..d499edf08c 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -69,6 +69,7 @@ private slots:
void maximumFlickVelocity();
void flickDeceleration();
void pressDelay();
+ void disabledContent();
void nestedPressDelay();
void flickableDirection();
void qgraphicswidget();
@@ -247,6 +248,44 @@ void tst_qdeclarativeflickable::pressDelay()
QCOMPARE(spy.count(),1);
}
+// QT-4677
+void tst_qdeclarativeflickable::disabledContent()
+{
+ QDeclarativeView *canvas = new QDeclarativeView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabledcontent.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ QVERIFY(flickable->contentX() == 0);
+ QVERIFY(flickable->contentY() == 0);
+
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50)));
+ {
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(70,70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(90,90)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(100,100)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ }
+
+ QVERIFY(flickable->contentX() < 0);
+ QVERIFY(flickable->contentY() < 0);
+
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(90, 90)));
+
+ delete canvas;
+}
+
+
// QTBUG-17361
void tst_qdeclarativeflickable::nestedPressDelay()
{
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 5ced02b73c..c18393429f 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -69,6 +69,7 @@ private slots:
void changed();
void inserted();
void removed();
+ void clear();
void moved();
void changeFlow();
void currentIndex();
@@ -501,6 +502,44 @@ void tst_QDeclarativeGridView::removed()
delete canvas;
}
+void tst_QDeclarativeGridView::clear()
+{
+ 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);
+ 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);
+
+ model.clear();
+
+ QVERIFY(gridview->count() == 0);
+ QVERIFY(gridview->currentItem() == 0);
+ QVERIFY(gridview->contentY() == 0);
+ QVERIFY(gridview->currentIndex() == -1);
+
+ // confirm sanity when adding an item to cleared list
+ model.addItem("New", "1");
+ QVERIFY(gridview->count() == 1);
+ QVERIFY(gridview->currentItem() != 0);
+ QVERIFY(gridview->currentIndex() == 0);
+
+ delete canvas;
+}
+
void tst_QDeclarativeGridView::moved()
{
QDeclarativeView *canvas = createView();
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml
new file mode 100644
index 0000000000..4526cf043e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+
+QtObject {
+ property InlineAssignmentsOverrideBindingsType2 nested: InlineAssignmentsOverrideBindingsType2 {
+ value: 19 * 33
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml
new file mode 100644
index 0000000000..4127ca4375
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml
@@ -0,0 +1,5 @@
+import QtQuick 1.0
+
+QtObject {
+ property int value
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml b/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml
new file mode 100644
index 0000000000..8f3c5cef79
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml
@@ -0,0 +1,6 @@
+import QtQuick 1.0
+
+InlineAssignmentsOverrideBindingsType {
+ property int test: nested.value
+ nested.value: 11
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index f3f41a999c..5a2591f042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -134,6 +134,7 @@ private slots:
void dontDoubleCallClassBegin();
void reservedWords_data();
void reservedWords();
+ void inlineAssignmentsOverrideBindings();
void basicRemote_data();
void basicRemote();
@@ -1413,9 +1414,18 @@ void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type,
}
}
+// QTBUG-17276
+void tst_qdeclarativelanguage::inlineAssignmentsOverrideBindings()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("inlineAssignmentsOverrideBindings.qml"));
-// Import tests (QT-558)
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toInt(), 11);
+ delete o;
+}
+// Import tests (QT-558)
void tst_qdeclarativelanguage::importsBuiltin_data()
{
// QT-610
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index c87318ea94..2267a894b2 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -741,6 +741,13 @@ void tst_QDeclarativeListView::clear()
QTRY_VERIFY(listview->count() == 0);
QTRY_VERIFY(listview->currentItem() == 0);
QTRY_VERIFY(listview->contentY() == 0);
+ QVERIFY(listview->currentIndex() == -1);
+
+ // confirm sanity when adding an item to cleared list
+ model.addItem("New", "1");
+ QTRY_VERIFY(listview->count() == 1);
+ QVERIFY(listview->currentItem() != 0);
+ QVERIFY(listview->currentIndex() == 0);
delete canvas;
}
diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
index 79f22138fc..9434a0b6a4 100644
--- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -163,10 +163,11 @@ static inline bool fuzzyCompare(qreal p1, qreal p2)
{
// increase delta on small machines using float instead of double
if (sizeof(qreal) == sizeof(float))
- return (qAbs(p1 - p2) <= 0.00002f * qMin(qAbs(p1), qAbs(p2)));
+ return (qAbs(p1 - p2) <= 0.00003f * qMin(qAbs(p1), qAbs(p2)));
else
return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
}
+
static bool fuzzyCompare(const QTransform& t1, const QTransform& t2)
{
return fuzzyCompare(t1.m11(), t2.m11()) &&
@@ -180,6 +181,15 @@ static bool fuzzyCompare(const QTransform& t1, const QTransform& t2)
fuzzyCompare(t1.m33(), t2.m33());
}
+static inline bool fuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2)
+{
+ bool ok = true;
+ for (int y = 0; y < 4; ++y)
+ for (int x = 0; x < 4; ++x)
+ ok &= fuzzyCompare(m1(y, x), m2(y, x));
+ return ok;
+}
+
void tst_QGraphicsTransform::rotation()
{
QGraphicsRotation rotation;
@@ -267,7 +277,7 @@ void tst_QGraphicsTransform::rotation3d()
// because the deg2rad value in QTransform is not accurate
// enough to match what QMatrix4x4 is doing.
} else {
- QVERIFY(qFuzzyCompare(t, r));
+ QVERIFY(fuzzyCompare(t, r));
}
//now let's check that a null vector will not change the transform
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index a7e6f9f225..49ae7685e7 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -969,6 +969,7 @@ tst_QNetworkReply::tst_QNetworkReply()
#ifndef QT_NO_OPENSSL
qRegisterMetaType<QList<QSslError> >();
#endif
+ qRegisterMetaType<QNetworkReply::NetworkError>();
Q_SET_DEFAULT_IAP
@@ -2605,6 +2606,9 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer_data()
QTest::newRow("justHalfStatus+disconnect") << QByteArray("HTTP/1.1") << true;
QTest::newRow("justStatus+disconnect") << QByteArray("HTTP/1.1 200 OK\r\n") << true;
QTest::newRow("justStatusAndHalfHeaders+disconnect") << QByteArray("HTTP/1.1 200 OK\r\nContent-L") << true;
+
+ QTest::newRow("halfContent+disconnect") << QByteArray("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\nAB") << true;
+
}
void tst_QNetworkReply::ioGetFromHttpBrokenServer()
@@ -2616,29 +2620,35 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply = manager.get(request);
+ QSignalSpy spy(reply, SIGNAL(error(QNetworkReply::NetworkError)));
+
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(reply->url(), request.url());
+ QCOMPARE(spy.count(), 1);
QVERIFY(reply->error() != QNetworkReply::NoError);
}
void tst_QNetworkReply::ioGetFromHttpStatus100_data()
{
QTest::addColumn<QByteArray>("dataToSend");
- QTest::newRow("normal") << QByteArray("HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
- QTest::newRow("minimal") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
- QTest::newRow("minimal2") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\r\n\r\n");
- QTest::newRow("minimal3") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\n\n");
- QTest::newRow("with_headers") << QByteArray("HTTP/1.1 100 Continue\r\nBla: x\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
- QTest::newRow("with_headers2") << QByteArray("HTTP/1.1 100 Continue\nBla: x\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ QTest::addColumn<int>("statusCode");
+ QTest::newRow("normal") << QByteArray("HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << 200;
+ QTest::newRow("minimal") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << 200;
+ QTest::newRow("minimal2") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\r\n\r\n") << 200;
+ QTest::newRow("minimal3") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\n\n") << 200;
+ QTest::newRow("minimal+404") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 204 No Content\r\n\r\n") << 204;
+ QTest::newRow("with_headers") << QByteArray("HTTP/1.1 100 Continue\r\nBla: x\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << 200;
+ QTest::newRow("with_headers2") << QByteArray("HTTP/1.1 100 Continue\nBla: x\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << 200;
}
void tst_QNetworkReply::ioGetFromHttpStatus100()
{
QFETCH(QByteArray, dataToSend);
+ QFETCH(int, statusCode);
MiniHttpServer server(dataToSend);
server.doClose = true;
@@ -2651,7 +2661,7 @@ void tst_QNetworkReply::ioGetFromHttpStatus100()
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), QNetworkReply::NoError);
- QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode);
QVERIFY(reply->rawHeader("bla").isNull());
}
diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp
index 8382edc1fc..86adabb4b4 100644
--- a/tests/auto/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp
@@ -305,6 +305,11 @@ void tst_QPainterPath::contains_QPointF_data()
QTest::newRow("horizontal cubic, out left") << path << QPointF(0, 100) << false;
QTest::newRow("horizontal cubic, out right") << path << QPointF(300, 100) <<false;
QTest::newRow("horizontal cubic, in mid") << path << QPointF(150, 100) << true;
+
+ path = QPainterPath();
+ path.addEllipse(QRectF(-5000.0, -5000.0, 1500000.0, 1500000.0));
+ QTest::newRow("huge ellipse, qreal=float crash") << path << QPointF(1100000.35, 1098000.2) << true;
+
}
void tst_QPainterPath::contains_QPointF()
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index 0a14e4a8ff..83c7094ae3 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -126,6 +126,7 @@ private slots:
void textWidthVsWIdth();
void textWithSurrogates_qtbug15679();
void textWidthWithStackedTextEngine();
+ void textWidthWithLineSeparator();
private:
QFont testFont;
@@ -1443,5 +1444,21 @@ void tst_QTextLayout::textWidthWithStackedTextEngine()
QCOMPARE(line.naturalTextWidth(), fm.width(text));
}
+void tst_QTextLayout::textWidthWithLineSeparator()
+{
+ QString s1("Save Project"), s2("Save Project\ntest");
+ s2.replace('\n', QChar::LineSeparator);
+
+ QTextLayout layout1(s1), layout2(s2);
+ layout1.beginLayout();
+ layout2.beginLayout();
+
+ QTextLine line1 = layout1.createLine();
+ QTextLine line2 = layout2.createLine();
+ line1.setLineWidth(0x1000);
+ line2.setLineWidth(0x1000);
+ QCOMPARE(line1.naturalTextWidth(), line2.naturalTextWidth());
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"