aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-05 09:02:17 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-05 09:02:17 +0200
commit45f79dc7e572c1a1e4c40633d5055d0c6741cfbe (patch)
tree61147ab31b0be97647417649934461b07ffa6983 /tests
parent6839f03051d2950e4721cbb5ee88fa7b07109588 (diff)
parentffe113ab628adf6c22e96a22cf0bcda8e80c290d (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h Change-Id: I1e6a9424e7f87d9e4ac1ea387ec70e151106f1c7
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp7
-rw-r--r--tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp4
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp32
-rw-r--r--tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp2
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp46
5 files changed, 60 insertions, 31 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index aeb8b08cd4..2c9f08c82a 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -7420,8 +7420,11 @@ void tst_qqmlecmascript::negativeYear()
QVariant q;
QMetaObject::invokeMethod(object, "check_negative_tostring", Q_RETURN_ARG(QVariant, q));
- // Strip the timezone. It should be irrelevant as the date was created with the same one.
- QCOMPARE(q.toString().left(32), QStringLiteral("result: Sat Jan 1 00:00:00 -2001"));
+
+ // Only check for the year. We hope that every language writes the year in arabic numerals and
+ // in relation to a specific dude's date of birth. We also hope that no language adds a "-2001"
+ // junk string somewhere in the middle.
+ QVERIFY(q.toString().indexOf(QStringLiteral("-2001")) != -1);
QMetaObject::invokeMethod(object, "check_negative_toisostring", Q_RETURN_ARG(QVariant, q));
QCOMPARE(q.toString().left(16), QStringLiteral("result: -002000-"));
diff --git a/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp b/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp
index ea988bb50d..d4922599be 100644
--- a/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp
+++ b/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp
@@ -180,7 +180,7 @@ void tst_QQuickFramebufferObject::testThatStuffWorks()
qmlRegisterType<FBOItem>("FBOItem", 1, 0, "FBOItem");
QQuickView view;
- view.setSource(QUrl::fromLocalFile("data/testStuff.qml"));
+ view.setSource(testFileUrl("testStuff.qml"));
FBOItem *item = view.rootObject()->findChild<FBOItem *>("fbo");
@@ -224,7 +224,7 @@ void tst_QQuickFramebufferObject::testInvalidate()
qmlRegisterType<FBOItem>("FBOItem", 1, 0, "FBOItem");
QQuickView view;
- view.setSource(QUrl::fromLocalFile("data/testStuff.qml"));
+ view.setSource(testFileUrl("testStuff.qml"));
FBOItem *item = view.rootObject()->findChild<FBOItem *>("fbo");
item->setTextureFollowsItemSize(false);
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index bf9df7850d..b0d903908f 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -250,6 +250,7 @@ private slots:
void QTBUG_50105();
void keyNavigationEnabled();
void QTBUG_50097_stickyHeader_positionViewAtIndex();
+ void itemFiltered();
private:
template <class T> void items(const QUrl &source);
@@ -8343,6 +8344,37 @@ void tst_QQuickListView::QTBUG_50097_stickyHeader_positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), -100.0); // back to the same position: header visible, items not under the header.
}
+void tst_QQuickListView::itemFiltered()
+{
+ QStringListModel model(QStringList() << "one" << "two" << "three" << "four" << "five" << "six");
+ QSortFilterProxyModel proxy1;
+ proxy1.setSourceModel(&model);
+ proxy1.setSortRole(Qt::DisplayRole);
+ proxy1.setDynamicSortFilter(true);
+ proxy1.sort(0);
+
+ QSortFilterProxyModel proxy2;
+ proxy2.setSourceModel(&proxy1);
+ proxy2.setFilterRole(Qt::DisplayRole);
+ proxy2.setFilterRegExp("^[^ ]*$");
+ proxy2.setDynamicSortFilter(true);
+
+ QScopedPointer<QQuickView> window(createView());
+ window->engine()->rootContext()->setContextProperty("_model", &proxy2);
+ QQmlComponent component(window->engine());
+ component.setData("import QtQuick 2.4; ListView { "
+ "anchors.fill: parent; model: _model; delegate: Text { width: parent.width;"
+ "text: model.display; } }",
+ QUrl());
+ window->setContent(QUrl(), &component, component.create());
+
+ window->show();
+ QTest::qWaitForWindowExposed(window.data());
+
+ // this should not crash
+ model.setData(model.index(2), QStringLiteral("modified three"), Qt::DisplayRole);
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"
diff --git a/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp b/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp
index 355301878d..3bf61e8f17 100644
--- a/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp
+++ b/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp
@@ -48,7 +48,7 @@ private slots:
void tst_QQuickOpenGLInfo::testProperties()
{
QQuickView view;
- view.setSource(QUrl::fromLocalFile("data/basic.qml"));
+ view.setSource(testFileUrl("basic.qml"));
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index 1cca56a876..1e46727526 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -39,6 +39,7 @@
#include <private/qsgcontext_p.h>
#include <private/qsgrenderloop_p.h>
+#include "../../shared/util.h"
class PerPixelRect : public QQuickItem
{
@@ -84,7 +85,7 @@ private:
QColor m_color;
};
-class tst_SceneGraph : public QObject
+class tst_SceneGraph : public QQmlDataTest
{
Q_OBJECT
@@ -104,6 +105,7 @@ private slots:
private:
bool m_brokenMipmapSupport;
+ QQuickView *createView(const QString &file, QWindow *parent = 0, int x = -1, int y = -1, int w = -1, int h = -1);
};
template <typename T> class ScopedList : public QList<T> {
@@ -115,6 +117,8 @@ void tst_SceneGraph::initTestCase()
{
qmlRegisterType<PerPixelRect>("SceneGraphTest", 1, 0, "PerPixelRect");
+ QQmlDataTest::initTestCase();
+
QSGRenderLoop *loop = QSGRenderLoop::instance();
qDebug() << "RenderLoop: " << loop;
@@ -152,26 +156,16 @@ void tst_SceneGraph::initTestCase()
context.doneCurrent();
}
-QQuickView *createView(const QString &file, QWindow *parent = 0, int x = -1, int y = -1, int w = -1, int h = -1)
+QQuickView *tst_SceneGraph::createView(const QString &file, QWindow *parent, int x, int y, int w, int h)
{
QQuickView *view = new QQuickView(parent);
- view->setSource(QUrl::fromLocalFile("data/" + file));
+ view->setSource(testFileUrl(file));
if (x >= 0 && y >= 0) view->setPosition(x, y);
if (w >= 0 && h >= 0) view->resize(w, h);
view->show();
return view;
}
-QImage showAndGrab(const QString &file, int w, int h)
-{
- QQuickView view;
- view.setSource(QUrl::fromLocalFile(QStringLiteral("data/") + file));
- if (w >= 0 && h >= 0)
- view.resize(w, h);
- view.create();
- return view.grabWindow();
-}
-
// Assumes the images are opaque white...
bool containsSomethingOtherThanWhite(const QImage &image)
{
@@ -405,17 +399,17 @@ void tst_SceneGraph::render_data()
QTest::addColumn<QList<Sample> >("finalStage");
QList<QString> files;
- files << "data/render_DrawSets.qml"
- << "data/render_Overlap.qml"
- << "data/render_MovingOverlap.qml"
- << "data/render_BreakOpacityBatch.qml"
- << "data/render_OutOfFloatRange.qml"
- << "data/render_StackingOrder.qml"
- << "data/render_ImageFiltering.qml"
- << "data/render_bug37422.qml"
- << "data/render_OpacityThroughBatchRoot.qml";
+ files << "render_DrawSets.qml"
+ << "render_Overlap.qml"
+ << "render_MovingOverlap.qml"
+ << "render_BreakOpacityBatch.qml"
+ << "render_OutOfFloatRange.qml"
+ << "render_StackingOrder.qml"
+ << "render_ImageFiltering.qml"
+ << "render_bug37422.qml"
+ << "render_OpacityThroughBatchRoot.qml";
if (!m_brokenMipmapSupport)
- files << "data/render_Mipmap.qml";
+ files << "render_Mipmap.qml";
QRegExp sampleCount("#samples: *(\\d+)");
// X:int Y:int R:float G:float B:float Error:float
@@ -423,7 +417,7 @@ void tst_SceneGraph::render_data()
QRegExp finalSamples("#final: *(\\d+) *(\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+) *(\\d\\.\\d+)");
foreach (QString fileName, files) {
- QFile file(fileName);
+ QFile file(testFile(fileName));
if (!file.open(QFile::ReadOnly)) {
qFatal("render_data: QFile::open failed! file=%s, error=%s",
qPrintable(fileName), qPrintable(file.errorString()));
@@ -466,7 +460,7 @@ void tst_SceneGraph::render()
QQuickView view;
view.rootContext()->setContextProperty("suite", &suite);
- view.setSource(QUrl::fromLocalFile(file));
+ view.setSource(testFileUrl(file));
view.setResizeMode(QQuickView::SizeViewToRootObject);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -514,7 +508,7 @@ void tst_SceneGraph::hideWithOtherContext()
{
QQuickView view;
- view.setSource(QUrl::fromLocalFile("data/simple.qml"));
+ view.setSource(testFileUrl("simple.qml"));
view.setResizeMode(QQuickView::SizeViewToRootObject);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));