Merge branch 'qtquick2' of scm.dev.nokia.troll.no:qt/qtdeclarative-staging into qtquick2

This commit is contained in:
Alan Alpert 2011-05-18 21:11:51 +10:00
commit 1edb32e75d
33 changed files with 462 additions and 201 deletions

View File

@ -0,0 +1,140 @@
import QtQuick 2.0
Canvas {
id:motionChart
width:1300
height: 700
property int progress:-1
property variant applesFrom: [1000, 300];
property variant applesTo:[1200, 400];
property variant orangesFrom: [1150, 200];
property variant orangesTo:[250, 550];
property variant bananasFrom: [300, 250];
property variant bananasTo:[788, 617];
property date startDate:new Date (1988,0,1)
property date endDate:new Date (1989,6,1)
property variant title:["Fruit", "Sales", "Expenses", "Location"];
property bool clearTrace:true
Text {id:appleText; text:"Apples"; font.bold:true; font.pixelSize:12; opacity:0}
Text {id:orangeText; text:"Oranges"; font.bold:true; font.pixelSize:12; opacity:0}
Text {id:bananaText; text:"Bananas"; font.bold:true; font.pixelSize:12; opacity:0}
Text {id:sales; text: "700 Sales"; x:15; y:15;font.bold:true; font.pixelSize:15; opacity:0}
Text {id:expenses; text: "Expenses 1300"; x:1170; y:670;font.bold:true; font.pixelSize:15; opacity:0}
Timer {
id:timer
interval: 1; running: true; repeat: true
onTriggered: {
if (motionChart.progress == -1) {
motionChart.setup();
running = false;
}
motionChart.draw();
}
}
MouseArea {
anchors.fill: parent
onPressed : {
motionChart.progress = 0;
setup();
timer.running = true;
motionChart.clearTrace = true;
}
onDoubleClicked : {
motionChart.progress = 0;
setup();
timer.running = true;
motionChart.clearTrace = false;
}
}
function setup() {
var ctx = motionChart.getContext("2d");
ctx.globalCompositeOperation = "source-over";
ctx.clearRect(0, 0, motionChart.width, motionChart.height);
ctx.strokeColor = Qt.rgba(133, 133, 133,1);
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(10,690);
ctx.lineTo(10, 5);
ctx.moveTo(10,690);
ctx.lineTo(1295, 690);
for ( var i = 0; i < 10; i++) {
ctx.moveTo(10, i*70);
ctx.lineTo(15, i*70);
ctx.moveTo(i*130, 690);
ctx.lineTo(i*130, 685);
}
ctx.stroke();
sales.opacity =1;
expenses.opacity = 1;
appleText.opacity = 1;
orangeText.opacity = 1;
bananaText.opacity = 1;
}
function draw() {
var totalDays = Math.ceil((endDate.getTime()-startDate.getTime())/(1000*60*60*24));
if (motionChart.progress >= totalDays) {
timer.running = false;
return;
}
var apples = [];
apples[0] = applesFrom[0] + ((applesTo[0] - applesFrom[0]) * (motionChart.progress/totalDays));
apples[1] = applesFrom[1] + ((applesTo[1] - applesFrom[1]) * (motionChart.progress/totalDays));
var oranges = [];
oranges[0] = orangesFrom[0] + ((orangesTo[0] - orangesFrom[0]) * (motionChart.progress/totalDays));
oranges[1] = orangesFrom[1] + ((orangesTo[1] - orangesFrom[1]) * (motionChart.progress/totalDays));
var bananas = [];
bananas[0] = bananasFrom[0] + ((bananasTo[0] - bananasFrom[0]) * (motionChart.progress/totalDays));
bananas[1] = bananasFrom[1] + ((bananasTo[1] - bananasFrom[1]) * (motionChart.progress/totalDays));
var ctx = motionChart.getContext("2d");
ctx.globalCompositeOperation = "source-over";
if (motionChart.clearTrace)
ctx.clearRect(15, 15, motionChart.width - 15, motionChart.height - 30);
//apples
ctx.fillColor = Qt.rgba(0,255,0,1);
ctx.beginPath();
ctx.arc( apples[0] , 700 - apples[1] , 20 , 0 , Math.PI * 2 , true );
//ctx.closePath();
ctx.fill();
ctx.fillRect(apples[0], 700 - apples[1], 28, 28);
appleText.x = apples[0];
appleText.y = 700 - apples[1] - 30;
//oranges
ctx.fillColor = Qt.rgba(0,0,255,1);
ctx.beginPath();
ctx.arc( oranges[0], 700 - oranges[1] , 20 , 0 , Math.PI * 2 , true );
ctx.closePath();
ctx.fill();
ctx.fillRect(oranges[0], 700 - oranges[1], 28, 28);
orangeText.x = oranges[0];
orangeText.y = 700 - oranges[1] - 30;
//bananas
ctx.fillColor = Qt.rgba(255,0,0,1);
ctx.beginPath();
ctx.arc( bananas[0] , 700 - bananas[1] , 20 , 0 , Math.PI * 2 , true );
ctx.closePath();
ctx.fill();
ctx.fillRect(bananas[0], 700 - bananas[1], 28, 28);
bananaText.x = bananas[0];
bananaText.y = 700 - bananas[1] - 30;
ctx.sync();
motionChart.progress ++;
}
}

View File

@ -774,12 +774,12 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod
tex->setLive(m_live);
tex->setItem(QSGItemPrivate::get(m_sourceItem)->itemNode());
QRectF sourceRect = m_sourceRect.isNull()
QRectF sourceRect = m_sourceRect.isEmpty()
? QRectF(0, 0, m_sourceItem->width(), m_sourceItem->height())
: m_sourceRect;
tex->setRect(sourceRect);
QSize textureSize = m_textureSize.isEmpty()
? QSize(qCeil(qAbs(sourceRect.width())), qCeil(qAbs(sourceRect.height())))
? QSize(qCeil(sourceRect.width()), qCeil(sourceRect.height()))
: m_textureSize;
tex->setSize(textureSize);
tex->setRecursive(m_recursive);

View File

@ -1740,6 +1740,9 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine
qsreal w = ctxt->argument(2).toNumber();
qsreal h = ctxt->argument(3).toNumber();
if (w < 0 || h < 0)
return engine->nullValue();
return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QRectF(x, y, w, h)));
}

View File

@ -76,12 +76,14 @@ contains(QT_CONFIG, private_tests) {
qdeclarativexmllistmodel \
qpacketprotocol \
qdeclarativev4 \
qsganimatedimage \
qsgborderimage \
qsgcanvas \
qsgflickable \
qsgflipable \
qsgfocusscope \
qsggridview \
qsgimage \
qsgitem \
qsglistview \
qsgloader \

View File

@ -80,7 +80,7 @@ private:
void recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const;
void recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const;
void compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const;
QDeclarativeDebugConnection *m_conn;
QDeclarativeEngineDebug *m_dbg;
QDeclarativeEngine *m_engine;
@ -134,7 +134,7 @@ QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject(int conte
{
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
if (q_engines->engines().count() == 0)
return QDeclarativeDebugObjectReference();
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
@ -368,7 +368,7 @@ void tst_QDeclarativeDebug::initTestCase()
for (int i=0; i<qml.count(); i++) {
QDeclarativeComponent component(m_engine);
component.setData(qml[i], QUrl::fromLocalFile(""));
Q_ASSERT(component.isReady()); // fails if bad syntax
QVERIFY(component.isReady()); // fails if bad syntax
m_components << qobject_cast<QDeclarativeItem*>(component.create());
}
m_rootItem = qobject_cast<QDeclarativeItem*>(m_components.first());
@ -382,7 +382,7 @@ void tst_QDeclarativeDebug::initTestCase()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
Q_ASSERT(ok);
QVERIFY(ok);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
m_dbg = new QDeclarativeEngineDebug(m_conn, this);
QTRY_VERIFY(m_dbg->status() == QDeclarativeEngineDebug::Enabled);
@ -439,7 +439,7 @@ void tst_QDeclarativeDebug::watch_property()
QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width");
QDeclarativeDebugPropertyWatch *watch;
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
watch = unconnected->addWatch(prop, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
@ -450,7 +450,7 @@ void tst_QDeclarativeDebug::watch_property()
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
delete watch;
watch = m_dbg->addWatch(prop, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
QCOMPARE(watch->objectDebugId(), obj.debugId());
@ -482,12 +482,12 @@ void tst_QDeclarativeDebug::watch_object()
{
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
Q_ASSERT(q_engines->engines().count() > 0);
QVERIFY(q_engines->engines().count() > 0);
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
Q_ASSERT(q_context->rootContext().objects().count() > 0);
QVERIFY(q_context->rootContext().objects().count() > 0);
QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
waitForQuery(q_obj);
@ -504,7 +504,7 @@ void tst_QDeclarativeDebug::watch_object()
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
delete watch;
delete unconnected;
watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), this);
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
@ -558,7 +558,7 @@ void tst_QDeclarativeDebug::watch_expression()
QFETCH(int, incrementCount);
int origWidth = m_rootItem->property("width").toInt();
QDeclarativeDebugObjectReference obj = findRootObject();
QDeclarativeDebugObjectExpressionWatch *watch;
@ -568,12 +568,12 @@ void tst_QDeclarativeDebug::watch_expression()
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
delete watch;
delete unconnected;
watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), expr, this);
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
delete watch;
watch = m_dbg->addWatch(obj, expr, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
QCOMPARE(watch->objectDebugId(), obj.debugId());
@ -603,7 +603,7 @@ void tst_QDeclarativeDebug::watch_expression()
delete watch;
// restore original value and verify spy doesn't get a signal since watch has been removed
m_rootItem->setProperty("width", origWidth);
m_rootItem->setProperty("width", origWidth);
QTest::qWait(100);
QCOMPARE(spy.count(), expectedSpyCount);
@ -681,7 +681,7 @@ void tst_QDeclarativeDebug::queryRootContexts()
delete q_engines;
QDeclarativeDebugRootContextQuery *q_context;
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
q_context = unconnected->queryRootContexts(engineId, this);
QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
@ -725,7 +725,7 @@ void tst_QDeclarativeDebug::queryObject()
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[0];
@ -806,7 +806,7 @@ void tst_QDeclarativeDebug::queryExpressionResult()
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines); // check immediate deletion is ok
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
int objectId = q_context->rootContext().objects()[0].debugId();
@ -818,7 +818,7 @@ void tst_QDeclarativeDebug::queryExpressionResult()
QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
delete q_expr;
delete unconnected;
q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
delete q_expr;
@ -964,7 +964,7 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
QDeclarativeDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
waitForQuery(query);
QDeclarativeDebugObjectReference obj = query->object();
delete query;
delete query;
QDeclarativeDebugPropertyReference ref = findProperty(obj.properties(), "scale");
QVERIFY(ref.objectDebugId() > 0);
@ -973,7 +973,7 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
QVERIFY(!ref.valueTypeName().isEmpty());
QVERIFY(!ref.binding().isEmpty());
QVERIFY(ref.hasNotifySignal());
QDeclarativeDebugPropertyReference copy(ref);
QDeclarativeDebugPropertyReference copyAssign;
copyAssign = ref;

View File

@ -88,7 +88,7 @@ void tst_QDeclarativeDebugClient::initTestCase()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
Q_ASSERT(ok);
QVERIFY(ok);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled);

View File

@ -87,7 +87,7 @@ void tst_QDeclarativeDebugService::initTestCase()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
Q_ASSERT(ok);
QVERIFY(ok);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
}

View File

@ -2272,16 +2272,12 @@ public:
~CppOwnershipReturnValue() { delete value; }
Q_INVOKABLE QObject *create() {
Q_ASSERT(value == 0);
value = new QObject;
QDeclarativeEngine::setObjectOwnership(value, QDeclarativeEngine::CppOwnership);
return value;
}
Q_INVOKABLE MyQmlObject *createQmlObject() {
Q_ASSERT(value == 0);
MyQmlObject *rv = new MyQmlObject;
value = rv;
return rv;

View File

@ -55,13 +55,13 @@
#endif
class tst_qdeclarativefontloader : public QObject
{
Q_OBJECT
public:
tst_qdeclarativefontloader();
private slots:
void init();
void noFont();
void namedFont();
void localFont();
@ -71,8 +71,6 @@ private slots:
void failWebFont();
void changeFont();
private slots:
private:
QDeclarativeEngine engine;
TestHTTPServer server;
@ -82,7 +80,11 @@ tst_qdeclarativefontloader::tst_qdeclarativefontloader() :
server(SERVER_PORT)
{
server.serveDirectory(SRCDIR "/data");
Q_ASSERT(server.isValid());
}
void tst_qdeclarativefontloader::init()
{
QVERIFY(server.isValid());
}
void tst_qdeclarativefontloader::noFont()

View File

@ -115,7 +115,6 @@ int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model,
if (model->toString(roles[i]) == roleName)
return roles[i];
}
Q_ASSERT(false);
return -1;
}
@ -741,6 +740,7 @@ void tst_qdeclarativelistmodel::get()
"}", QUrl());
QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
int role = roleFromName(model, roleName);
QVERIFY(role >= 0);
QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>)));
QDeclarativeExpression expr(eng.rootContext(), model, expression);
@ -804,6 +804,7 @@ void tst_qdeclarativelistmodel::get_worker()
model.append(sv);
model.append(sv);
int role = roleFromName(&model, roleName);
QVERIFY(role >= 0);
const char *warning = "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script";
if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map)
@ -895,6 +896,7 @@ void tst_qdeclarativelistmodel::get_nested()
int outerListIndex = testData[i].first;
QString outerListRoleName = testData[i].second;
int outerListRole = roleFromName(model, outerListRoleName);
QVERIFY(outerListRole >= 0);
childModel = qobject_cast<QDeclarativeListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>());
QVERIFY(childModel);
@ -907,6 +909,7 @@ void tst_qdeclarativelistmodel::get_nested()
QVERIFY(!expr.hasError());
int role = roleFromName(childModel, roleName);
QVERIFY(role >= 0);
QCOMPARE(childModel->data(index, role), roleValue);
QCOMPARE(spy.count(), 1);

View File

@ -126,7 +126,10 @@ private:
QStringList fields = item.split(",");
foreach(const QString &field, fields) {
QStringList values = field.split("=");
Q_ASSERT(values.count() == 2);
if (values.count() != 2) {
qWarning() << "makeItemXmlAndData: invalid field:" << field;
continue;
}
xml += QString("<%1>%2</%1>").arg(values[0], values[1]);
if (!modelData)
continue;

View File

@ -185,16 +185,22 @@ QString tst_qmlvisual::toTestScript(const QString &file, Mode mode)
if (platformsuffix && (mode == UpdatePlatformVisuals || QFile::exists(testdata+QLatin1String(platformsuffix)+QDir::separator()+testname+".qml"))) {
QString platformdir = testdata + QLatin1String(platformsuffix);
if (mode == UpdatePlatformVisuals) {
Q_ASSERT(QDir().mkpath(platformdir));
if (!QDir().mkpath(platformdir)) {
qFatal("Cannot make path %s", qPrintable(platformdir));
}
// Copy from base
QDir dir(testdata,testname+".*");
dir.setFilter(QDir::Files);
QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i) {
QFile in(list.at(i).filePath());
Q_ASSERT(in.open(QIODevice::ReadOnly));
if (!in.open(QIODevice::ReadOnly)) {
qFatal("Cannot open file %s: %s", qPrintable(in.fileName()), qPrintable(in.errorString()));
}
QFile out(platformdir + QDir::separator() + list.at(i).fileName());
Q_ASSERT(out.open(QIODevice::WriteOnly));
if (!out.open(QIODevice::WriteOnly)) {
qFatal("Cannot open file %s: %s", qPrintable(out.fileName()), qPrintable(out.errorString()));
}
out.write(in.readAll());
}
}
@ -234,8 +240,6 @@ QStringList tst_qmlvisual::findQmlFiles(const QDir &d)
void action(Mode mode, const QString &file)
{
Q_ASSERT(mode != Test);
QString testdata = tst_qmlvisual::toTestScript(file,mode);
QStringList arguments;

View File

@ -209,7 +209,7 @@ void tst_qsganimatedimage::mirror_notRunning()
anim->setProperty("mirror", true);
screenshot = canvas->renderPixmap();
QEXPECT_FAIL("", "QTBUG-19252", Abort);
QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved", SkipSingle);
QCOMPARE(screenshot, expected);
// mirroring should not change the current frame or playing status
@ -288,7 +288,7 @@ void tst_qsganimatedimage::invalidSource()
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
component.setData("import QtQuick 1.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
component.setData("import QtQuick 2.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
QVERIFY(component.isReady());
QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif");
@ -332,7 +332,7 @@ void tst_qsganimatedimage::progressAndStatusChanges()
server.serveDirectory(SRCDIR "/data");
QDeclarativeEngine engine;
QString componentStr = "import QtQuick 1.0\nAnimatedImage { source: srcImage }";
QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }";
QDeclarativeContext *ctxt = engine.rootContext();
ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/stickman.gif"));
QDeclarativeComponent component(&engine);

View File

@ -1,4 +1,4 @@
import QtQuick 1.0
import QtQuick 2.0
BorderImage {
source: "heart200.png"

View File

@ -98,7 +98,7 @@ tst_qsgborderimage::tst_qsgborderimage()
void tst_qsgborderimage::noSource()
{
QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"\" }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"\" }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());
@ -142,7 +142,7 @@ void tst_qsgborderimage::imageSource()
if (!error.isEmpty())
QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\" }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());
@ -171,7 +171,7 @@ void tst_qsgborderimage::imageSource()
void tst_qsgborderimage::clearSource()
{
QString componentStr = "import QtQuick 1.0\nBorderImage { source: srcImage }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: srcImage }";
QDeclarativeContext *ctxt = engine.rootContext();
ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
QDeclarativeComponent component(&engine);
@ -191,7 +191,7 @@ void tst_qsgborderimage::clearSource()
void tst_qsgborderimage::resized()
{
QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() + "\"; width: 300; height: 300 }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() + "\"; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());
@ -208,7 +208,7 @@ void tst_qsgborderimage::resized()
void tst_qsgborderimage::smooth()
{
QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());
@ -238,7 +238,7 @@ void tst_qsgborderimage::mirror()
image->setProperty("mirror", true);
QPixmap mirrored;
QEXPECT_FAIL("", "QTBUG-19252", Abort);
QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved", SkipSingle);
QCOMPARE(screenshot, mirrored);
delete canvas;
@ -247,7 +247,7 @@ void tst_qsgborderimage::mirror()
void tst_qsgborderimage::tileModes()
{
{
QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());
@ -260,7 +260,7 @@ void tst_qsgborderimage::tileModes()
delete obj;
}
{
QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());
@ -287,7 +287,7 @@ void tst_qsgborderimage::sciSource()
server->serveDirectory(SRCDIR "/data");
}
QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());
@ -333,7 +333,7 @@ void tst_qsgborderimage::invalidSciFile()
QTest::ignoreMessage(QtWarningMsg, "QSGGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun"
QTest::ignoreMessage(QtWarningMsg, "QSGGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea"
QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());
@ -351,7 +351,7 @@ void tst_qsgborderimage::pendingRemoteRequest()
{
QFETCH(QString, source);
QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\" }";
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGBorderImage *obj = qobject_cast<QSGBorderImage*>(component.create());

View File

@ -47,6 +47,7 @@
#include <private/qdeclarativevaluetype_p.h>
#include <math.h>
#include "../../../shared/util.h"
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -60,6 +61,9 @@ public:
tst_qsgflickable();
private slots:
void initTestCase();
void cleanupTestCase();
void create();
void horizontalViewportSize();
void verticalViewportSize();
@ -86,6 +90,18 @@ tst_qsgflickable::tst_qsgflickable()
{
}
void tst_qsgflickable::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("Flickable item needs OpenGL 2.0", SkipAll);
}
void tst_qsgflickable::cleanupTestCase()
{
}
void tst_qsgflickable::create()
{
QDeclarativeEngine engine;

View File

@ -47,6 +47,8 @@
#include <QFontMetrics>
#include <private/qsgrectangle_p.h>
#include <math.h>
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -60,6 +62,8 @@ public:
tst_qsgflipable();
private slots:
void initTestCase();
void cleanupTestCase();
void create();
void checkFrontAndBack();
void setFrontAndBack();
@ -74,6 +78,17 @@ private:
tst_qsgflipable::tst_qsgflipable()
{
}
void tst_qsgflipable::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("Flipable item needs OpenGL 2.0", SkipAll);
}
void tst_qsgflipable::cleanupTestCase()
{
}
void tst_qsgflipable::create()

View File

@ -47,6 +47,7 @@
#include <private/qsgtextedit_p.h>
#include <private/qsgtext_p.h>
#include <QtDeclarative/private/qsgfocusscope_p.h>
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -63,6 +64,8 @@ public:
T *findItem(QSGItem *parent, const QString &id);
private slots:
void initTestCase();
void cleanupTestCase();
void basic();
void nested();
void noFocus();
@ -73,6 +76,17 @@ private slots:
void qtBug13380();
void forceActiveFocus();
};
void tst_qsgfocusscope::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("FocusScope item needs OpenGL 2.0", SkipAll);
}
void tst_qsgfocusscope::cleanupTestCase()
{
}
/*
Find an item with the specified id.

View File

@ -52,6 +52,7 @@
#include <QtDeclarative/private/qsgtext_p.h>
#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
#include "../../../shared/util.h"
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -65,6 +66,8 @@ public:
tst_QSGGridView();
private slots:
void initTestCase();
void cleanupTestCase();
void items();
void changed();
void inserted();
@ -106,7 +109,17 @@ private:
QList<T*> findItems(QSGItem *parent, const QString &objectName);
void dumpTree(QSGItem *parent, int depth = 0);
};
void tst_QSGGridView::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("QSGGridView needs OpenGL 2.0", SkipAll);
}
void tst_QSGGridView::cleanupTestCase()
{
}
class TestModel : public QAbstractListModel
{
public:

View File

@ -0,0 +1,11 @@
import QtQuick 2.0
Rectangle {
width: 200; height: 550
Image {
objectName: "tiling"; anchors.fill: parent
source: "green.png"; fillMode: Image.TileHorizontally
}
}

View File

@ -0,0 +1,5 @@
import QtQuick 2.0
Image {
source: "heart200.png"
}

View File

@ -0,0 +1,6 @@
import QtQuick 2.0
Image {
width: 10; height:10; fillMode: Image.PreserveAspectFit
source: ""
}

View File

@ -1,16 +0,0 @@
import QtQuick 2.0
Rectangle {
width: 800; height: 600
Image {
objectName: "vTiling"; height: 550; width: 200
source: "green.png"; fillMode: Image.TileVertically
}
Image {
objectName: "hTiling"; x: 225; height: 250; width: 550
source: "green.png"; fillMode: Image.TileHorizontally
}
}

View File

@ -0,0 +1,11 @@
import QtQuick 2.0
Rectangle {
width: 550; height: 200
Image {
objectName: "tiling"; anchors.fill: parent
source: "green.png"; fillMode: Image.TileVertically
}
}

View File

@ -86,13 +86,12 @@ private slots:
void geometry_data();
void big();
void tiling_QTBUG_6716();
void tiling_QTBUG_6716_data();
void noLoading();
void paintedWidthHeight();
void sourceSize_QTBUG_14303();
void sourceSize_QTBUG_16389();
void nullPixmapPaint();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
private:
template<typename T>
@ -107,7 +106,7 @@ tst_qsgimage::tst_qsgimage()
void tst_qsgimage::noSource()
{
QString componentStr = "import QtQuick 1.0\nImage { source: \"\" }";
QString componentStr = "import QtQuick 2.0\nImage { source: \"\" }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGImage *obj = qobject_cast<QSGImage*>(component.create());
@ -167,7 +166,7 @@ void tst_qsgimage::imageSource()
if (!error.isEmpty())
QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
QString componentStr = "import QtQuick 1.1\nImage { source: \"" + source + "\"; asynchronous: "
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; asynchronous: "
+ (async ? QLatin1String("true") : QLatin1String("false")) + "; cache: "
+ (cache ? QLatin1String("true") : QLatin1String("false")) + " }";
QDeclarativeComponent component(&engine);
@ -205,7 +204,7 @@ void tst_qsgimage::imageSource()
void tst_qsgimage::clearSource()
{
QString componentStr = "import QtQuick 1.0\nImage { source: srcImage }";
QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
QDeclarativeContext *ctxt = engine.rootContext();
ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
QDeclarativeComponent component(&engine);
@ -229,7 +228,7 @@ void tst_qsgimage::clearSource()
void tst_qsgimage::resized()
{
QString componentStr = "import QtQuick 1.0\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
QString componentStr = "import QtQuick 2.0\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGImage *obj = qobject_cast<QSGImage*>(component.create());
@ -264,7 +263,7 @@ void tst_qsgimage::preserveAspectRatio()
void tst_qsgimage::smooth()
{
QString componentStr = "import QtQuick 1.0\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
QString componentStr = "import QtQuick 2.0\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGImage *obj = qobject_cast<QSGImage*>(component.create());
@ -284,12 +283,11 @@ void tst_qsgimage::mirror()
qreal width = 300;
qreal height = 250;
QString src = QUrl::fromLocalFile(SRCDIR "/data/heart200.png").toString();
QString componentStr = "import QtQuick 1.1\nImage { source: \"" + src + "\"; }";
QSGView *canvas = new QSGView;
canvas->show();
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirror.qml"));
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGImage *obj = qobject_cast<QSGImage*>(component.create());
QSGImage *obj = qobject_cast<QSGImage*>(canvas->rootObject());
QVERIFY(obj != 0);
obj->setProperty("width", width);
@ -297,12 +295,7 @@ void tst_qsgimage::mirror()
obj->setFillMode((QSGImage::FillMode)fillMode);
obj->setProperty("mirror", true);
QGraphicsScene scene;
scene.addItem(qobject_cast<QSGItem *>(obj));
QPixmap screenshot(width, height);
screenshot.fill();
QPainter p_screenshot(&screenshot);
scene.render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height));
QPixmap screenshot = canvas->renderPixmap();
QPixmap srcPixmap;
QVERIFY(srcPixmap.load(SRCDIR "/data/heart200.png"));
@ -344,9 +337,10 @@ void tst_qsgimage::mirror()
break;
}
QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved", SkipSingle);
QCOMPARE(screenshot, expected);
delete obj;
delete canvas;
}
void tst_qsgimage::mirror_data()
@ -364,32 +358,17 @@ void tst_qsgimage::mirror_data()
void tst_qsgimage::svg()
{
QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.svg").toString();
QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }";
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGImage *obj = qobject_cast<QSGImage*>(component.create());
QVERIFY(obj != 0);
QCOMPARE(obj->pixmap().width(), 300);
QCOMPARE(obj->pixmap().height(), 300);
QCOMPARE(obj->width(), 300.0);
QCOMPARE(obj->height(), 300.0);
#if defined(Q_OS_LINUX)
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png"));
#elif defined(Q_OS_WIN32)
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png"));
#endif
obj->setSourceSize(QSize(200,200));
QCOMPARE(obj->pixmap().width(), 200);
QCOMPARE(obj->pixmap().height(), 200);
QCOMPARE(obj->width(), 200.0);
QCOMPARE(obj->height(), 200.0);
#if defined(Q_OS_LINUX)
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png"));
#elif defined(Q_OS_WIN32)
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png"));
#endif
delete obj;
}
@ -443,7 +422,7 @@ void tst_qsgimage::geometry()
QFETCH(double, boundingHeight);
QString src = QUrl::fromLocalFile(SRCDIR "/data/rect.png").toString();
QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; ";
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; ";
if (explicitWidth)
componentStr.append("width: 300; ");
@ -471,63 +450,48 @@ void tst_qsgimage::big()
// have to build a 400 MB image. That would be a bug in the JPEG loader.
QString src = QUrl::fromLocalFile(SRCDIR "/data/big.jpeg").toString();
QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }";
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGImage *obj = qobject_cast<QSGImage*>(component.create());
QVERIFY(obj != 0);
QCOMPARE(obj->pixmap().width(), 256);
QCOMPARE(obj->pixmap().height(), 256);
QCOMPARE(obj->width(), 100.0);
QCOMPARE(obj->height(), 256.0);
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/big256.png"));
delete obj;
}
void tst_qsgimage::tiling_QTBUG_6716()
{
QFETCH(QString, source);
QSGView *canvas = new QSGView(0);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/tiling.qml"));
canvas->setSource(QUrl::fromLocalFile(SRCDIR + source));
canvas->show();
qApp->processEvents();
QSGImage *vTiling = findItem<QSGImage>(canvas->rootObject(), "vTiling");
QSGImage *hTiling = findItem<QSGImage>(canvas->rootObject(), "hTiling");
QSGImage *tiling = findItem<QSGImage>(canvas->rootObject(), "tiling");
QVERIFY(vTiling != 0);
QVERIFY(hTiling != 0);
{
QPixmap pm(vTiling->width(), vTiling->height());
QPainter p(&pm);
vTiling->paint(&p, 0, 0);
QImage img = pm.toImage();
for (int x = 0; x < vTiling->width(); ++x) {
for (int y = 0; y < vTiling->height(); ++y) {
QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
}
QVERIFY(tiling != 0);
QPixmap pm = canvas->renderPixmap();
QImage img = pm.toImage();
for (int x = 0; x < tiling->width(); ++x) {
for (int y = 0; y < tiling->height(); ++y) {
QEXPECT_FAIL("", "QTBUG-19351", Abort);
QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
}
}
{
QPixmap pm(hTiling->width(), hTiling->height());
QPainter p(&pm);
hTiling->paint(&p, 0, 0);
QImage img = pm.toImage();
for (int x = 0; x < hTiling->width(); ++x) {
for (int y = 0; y < hTiling->height(); ++y) {
QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
}
}
}
delete canvas;
}
void tst_qsgimage::tiling_QTBUG_6716_data()
{
QTest::addColumn<QString>("source");
QTest::newRow("vertical_tiling") << "/data/vtiling.qml";
QTest::newRow("horizontal_tiling") << "/data/htiling.qml";
}
void tst_qsgimage::noLoading()
{
TestHTTPServer server(SERVER_PORT);
@ -535,7 +499,7 @@ void tst_qsgimage::noLoading()
server.serveDirectory(SRCDIR "/data");
server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
QString componentStr = "import QtQuick 1.0\nImage { source: srcImage }";
QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
QDeclarativeContext *ctxt = engine.rootContext();
ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart.png"));
QDeclarativeComponent component(&engine);
@ -582,37 +546,31 @@ void tst_qsgimage::paintedWidthHeight()
{
{
QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.png").toString();
QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }";
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGImage *obj = qobject_cast<QSGImage*>(component.create());
QVERIFY(obj != 0);
QCOMPARE(obj->pixmap().width(), 300);
QCOMPARE(obj->pixmap().height(), 300);
QCOMPARE(obj->width(), 200.0);
QCOMPARE(obj->height(), 25.0);
QCOMPARE(obj->paintedWidth(), 25.0);
QCOMPARE(obj->paintedHeight(), 25.0);
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png"));
delete obj;
}
{
QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.png").toString();
QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }";
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGImage *obj = qobject_cast<QSGImage*>(component.create());
QVERIFY(obj != 0);
QCOMPARE(obj->pixmap().width(), 300);
QCOMPARE(obj->pixmap().height(), 300);
QCOMPARE(obj->width(), 26.0);
QCOMPARE(obj->height(), 175.0);
QCOMPARE(obj->paintedWidth(), 26.0);
QCOMPARE(obj->paintedHeight(), 26.0);
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png"));
delete obj;
}
@ -620,7 +578,7 @@ void tst_qsgimage::paintedWidthHeight()
void tst_qsgimage::sourceSize_QTBUG_14303()
{
QString componentStr = "import QtQuick 1.0\nImage { source: srcImage }";
QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
QDeclarativeContext *ctxt = engine.rootContext();
ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png"));
QDeclarativeComponent component(&engine);
@ -681,65 +639,24 @@ static void checkWarnings(QtMsgType, const char *)
// QTBUG-15690
void tst_qsgimage::nullPixmapPaint()
{
QString componentStr = QString("import QtQuick 1.0\nImage { width: 10; height:10; fillMode: Image.PreserveAspectFit; source: \"")
+ SERVER_ADDR + QString("/no-such-file.png\" }");
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGImage *image = qobject_cast<QSGImage*>(component.create());
QSGView *canvas = new QSGView(0);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/nullpixmap.qml"));
canvas->show();
QSGImage *image = qobject_cast<QSGImage*>(canvas->rootObject());
QTRY_VERIFY(image != 0);
image->setSource(SERVER_ADDR + QString("/no-such-file.png"));
QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
QPixmap pm(100, 100);
QPainter p(&pm);
// used to print "QTransform::translate with NaN called"
image->paint(&p, 0, 0);
QPixmap pm = canvas->renderPixmap();
qInstallMsgHandler(previousMsgHandler);
QVERIFY(numberOfWarnings == 0);
delete image;
}
void tst_qsgimage::testQtQuick11Attributes()
{
QFETCH(QString, code);
QFETCH(QString, warning);
QFETCH(QString, error);
QDeclarativeEngine engine;
QObject *obj;
QDeclarativeComponent valid(&engine);
valid.setData("import QtQuick 1.1; Image { " + code.toUtf8() + " }", QUrl(""));
obj = valid.create();
QVERIFY(obj);
QVERIFY(valid.errorString().isEmpty());
delete obj;
QDeclarativeComponent invalid(&engine);
invalid.setData("import QtQuick 1.0; Image { " + code.toUtf8() + " }", QUrl(""));
QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
obj = invalid.create();
QCOMPARE(invalid.errorString(), error);
delete obj;
}
void tst_qsgimage::testQtQuick11Attributes_data()
{
QTest::addColumn<QString>("code");
QTest::addColumn<QString>("warning");
QTest::addColumn<QString>("error");
QTest::newRow("mirror") << "mirror: true"
<< "QDeclarativeComponent: Component is not ready"
<< ":1 \"Image.mirror\" is not available in QtQuick 1.0.\n";
QTest::newRow("cache") << "cache: true"
<< "QDeclarativeComponent: Component is not ready"
<< ":1 \"Image.cache\" is not available in QtQuick 1.0.\n";
}
/*
Find an item with the specified objectName. If index is supplied then the
item must also evaluate the {index} expression equal to index

View File

@ -53,6 +53,7 @@
#include <QtDeclarative/private/qlistmodelinterface_p.h>
#include "../../../shared/util.h"
#include "incrementalmodel.h"
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -66,6 +67,8 @@ public:
tst_QSGListView();
private slots:
void initTestCase();
void cleanupTestCase();
// Test both QListModelInterface and QAbstractItemModel model types
void qListModelInterface_items();
void qAbstractItemModel_items();
@ -133,6 +136,17 @@ private:
void dumpTree(QSGItem *parent, int depth = 0);
};
void tst_QSGListView::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("QSGListView needs OpenGL 2.0", SkipAll);
}
void tst_QSGListView::cleanupTestCase()
{
}
class TestObject : public QObject
{
Q_OBJECT

View File

@ -47,6 +47,7 @@
#include <QtDeclarative/qsgview.h>
#include <QtDeclarative/qdeclarativecontext.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -57,6 +58,8 @@ class tst_QSGMouseArea: public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void dragProperties();
void resetDrag();
void dragging();
@ -77,6 +80,18 @@ private:
QSGView *createView();
};
void tst_QSGMouseArea::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("MouseArea needs OpenGL 2.0", SkipAll);
}
void tst_QSGMouseArea::cleanupTestCase()
{
}
void tst_QSGMouseArea::dragProperties()
{
QSGView *canvas = createView();

View File

@ -55,6 +55,7 @@
#include <QStringListModel>
#include <QStandardItemModel>
#include <QFile>
#include <QtOpenGL/QGLShaderProgram>
#include "../../../shared/util.h"
@ -89,6 +90,8 @@ public:
tst_QSGPathView();
private slots:
void initTestCase();
void cleanupTestCase();
void initValues();
void items();
void dataModel();
@ -121,6 +124,18 @@ private:
QList<T*> findItems(QSGItem *parent, const QString &objectName);
};
void tst_QSGPathView::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("PathView needs OpenGL 2.0", SkipAll);
}
void tst_QSGPathView::cleanupTestCase()
{
}
class TestObject : public QObject
{
Q_OBJECT

View File

@ -45,6 +45,7 @@
#include <private/qsgrectangle_p.h>
#include <QtDeclarative/qsgview.h>
#include <QtDeclarative/qdeclarativecontext.h>
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -55,6 +56,8 @@ class tst_QSGPinchArea: public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void pinchProperties();
void scale();
void pan();
@ -62,7 +65,17 @@ private slots:
private:
QSGView *createView();
};
void tst_QSGPinchArea::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("PinchArea needs OpenGL 2.0", SkipAll);
}
void tst_QSGPinchArea::cleanupTestCase()
{
}
void tst_QSGPinchArea::pinchProperties()
{
QSGView *canvas = createView();

View File

@ -54,6 +54,7 @@
#include "../../../shared/util.h"
#include "testhttpserver.h"
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -68,6 +69,8 @@ public:
tst_qsgtext();
private slots:
void initTestCase();
void cleanupTestCase();
void text();
void width();
void wrap();
@ -127,7 +130,17 @@ private:
QSGView *createView(const QString &filename);
};
void tst_qsgtext::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("Text item needs OpenGL 2.0", SkipAll);
}
void tst_qsgtext::cleanupTestCase()
{
}
tst_qsgtext::tst_qsgtext()
{
standard << "the quick brown fox jumped over the lazy dog"
@ -461,6 +474,8 @@ void tst_qsgtext::alignments_data()
void tst_qsgtext::alignments()
{
QSKIP("Text alignment pixmap comparison tests will not work with scenegraph", SkipAll);
QFETCH(int, hAlign);
QFETCH(int, vAlign);
QFETCH(QString, expectfile);

View File

@ -60,6 +60,7 @@
#include <QMimeData>
#include <private/qapplication_p.h>
#include <private/qtextcontrol_p.h>
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_WS_MAC
#include <Carbon/Carbon.h>
@ -97,6 +98,8 @@ public:
tst_qsgtextedit();
private slots:
void initTestCase();
void cleanupTestCase();
void text();
void width();
void wrap();
@ -170,7 +173,17 @@ private:
QDeclarativeEngine engine;
};
void tst_qsgtextedit::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("TextEdit item needs OpenGL 2.0", SkipAll);
}
void tst_qsgtextedit::cleanupTestCase()
{
}
tst_qsgtextedit::tst_qsgtextedit()
{
standard << "the quick brown fox jumped over the lazy dog"
@ -2173,6 +2186,8 @@ void tst_qsgtextedit::preeditMicroFocus()
QSGTextEdit *edit = qobject_cast<QSGTextEdit *>(view.rootObject());
QVERIFY(edit);
QSignalSpy cursorRectangleSpy(edit, SIGNAL(cursorRectangleChanged()));
QRect currentRect;
QRect previousRect = edit->inputMethodQuery(Qt::ImMicroFocus).toRect();
@ -2183,8 +2198,9 @@ void tst_qsgtextedit::preeditMicroFocus()
currentRect = edit->inputMethodQuery(Qt::ImMicroFocus).toRect();
QCOMPARE(currentRect, previousRect);
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
QCOMPARE(ic.updateReceived, true);
QCOMPARE(ic.updateReceived, false); // The cursor position hasn't changed.
#endif
QCOMPARE(cursorRectangleSpy.count(), 0);
// Verify that the micro focus rect moves to the left as the cursor position
// is incremented.
@ -2196,6 +2212,8 @@ void tst_qsgtextedit::preeditMicroFocus()
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
QCOMPARE(ic.updateReceived, true);
#endif
QVERIFY(cursorRectangleSpy.count() > 0);
cursorRectangleSpy.clear();
previousRect = currentRect;
}
@ -2209,6 +2227,7 @@ void tst_qsgtextedit::preeditMicroFocus()
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
QCOMPARE(ic.updateReceived, true);
#endif
QVERIFY(cursorRectangleSpy.count() > 0);
}
void tst_qsgtextedit::inputContextMouseHandler()

View File

@ -51,6 +51,7 @@
#include <QStyle>
#include <QInputContext>
#include <private/qapplication_p.h>
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -83,7 +84,8 @@ public:
tst_qsgtextinput();
private slots:
void initTestCase();
void cleanupTestCase();
void text();
void width();
void font();
@ -144,7 +146,17 @@ private:
QStringList standard;
QStringList colorStrings;
};
void tst_qsgtextinput::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("TextInput item needs OpenGL 2.0", SkipAll);
}
void tst_qsgtextinput::cleanupTestCase()
{
}
tst_qsgtextinput::tst_qsgtextinput()
{
standard << "the quick brown fox jumped over the lazy dog"

View File

@ -51,6 +51,7 @@
#include <private/qsgvisualitemmodel_p.h>
#include <private/qdeclarativevaluetype_p.h>
#include <math.h>
#include <QtOpenGL/QGLShaderProgram>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@ -115,6 +116,8 @@ public:
tst_qsgvisualdatamodel();
private slots:
void initTestCase();
void cleanupTestCase();
void rootIndex();
void updateLayout();
void childChanged();
@ -128,7 +131,17 @@ private:
template<typename T>
T *findItem(QSGItem *parent, const QString &objectName, int index);
};
void tst_qsgvisualdatamodel::initTestCase()
{
QSGView canvas;
if (!QGLShaderProgram::hasOpenGLShaderPrograms(canvas.context()))
QSKIP("VisualDatamodel item needs OpenGL 2.0", SkipAll);
}
void tst_qsgvisualdatamodel::cleanupTestCase()
{
}
class DataObject : public QObject
{
Q_OBJECT