diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-02-24 17:36:04 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-02-24 17:36:04 +0100 |
commit | ad67ec26d0cbc98e3440dd38bb20eef4da2ee96d (patch) | |
tree | 9f8135751df2f995a4f55837ea065a4687245b71 /tests/auto/quick | |
parent | 83a16630c13969e68cd3a5aaab73335ccb0d4414 (diff) | |
parent | 20d160d0513a04be187ed851a25b029f47c27b27 (diff) |
Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts:
.qmake.conf
LICENSE.GPLv2
examples/qml/networkaccessmanagerfactory/view.qml
src/qml/jsruntime/qv4runtime.cpp
src/qml/jsruntime/qv4stringobject.cpp
Change-Id: I5d12f436d60995e51d5c2f59d364e9cbc24f8e32
Diffstat (limited to 'tests/auto/quick')
7 files changed, 139 insertions, 11 deletions
diff --git a/tests/auto/quick/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp index 50114201a5..b49ce34951 100644 --- a/tests/auto/quick/nodes/tst_nodestest.cpp +++ b/tests/auto/quick/nodes/tst_nodestest.cpp @@ -90,19 +90,24 @@ void NodesTest::initTestCase() surface = new QOffscreenSurface; surface->create(); + QVERIFY(surface->isValid()); context = new QOpenGLContext(); - context->create(); - context->makeCurrent(surface); + QVERIFY(context->create()); + QVERIFY(context->makeCurrent(surface)); renderContext = renderLoop->createRenderContext(renderLoop->sceneGraphContext()); + QVERIFY(renderContext); renderContext->initialize(context); + QVERIFY(renderContext->isValid()); } void NodesTest::cleanupTestCase() { - renderContext->invalidate(); - context->doneCurrent(); + if (renderContext) + renderContext->invalidate(); + if (context) + context->doneCurrent(); delete context; delete surface; } @@ -141,10 +146,12 @@ public: int DummyRenderer::globalRendereringOrder; NodesTest::NodesTest() + : surface(Q_NULLPTR) + , context(Q_NULLPTR) + , renderContext(Q_NULLPTR) { } - void NodesTest::propegate() { QSGRootNode root; diff --git a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml index b0cae69fe3..e49f0ac462 100644 --- a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml +++ b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml @@ -25,6 +25,11 @@ TestCase { return []; } + function renderStrategyToString(renderStrategy) { + return renderStrategy === Canvas.Immediate ? "Canvas.Immediate" : + (renderStrategy === Canvas.Threaded ? "Canvas.Threaded" : "Canvas.Cooperative"); + } + function createCanvasObject(data) { return component.createObject(testCase, data.properties); } diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml index 31413c23cd..5960e53557 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml @@ -1,5 +1,10 @@ import QtQuick 2.0 +Item { + id: container + width: 200 + height: 200 + CanvasTestCase { id:testCase name: "canvas" @@ -595,5 +600,82 @@ CanvasTestCase { canvas.destroy(); } -} + function test_getContextOnDestruction_data() { + // We want to test all possible combinations deemed valid by the testcase, + // but we can't test FramebufferObject due to difficulties ignoring the "available" warning. + var allData = testData("2d"); + var ourData = []; + + for (var i = 0; i < allData.length; ++i) { + if (allData[i].properties.renderTarget !== Canvas.FramebufferObject) { + var row = allData[i].properties; + row.tag = allData[i].tag; + ourData.push(row); + } + } + + return ourData; + } + + function test_getContextOnDestruction(data) { + try { + var canvasWindow = Qt.createQmlObject(" + import QtQuick 2.4\n + import QtQuick.Window 2.2\n + Window {\n + function test() {\n + loader.active = true\n + loader.active = false\n + }\n + Loader {\n + id: loader\n + active: false\n + sourceComponent: Canvas {\n + renderStrategy: " + renderStrategyToString(data.renderStrategy) + "\n + Component.onDestruction: getContext(\"2d\") + }\n + }\n + }\n", + testCase); + verify(canvasWindow); + canvasWindow.test(); + // Shouldn't crash when destruction is done. + wait(0); + } catch (exception) { + fail(exception.message); + } + } + + property Component implicitlySizedComponent: Item { + implicitWidth: 32 + implicitHeight: implicitWidth + anchors.centerIn: parent + + property alias canvas: canvas + + Canvas { + id: canvas + width: Math.max(1, Math.min(parent.width, parent.height)) + height: width + + onPaint: { + var ctx = getContext("2d"); + ctx.reset(); + ctx.beginPath(); + ctx.fillRect(0, 0, width, height); + } + } + } + + function test_implicitlySizedParent() { + var implicitlySizedItem = implicitlySizedComponent.createObject(container); + verify(implicitlySizedItem); + + var xCenter = implicitlySizedItem.width / 2; + var yCenter = implicitlySizedItem.height / 2; + waitForRendering(implicitlySizedItem); + comparePixel(implicitlySizedItem.canvas.context, xCenter, yCenter, 0, 0, 0, 255); + } +} +} diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 48be97c7ba..25a75c0580 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -62,6 +62,7 @@ public: } private slots: + void initTestCase() Q_DECL_OVERRIDE; void layerEnabled(); void layerSmooth(); void layerMipmap(); @@ -92,14 +93,20 @@ private: }; tst_QQuickItemLayer::tst_QQuickItemLayer() - : m_mesaVersion(0) + : m_isMesaSoftwareRasterizer(false) + , m_mesaVersion(0) { +} + +void tst_QQuickItemLayer::initTestCase() +{ + QQmlDataTest::initTestCase(); QWindow window; QOpenGLContext context; window.setSurfaceType(QWindow::OpenGLSurface); window.create(); - context.create(); - context.makeCurrent(&window); + QVERIFY(context.create()); + QVERIFY(context.makeCurrent(&window)); const char *vendor = (const char *)context.functions()->glGetString(GL_VENDOR); const char *renderer = (const char *)context.functions()->glGetString(GL_RENDERER); m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0 diff --git a/tests/auto/quick/qquicktext/data/growFromZeroWidth.qml b/tests/auto/quick/qquicktext/data/growFromZeroWidth.qml new file mode 100644 index 0000000000..a264191e45 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/growFromZeroWidth.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Text { + width: 0 + wrapMode: Text.Wrap + horizontalAlignment: Text.AlignHCenter + text: "AA\nBBBBBBB\nCCCCCCCCCCCCCCCC" +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 9a7f15c953..4b0bb48a75 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -148,6 +148,8 @@ private slots: void hover(); + void growFromZeroWidth(); + private: QStringList standard; QStringList richText; @@ -3881,6 +3883,23 @@ void tst_qquicktext::hover() QVERIFY(mouseArea->property("wasHovered").toBool()); } +void tst_qquicktext::growFromZeroWidth() +{ + QQmlComponent component(&engine, testFile("growFromZeroWidth.qml")); + + QScopedPointer<QObject> object(component.create()); + + QQuickText *text = qobject_cast<QQuickText *>(object.data()); + QVERIFY(text); + + QCOMPARE(text->lineCount(), 3); + + text->setWidth(80); + + // the new width should force our contents to wrap + QVERIFY(text->lineCount() > 3); +} + QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 79680c6f40..d2d3643ca8 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -222,7 +222,7 @@ void tst_SceneGraph::manyWindows() QOpenGLContext sharedGLContext; ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure. if (shared) { - sharedGLContext.create(); + QVERIFY(sharedGLContext.create()); QOpenGLContextPrivate::setGlobalShareContext(&sharedGLContext); } @@ -459,7 +459,7 @@ void tst_SceneGraph::hideWithOtherContext() window.resize(100, 100); window.create(); QOpenGLContext context; - context.create(); + QVERIFY(context.create()); bool renderingOnMainThread = false; { |