diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-01-24 16:37:45 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-01-24 18:27:41 +0100 |
commit | 22041acdfe85c9a9b814e11cd86e8ee5a55be82d (patch) | |
tree | 1b4d1bfa0ebba9e5d1495b5ca7055dba94642c46 /tests | |
parent | 6ae57f01bb1495a74b23a81c590672ce788d5400 (diff) | |
parent | 2407cd29e628671f7f5144e0d241d4249a3ab612 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/imports/dialogs/qquickmessagedialog.cpp
src/imports/dialogs/qquickmessagedialog_p.h
src/qml/debugger/qqmlprofilerservice_p.h
src/qml/jsruntime/qv4regexpobject.cpp
tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
Change-Id: Ic8a43366b44d6970966acbf03b206d0dee00c28d
Diffstat (limited to 'tests')
6 files changed, 158 insertions, 6 deletions
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/signalSourceLocation.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/signalSourceLocation.qml new file mode 100644 index 0000000000..25e63669c4 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/signalSourceLocation.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + onWidthChanged: console.log(width); + Component.onCompleted: width = 500; +} diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro index 87d8b647d1..647d761dc4 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro +++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro @@ -19,4 +19,5 @@ OTHER_FILES += \ data/test.qml \ data/exit.qml \ data/scenegraphTest.qml \ - data/TestImage_2x2.png + data/TestImage_2x2.png \ + data/signalSourceLocation.qml diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 56ed65f54d..9d2e0ecbb4 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -181,6 +181,7 @@ private slots: void scenegraphData(); void profileOnExit(); void controlFromJS(); + void signalSourceLocation(); }; void QQmlProfilerClient::messageReceived(const QByteArray &message) @@ -513,6 +514,35 @@ void tst_QQmlProfilerService::controlFromJS() QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); } +void tst_QQmlProfilerService::signalSourceLocation() +{ + connect(true, "signalSourceLocation.qml"); + QVERIFY(m_client); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->setTraceState(true); + while (!(m_process->output().contains(QLatin1String("500")))) + QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); + m_client->setTraceState(false); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); + + // must start with "StartTrace" + QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event); + QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); + + QVERIFY(m_client->traceMessages[14].detailData.endsWith("signalSourceLocation.qml")); + QVERIFY(m_client->traceMessages[14].line == 8); + QVERIFY(m_client->traceMessages[14].column == 28); + + QVERIFY(m_client->traceMessages[16].detailData.endsWith("signalSourceLocation.qml")); + QVERIFY(m_client->traceMessages[16].line == 7); + QVERIFY(m_client->traceMessages[16].column == 21); + + // must end with "EndTrace" + QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event); + QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); +} + QTEST_MAIN(tst_QQmlProfilerService) #include "tst_qqmlprofilerservice.moc" diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index a1662b495c..ba99b34935 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -148,6 +148,8 @@ private slots: void functionDeclarationsInConditionals(); void arrayPop_QTBUG_35979(); + + void regexpLastMatch(); }; tst_QJSEngine::tst_QJSEngine() @@ -2705,6 +2707,68 @@ void tst_QJSEngine::arrayPop_QTBUG_35979() QCOMPARE(result.toString(), QString("1,3")); } +void tst_QJSEngine::regexpLastMatch() +{ + QJSEngine eng; + + QCOMPARE(eng.evaluate("RegExp.input").toString(), QString()); + + QJSValue hasProperty; + + for (int i = 1; i < 9; ++i) { + hasProperty = eng.evaluate("RegExp.hasOwnProperty(\"$" + QString::number(i) + "\")"); + QVERIFY(hasProperty.isBool()); + QVERIFY(hasProperty.toBool()); + } + + hasProperty = eng.evaluate("RegExp.hasOwnProperty(\"$0\")"); + QVERIFY(hasProperty.isBool()); + QVERIFY(!hasProperty.toBool()); + + hasProperty = eng.evaluate("RegExp.hasOwnProperty(\"$10\")"); + QVERIFY(!hasProperty.toBool()); + + hasProperty = eng.evaluate("RegExp.hasOwnProperty(\"lastMatch\")"); + QVERIFY(hasProperty.toBool()); + hasProperty = eng.evaluate("RegExp.hasOwnProperty(\"$&\")"); + QVERIFY(hasProperty.toBool()); + + QJSValue result = eng.evaluate("" + "var re = /h(el)l(o)/\n" + "var text = \"blah hello world\"\n" + "text.match(re)\n"); + QVERIFY(!result.isError()); + QJSValue match = eng.evaluate("RegExp.$1"); + QCOMPARE(match.toString(), QString("el")); + match = eng.evaluate("RegExp.$2"); + QCOMPARE(match.toString(), QString("o")); + for (int i = 3; i <= 9; ++i) { + match = eng.evaluate("RegExp.$" + QString::number(i)); + QVERIFY(match.isString()); + QCOMPARE(match.toString(), QString()); + } + QCOMPARE(eng.evaluate("RegExp.input").toString(), QString("blah hello world")); + QCOMPARE(eng.evaluate("RegExp.lastParen").toString(), QString("o")); + QCOMPARE(eng.evaluate("RegExp.leftContext").toString(), QString("blah ")); + QCOMPARE(eng.evaluate("RegExp.rightContext").toString(), QString(" world")); + + QCOMPARE(eng.evaluate("RegExp.lastMatch").toString(), QString("hello")); + + result = eng.evaluate("" + "var re = /h(ello)/\n" + "var text = \"hello\"\n" + "text.match(re)\n"); + QVERIFY(!result.isError()); + match = eng.evaluate("RegExp.$1"); + QCOMPARE(match.toString(), QString("ello")); + for (int i = 2; i <= 9; ++i) { + match = eng.evaluate("RegExp.$" + QString::number(i)); + QVERIFY(match.isString()); + QCOMPARE(match.toString(), QString()); + } + +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 86321c775e..59b54e7ba5 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -1440,17 +1440,23 @@ void tst_qquickflickable::stopAtBounds_data() { QTest::addColumn<bool>("transpose"); QTest::addColumn<bool>("invert"); - - QTest::newRow("left") << false << false; - QTest::newRow("right") << false << true; - QTest::newRow("top") << true << false; - QTest::newRow("bottom") << true << true; + QTest::addColumn<bool>("pixelAligned"); + + QTest::newRow("left") << false << false << false; + QTest::newRow("right") << false << true << false; + QTest::newRow("top") << true << false << false; + QTest::newRow("bottom") << true << true << false; + QTest::newRow("left,pixelAligned") << false << false << true; + QTest::newRow("right,pixelAligned") << false << true << true; + QTest::newRow("top,pixelAligned") << true << false << true; + QTest::newRow("bottom,pixelAligned") << true << true << true; } void tst_qquickflickable::stopAtBounds() { QFETCH(bool, transpose); QFETCH(bool, invert); + QFETCH(bool, pixelAligned); QQuickView view; view.setSource(testFileUrl("stopAtBounds.qml")); @@ -1469,6 +1475,7 @@ void tst_qquickflickable::stopAtBounds() flickable->setContentY(invert ? 100 : 0); else flickable->setContentX(invert ? 100 : 0); + flickable->setPixelAligned(pixelAligned); const int threshold = qApp->styleHints()->startDragDistance(); @@ -1518,6 +1525,29 @@ void tst_qquickflickable::stopAtBounds() } QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + + if (transpose) { + flickable->setContentY(invert ? 100 : 0); + } else { + flickable->setContentX(invert ? 100 : 0); + } + if (invert) + flick(&view, QPoint(20,20), QPoint(100,100), 100); + else + flick(&view, QPoint(100,100), QPoint(20,20), 100); + + QVERIFY(flickable->isFlicking()); + if (transpose) { + if (invert) + QTRY_COMPARE(flickable->isAtYBeginning(), true); + else + QTRY_COMPARE(flickable->isAtYEnd(), true); + } else { + if (invert) + QTRY_COMPARE(flickable->isAtXBeginning(), true); + else + QTRY_COMPARE(flickable->isAtXEnd(), true); + } } void tst_qquickflickable::nestedMouseAreaUsingTouch() diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index d241ac2d70..e6a74bb062 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -1724,6 +1724,12 @@ void tst_qquicktext::linkInteraction_data() << (PointVector() << metrics.characterRectangle(18, Qt::AlignRight, Qt::AlignBottom).center()) << singleLineLink << singleLineLink << singleLineLink; + QTest::newRow("click on mirrored link") + << singleLineText << 240. + << "horizontalAlignment: Text.AlignLeft; LayoutMirroring.enabled: true" + << (PointVector() << metrics.characterRectangle(18, Qt::AlignRight, Qt::AlignTop).center()) + << singleLineLink + << singleLineLink << singleLineLink; QTest::newRow("click on center aligned link") << singleLineText << 240. << "horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter" @@ -2545,6 +2551,18 @@ void tst_qquicktext::boundingRect() QCOMPARE(text->boundingRect().width(), line.naturalTextWidth()); QCOMPARE(text->boundingRect().height(), line.height()); + QQuickItemPrivate::get(text)->setLayoutMirror(true); + QCOMPARE(text->boundingRect().x(), qreal(0)); + QCOMPARE(text->boundingRect().y(), qreal(0)); + QCOMPARE(text->boundingRect().width(), line.naturalTextWidth()); + QCOMPARE(text->boundingRect().height(), line.height()); + + text->setHAlign(QQuickText::AlignLeft); + QCOMPARE(text->boundingRect().x(), text->width() - line.naturalTextWidth()); + QCOMPARE(text->boundingRect().y(), qreal(0)); + QCOMPARE(text->boundingRect().width(), line.naturalTextWidth()); + QCOMPARE(text->boundingRect().height(), line.height()); + text->setWrapMode(QQuickText::Wrap); QCOMPARE(text->boundingRect().right(), text->width()); QCOMPARE(text->boundingRect().y(), qreal(0)); |