summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-06-22 22:15:40 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-06-22 22:15:40 (GMT)
commit00062150f61f5930a158594583a564d659232216 (patch)
tree2d1685fa729bcac9c08fdd43b5c2436d6ad1d342 /tests/auto
parentf28990edd2c95f4382d661e4731d06060bb11b39 (diff)
parent14f10211e72f2d04fa7f4e0faa430eb94c1f8f83 (diff)
downloadQt-00062150f61f5930a158594583a564d659232216.zip
Qt-00062150f61f5930a158594583a564d659232216.tar.gz
Qt-00062150f61f5930a158594583a564d659232216.tar.bz2
Merge branch 'qt-4.8-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration into master-integration
* 'qt-4.8-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration: Fix crash in PropertyChanges. Scroll correctly when cursorPosition is changed within onTextChanged. Fixing OpenGL module build error on Solaris Fix dialog position adjustment regression in Symbian SSL readbuffer 16->32 kB Fixes to how resize event and layout request are posted. Limit the cookies count per domain to 50. Add missing freeTexture() from fix for QTBUG-19180 Last word inputted was duplicated after input method hints changed Simplify texture pooling logic in GL graphics system. Fixed move a QGraphicsWidget and invalidate its layout at the same time Fix infinite recursion when changing geometry on Mac
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp265
-rw-r--r--tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp41
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp14
3 files changed, 300 insertions, 20 deletions
diff --git a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp
index d5d56fc..cd91008 100644
--- a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -63,6 +63,14 @@ private slots:
void automaticReparenting();
void verifyActivate();
void invalidate();
+ void moveAndResize_data();
+ void moveAndResize();
+ void moveAndResizeWidgetInWidget_data();
+ void moveAndResizeWidgetInWidget();
+ void changingMinimumSize_data();
+ void changingMinimumSize();
+ void invalidateAndMove_data();
+ void invalidateAndMove();
void constructors();
void alternativeLayoutItems();
void ownership();
@@ -443,7 +451,7 @@ void tst_QGraphicsLayout::invalidate()
QCoreApplication::sendPostedEvents();
QCOMPARE(a->eventCount(QEvent::LayoutRequest), 1);
QCOMPARE(b->eventCount(QEvent::LayoutRequest), 0);
- QCOMPARE(c->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(c->eventCount(QEvent::GraphicsSceneResize), 1);
QCOMPARE(d->eventCount(QEvent::LayoutRequest), 0);
QCOMPARE(a->functionCount[SetGeometry], 1);
@@ -479,30 +487,18 @@ void tst_QGraphicsLayout::invalidate()
QCOMPARE(c->eventCount(QEvent::LayoutRequest), 0);
QCoreApplication::sendPostedEvents();
- QCOMPARE(a->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(a->eventCount(QEvent::GraphicsSceneResize), 1);
QCOMPARE(b->eventCount(QEvent::LayoutRequest), 0);
- QCOMPARE(c->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(c->eventCount(QEvent::GraphicsSceneResize), 1);
QCOMPARE(d->eventCount(QEvent::LayoutRequest), 0);
QCOMPARE(a->functionCount[SetGeometry], 1);
- /* well, ideally one call to setGeometry(), but it will currently
- * get two calls to setGeometry():
- * 1. The first LayoutRequest will call activate() - that will call
- * setGeometry() on the layout. This geometry will be based on
- * the widget geometry which is not correct at this moment.
- * (it is still 150 wide)
- * 2. Next, we check if the widget is top level, and then we call
- * parentWidget->resize(parentWidget->size());
- * This will be adjusted to be minimum 200 pixels wide.
- * The new size will then be propagated down to the layout
- *
- */
- QCOMPARE(alay->functionCount[SetGeometry], 2);
-
- QCOMPARE(b->functionCount[SetGeometry], 2);
- QCOMPARE(c->functionCount[SetGeometry], 2);
- QCOMPARE(d->functionCount[SetGeometry], 2);
+ QCOMPARE(alay->functionCount[SetGeometry], 1);
+
+ QCOMPARE(b->functionCount[SetGeometry], 1);
+ QCOMPARE(c->functionCount[SetGeometry], 1);
+ QCOMPARE(d->functionCount[SetGeometry], 1);
// f actually got wider, need to rearrange its siblings
QCOMPARE(blay->functionCount[SetGeometry], 1);
QCOMPARE(clay->functionCount[SetGeometry], 1);
@@ -555,7 +551,236 @@ void tst_QGraphicsLayout::invalidate()
QGraphicsLayout::setInstantInvalidatePropagation(false);
}
+void tst_QGraphicsLayout::changingMinimumSize_data()
+{
+ QTest::addColumn<bool>("instantInvalidatePropagation");
+ QTest::newRow("Without instantInvalidatePropagation") << false;
+ QTest::newRow("With instantInvalidatePropagation") << true;
+}
+void tst_QGraphicsLayout::changingMinimumSize()
+{
+ QFETCH(bool, instantInvalidatePropagation);
+ QGraphicsLayout::setInstantInvalidatePropagation(instantInvalidatePropagation);
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ qApp->processEvents();
+ widget->setMinimumSize(300,300);
+ qApp->processEvents();
+ QCOMPARE(widget->size(), QSizeF(300,300));
+ QGraphicsLayout::setInstantInvalidatePropagation(false);
+}
+
+struct WidgetToTestResizeEvents : public QGraphicsWidget
+{
+ virtual void resizeEvent ( QGraphicsSceneResizeEvent * event )
+ {
+ QGraphicsWidget::resizeEvent(event);
+ resizeEventCalled = true;
+ }
+
+ bool resizeEventCalled;
+};
+
+void tst_QGraphicsLayout::moveAndResizeWidgetInWidget_data()
+{
+ QTest::addColumn<bool>("instantInvalidatePropagation");
+
+ QTest::newRow("Without instantInvalidatePropagation") << false;
+ QTest::newRow("With instantInvalidatePropagation") << true;
+}
+void tst_QGraphicsLayout::moveAndResizeWidgetInWidget()
+{
+ QFETCH(bool, instantInvalidatePropagation);
+ QGraphicsLayout::setInstantInvalidatePropagation(instantInvalidatePropagation);
+ QGraphicsScene scene;
+
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(widget);
+ layout->setContentsMargins(0,0,0,0);
+ WidgetToTestResizeEvents *innerWidget = new WidgetToTestResizeEvents;
+ QGraphicsLinearLayout *innerLayout = new QGraphicsLinearLayout(innerWidget);
+ innerLayout->setContentsMargins(0,0,0,0);
+ QCOMPARE(widget->maximumSize(), QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
+ layout->addItem(innerWidget);
+ widget->setMinimumSize(1,1);
+ widget->setPreferredSize(1000,1000);
+ widget->setMaximumSize(2000,2000);
+ widget->resize(widget->preferredSize());
+ innerWidget->setMinimumSize(1,1);
+ qApp->processEvents();
+ innerWidget->resizeEventCalled = false;
+
+ QCOMPARE(widget->size(), QSizeF(1000, 1000));
+ QCOMPARE(layout->geometry().size(), QSizeF(1000, 1000));
+ QCOMPARE(innerWidget->size(), QSizeF(1000, 1000));
+
+ innerLayout->invalidate();
+ widget->setMaximumHeight(500);
+ widget->setX(1);
+ qApp->processEvents();
+ QCOMPARE(widget->size(), QSizeF(1000, 500));
+ QCOMPARE(innerWidget->size(), QSizeF(1000, 500));
+ QVERIFY(innerWidget->resizeEventCalled);
+}
+void tst_QGraphicsLayout::moveAndResize_data()
+{
+ QTest::addColumn<bool>("instantInvalidatePropagation");
+ QTest::addColumn<bool>("insideLayout");
+ QTest::addColumn<bool>("insideLayoutInLayout");
+ QTest::addColumn<bool>("insideWidget");
+ QTest::newRow("Without instantInvalidatePropagation") << false << false << false << false;
+ QTest::newRow("With instantInvalidatePropagation") << true << false << false << false;
+ QTest::newRow("Without instantInvalidatePropagation, inside widget with no layout") << false << false << false << true;
+ QTest::newRow("With instantInvalidatePropagation, inside widget with no layout") << true << false << false << true;
+ QTest::newRow("Without instantInvalidatePropagation, inside widget with layout") << false << true << false << true;
+ QTest::newRow("With instantInvalidatePropagation, inside widget with layout") << true << true << false << true;
+ QTest::newRow("Without instantInvalidatePropagation, inside widget with layout in layout") << false << true << true << true;
+ QTest::newRow("With instantInvalidatePropagation, inside widget with layout in layout") << true << true << true << true;
+
+}
+void tst_QGraphicsLayout::moveAndResize()
+{
+ QFETCH(bool, instantInvalidatePropagation);
+ QFETCH(bool, insideLayout);
+ QFETCH(bool, insideLayoutInLayout);
+ QFETCH(bool, insideWidget);
+ QGraphicsLayout::setInstantInvalidatePropagation(instantInvalidatePropagation);
+ QGraphicsScene scene;
+
+ WidgetToTestResizeEvents *widget = new WidgetToTestResizeEvents;
+
+ /* Setup its parent if we want them */
+ QGraphicsWidget *parent = NULL;
+ if (insideWidget)
+ parent = new QGraphicsWidget;
+ if (insideLayout) {
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(parent);
+ QGraphicsLinearLayout *innerLayout = NULL;
+ if (insideLayoutInLayout) {
+ innerLayout = new QGraphicsLinearLayout;
+ layout->addItem(innerLayout);
+ innerLayout->addItem(widget);
+ } else
+ layout->addItem(widget);
+ } else if (insideWidget) {
+ widget->setParentItem(parent);
+ }
+
+ new QGraphicsLinearLayout(widget);
+ widget->setGeometry(0,0,100,100);
+ qApp->processEvents();
+ widget->resizeEventCalled = false;
+
+ /* Force it grow by changing the minimum size */
+ widget->setMinimumSize(200,200);
+ qApp->processEvents();
+ qApp->processEvents();
+ qApp->processEvents();
+ QCOMPARE(widget->size(), QSizeF(200,200));
+ QVERIFY(widget->resizeEventCalled);
+ widget->resizeEventCalled = false;
+
+ /* Call setPos followed by a resize. We should get a resize event */
+ widget->setPos(10,10);
+ widget->resize(300,300);
+ qApp->processEvents();
+ QVERIFY(widget->resizeEventCalled);
+ widget->resizeEventCalled = false;
+
+ /* Check that just calling setGeometry gives us a resize event */
+ widget->setGeometry(10,10, 400, 400);
+ qApp->processEvents();
+ QVERIFY(widget->resizeEventCalled);
+ widget->resizeEventCalled = false;
+
+ /* Now call setPos followed by increasing the size using setGeometry,*/
+ widget->setPos(30,30);
+ widget->setGeometry(10,10, 500, 500);
+ qApp->processEvents();
+ QVERIFY(widget->resizeEventCalled);
+ widget->resizeEventCalled = false;
+
+ /* Now call setPos followed by increasing the minimum size, to force it to grow */
+ widget->setMinimumSize(600,600);
+ widget->setPos(30,30);
+ qApp->processEvents();
+ QCOMPARE(widget->size(), QSizeF(600,600));
+ QVERIFY(widget->resizeEventCalled);
+ widget->resizeEventCalled = false;
+
+ QGraphicsLayout::setInstantInvalidatePropagation(false);
+}
+void tst_QGraphicsLayout::invalidateAndMove_data()
+{
+ QTest::addColumn<bool>("instantInvalidatePropagation");
+ QTest::newRow("Without instantInvalidatePropagation") << false;
+ QTest::newRow("With instantInvalidatePropagation") << true;
+
+}
+void tst_QGraphicsLayout::invalidateAndMove()
+{
+ // Check that if we set the position of an item and invalidate its layout at the same
+ // time, the widget keeps its correct size
+ QFETCH(bool, instantInvalidatePropagation);
+ QGraphicsLayout::setInstantInvalidatePropagation(instantInvalidatePropagation);
+ QGraphicsScene scene;
+
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ new QGraphicsLinearLayout(widget);
+
+ widget->setMinimumSize(1,1);
+ widget->setPreferredSize(34,34);
+ widget->setMaximumSize(100,100);
+ widget->resize(widget->preferredSize());
+
+ scene.addItem(widget);
+
+ qApp->processEvents();
+
+ /* Invalidate and reactivate. The size should not have changed */
+ widget->layout()->invalidate();
+ widget->layout()->activate();
+
+ QCOMPARE(widget->geometry().size(), widget->preferredSize());
+ QCOMPARE(widget->layout()->geometry().size(), widget->preferredSize());
+ qApp->processEvents();
+ QCOMPARE(widget->geometry().size(), widget->preferredSize());
+ QCOMPARE(widget->layout()->geometry().size(), widget->preferredSize());
+
+ widget->layout()->invalidate();
+ widget->setX(1); //Change just the position using setX
+ QCOMPARE(widget->geometry().size(), widget->preferredSize());
+ QCOMPARE(widget->layout()->geometry().size(), widget->preferredSize());
+ qApp->processEvents();
+ QCOMPARE(widget->geometry().size(), widget->preferredSize());
+ QCOMPARE(widget->layout()->geometry().size(), widget->preferredSize());
+
+ widget->layout()->invalidate();
+ widget->setGeometry(1,1,34,34); //Change just the position using setGeometry
+ QCOMPARE(widget->geometry().size(), widget->preferredSize());
+ QCOMPARE(widget->layout()->geometry().size(), widget->preferredSize());
+ qApp->processEvents();
+ QCOMPARE(widget->geometry().size(), widget->preferredSize());
+ QCOMPARE(widget->layout()->geometry().size(), widget->preferredSize());
+
+ widget->layout()->invalidate();
+ widget->setGeometry(1,1,60,60); //Change just the size using setGeometry
+ QCOMPARE(widget->geometry().size(), QSizeF(60,60));
+ QCOMPARE(widget->layout()->geometry().size(), QSizeF(60,60));
+ qApp->processEvents();
+ QCOMPARE(widget->geometry().size(), QSizeF(60,60));
+ QCOMPARE(widget->layout()->geometry().size(), QSizeF(60,60));
+
+ widget->layout()->invalidate();
+ widget->setGeometry(0,0,34,34); //Change the size and position using setGeometry
+ QCOMPARE(widget->geometry().size(), widget->preferredSize());
+ QCOMPARE(widget->layout()->geometry().size(), widget->preferredSize());
+ qApp->processEvents();
+ QCOMPARE(widget->geometry().size(), widget->preferredSize());
+ QCOMPARE(widget->layout()->geometry().size(), widget->preferredSize());
+
+ QGraphicsLayout::setInstantInvalidatePropagation(false);
+}
class Layout : public QGraphicsLayout
{
public:
diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index 1b4256b..d1c376a 100644
--- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -52,6 +52,7 @@ private slots:
void getterSetter();
void setCookiesFromUrl_data();
void setCookiesFromUrl();
+ void setCookiesFromUrl_50CookiesLimitPerDomain();
void cookiesForUrl_data();
void cookiesForUrl();
void effectiveTLDs_data();
@@ -251,6 +252,46 @@ void tst_QNetworkCookieJar::setCookiesFromUrl()
QVERIFY2(result.isEmpty(), QTest::toString(result));
}
+static bool findCookieName(const QList<QNetworkCookie> &cookieList, const QString &name)
+{
+ foreach(QNetworkCookie cookie, cookieList)
+ if (cookie.name() == name)
+ return true;
+ return false;
+}
+
+void tst_QNetworkCookieJar::setCookiesFromUrl_50CookiesLimitPerDomain()
+{
+ QNetworkCookie cookie;
+ cookie.setValue("value");
+ MyCookieJar jar;
+ QUrl url("http://a.b.c.com");
+
+ for (int i = 0; i < 20; ++i) {
+ // Add a list of 3 domain-matched cookies on each iteration for a total of 60 cookies.
+ QList<QNetworkCookie> cookieList;
+ cookie.setName(QString("CookieNo%1").arg(i*3+1).toAscii());
+ cookie.setDomain("a.b.c.com");
+ cookieList += cookie;
+ cookie.setName(QString("CookieNo%1").arg(i*3+2).toAscii());
+ cookie.setDomain(".b.c.com");
+ cookieList += cookie;
+ cookie.setName(QString("CookieNo%1").arg(i*3+3).toAscii());
+ cookie.setDomain(".c.com");
+ cookieList += cookie;
+ jar.setCookiesFromUrl(cookieList, url);
+
+ int expectedNumCookies = std::min((i+1)*3, 50);
+ QCOMPARE(jar.allCookies().size(), expectedNumCookies);
+ }
+
+ // Verify that the oldest cookies were the ones overwritten.
+ QVERIFY(!findCookieName(jar.allCookies(), "CookieNo1"));
+ QVERIFY(!findCookieName(jar.allCookies(), "CookieNo10"));
+ QVERIFY(findCookieName(jar.allCookies(), "CookieNo11"));
+ QVERIFY(findCookieName(jar.allCookies(), "CookieNo60"));
+}
+
void tst_QNetworkCookieJar::cookiesForUrl_data()
{
QTest::addColumn<QList<QNetworkCookie> >("allCookies");
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 5550fe8..86773ad 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -71,6 +71,7 @@
#include <QtGui/qpaintengine.h>
#include <private/qbackingstore_p.h>
#include <qmenubar.h>
+#include <qtableview.h>
#include <QtGui/QGraphicsView>
#include <QtGui/QGraphicsProxyWidget>
@@ -406,6 +407,7 @@ private slots:
void childAt();
#ifdef Q_WS_MAC
void childAt_unifiedToolBar();
+ void taskQTBUG_17333_ResizeInfiniteRecursion();
#ifdef QT_MAC_USE_COCOA
void taskQTBUG_11373();
#endif // QT_MAC_USE_COCOA
@@ -10572,6 +10574,18 @@ void tst_QWidget::childAt_unifiedToolBar()
QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast<QWidget *>(label));
}
+void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion()
+{
+ QTableView tb;
+ const char *s = "border: 1px solid;";
+ tb.setStyleSheet(s);
+ tb.show();
+
+ QTest::qWaitForWindowShown(&tb);
+ tb.setGeometry(QRect(100, 100, 0, 100));
+ // No crash, it works.
+}
+
#ifdef QT_MAC_USE_COCOA
void tst_QWidget::taskQTBUG_11373()
{