summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-06-08 10:02:23 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-06-08 10:02:23 (GMT)
commit03dc74984749adf5b11482bf871a47086217845c (patch)
tree58eaa299c0d87d6d678fe635fddaab42177328cf /tests/auto
parentdfd7c876263310c03d8b64033749efe2b6b1e081 (diff)
parent0cd433404210fdaa6b21a98ef5768c9b761ed024 (diff)
downloadQt-03dc74984749adf5b11482bf871a47086217845c.zip
Qt-03dc74984749adf5b11482bf871a47086217845c.tar.gz
Qt-03dc74984749adf5b11482bf871a47086217845c.tar.bz2
Merge remote branch 'origin/4.6' into qt-4.7-from-4.6
Conflicts: src/3rdparty/webkit/VERSION src/3rdparty/webkit/WebCore/ChangeLog src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp src/3rdparty/webkit/WebKit/qt/ChangeLog src/gui/painting/qpainter.cpp src/gui/painting/qtextureglyphcache.cpp src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h src/s60installs/bwins/QtGuiu.def src/s60installs/eabi/QtCoreu.def src/s60installs/eabi/QtGuiu.def src/s60installs/eabi/QtNetworku.def src/s60installs/eabi/QtOpenVGu.def tests/auto/qfontmetrics/tst_qfontmetrics.cpp tools/linguist/lupdate/main.cpp
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/cmdline_order/a.h42
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/cmdline_order/b.h44
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/cmdline_order/lupdatecmd1
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/cmdline_order/project.ts.result20
-rw-r--r--tests/auto/qfontmetrics/tst_qfontmetrics.cpp12
-rw-r--r--tests/auto/qhash/tst_qhash.cpp20
-rw-r--r--tests/auto/qmap/tst_qmap.cpp20
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp258
8 files changed, 397 insertions, 20 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_order/a.h b/tests/auto/linguist/lupdate/testdata/good/cmdline_order/a.h
new file mode 100644
index 0000000..7059132
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_order/a.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** 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 test suite 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$
+**
+****************************************************************************/
+
+#define XX QT_TRANSLATE_NOOP("aaa", "some text")
diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_order/b.h b/tests/auto/linguist/lupdate/testdata/good/cmdline_order/b.h
new file mode 100644
index 0000000..ce3e1a2
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_order/b.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** 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 test suite 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 "a.h"
+
+#define YY QT_TRANSLATE_NOOP("bbb", "some text")
diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_order/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/cmdline_order/lupdatecmd
new file mode 100644
index 0000000..edd91f7
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_order/lupdatecmd
@@ -0,0 +1 @@
+lupdate b.h a.h -ts project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_order/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/cmdline_order/project.ts.result
new file mode 100644
index 0000000..6028cbb
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_order/project.ts.result
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>aaa</name>
+ <message>
+ <location filename="a.h" line="42"/>
+ <source>some text</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>bbb</name>
+ <message>
+ <location filename="b.h" line="44"/>
+ <source>some text</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
index 2567a41..a22d624 100644
--- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
@@ -74,7 +74,6 @@ private slots:
void bypassShaping();
void elidedMultiLength();
void elidedMultiLengthF();
- void bearingIncludedInBoundingRect();
};
tst_QFontMetrics::tst_QFontMetrics()
@@ -267,16 +266,5 @@ void tst_QFontMetrics::elidedMultiLengthF()
elidedMultiLength_helper<QFontMetricsF>();
}
-void tst_QFontMetrics::bearingIncludedInBoundingRect()
-{
- QFont font;
- font.setItalic(true);
- QRect brectItalic = QFontMetrics(font).boundingRect("ITALIC");
- font.setItalic(false);
- QRect brectNormal = QFontMetrics(font).boundingRect("ITALIC");
-
- QVERIFY(brectItalic.width() >= brectNormal.width());
-}
-
QTEST_MAIN(tst_QFontMetrics)
#include "tst_qfontmetrics.moc"
diff --git a/tests/auto/qhash/tst_qhash.cpp b/tests/auto/qhash/tst_qhash.cpp
index 59576d9..3a7b54a 100644
--- a/tests/auto/qhash/tst_qhash.cpp
+++ b/tests/auto/qhash/tst_qhash.cpp
@@ -1154,6 +1154,26 @@ void tst_QHash::qmultihash_specific()
QVERIFY(i.key() == 9);
QVERIFY(i.value() == 98);
}
+
+ {
+ QMultiHash<int, int> map1;
+ map1.insert(42, 1);
+ map1.insert(10, 2);
+ map1.insert(48, 3);
+ QMultiHash<int, int> map2;
+ map2.insert(8, 4);
+ map2.insert(42, 5);
+ map2.insert(95, 12);
+
+ map1+=map2;
+ map2.insert(42, 1);
+ map2.insert(10, 2);
+ map2.insert(48, 3);
+ QCOMPARE(map1.count(), map2.count());
+ QVERIFY(map1.remove(42,5));
+ QVERIFY(map2.remove(42,5));
+ QVERIFY(map1 == map2);
+ }
}
template <typename T>
diff --git a/tests/auto/qmap/tst_qmap.cpp b/tests/auto/qmap/tst_qmap.cpp
index d3ed76d..a1b8de7 100644
--- a/tests/auto/qmap/tst_qmap.cpp
+++ b/tests/auto/qmap/tst_qmap.cpp
@@ -837,6 +837,26 @@ void tst_QMap::qmultimap_specific()
QVERIFY(i.key() == 9);
QVERIFY(i.value() == 98);
}
+
+ {
+ QMultiMap<int, int> map1;
+ map1.insert(42, 1);
+ map1.insert(10, 2);
+ map1.insert(48, 3);
+ QMultiMap<int, int> map2;
+ map2.insert(8, 4);
+ map2.insert(42, 5);
+ map2.insert(95, 12);
+
+ map1+=map2;
+ map2.insert(42, 1);
+ map2.insert(10, 2);
+ map2.insert(48, 3);
+ QCOMPARE(map1.count(), map2.count());
+ QVERIFY(map1.remove(42,5));
+ QVERIFY(map2.remove(42,5));
+ QVERIFY(map1 == map2);
+ }
}
QTEST_APPLESS_MAIN(tst_QMap)
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 5d47aed..a1fc607 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -385,6 +385,7 @@ private slots:
void setGraphicsEffect();
void destroyBackingStore();
+ void destroyBackingStoreWhenHidden();
void activateWindow();
@@ -9499,9 +9500,7 @@ void tst_QWidget::destroyBackingStore()
QTRY_VERIFY(w.numPaintEvents > 0);
w.reset();
w.update();
- delete qt_widget_private(&w)->topData()->backingStore;
- qt_widget_private(&w)->topData()->backingStore = 0;
- qt_widget_private(&w)->topData()->backingStore = new QWidgetBackingStore(&w);
+ qt_widget_private(&w)->topData()->backingStore.create(&w);
w.update();
QApplication::processEvents();
@@ -9519,6 +9518,252 @@ void tst_QWidget::destroyBackingStore()
#endif
}
+// Helper function
+QWidgetBackingStore* backingStore(QWidget &widget)
+{
+ QWidgetBackingStore *backingStore = 0;
+#ifdef QT_BUILD_INTERNAL
+ if (QTLWExtra *topExtra = qt_widget_private(&widget)->maybeTopData())
+ backingStore = topExtra->backingStore.data();
+#endif
+ return backingStore;
+}
+
+// Wait for a condition to be true, timing out after 1 second
+// This is used following calls to QWidget::show() and QWidget::hide(), which are
+// expected to asynchronously trigger native window visibility events.
+#define WAIT_AND_VERIFY(condition) \
+ do { \
+ QTime start = QTime::currentTime(); \
+ while (!(condition) && (start.elapsed() < 1000)) { \
+ qApp->processEvents(); \
+ QTest::qWait(50); \
+ } \
+ if (!QTest::qVerify((condition), #condition, "", __FILE__, __LINE__)) \
+ return; \
+ } while (0)
+
+void tst_QWidget::destroyBackingStoreWhenHidden()
+{
+#ifndef QT_BUILD_INTERNAL
+ QSKIP("Test step requires access to Q_AUTOTEST_EXPORT", SkipAll);
+#endif
+
+#ifndef Q_OS_SYMBIAN
+ QSKIP("Only Symbian destroys backing store when native window becomes invisible", SkipAll);
+#endif
+
+ testWidget->hide();
+ QTest::qWait(1000);
+
+ // 1. Single top-level QWidget
+ {
+ QWidget w;
+ w.setAutoFillBackground(true);
+ w.setPalette(Qt::yellow);
+ w.setGeometry(0, 0, 100, 100);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ QVERIFY(0 != backingStore(w));
+
+ w.hide();
+ WAIT_AND_VERIFY(0 == backingStore(w));
+
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ QVERIFY(0 != backingStore(w));
+ }
+
+ // 2. Two top-level widgets
+ {
+ QWidget w1;
+ w1.setGeometry(0, 0, 100, 100);
+ w1.setAutoFillBackground(true);
+ w1.setPalette(Qt::red);
+ w1.show();
+ QTest::qWaitForWindowShown(&w1);
+ QVERIFY(0 != backingStore(w1));
+
+ QWidget w2;
+ w2.setGeometry(w1.geometry());
+ w1.setAutoFillBackground(true);
+ w1.setPalette(Qt::blue);
+ w2.show();
+ QTest::qWaitForWindowShown(&w2);
+ QVERIFY(0 != backingStore(w2));
+
+ // Check that w1 deleted its backing store when obscured by w2
+ QVERIFY(0 == backingStore(w1));
+
+ w2.move(w2.pos() + QPoint(10, 10));
+
+ // Check that w1 recreates its backing store when partially revealed
+ WAIT_AND_VERIFY(0 != backingStore(w1));
+ }
+
+ // 3. Native child widget
+ {
+ QWidget parent;
+ parent.setGeometry(0, 0, 100, 100);
+ parent.setAutoFillBackground(true);
+ parent.setPalette(Qt::yellow);
+
+ QWidget child(&parent);
+ child.setAutoFillBackground(true);
+ child.setPalette(Qt::green);
+
+ QVBoxLayout layout(&parent);
+ layout.setContentsMargins(10, 10, 10, 10);
+ layout.addWidget(&child);
+ parent.setLayout(&layout);
+
+ child.winId();
+
+ parent.show();
+ QTest::qWaitForWindowShown(&parent);
+
+ // Check that child window does not obscure parent window
+ QVERIFY(!parent.visibleRegion().subtracted(child.visibleRegion()).isEmpty());
+
+ // Native child widget should share parent's backing store
+ QWidgetBackingStore *const parentBs = backingStore(parent);
+ QVERIFY(0 != parentBs);
+ QVERIFY(0 == backingStore(child));
+
+ // Set margins to zero so that child widget totally obscures parent
+ layout.setContentsMargins(0, 0, 0, 0);
+
+ WAIT_AND_VERIFY(parent.visibleRegion().subtracted(child.visibleRegion()).isEmpty());
+
+ // Backing store should remain unchanged despite child window obscuring
+ // parent window
+ QVERIFY(parentBs == backingStore(parent));
+ QVERIFY(0 == backingStore(child));
+ }
+
+ // 4. Alien child widget which is made full-screen
+ {
+ QWidget parent;
+ parent.setGeometry(0, 0, 100, 100);
+ parent.setAutoFillBackground(true);
+ parent.setPalette(Qt::red);
+
+ QWidget child(&parent);
+ child.setAutoFillBackground(true);
+ child.setPalette(Qt::blue);
+
+ QVBoxLayout layout(&parent);
+ layout.setContentsMargins(10, 10, 10, 10);
+ layout.addWidget(&child);
+ parent.setLayout(&layout);
+
+ parent.show();
+ QTest::qWaitForWindowShown(&parent);
+
+ // Check that child window does not obscure parent window
+ QVERIFY(!parent.visibleRegion().subtracted(child.visibleRegion()).isEmpty());
+
+ // Native child widget should share parent's backing store
+ QVERIFY(0 != backingStore(parent));
+ QVERIFY(0 == backingStore(child));
+
+ // Make child widget full screen
+ child.setWindowFlags((child.windowFlags() | Qt::Window) ^ Qt::SubWindow);
+ child.setWindowState(child.windowState() | Qt::WindowFullScreen);
+ child.show();
+ QTest::qWaitForWindowShown(&child);
+
+ // Check that child window obscures parent window
+ QVERIFY(parent.visibleRegion().subtracted(child.visibleRegion()).isEmpty());
+
+ // Now that extent of child widget goes beyond parent's extent,
+ // a new backing store should be created for the child widget.
+ QVERIFY(0 != backingStore(child));
+
+ // Parent is obscured, therefore its backing store should be destroyed
+ QVERIFY(0 == backingStore(parent));
+
+ // Disable full screen
+ child.setWindowFlags(child.windowFlags() ^ (Qt::Window | Qt::SubWindow));
+ child.setWindowState(child.windowState() ^ Qt::WindowFullScreen);
+ child.show();
+ QTest::qWaitForWindowShown(&child);
+
+ // Check that parent is now visible again
+ QVERIFY(!parent.visibleRegion().subtracted(child.visibleRegion()).isEmpty());
+
+ // Native child widget should once again share parent's backing store
+ QVERIFY(0 != backingStore(parent));
+ QEXPECT_FAIL("", "QTBUG-10643", Continue);
+ QVERIFY(0 == backingStore(child));
+ }
+
+ // 5. Native child widget which is made full-screen
+ {
+ QWidget parent;
+ parent.setGeometry(0, 0, 100, 100);
+ parent.setAutoFillBackground(true);
+ parent.setPalette(Qt::red);
+
+ QWidget child(&parent);
+ child.setAutoFillBackground(true);
+ child.setPalette(Qt::blue);
+
+ QVBoxLayout layout(&parent);
+ layout.setContentsMargins(10, 10, 10, 10);
+ layout.addWidget(&child);
+ parent.setLayout(&layout);
+
+ child.winId();
+
+ parent.show();
+ QTest::qWaitForWindowShown(&parent);
+
+ // Check that child window does not obscure parent window
+ QVERIFY(!parent.visibleRegion().subtracted(child.visibleRegion()).isEmpty());
+
+ // Native child widget should share parent's backing store
+ QVERIFY(0 != backingStore(parent));
+ QVERIFY(0 == backingStore(child));
+
+ // Make child widget full screen
+ child.setWindowFlags((child.windowFlags() | Qt::Window) ^ Qt::SubWindow);
+ child.setWindowState(child.windowState() | Qt::WindowFullScreen);
+ child.show();
+ QTest::qWaitForWindowShown(&child);
+
+ // Ensure that 'window hidden' event is received by parent
+ qApp->processEvents();
+
+ // Check that child window obscures parent window
+ QVERIFY(parent.visibleRegion().subtracted(child.visibleRegion()).isEmpty());
+
+ // Now that extent of child widget goes beyond parent's extent,
+ // a new backing store should be created for the child widget.
+ QVERIFY(0 != backingStore(child));
+
+ // Parent is obscured, therefore its backing store should be destroyed
+ QEXPECT_FAIL("", "QTBUG-10643", Continue);
+ QVERIFY(0 == backingStore(parent));
+
+ // Disable full screen
+ child.setWindowFlags(child.windowFlags() ^ (Qt::Window | Qt::SubWindow));
+ child.setWindowState(child.windowState() ^ Qt::WindowFullScreen);
+ child.show();
+ QTest::qWaitForWindowShown(&child);
+
+ // Check that parent is now visible again
+ QVERIFY(!parent.visibleRegion().subtracted(child.visibleRegion()).isEmpty());
+
+ // Native child widget should once again share parent's backing store
+ QVERIFY(0 != backingStore(parent));
+ QEXPECT_FAIL("", "QTBUG-10643", Continue);
+ QVERIFY(0 == backingStore(child));
+ }
+}
+
+#undef WAIT_AND_VERIFY
+
void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
{
#ifdef Q_OS_WINCE_WM
@@ -10000,15 +10245,12 @@ class scrollWidgetWBS : public QWidget
public:
void deleteBackingStore()
{
- if (static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) {
- delete static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore;
- static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = 0;
- }
+ static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore.destroy();
}
void enableBackingStore()
{
if (!static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) {
- static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = new QWidgetBackingStore(this);
+ static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore.create(this);
static_cast<QWidgetPrivate*>(d_ptr.data())->invalidateBuffer(this->rect());
repaint();
}