summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-01 15:43:42 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-01 15:43:42 (GMT)
commite95d8b9bc027dee5cfd8a13afa0c9204607ad7f1 (patch)
treeac59ce25d31fe953355dca66421842af15b32b94 /tests
parent405ae4ef5382cd8ee0adfbe45c59c8d92e3ffdf6 (diff)
parent71547238ea4391636e37f5cf89905433faeb32d1 (diff)
downloadQt-e95d8b9bc027dee5cfd8a13afa0c9204607ad7f1.zip
Qt-e95d8b9bc027dee5cfd8a13afa0c9204607ad7f1.tar.gz
Qt-e95d8b9bc027dee5cfd8a13afa0c9204607ad7f1.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (51 commits) Symbian on Linux: $QTDIR/bin is not necessarily in the path. Updated Symbian def files with new EGL exports. Added another missing EGL stub. Fixed compilation on Symbian. Added missing EGL stub function. Got rid of unused variable compiler warning. QGLWindowSurface support for partial updates via EGL_NOK_swap_region2 Adding func prototypes for EGL_NOK_swap_region2 extension. Check for EGLSurface leak only when paint device is a QGLWidget. Fixed bug in drawTiledPixmap when width of pixmap matches target rect. Update def files for symbian Improved performance of 16 bit memrotates using NEON instructions. Use built-in iconv on Solaris if available Export various symbols needed to make a custom GL graphicssystem. Moc: fix compilation when templated types with multiple arguments are used. Fixes the documentation of QGraphicsEffect::update(). support BGRA textures on SGX Avoid calling time.elapsed() twice in abstract animation Adds slowdownFactor to UnifiedTimer in abstract animation Add the conversion in-place for QPixmap::fromImageReader() on raster. ...
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/moc/tst_moc.cpp19
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp54
-rw-r--r--tests/auto/qimage/tst_qimage.cpp4
-rw-r--r--tests/auto/qmenubar/tst_qmenubar.cpp29
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp2
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp16
-rw-r--r--tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha_animated.gifbin0 -> 4138 bytes
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp61
-rw-r--r--tests/benchmarks/opengl/main.cpp51
-rw-r--r--tests/manual/qtabletevent/regular_widgets/main.cpp150
-rw-r--r--tests/manual/qtabletevent/regular_widgets/regular_widgets.pro3
11 files changed, 381 insertions, 8 deletions
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index a56d842..19f3677 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -1322,6 +1322,25 @@ public slots:
void foo(struct const_ *) {};
};
+
+template<typename T1, typename T2>
+class TestTemplate2
+{
+};
+
+class QTBUG11647_constInTemplateParameter : public QObject
+{ Q_OBJECT
+public slots:
+ void testSlot(TestTemplate2<const int, const short*>) {}
+ void testSlot2(TestTemplate2<int, short const * const >) {}
+ void testSlot3(TestTemplate2<TestTemplate2 < const int, const short* > const *,
+ TestTemplate2< TestTemplate2 < void, int > , unsigned char *> > ) {}
+
+signals:
+ void testSignal(TestTemplate2<const int, const short*>);
+};
+
+
QTEST_APPLESS_MAIN(tst_Moc)
#include "tst_moc.moc"
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index fe68c8e..31a6845 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -442,6 +442,7 @@ private slots:
void updateMicroFocus();
void textItem_shortcuts();
void scroll();
+ void stopClickFocusPropagation();
// task specific tests below me
void task141694_textItemEnsureVisible();
@@ -10268,6 +10269,59 @@ void tst_QGraphicsItem::scroll()
QCOMPARE(item2->lastExposedRect, expectedItem2Expose);
}
+void tst_QGraphicsItem::stopClickFocusPropagation()
+{
+ class MyItem : public QGraphicsRectItem
+ {
+ public:
+ MyItem() : QGraphicsRectItem(0, 0, 100, 100) {}
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+ {
+ painter->fillRect(boundingRect(), hasFocus() ? QBrush(Qt::red) : brush());
+ }
+ };
+
+ QGraphicsScene scene(-50, -50, 400, 400);
+ scene.setStickyFocus(true);
+
+ QGraphicsRectItem *noFocusOnTop = new MyItem;
+ noFocusOnTop->setBrush(Qt::yellow);
+ noFocusOnTop->setFlag(QGraphicsItem::ItemStopsClickFocusPropagation);
+
+ QGraphicsRectItem *focusableUnder = new MyItem;
+ focusableUnder->setBrush(Qt::blue);
+ focusableUnder->setFlag(QGraphicsItem::ItemIsFocusable);
+ focusableUnder->setPos(50, 50);
+
+ QGraphicsRectItem *itemWithFocus = new MyItem;
+ itemWithFocus->setBrush(Qt::black);
+ itemWithFocus->setFlag(QGraphicsItem::ItemIsFocusable);
+ itemWithFocus->setPos(250, 10);
+
+ scene.addItem(noFocusOnTop);
+ scene.addItem(focusableUnder);
+ scene.addItem(itemWithFocus);
+ focusableUnder->stackBefore(noFocusOnTop);
+ itemWithFocus->setFocus();
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QApplication::setActiveWindow(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+ QVERIFY(itemWithFocus->hasFocus());
+
+ QPointF mousePressPoint = noFocusOnTop->mapToScene(QPointF());
+ mousePressPoint.rx() += 60;
+ mousePressPoint.ry() += 60;
+ const QList<QGraphicsItem *> itemsAtMousePressPosition = scene.items(mousePressPoint);
+ QVERIFY(itemsAtMousePressPosition.contains(focusableUnder));
+
+ sendMousePress(&scene, mousePressPoint);
+ QVERIFY(itemWithFocus->hasFocus());
+}
+
void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
{
struct Item : public QGraphicsTextItem
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index 16deb03..5052114 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -945,11 +945,11 @@ void tst_QImage::rotate()
const int n = original.colorTable().size();
for (int x = 0; x < w; ++x) {
original.setPixel(x, 0, x % n);
- original.setPixel(x,h - 1, n - (x % n));
+ original.setPixel(x, h - 1, n - (x % n) - 1);
}
for (int y = 0; y < h; ++y) {
original.setPixel(0, y, y % n);
- original.setPixel(w - 1, y, n - (y % n));
+ original.setPixel(w - 1, y, n - (y % n) - 1);
}
}
diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp
index 4cb63a1..cc9fb0c 100644
--- a/tests/auto/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/qmenubar/tst_qmenubar.cpp
@@ -168,6 +168,7 @@ private slots:
void task256322_highlight();
void menubarSizeHint();
void taskQTBUG4965_escapeEaten();
+ void taskQTBUG11823_crashwithInvisibleActions();
#if defined(QT3_SUPPORT)
void indexBasedInsertion_data();
@@ -1690,6 +1691,34 @@ void tst_QMenuBar::taskQTBUG4965_escapeEaten()
QTRY_VERIFY(!menubar.isVisible());
}
+void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions()
+{
+ QMenuBar menubar;
+ menubar.setNativeMenuBar(false); //we can't check the geometry of native menubars
+
+ QAction * m = menubar.addAction( "&m" );
+ QAction * a = menubar.addAction( "&a" );
+
+ menubar.show();
+ QApplication::setActiveWindow(&menubar);
+ QTest::qWaitForWindowShown(&menubar);
+ menubar.setActiveAction(m);
+ QCOMPARE(menubar.activeAction(), m);
+ QTest::keyClick(0, Qt::Key_Right);
+ QCOMPARE(menubar.activeAction(), a);
+ QTest::keyClick(0, Qt::Key_Right);
+ QCOMPARE(menubar.activeAction(), m);
+ a->setVisible(false);
+
+ menubar.setActiveAction(m);
+ QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed
+
+ //it used to crash here because the action is invisible
+ QTest::keyClick(0, Qt::Key_Right);
+ QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed
+}
+
+
#if defined(QT3_SUPPORT)
void tst_QMenuBar::indexBasedInsertion_data()
{
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index b6d4558..62416b1 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -740,6 +740,8 @@ void tst_QMetaObject::normalizedType_data()
QTest::newRow("template5") << "QList< ::Foo::Bar>" << "QList< ::Foo::Bar>";
QTest::newRow("template6") << "QList<::Foo::Bar>" << "QList<::Foo::Bar>";
QTest::newRow("template7") << "QList<QList<int> >" << "QList<QList<int> >";
+ QTest::newRow("template8") << "QMap<const int, const short*>" << "QMap<const int,const short*>";
+ QTest::newRow("template9") << "QPair<const QPair<int, int const *> , QPair<QHash<int, const char*> > >" << "QPair<const QPair<int,const int*>,QPair<QHash<int,const char*> > >";
QTest::newRow("value1") << "const QString &" << "QString";
QTest::newRow("value2") << "QString const &" << "QString";
QTest::newRow("constInName1") << "constconst" << "constconst";
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 701dc2e..27ee6e7 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -2648,12 +2648,16 @@ void tst_QPainter::setOpacity()
p.drawImage(imageRect, src, imageRect);
p.end();
- QImage expected(imageSize, destFormat);
- p.begin(&expected);
- p.fillRect(imageRect, QColor(127, 127, 127));
- p.end();
-
- QCOMPARE(dest, expected);
+ QImage actual = dest.convertToFormat(QImage::Format_RGB32);
+
+ for (int y = 0; y < actual.height(); ++y) {
+ QRgb *p = (QRgb *)actual.scanLine(y);
+ for (int x = 0; x < actual.width(); ++x) {
+ QVERIFY(qAbs(qRed(p[x]) - 127) <= 0xf);
+ QVERIFY(qAbs(qGreen(p[x]) - 127) <= 0xf);
+ QVERIFY(qAbs(qBlue(p[x]) - 127) <= 0xf);
+ }
+ }
}
void tst_QPainter::drawhelper_blend_untransformed_data()
diff --git a/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha_animated.gif b/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha_animated.gif
new file mode 100644
index 0000000..f813c05
--- /dev/null
+++ b/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha_animated.gif
Binary files differ
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 179f068..f22edf6 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -44,6 +44,7 @@
#include <qpixmap.h>
#include <qbitmap.h>
#include <qimage.h>
+#include <qimagereader.h>
#include <qmatrix.h>
#include <qdesktopwidget.h>
#include <qpaintengine.h>
@@ -175,6 +176,11 @@ private slots:
void loadFromDataImage_data();
void loadFromDataImage();
+ void fromImageReader_data();
+ void fromImageReader();
+
+ void fromImageReaderAnimatedGif();
+
void preserveDepth();
void splash_crash();
@@ -1577,6 +1583,61 @@ void tst_QPixmap::loadFromDataImage()
QVERIFY(pixmapsAreEqual(&pixmapWithCopy, &directLoadingPixmap));
}
+void tst_QPixmap::fromImageReader_data()
+{
+ QTest::addColumn<QString>("imagePath");
+#ifdef Q_OS_SYMBIAN
+ const QString prefix = QLatin1String(SRCDIR) + "loadFromData";
+#else
+ const QString prefix = QLatin1String(SRCDIR) + "/loadFromData";
+#endif
+ QTest::newRow("designer_argb32.png") << prefix + "/designer_argb32.png";
+ QTest::newRow("designer_indexed8_no_alpha.png") << prefix + "/designer_indexed8_no_alpha.png";
+ QTest::newRow("designer_indexed8_with_alpha.png") << prefix + "/designer_indexed8_with_alpha.png";
+ QTest::newRow("designer_rgb32.png") << prefix + "/designer_rgb32.png";
+ QTest::newRow("designer_indexed8_no_alpha.gif") << prefix + "/designer_indexed8_no_alpha.gif";
+ QTest::newRow("designer_indexed8_with_alpha.gif") << prefix + "/designer_indexed8_with_alpha.gif";
+ QTest::newRow("designer_rgb32.jpg") << prefix + "/designer_rgb32.jpg";
+}
+
+void tst_QPixmap::fromImageReader()
+{
+ QFETCH(QString, imagePath);
+
+ QImage imageRef(imagePath);
+ QPixmap pixmapWithCopy = QPixmap::fromImage(imageRef);
+
+ QImageReader imageReader(imagePath);
+
+ QPixmap directLoadingPixmap = QPixmap::fromImageReader(&imageReader);
+
+ QVERIFY(pixmapsAreEqual(&pixmapWithCopy, &directLoadingPixmap));
+}
+
+void tst_QPixmap::fromImageReaderAnimatedGif()
+{
+#ifdef Q_OS_SYMBIAN
+ const QString prefix = QLatin1String(SRCDIR) + "loadFromData";
+#else
+ const QString prefix = QLatin1String(SRCDIR) + "/loadFromData";
+#endif
+ const QString path = prefix + QString::fromLatin1("/designer_indexed8_with_alpha_animated.gif");
+
+ QImageReader referenceReader(path);
+ QImageReader pixmapReader(path);
+
+ Q_ASSERT(referenceReader.canRead());
+ Q_ASSERT(referenceReader.imageCount() > 1);
+
+ for (int i = 0; i < referenceReader.imageCount(); ++i) {
+ QImage refImage = referenceReader.read();
+ QPixmap refPixmap = QPixmap::fromImage(refImage);
+
+ QPixmap directLoadingPixmap = QPixmap::fromImageReader(&pixmapReader);
+ QVERIFY(pixmapsAreEqual(&refPixmap, &directLoadingPixmap));
+ }
+}
+
void tst_QPixmap::task_246446()
{
// This crashed without the bugfix in 246446
diff --git a/tests/benchmarks/opengl/main.cpp b/tests/benchmarks/opengl/main.cpp
index beb4d43..c042fce 100644
--- a/tests/benchmarks/opengl/main.cpp
+++ b/tests/benchmarks/opengl/main.cpp
@@ -75,6 +75,10 @@ private slots:
void gradients_data();
void gradients();
+ void textureUpload_data();
+ void textureUpload();
+
+
private:
QGLPixelBuffer *pb;
};
@@ -374,6 +378,53 @@ void OpenGLBench::gradients()
}
}
+void OpenGLBench::textureUpload_data()
+{
+ QTest::addColumn<int>("size");
+ QTest::addColumn<int>("flags");
+ QTest::addColumn<int>("format");
+
+ int sizes[] = { 8, 10, 16, 20, 32, 50, 64, 100, 128, 200, 256, 500, 512, 1000, 1024, 2000, 2048, -1 };
+ int flags[] = { QGLContext::InternalBindOption,
+ QGLContext::DefaultBindOption,
+ -1 };
+ int formats[] = { GL_RGB, GL_RGBA, -1 };
+
+ for (int s = 0; sizes[s] != -1; ++s) {
+ for (int f = 0; flags[f] != -1; ++f) {
+ for (int a = 0; formats[a] != -1; ++a) {
+ QByteArray name;
+ name.append("size=").append(QByteArray::number(sizes[s]));
+ name.append(", flags=").append(f == 0 ? "internal" : "default");
+ name.append(", format=").append(a == 0 ? "RGB" : "RGBA");
+ QTest::newRow(name.constData()) << sizes[s] << flags[f] << formats[a];
+ }
+ }
+ }
+}
+
+void OpenGLBench::textureUpload()
+{
+ QFETCH(int, size);
+ QFETCH(int, flags);
+ QFETCH(int, format);
+
+ QPixmap pixmap(size, size);
+
+ if (format == GL_RGB)
+ pixmap.fill(Qt::red);
+ else
+ pixmap.fill(Qt::transparent);
+
+ pb->makeCurrent();
+ QGLContext *context = const_cast<QGLContext *>(QGLContext::currentContext());
+ QTime time;
+
+ time.start();
+ context->bindTexture(pixmap, GL_TEXTURE_2D, format, (QGLContext::BindOptions) flags);
+ QTest::setBenchmarkResult(time.elapsed(), QTest::WalltimeMilliseconds);
+}
+
QTEST_MAIN(OpenGLBench)
#include "main.moc"
diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp
new file mode 100644
index 0000000..a39e094
--- /dev/null
+++ b/tests/manual/qtabletevent/regular_widgets/main.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QDebug>
+#include <QMouseEvent>
+#include <QTabletEvent>
+#include <QWidget>
+
+class EventReportWidget : public QWidget
+{
+public:
+ EventReportWidget();
+protected:
+ void mouseDoubleClickEvent(QMouseEvent *event) { outputMouseEvent(event); }
+ void mouseMoveEvent(QMouseEvent *event) { outputMouseEvent(event); }
+ void mousePressEvent(QMouseEvent *event) { outputMouseEvent(event); }
+ void mouseReleaseEvent(QMouseEvent *event) { outputMouseEvent(event); }
+
+ void tabletEvent(QTabletEvent *);
+
+private:
+ void outputMouseEvent(QMouseEvent *event);
+
+ bool m_lastIsMouseMove;
+ bool m_lastIsTabletMove;
+};
+
+EventReportWidget::EventReportWidget()
+ : m_lastIsMouseMove(false)
+ , m_lastIsTabletMove(false)
+{ }
+
+void EventReportWidget::tabletEvent(QTabletEvent *event)
+{
+ QWidget::tabletEvent(event);
+
+ QString type;
+ switch (event->type()) {
+ case QEvent::TabletEnterProximity:
+ m_lastIsTabletMove = false;
+ type = QString::fromLatin1("TabletEnterProximity");
+ break;
+ case QEvent::TabletLeaveProximity:
+ m_lastIsTabletMove = false;
+ type = QString::fromLatin1("TabletLeaveProximity");
+ break;
+ case QEvent::TabletMove:
+ if (m_lastIsTabletMove)
+ return;
+
+ m_lastIsTabletMove = true;
+ type = QString::fromLatin1("TabletMove");
+ break;
+ case QEvent::TabletPress:
+ m_lastIsTabletMove = false;
+ type = QString::fromLatin1("TabletPress");
+ break;
+ case QEvent::TabletRelease:
+ m_lastIsTabletMove = false;
+ type = QString::fromLatin1("TabletRelease");
+ break;
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+
+ qDebug() << "Tablet event, type = " << type
+ << " position = " << event->pos()
+ << " global position = " << event->globalPos();
+}
+
+void EventReportWidget::outputMouseEvent(QMouseEvent *event)
+{
+ QString type;
+ switch (event->type()) {
+ case QEvent::MouseButtonDblClick:
+ m_lastIsMouseMove = false;
+ type = QString::fromLatin1("MouseButtonDblClick");
+ break;
+ case QEvent::MouseButtonPress:
+ m_lastIsMouseMove = false;
+ type = QString::fromLatin1("MouseButtonPress");
+ break;
+ case QEvent::MouseButtonRelease:
+ m_lastIsMouseMove = false;
+ type = QString::fromLatin1("MouseButtonRelease");
+ break;
+ case QEvent::MouseMove:
+ if (m_lastIsMouseMove)
+ return; // only show one move to keep things readable
+
+ m_lastIsMouseMove = true;
+ type = QString::fromLatin1("MouseMove");
+ break;
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+
+ qDebug() << "Mouse event, type = " << type
+ << " position = " << event->pos()
+ << " global position = " << event->globalPos();
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ EventReportWidget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro b/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro
new file mode 100644
index 0000000..9f0da76
--- /dev/null
+++ b/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro
@@ -0,0 +1,3 @@
+TEMPLATE = app
+
+SOURCES += main.cpp