Tst_qsgitem2 test update inline with refactor
authorDamian Jansen <damian.jansen@nokia.com>
Fri, 14 Oct 2011 01:37:25 +0000 (11:37 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 14 Oct 2011 02:47:56 +0000 (04:47 +0200)
Change widget to window based code
Make compile and pass
Add license header

Change-Id: Id0826bf644836654de7eff559a8ff40a55d02616
Reviewed-on: http://codereview.qt-project.org/6635
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
tests/auto/declarative/declarative.pro
tests/auto/declarative/qsgitem2/data/mapCoordinates.qml
tests/auto/declarative/qsgitem2/qsgitem2.pro [moved from tests/auto/declarative/qsgitem2/qsgitem.pro with 100% similarity]
tests/auto/declarative/qsgitem2/tst_qsgitem.cpp

index 6e14648..9f1cf1c 100644 (file)
@@ -75,6 +75,7 @@ SGTESTS =  \
     qsggridview \
     qsgimage \
     qsgitem \
+    qsgitem2 \
     qsglistview \
     qsgloader \
     qsgmousearea \
index a5a073c..566cb22 100644 (file)
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
 import QtQuick 2.0
 
 Item {
@@ -33,11 +74,11 @@ Item {
 
     function checkMapAToInvalid(x, y) {
         var pos = itemA.mapToItem(1122, x, y)
-        return pos.x == undefined && pos.y == undefined
+        return pos == undefined;
     }
 
     function checkMapAFromInvalid(x, y) {
         var pos = itemA.mapFromItem(1122, x, y)
-        return pos.x == undefined && pos.y == undefined
+        return pos == undefined;
     }
 }
index bd437df..fd1f9cd 100644 (file)
@@ -204,7 +204,7 @@ void tst_QSGItem::initTestCase()
 void tst_QSGItem::keys()
 {
     QSGView *canvas = new QSGView(0);
-    canvas->setFixedSize(240,320);
+    canvas->setBaseSize(QSize(240,320));
 
     KeysTestObject *testObject = new KeysTestObject;
     canvas->rootContext()->setContextProperty("keysTestObject", testObject);
@@ -328,7 +328,7 @@ void tst_QSGItem::keys()
 void tst_QSGItem::keysProcessingOrder()
 {
     QSGView *canvas = new QSGView(0);
-    canvas->setFixedSize(240,320);
+    canvas->setBaseSize(QSize(240,320));
 
     KeysTestObject *testObject = new KeysTestObject;
     canvas->rootContext()->setContextProperty("keysTestObject", testObject);
@@ -543,7 +543,7 @@ void tst_QSGItem::layoutMirroringIllegalParent()
 void tst_QSGItem::keyNavigation()
 {
     QSGView *canvas = new QSGView(0);
-    canvas->setFixedSize(240,320);
+    canvas->setBaseSize(QSize(240,320));
 
     canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest.qml")));
     canvas->show();
@@ -623,7 +623,7 @@ void tst_QSGItem::keyNavigation()
 void tst_QSGItem::keyNavigation_RightToLeft()
 {
     QSGView *canvas = new QSGView(0);
-    canvas->setFixedSize(240,320);
+    canvas->setBaseSize(QSize(240,320));
 
     canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest.qml")));
     canvas->show();
@@ -676,7 +676,7 @@ void tst_QSGItem::keyNavigation_RightToLeft()
 void tst_QSGItem::keyNavigation_skipNotVisible()
 {
     QSGView *canvas = new QSGView(0);
-    canvas->setFixedSize(240,320);
+    canvas->setBaseSize(QSize(240,320));
 
     canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest.qml")));
     canvas->show();
@@ -754,7 +754,7 @@ void tst_QSGItem::keyNavigation_skipNotVisible()
 void tst_QSGItem::keyNavigation_implicitSetting()
 {
     QSGView *canvas = new QSGView(0);
-    canvas->setFixedSize(240,320);
+    canvas->setBaseSize(QSize(240,320));
 
     canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest_implicit.qml")));
     canvas->show();
@@ -941,7 +941,7 @@ void tst_QSGItem::mapCoordinates()
     QFETCH(int, y);
 
     QSGView *canvas = new QSGView(0);
-    canvas->setFixedSize(300, 300);
+    canvas->setBaseSize(QSize(300, 300));
     canvas->setSource(QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")));
     canvas->show();
     qApp->processEvents();
@@ -971,8 +971,8 @@ void tst_QSGItem::mapCoordinates()
             Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
     QCOMPARE(result.value<QPointF>(), qobject_cast<QSGItem*>(a)->mapFromScene(QPointF(x, y)));
 
-    QString warning1 = QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")).toString() + ":7:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item";
-    QString warning2 = QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")).toString() + ":7:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item";
+    QString warning1 = QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")).toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item";
+    QString warning2 = QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")).toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item";
 
     QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
     QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid",
@@ -1054,13 +1054,11 @@ void tst_QSGItem::resourcesProperty()
 void tst_QSGItem::propertyChanges()
 {
     QSGView *canvas = new QSGView(0);
-    canvas->setFixedSize(240,320);
+    canvas->setBaseSize(QSize(300, 300));
     canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml")));
     canvas->show();
 
-    QApplication::setActiveWindow(canvas);
     QTest::qWaitForWindowShown(canvas);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
 
     QSGItem *item = findItem<QSGItem>(canvas->rootObject(), "item");
     QSGItem *parentItem = findItem<QSGItem>(canvas->rootObject(), "parentItem");
@@ -1137,8 +1135,8 @@ void tst_QSGItem::propertyChanges()
 void tst_QSGItem::childrenRect()
 {
     QSGView *canvas = new QSGView(0);
-    canvas->setFixedSize(240,320);
     canvas->setSource(QUrl::fromLocalFile(TESTDATA("childrenRect.qml")));
+    canvas->setBaseSize(QSize(240,320));
     canvas->show();
 
     QSGItem *o = canvas->rootObject();