summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/massive.pngbin0 -> 31834 bytes
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp40
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/extendsBug.qml26
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp16
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp36
-rw-r--r--tests/auto/mediaobject/tst_mediaobject.cpp4
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp65
7 files changed, 180 insertions, 7 deletions
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/data/massive.png b/tests/auto/declarative/qdeclarativepixmapcache/data/massive.png
new file mode 100644
index 0000000..bc6cc9e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepixmapcache/data/massive.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
index 0c7780c..16d2063 100644
--- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
+++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
@@ -70,6 +70,7 @@ private slots:
void single_data();
void parallel();
void parallel_data();
+ void massive();
private:
QDeclarativeEngine engine;
@@ -276,6 +277,45 @@ void tst_qdeclarativepixmapcache::parallel()
qDeleteAll(pixmaps);
}
+void tst_qdeclarativepixmapcache::massive()
+{
+ QUrl url = thisfile.resolved(QUrl("data/massive.png"));
+
+ // Confirm that massive images remain in the cache while they are
+ // in use by the application.
+ {
+ qint64 cachekey = 0;
+ QDeclarativePixmap p(0, url);
+ QVERIFY(p.isReady());
+ QVERIFY(p.pixmap().size() == QSize(10000, 1000));
+ cachekey = p.pixmap().cacheKey();
+
+ QDeclarativePixmap p2(0, url);
+ QVERIFY(p2.isReady());
+ QVERIFY(p2.pixmap().size() == QSize(10000, 1000));
+
+ QVERIFY(p2.pixmap().cacheKey() == cachekey);
+ }
+
+ // Confirm that massive images are removed from the cache when
+ // they become unused
+ {
+ qint64 cachekey = 0;
+ {
+ QDeclarativePixmap p(0, url);
+ QVERIFY(p.isReady());
+ QVERIFY(p.pixmap().size() == QSize(10000, 1000));
+ cachekey = p.pixmap().cacheKey();
+ }
+
+ QDeclarativePixmap p2(0, url);
+ QVERIFY(p2.isReady());
+ QVERIFY(p2.pixmap().size() == QSize(10000, 1000));
+
+ QVERIFY(p2.pixmap().cacheKey() != cachekey);
+ }
+}
+
QTEST_MAIN(tst_qdeclarativepixmapcache)
#include "tst_qdeclarativepixmapcache.moc"
diff --git a/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml b/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml
new file mode 100644
index 0000000..a3c4827
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml
@@ -0,0 +1,26 @@
+import Qt 4.7
+
+Rectangle {
+ width: 200
+ height: 200
+
+ Rectangle {
+ id: rect
+ objectName: "greenRect"
+ width: 100
+ height: 100
+ color: "green"
+ }
+
+ states:[
+ State {
+ name: "a"
+ PropertyChanges { target: rect; x: 100 }
+ },
+ State {
+ name: "b"
+ extend:"a"
+ PropertyChanges { target: rect; y: 100 }
+ }
+ ]
+}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 3b6a420..6ae2759 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -139,6 +139,7 @@ private slots:
void urlResolution();
void unnamedWhen();
void returnToBase();
+ void extendsBug();
};
void tst_qdeclarativestates::initTestCase()
@@ -1186,6 +1187,21 @@ void tst_qdeclarativestates::returnToBase()
QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState"));
}
+//QTBUG-12559
+void tst_qdeclarativestates::extendsBug()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/extendsBug.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+ QDeclarativeRectangle *greenRect = rect->findChild<QDeclarativeRectangle*>("greenRect");
+
+ rectPrivate->setState("b");
+ QCOMPARE(greenRect->x(), qreal(100));
+ QCOMPARE(greenRect->y(), qreal(100));
+}
QTEST_MAIN(tst_qdeclarativestates)
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
index de8d222..1c1c04b 100644
--- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -43,9 +43,11 @@
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativeitem.h>
+#include <QtDeclarative/qdeclarativecontext.h>
#include <QtGui/qmenubar.h>
#include "../../../shared/util.h"
#include "qmlruntime.h"
+#include "deviceorientation.h"
#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
@@ -67,7 +69,7 @@ public:
tst_QDeclarativeViewer();
private slots:
- void orientation();
+ void runtimeContextProperty();
void loading();
void fileBrowser();
void resizing();
@@ -94,7 +96,7 @@ tst_QDeclarativeViewer::tst_QDeclarativeViewer()
QCOMPARE(viewer->size(), viewer->sizeHint()); \
}
-void tst_QDeclarativeViewer::orientation()
+void tst_QDeclarativeViewer::runtimeContextProperty()
{
QDeclarativeViewer *viewer = new QDeclarativeViewer();
QVERIFY(viewer);
@@ -103,17 +105,30 @@ void tst_QDeclarativeViewer::orientation()
QVERIFY(viewer->menuBar());
QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
QVERIFY(rootItem);
+ QObject *runtimeObject = qvariant_cast<QObject*>(viewer->view()->engine()->rootContext()->contextProperty("runtime"));
+ QVERIFY(runtimeObject);
+
+ // test isActiveWindow property
+ QVERIFY(!runtimeObject->property("isActiveWindow").toBool());
+
viewer->show();
-
QApplication::setActiveWindow(viewer);
QTest::qWaitForWindowShown(viewer);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer));
+ QVERIFY(runtimeObject->property("isActiveWindow").toBool());
+
TEST_INITIAL_SIZES(viewer);
+ // test orientation property
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Portrait));
+
viewer->rotateOrientation();
qApp->processEvents();
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Landscape));
+ QCOMPARE(rootItem->width(), 300.0);
+
QCOMPARE(rootItem->width(), 300.0);
QCOMPARE(rootItem->height(), 200.0);
QTRY_COMPARE(viewer->view()->size(), QSize(300, 200));
@@ -124,6 +139,8 @@ void tst_QDeclarativeViewer::orientation()
viewer->rotateOrientation();
qApp->processEvents();
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::PortraitInverted));
+
QCOMPARE(rootItem->width(), 200.0);
QCOMPARE(rootItem->height(), 300.0);
QTRY_COMPARE(viewer->view()->size(), QSize(200, 300));
@@ -131,6 +148,19 @@ void tst_QDeclarativeViewer::orientation()
QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
+ viewer->rotateOrientation();
+ qApp->processEvents();
+
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::LandscapeInverted));
+
+ viewer->rotateOrientation();
+ qApp->processEvents();
+
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Portrait));
+
+ viewer->hide();
+ QVERIFY(!runtimeObject->property("isActiveWindow").toBool());
+
delete viewer;
}
diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp
index 2f98521..322e2e4 100644
--- a/tests/auto/mediaobject/tst_mediaobject.cpp
+++ b/tests/auto/mediaobject/tst_mediaobject.cpp
@@ -201,9 +201,6 @@ void tst_MediaObject::stateChanged(Phonon::State newstate, Phonon::State oldstat
void tst_MediaObject::testPlayFromResource()
{
-#ifdef Q_OS_SYMBIAN
- QSKIP("Not implemented yet.", SkipAll);
-#else
MediaObject media;
media.setCurrentSource(QString(MEDIA_FILEPATH));
QVERIFY(media.state() != Phonon::ErrorState);
@@ -214,7 +211,6 @@ void tst_MediaObject::testPlayFromResource()
if (media.state() != Phonon::PlayingState)
QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000);
QCOMPARE(media.state(), Phonon::PlayingState);
-#endif
}
void tst_MediaObject::testPlayIllegalFile()
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index f358681..2cbb9b2 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -118,10 +118,12 @@ private slots:
void drawLine_task190634();
void drawLine_task229459();
void drawLine_task234891();
+ void drawHorizontalLineF();
void drawRect_data() { fillData(); }
void drawRect();
void drawRect2();
+ void drawRectFHorizontalLine();
void fillRect();
void fillRect2();
@@ -251,6 +253,7 @@ private slots:
void setPenColorOnPixmap();
void QTBUG5939_attachPainterPrivate();
+ void drawHorizontalLine();
private:
void fillData();
@@ -1218,6 +1221,26 @@ void tst_QPainter::drawLine_task234891()
QCOMPARE(expected, img);
}
+void tst_QPainter::drawHorizontalLineF()
+{
+ QPixmap pixmap(100, 3);
+ pixmap.fill();
+
+ {
+ QPainter painter(&pixmap);
+ painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f));
+ }
+
+ QImage refImage(100, 3, QImage::Format_ARGB32);
+ refImage.fill(0xFFFFFFFF);
+ {
+ QPainter painter(&refImage);
+ painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f));
+ }
+
+ QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage);
+}
+
void tst_QPainter::drawLine_task216948()
{
QImage img(1, 10, QImage::Format_ARGB32_Premultiplied);
@@ -1302,6 +1325,26 @@ void tst_QPainter::drawRect2()
}
}
+void tst_QPainter::drawRectFHorizontalLine()
+{
+ QPixmap pixmap(100, 3);
+ pixmap.fill();
+
+ {
+ QPainter painter(&pixmap);
+ painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f));
+ }
+
+ QImage refImage(100, 3, QImage::Format_ARGB32);
+ refImage.fill(0xFFFFFFFF);
+ {
+ QPainter painter(&refImage);
+ painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f));
+ }
+
+ QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage);
+}
+
void tst_QPainter::fillRect()
{
QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
@@ -4522,6 +4565,28 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate()
QCOMPARE(widget->deviceTransform, proxy->deviceTransform);
}
+void tst_QPainter::drawHorizontalLine()
+{
+ QPixmap pixmap(100, 3);
+ pixmap.fill();
+
+ {
+ QPainter painter(&pixmap);
+ painter.translate(0.3, 0.3);
+ painter.drawLine(QLine(1, 1, 99, 1));
+ }
+
+ QImage refImage(100, 3, QImage::Format_ARGB32);
+ refImage.fill(0xFFFFFFFF);
+ {
+ QPainter painter(&refImage);
+ painter.translate(0.3, 0.3);
+ painter.drawLine(QLine(1, 1, 99, 1));
+ }
+
+ QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage);
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"