aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-03-03 17:22:51 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-03-03 18:31:04 +0000
commite7c18e2a2b39f35667e76aaafa7135bde161a806 (patch)
tree0a7480d6f84feef46763d6cec45211eb31b59323 /tests/auto/quick
parentcd3b88c5949de902b5ee83711264dcab398df8eb (diff)
parent6dbf435ca46e87893dc46b3f7f09a95f29998e3e (diff)
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/nodes/tst_nodestest.cpp17
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml5
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml84
-rw-r--r--tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp13
-rw-r--r--tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp64
-rw-r--r--tests/auto/quick/qquicktext/data/growFromZeroWidth.qml8
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp19
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp4
8 files changed, 203 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/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
index 3d5dcaaaaf..8063453993 100644
--- a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
+++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
@@ -54,6 +54,7 @@ private slots:
void scale();
void pan();
void retouch();
+ void cancel();
void transformedPinchArea_data();
void transformedPinchArea();
@@ -421,6 +422,69 @@ void tst_QQuickPinchArea::retouch()
}
}
+void tst_QQuickPinchArea::cancel()
+{
+ QQuickView *window = createView();
+ QScopedPointer<QQuickView> scope(window);
+ window->setSource(testFileUrl("pinchproperties.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(window->rootObject() != 0);
+ qApp->processEvents();
+
+ QQuickPinchArea *pinchArea = window->rootObject()->findChild<QQuickPinchArea*>("pincharea");
+ QQuickPinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
+ QVERIFY(root != 0);
+
+ // target
+ QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+
+ QPoint p1(80, 80);
+ QPoint p2(100, 100);
+ {
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device);
+ pinchSequence.press(0, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ // In order for the stationary point to remember its previous position,
+ // we have to reuse the same pinchSequence object. Otherwise if we let it
+ // be destroyed and then start a new sequence, point 0 will default to being
+ // stationary at 0, 0, and PinchArea will filter out that touchpoint because
+ // it is outside its bounds.
+ pinchSequence.stationary(0).press(1, p2, window).commit();
+ QQuickTouchUtils::flush(window);
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ pinchSequence.move(0, p1,window).move(1, p2,window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+ QVERIFY(root->property("pinchActive").toBool());
+
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ pinchSequence.move(0, p1,window).move(1, p2,window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(root->property("scale").toReal(), 1.5);
+ QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
+ QCOMPARE(blackRect->scale(), 1.5);
+
+ QTouchEvent cancelEvent(QEvent::TouchCancel);
+ QCoreApplication::sendEvent(window, &cancelEvent);
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+ QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
+ QCOMPARE(blackRect->scale(), 1.0);
+ QVERIFY(!root->property("pinchActive").toBool());
+ }
+}
+
void tst_QQuickPinchArea::transformedPinchArea_data()
{
QTest::addColumn<QPoint>("p1");
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;
{