From 151061ad4af9d1b844f0b029b4e84a3577487048 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 3 Oct 2014 19:30:04 +1000 Subject: update QtBearer NetworkManager backend API Task-number: QTBUG-41747 Change-Id: Idb4afea0215b94957a11895c7db97a72ae680804 Reviewed-by: Lorn Potter --- .../bearer/qnetworksession/test/tst_qnetworksession.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp index d3ff95a26d..1e0d9555dd 100644 --- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp @@ -271,7 +271,11 @@ void tst_QNetworkSession::sessionProperties() << QLatin1String("WCDMA") << QLatin1String("HSPA") << QLatin1String("Bluetooth") - << QLatin1String("WiMAX"); + << QLatin1String("WiMAX") + << QLatin1String("BearerEVDO") + << QLatin1String("BearerLTE") + << QLatin1String("Bearer3G") + << QLatin1String("Bearer4G"); if (!configuration.isValid()) { QVERIFY(configuration.bearerTypeName().isEmpty()); @@ -1022,7 +1026,11 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur if (config.bearerTypeName() != "2G" && config.bearerTypeName() != "CDMA2000" && config.bearerTypeName() != "WCDMA" && - config.bearerTypeName() != "HSPA") { + config.bearerTypeName() != "HSPA" && + config.bearerTypeName() != "EVDO" && + config.bearerTypeName() != "LTE" && + config.bearerTypeName() != "3G" && + config.bearerTypeName() != "4G") { // qDebug() << "Dumping config because bearer mismatches (cellular): " << config.name(); discoveredConfigs.removeOne(config); } -- cgit v1.2.3 From 6c7a348cf82665f7f09bc3e0cfe03256f1462744 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 20 Oct 2014 16:25:47 +0200 Subject: Set correct transient parent in q_createNativeChildrenAndSetParent(). Fix warning: void QWindow::setTransientParent(QWindow*) ... must be a top level window. which occurred for example when parenting a QMenu onto a native child widget. Task-number: QTBUG-41898 Change-Id: Icc25fb2108bd68b2d9c0e551949b90fc7a82d358 Reviewed-by: Laszlo Agocs --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index ec3e8ece6a..44d7671ca3 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -268,6 +269,7 @@ private slots: void winIdChangeEvent(); void persistentWinId(); void showNativeChild(); + void transientParent(); void qobject_castInDestroyedSlot(); void showHideEvent_data(); @@ -3992,6 +3994,21 @@ void tst_QWidget::persistentWinId() QCOMPARE(w3->winId(), winId3); } +void tst_QWidget::transientParent() +{ + QWidget topLevel; + topLevel.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWidgetSize)); + topLevel.setWindowTitle(__FUNCTION__); + QWidget *child = new QWidget(&topLevel); + QMenu *menu = new QMenu(child); // QTBUG-41898: Use top level as transient parent for native widgets as well. + QToolButton *toolButton = new QToolButton(child); + toolButton->setMenu(menu); + toolButton->winId(); + topLevel.show(); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); + QCOMPARE(menu->windowHandle()->transientParent(), topLevel.windowHandle()); +} + void tst_QWidget::showNativeChild() { QWidget topLevel; -- cgit v1.2.3 From ab556d6b321bb02cec2a0c0705b1212377fde095 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 20 Oct 2014 15:04:24 +0200 Subject: Fix height of combo popup when the list view has non-zero spacing. QListView::spacing() is the space around the item (layout margin), so the effective spacing is twice as big. This differs conceptionally from QTableView, which has a spacing of 1 and a line on top/bottom. Split up QComboBoxPrivateContainer::spacing() into functions return spacing and top/bottom margins to reflect this. Task-number: QTBUG-37865 Change-Id: I1ff812e7856e00a53f1119ef3304956cbb7cbfca Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../widgets/widgets/qcombobox/tst_qcombobox.cpp | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 54cf1af5d3..f6928f0b35 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -152,6 +152,7 @@ private slots: void resetModel(); void keyBoardNavigationWithMouse(); void task_QTBUG_1071_changingFocusEmitsActivated(); + void maxVisibleItems_data(); void maxVisibleItems(); void task_QTBUG_10491_currentIndexAndModelColumn(); void highlightedSignal(); @@ -2749,8 +2750,18 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() QTRY_COMPARE(spy.count(), 1); } +void tst_QComboBox::maxVisibleItems_data() +{ + QTest::addColumn("spacing"); + QTest::newRow("Default") << -1; + QTest::newRow("No spacing") << 0; + QTest::newRow("20") << -1; +} + void tst_QComboBox::maxVisibleItems() { + QFETCH(int, spacing); + QComboBox comboBox; QCOMPARE(comboBox.maxVisibleItems(), 10); //default value. @@ -2771,15 +2782,18 @@ void tst_QComboBox::maxVisibleItems() QTRY_VERIFY(comboBox.view()); QTRY_VERIFY(comboBox.view()->isVisible()); - QAbstractItemView *v = comboBox.view(); - int itemHeight = v->visualRect(v->model()->index(0,0)).height(); - QListView *lv = qobject_cast(v); - if (lv) - itemHeight += lv->spacing(); + QListView *listView = qobject_cast(comboBox.view()); + QVERIFY(listView); + if (spacing >= 0) + listView->setSpacing(spacing); + + const int itemHeight = listView->visualRect(listView->model()->index(0,0)).height() + + 2 * listView->spacing(); + QStyleOptionComboBox opt; opt.initFrom(&comboBox); if (!comboBox.style()->styleHint(QStyle::SH_ComboBox_Popup, &opt)) - QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems()); + QCOMPARE(listView->viewport()->height(), itemHeight * comboBox.maxVisibleItems()); } void tst_QComboBox::task_QTBUG_10491_currentIndexAndModelColumn() -- cgit v1.2.3 From bd4a19963e102f4a89fdc1f17349909605324519 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 10 Sep 2014 08:31:35 +0200 Subject: Respect contents margins when calculating the size hint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this part of the calendar widget get cut off when put in a layout and the contentsMargins are non zero. Task-number: QTBUG-40352 Change-Id: I9ce90476c59c270d92e876a5dc81ea8ce325848c Reviewed-by: Lars Knoll Reviewed-by: Shawn Rutledge Reviewed-by: Jan Arve Sæther --- .../widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp index e3e7b13cbe..d0a787d32a 100644 --- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp +++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp @@ -67,6 +67,8 @@ private slots: void showPrevNext(); void firstDayOfWeek(); + + void contentsMargins(); }; // Testing get/set functions @@ -391,5 +393,13 @@ void tst_QCalendarWidget::firstDayOfWeek() QCOMPARE(calendar.firstDayOfWeek(), germanLocale.firstDayOfWeek()); } +void tst_QCalendarWidget::contentsMargins() +{ + QCalendarWidget calendar1; + QCalendarWidget calendar2; + calendar2.setContentsMargins(10, 5, 20, 30); + QCOMPARE(calendar1.minimumSizeHint() + QSize(30, 35), calendar2.minimumSizeHint()); +} + QTEST_MAIN(tst_QCalendarWidget) #include "tst_qcalendarwidget.moc" -- cgit v1.2.3 From 1ff6c575ce57c84324e4be4919cac65e09b96025 Mon Sep 17 00:00:00 2001 From: Jeongmin Kim Date: Wed, 24 Sep 2014 18:51:21 +0900 Subject: QNetworkDiskCache: Fix QNetworkDiskCache don't handle to set CookieHeader. QNetworkDiskCache don't handle to set CookieHeader. so All Set-Cookie's value is invalid. The root of cause is that metaDataChanged() don't work because of no slot for it. Add the slot for it and renamed to _q_metaDataChanged. Task-number: QTBUG-41514 Change-Id: I5cec017e59a1de69c6e89c0bc7209a73dcdc11da Reviewed-by: Jeongmin Kim Reviewed-by: Jung Dong-Heon Reviewed-by: Peter Hartmann --- .../qnetworkdiskcache/tst_qnetworkdiskcache.cpp | 39 +++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index a6d75390c3..a2f1668ef5 100644 --- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -55,6 +55,7 @@ public slots: void init(); void cleanup(); void accessAfterRemoveReadyReadSlot(); + void setCookieHeaderMetaDataChangedSlot(); private slots: void qnetworkdiskcache_data(); @@ -68,6 +69,7 @@ private slots: void metaData(); void remove(); void accessAfterRemove(); // QTBUG-17400 + void setCookieHeader(); // QTBUG-41514 void setCacheDirectory_data(); void setCacheDirectory(); void updateMetaData(); @@ -86,8 +88,9 @@ private slots: private: QTemporaryDir tempDir; - QUrl url; // used by accessAfterRemove() + QUrl url; // used by accessAfterRemove(), setCookieHeader() QNetworkDiskCache *diskCache; // used by accessAfterRemove() + QNetworkAccessManager *manager; // used by setCookieHeader() }; // FIXME same as in tst_qnetworkreply.cpp .. could be unified @@ -403,6 +406,40 @@ void tst_QNetworkDiskCache::accessAfterRemoveReadyReadSlot() diskCache->remove(url); // this used to cause a crash later on } +void tst_QNetworkDiskCache::setCookieHeader() // QTBUG-41514 +{ + SubQNetworkDiskCache *cache = new SubQNetworkDiskCache(); + url = QUrl("http://www.foo.com/cookieTest.html"); + QNetworkCacheMetaData metaData; + metaData.setUrl(url); + + QNetworkCacheMetaData::RawHeaderList headers; + headers.append(QNetworkCacheMetaData::RawHeader("Set-Cookie", "aaa=bbb")); + metaData.setRawHeaders(headers); + metaData.setSaveToDisk(true); + cache->setupWithOne(tempDir.path(), url, metaData); + + manager = new QNetworkAccessManager(); + manager->setCache(cache); + + QNetworkRequest request(url); + QNetworkReply *reply = manager->get(request); + connect(reply, SIGNAL(metaDataChanged()), this, SLOT(setCookieHeaderMetaDataChangedSlot())); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + + reply->deleteLater(); + manager->deleteLater(); +} + +void tst_QNetworkDiskCache::setCookieHeaderMetaDataChangedSlot() +{ + QList actualCookieJar = manager->cookieJar()->cookiesForUrl(url); + QVERIFY(!actualCookieJar.empty()); +} + void tst_QNetworkDiskCache::setCacheDirectory_data() { QTest::addColumn("cacheDir"); -- cgit v1.2.3 From 047f4c4d799f46c8c0aa44b594d3afe416758280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 21 Oct 2014 15:02:28 +0200 Subject: Further limit the sparse file testing on OS X At 4GiB the CI test system still spends a considerable amount of time testing this. Tune the size down to 16 MiB. Change-Id: I417aa6829fcc734e5de4d7d34e503190f6b291e5 Reviewed-by: Friedemann Kleint --- tests/auto/corelib/io/largefile/tst_largefile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index bedbeb6181..62410f7c80 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -75,7 +75,7 @@ public: #elif defined(Q_OS_MAC) // HFS+ does not support sparse files, so we limit file size for the test // on Mac OS. - maxSizeBits = 32; // 4 GiB + maxSizeBits = 24; // 16 MiB #else maxSizeBits = 24; // 16 MiB #endif -- cgit v1.2.3 From ed0245e1452f94918853b7d4066c1e5749b74f5d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Oct 2014 12:24:52 +0200 Subject: Fix QWidget::mapTo/FromGlobal() when embedded in QGraphicsView. Map the positions via QGraphicsScene and the first QGraphicsView (as is done in existing code). Fall back to the previous code path when no QGraphicsView exists, which is hit in the tests. Change-Id: I0754765d05cded6bc1b64045f2513fef8afde337 Task-number: QTBUG-41135 Reviewed-by: Frederik Gladhorn --- .../tst_qgraphicsproxywidget.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index ab84c9e482..66d0f64ceb 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -174,6 +174,7 @@ private slots: void clickFocus(); void windowFrameMargins(); void QTBUG_6986_sendMouseEventToAlienWidget(); + void mapToGlobal(); }; // Subclass that exposes the protected functions. @@ -3659,5 +3660,32 @@ void tst_QGraphicsProxyWidget::QTBUG_6986_sendMouseEventToAlienWidget() QTRY_COMPARE(scene.hoverButton->hoverLeaveReceived, true); } +void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 +{ + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + const QSize size = availableGeometry.size() / 5; + QGraphicsScene scene; + QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(size); + view.move(availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100)); + QWidget *embeddedWidget = new QWidget; + embeddedWidget->setFixedSize(size / 2); + scene.addWidget(embeddedWidget); + QApplication::setActiveWindow(&view); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + const QPoint embeddedCenter = embeddedWidget->geometry().center(); + const QPoint embeddedCenterGlobal = embeddedWidget->mapToGlobal(embeddedCenter); + QCOMPARE(embeddedWidget->mapFromGlobal(embeddedCenterGlobal), embeddedCenter); + // This should be equivalent to the view center give or take rounding + // errors due to odd window margins + const QPoint viewCenter = view.geometry().center(); + QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 2, + qPrintable(QStringLiteral("%1, %2 != %3, %4") + .arg(viewCenter.x()).arg(viewCenter.y()) + .arg(embeddedCenterGlobal.x()).arg(embeddedCenterGlobal.y()))); +} + QTEST_MAIN(tst_QGraphicsProxyWidget) #include "tst_qgraphicsproxywidget.moc" -- cgit v1.2.3 From bf200fc948d89e1a735a8bcca879654028f944d2 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Mon, 20 Oct 2014 15:40:18 +0200 Subject: Adjust the layout if a QGraphicsWidget is explicitly hidden Since layout items can now be hidden, this also makes sure we respect the QSizePolicy::retainSizeWhenHidden Task-number: QTBUG-20132 Change-Id: Iab59fc9b61d4ca1bb2208c479a027da6eb0283a9 Reviewed-by: Paul Olav Tvete --- .../tst_qgraphicsgridlayout.cpp | 89 ++++++++++++++++++++++ .../qgraphicslayout/tst_qgraphicslayout.cpp | 25 ++++++ .../tst_qgraphicslinearlayout.cpp | 36 +++++++++ 3 files changed, 150 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index c90c431d8b..3b55fcd5fc 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -124,6 +124,7 @@ private slots: void heightForWidthWithSpanning(); void stretchAndHeightForWidth(); void testDefaultAlignment(); + void hiddenItems(); }; class RectWidget : public QGraphicsWidget @@ -3485,6 +3486,94 @@ void tst_QGraphicsGridLayout::testDefaultAlignment() QCOMPARE(w->geometry(), QRectF(0,0,50,50)); QCOMPARE(w2->geometry(), QRectF(0,50,100,100)); } + +static RectWidget *addWidget(QGraphicsGridLayout *grid, int row, int column) +{ + RectWidget *w = new RectWidget; + w->setPreferredSize(20, 20); + grid->addItem(w, row, column); + return w; +} + +static void setVisible(bool visible, QGraphicsWidget **widgets) +{ + for (int i = 0; i < 3; ++i) + if (widgets[i]) widgets[i]->setVisible(visible); +} + +static void setRetainSizeWhenHidden(bool retainSize, QGraphicsWidget **widgets) +{ + QSizePolicy sp = widgets[0]->sizePolicy(); + sp.setRetainSizeWhenHidden(retainSize); + for (int i = 0; i < 3; ++i) + if (widgets[i]) widgets[i]->setSizePolicy(sp); +} + +void tst_QGraphicsGridLayout::hiddenItems() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsGridLayout *layout = new QGraphicsGridLayout(widget); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(2); + + // Create a 3x3 layout + addWidget(layout, 0, 0); + RectWidget *w01 = addWidget(layout, 0, 1); + addWidget(layout, 0, 2); + RectWidget *w10 = addWidget(layout, 1, 0); + RectWidget *w11 = addWidget(layout, 1, 1); + RectWidget *w12 = addWidget(layout, 1, 2); + addWidget(layout, 2, 0); + RectWidget *w21 = addWidget(layout, 2, 1); + addWidget(layout, 2, 2); + + QGraphicsWidget *middleColumn[] = {w01, w11, w21 }; + QGraphicsWidget *topTwoOfMiddleColumn[] = {w01, w11, 0 }; + + // hide and show middle column + QCOMPARE(layout->preferredWidth(), qreal(64)); + setVisible(false, middleColumn); // hide middle column + QCOMPARE(layout->preferredWidth(), qreal(42)); + setVisible(true, middleColumn); // show middle column + QCOMPARE(layout->preferredWidth(), qreal(64)); + setRetainSizeWhenHidden(true, middleColumn); + QCOMPARE(layout->preferredWidth(), qreal(64)); + setVisible(false, middleColumn); // hide middle column + QCOMPARE(layout->preferredWidth(), qreal(64)); + setRetainSizeWhenHidden(false, middleColumn); + QCOMPARE(layout->preferredWidth(), qreal(42)); + setVisible(true, middleColumn); + QCOMPARE(layout->preferredWidth(), qreal(64)); + + // Hide only two items, => column should not collapse + setVisible(false, topTwoOfMiddleColumn); + QCOMPARE(layout->preferredWidth(), qreal(64)); + + + QGraphicsWidget *middleRow[] = {w10, w11, w12 }; + QGraphicsWidget *leftMostTwoOfMiddleRow[] = {w10, w11, 0 }; + + // hide and show middle row + QCOMPARE(layout->preferredHeight(), qreal(64)); + setVisible(false, middleRow); + QCOMPARE(layout->preferredHeight(), qreal(42)); + setVisible(true, middleRow); + QCOMPARE(layout->preferredHeight(), qreal(64)); + setRetainSizeWhenHidden(true, middleColumn); + QCOMPARE(layout->preferredHeight(), qreal(64)); + setVisible(false, middleRow); + QCOMPARE(layout->preferredHeight(), qreal(64)); + setRetainSizeWhenHidden(false, middleRow); + QCOMPARE(layout->preferredHeight(), qreal(42)); + setVisible(true, middleRow); + QCOMPARE(layout->preferredHeight(), qreal(64)); + + // Hide only two items => row should not collapse + setVisible(false, leftMostTwoOfMiddleRow); + QCOMPARE(layout->preferredHeight(), qreal(64)); + +} + QTEST_MAIN(tst_QGraphicsGridLayout) #include "tst_qgraphicsgridlayout.moc" diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp index d35667f215..107e3eb48a 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp @@ -50,6 +50,7 @@ private slots: void compressLayoutRequest(); void automaticReparenting(); void verifyActivate(); + void sizeHintOfHiddenLayout(); void invalidate(); void constructors(); void alternativeLayoutItems(); @@ -279,6 +280,30 @@ void tst_QGraphicsLayout::verifyActivate() } + +void tst_QGraphicsLayout::sizeHintOfHiddenLayout() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + QGraphicsWidget *window = new QGraphicsWidget(0, Qt::Window); + scene.addItem(window); + TestLayout *lout = new TestLayout(window); + lout->setContentsMargins(1,2,2,1); + QGraphicsWidget *w = new QGraphicsWidget; + w->setPreferredSize(20, 20); + w->setMaximumSize(50, 50); + lout->addItem(w); + window->setLayout(lout); + + for (int pass = 0; pass < 3; ++pass) { + QCOMPARE(lout->sizeHint(Qt::MinimumSize), QSizeF(3,3)); + QCOMPARE(lout->sizeHint(Qt::PreferredSize), QSizeF(23,23)); + QCOMPARE(lout->sizeHint(Qt::MaximumSize), QSizeF(53,53)); + window->setVisible(pass % 2); + } +} + static void clearAllCounters(TestGraphicsWidget *widget) { if (!widget) diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 7147bb8cce..1513abf0b1 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -103,6 +103,7 @@ private slots: void testOffByOneInLargerLayout(); void testDefaultAlignment(); void combineSizePolicies(); + void hiddenItems(); // Task specific tests void task218400_insertStretchCrash(); @@ -1721,6 +1722,41 @@ void tst_QGraphicsLinearLayout::combineSizePolicies() QCOMPARE(layout->maximumHeight(), qreal(200)); } +void tst_QGraphicsLinearLayout::hiddenItems() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, widget); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(2); + + RectWidget *w1 = new RectWidget; + w1->setPreferredSize(QSizeF(20, 20)); + layout->addItem(w1); + + RectWidget *w2 = new RectWidget; + w2->setPreferredSize(QSizeF(20, 20)); + layout->addItem(w2); + + RectWidget *w3 = new RectWidget; + w3->setPreferredSize(QSizeF(20, 20)); + layout->addItem(w3); + + QCOMPARE(layout->preferredWidth(), qreal(64)); + w2->hide(); + QCOMPARE(layout->preferredWidth(), qreal(42)); + w2->show(); + QCOMPARE(layout->preferredWidth(), qreal(64)); + QSizePolicy sp = w2->sizePolicy(); + sp.setRetainSizeWhenHidden(true); + w2->setSizePolicy(sp); + QCOMPARE(layout->preferredWidth(), qreal(64)); + w2->hide(); + QCOMPARE(layout->preferredWidth(), qreal(64)); + sp.setRetainSizeWhenHidden(false); + w2->setSizePolicy(sp); + QCOMPARE(layout->preferredWidth(), qreal(42)); +} + QTEST_MAIN(tst_QGraphicsLinearLayout) #include "tst_qgraphicslinearlayout.moc" -- cgit v1.2.3 From 68d83e82f80ba3af439f1eed74b2b4a0cefc4f2a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 29 Sep 2014 16:34:05 +0200 Subject: Add autotest for QGestureRecognizer. Task-number: QTBUG-12736 Task-number: QTBUG-15768 Task-number: QTBUG-40461 Change-Id: Ib6dfaa9336f615e17d41444f7aa686cb93d04fca Reviewed-by: Lars Knoll Reviewed-by: Shawn Rutledge Reviewed-by: Alex Blasche --- tests/auto/widgets/gestures/gestures.pro | 6 + .../qgesturerecognizer/qgesturerecognizer.pro | 4 + .../qgesturerecognizer/tst_qgesturerecognizer.cpp | 330 +++++++++++++++++++++ tests/auto/widgets/widgets.pro | 1 + 4 files changed, 341 insertions(+) create mode 100644 tests/auto/widgets/gestures/gestures.pro create mode 100644 tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro create mode 100644 tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp (limited to 'tests/auto') diff --git a/tests/auto/widgets/gestures/gestures.pro b/tests/auto/widgets/gestures/gestures.pro new file mode 100644 index 0000000000..5a87a01ee2 --- /dev/null +++ b/tests/auto/widgets/gestures/gestures.pro @@ -0,0 +1,6 @@ +TEMPLATE=subdirs +SUBDIRS=\ + qgesturerecognizer \ + +mac: SUBDIRS -= \ # Uses native recognizers + qgesturerecognizer \ diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro b/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro new file mode 100644 index 0000000000..7c9ddcfb03 --- /dev/null +++ b/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro @@ -0,0 +1,4 @@ +CONFIG += testcase +TARGET = tst_qgesturerecognizer +QT += widgets testlib gui-private core-private +SOURCES += tst_qgesturerecognizer.cpp diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp new file mode 100644 index 0000000000..867c6eb629 --- /dev/null +++ b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp @@ -0,0 +1,330 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +class tst_QGestureRecognizer : public QObject +{ + Q_OBJECT +public: + tst_QGestureRecognizer(); + +private Q_SLOTS: + void initTestCase(); +#ifndef QT_NO_GESTURES + void panGesture_data(); + void panGesture(); + void pinchGesture_data(); + void pinchGesture(); + void swipeGesture_data(); + void swipeGesture(); +#endif // !QT_NO_GESTURES + +private: + const int m_fingerDistance; + QTouchDevice *m_touchDevice; +}; + +tst_QGestureRecognizer::tst_QGestureRecognizer() + : m_fingerDistance(qRound(QGuiApplication::primaryScreen()->physicalDotsPerInch() / 2.0)) + , m_touchDevice(new QTouchDevice) +{ +} + +void tst_QGestureRecognizer::initTestCase() +{ + m_touchDevice->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(m_touchDevice); +} + +#ifndef QT_NO_GESTURES + +typedef QVector GestureTypeVector; + +class TestWidget : public QWidget +{ +public: + explicit TestWidget(const GestureTypeVector &gestureTypes); + + bool gestureReceived(Qt::GestureType gestureType) const + { return m_receivedGestures.value(gestureType); } + +protected: + bool event(QEvent * event) Q_DECL_OVERRIDE; + +private: + typedef QHash GestureTypeHash; + GestureTypeHash m_receivedGestures; +}; + +TestWidget::TestWidget(const GestureTypeVector &gestureTypes) +{ + setAttribute(Qt::WA_AcceptTouchEvents); + + foreach (Qt::GestureType gestureType, gestureTypes) { + grabGesture(gestureType); + m_receivedGestures.insert(gestureType, false); + } + + const QRect geometry = QGuiApplication::primaryScreen()->availableGeometry(); + const QSize size = geometry.size() / 2; + resize(size); + move(geometry.center() - QPoint(size.width() / 2, size.height() / 2)); +} + +bool TestWidget::event(QEvent * event) +{ + switch (event->type()) { + case QEvent::Gesture: { + const QGestureEvent *gestureEvent = static_cast(event); + const GestureTypeHash::iterator hend = m_receivedGestures.end(); + for (GestureTypeHash::iterator it = m_receivedGestures.begin(); it != hend; ++it) { + if (const QGesture *gesture = gestureEvent->gesture(it.key())) { + if (gesture->state() == Qt::GestureFinished) + it.value() = true; + } + } + } + break; + default: + break; + } + return QWidget::event(event); +} + +static void pressSequence(QTest::QTouchEventSequence &sequence, + QVector &points, + QWidget *widget) +{ + const int pointCount = points.size(); + for (int p = 0; p < pointCount; ++p) + sequence.press(p, points.at(p), widget); + sequence.commit(); +} + +static void linearSequence(int n, const QPoint &delta, + QTest::QTouchEventSequence &sequence, + QVector &points, + QWidget *widget) +{ + const int pointCount = points.size(); + for (int s = 0; s < n; ++s) { + for (int p = 0; p < pointCount; ++p) { + points[p] += delta; + sequence.move(p, points[p], widget); + } + sequence.commit(); + } +} + +static void releaseSequence(QTest::QTouchEventSequence &sequence, + QVector &points, + QWidget *widget) +{ + const int pointCount = points.size(); + for (int p = 0; p < pointCount; ++p) + sequence.release(p, points[p], widget); + sequence.commit(); +} + +// --- Pan + +enum PanSubTest { + TwoFingerPanSubTest +}; + +void tst_QGestureRecognizer::panGesture_data() +{ + QTest::addColumn("panSubTest"); + QTest::addColumn("gestureExpected"); + QTest::newRow("Two finger") << int(TwoFingerPanSubTest) << true; +} + +void tst_QGestureRecognizer::panGesture() +{ + QFETCH(int, panSubTest); + QFETCH(bool, gestureExpected); + + Q_UNUSED(panSubTest) // Single finger pan will be added later. + + const int panPoints = 2; + const Qt::GestureType gestureType = Qt::PanGesture; + TestWidget widget(GestureTypeVector(1, gestureType)); + widget.setWindowTitle(QTest::currentTestFunction()); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + + QVector points; + for (int i = 0; i < panPoints; ++i) + points.append(QPoint(10 + i *20, 10 + i *20)); + + QTest::QTouchEventSequence panSequence = QTest::touchEvent(&widget, m_touchDevice); + pressSequence(panSequence, points, &widget); + linearSequence(5, QPoint(20, 20), panSequence, points, &widget); + releaseSequence(panSequence, points, &widget); + + if (gestureExpected) { + QTRY_VERIFY(widget.gestureReceived(gestureType)); + } else { + QCoreApplication::processEvents(); + QVERIFY(!widget.gestureReceived(gestureType)); + } +} + +// --- Pinch + +enum PinchSubTest { + StandardPinchSubTest +}; + +void tst_QGestureRecognizer::pinchGesture_data() +{ + QTest::addColumn("pinchSubTest"); + QTest::addColumn("gestureExpected"); + QTest::newRow("Standard") << int(StandardPinchSubTest) << true; +} + +void tst_QGestureRecognizer::pinchGesture() +{ + QFETCH(int, pinchSubTest); + QFETCH(bool, gestureExpected); + + Q_UNUSED(pinchSubTest) + + const Qt::GestureType gestureType = Qt::PinchGesture; + TestWidget widget(GestureTypeVector(1, gestureType)); + widget.setWindowTitle(QTest::currentTestFunction()); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + + QVector points; + points.append(widget.rect().center()); + points.append(points.front() + QPoint(0, 20)); + + QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&widget, m_touchDevice); + pressSequence(pinchSequence, points, &widget); + + for (int s = 0; s < 5; ++s) { + points[0] += QPoint(5, 30); + pinchSequence.move(0, points[0], &widget); + points[1] += QPoint(5, -30); + pinchSequence.move(1, points[1], &widget); + pinchSequence.commit(); + } + + releaseSequence(pinchSequence, points, &widget); + + if (gestureExpected) { + QTRY_VERIFY(widget.gestureReceived(gestureType)); + } else { + QCoreApplication::processEvents(); + QVERIFY(!widget.gestureReceived(gestureType)); + } +} + +// --- Swipe + +enum SwipeSubTest { + SwipeLineSubTest, +}; + +void tst_QGestureRecognizer::swipeGesture_data() +{ + QTest::addColumn("swipeSubTest"); + QTest::addColumn("gestureExpected"); + QTest::newRow("Line") << int(SwipeLineSubTest) << true; +} + +void tst_QGestureRecognizer::swipeGesture() +{ + enum { swipePoints = 3 }; + + QFETCH(int, swipeSubTest); + QFETCH(bool, gestureExpected); + + const Qt::GestureType gestureType = Qt::SwipeGesture; + TestWidget widget(GestureTypeVector(1, gestureType)); + widget.setWindowTitle(QTest::currentTestFunction()); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + + // Start a swipe sequence with 2 points (QTBUG-15768) + const QPoint fingerDistance(m_fingerDistance, m_fingerDistance); + QVector points; + for (int i = 0; i < swipePoints - 1; ++i) + points.append(fingerDistance + i * fingerDistance); + + QTest::QTouchEventSequence swipeSequence = QTest::touchEvent(&widget, m_touchDevice); + pressSequence(swipeSequence, points, &widget); + + // Press point #3 + points.append(points.last() + fingerDistance); + swipeSequence.press(points.size() - 1, points.last(), &widget); + swipeSequence.commit(); + Q_ASSERT(points.size() == swipePoints); + + // Move. + const QPoint moveDelta(60, 20); + switch (swipeSubTest) { + case SwipeLineSubTest: + linearSequence(5, moveDelta, swipeSequence, points, &widget); + break; + } + + releaseSequence(swipeSequence, points, &widget); + + if (gestureExpected) { + QTRY_VERIFY(widget.gestureReceived(gestureType)); + } else { + QCoreApplication::processEvents(); + QVERIFY(!widget.gestureReceived(gestureType)); + } +} + +#endif // !QT_NO_GESTURES + +QTEST_MAIN(tst_QGestureRecognizer) + +#include "tst_qgesturerecognizer.moc" diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro index 8b6c4722be..efcc47171d 100644 --- a/tests/auto/widgets/widgets.pro +++ b/tests/auto/widgets/widgets.pro @@ -8,3 +8,4 @@ SUBDIRS=\ styles \ util \ widgets \ + gestures \ -- cgit v1.2.3 From 88057e3407aa16d0a9dc9dcc6d0ea6174dce693b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Oct 2014 17:31:55 +0200 Subject: QSwipeGestureRecognizer: Fix gesture cancel on direction change. Task-number: QTBUG-12736 Change-Id: I6d8d09843b45df17cb9158070f63b3397c5b4c07 Reviewed-by: Lars Knoll Reviewed-by: Frederik Gladhorn --- .../widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp index 867c6eb629..833494f25e 100644 --- a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp +++ b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp @@ -268,6 +268,7 @@ void tst_QGestureRecognizer::pinchGesture() enum SwipeSubTest { SwipeLineSubTest, + SwipeChangeDirectionSubTest, }; void tst_QGestureRecognizer::swipeGesture_data() @@ -275,6 +276,7 @@ void tst_QGestureRecognizer::swipeGesture_data() QTest::addColumn("swipeSubTest"); QTest::addColumn("gestureExpected"); QTest::newRow("Line") << int(SwipeLineSubTest) << true; + QTest::newRow("ChangeDirection") << int(SwipeChangeDirectionSubTest) << false; } void tst_QGestureRecognizer::swipeGesture() @@ -311,6 +313,10 @@ void tst_QGestureRecognizer::swipeGesture() case SwipeLineSubTest: linearSequence(5, moveDelta, swipeSequence, points, &widget); break; + case SwipeChangeDirectionSubTest: + linearSequence(5, moveDelta, swipeSequence, points, &widget); + linearSequence(3, QPoint(-moveDelta.x(), moveDelta.y()), swipeSequence, points, &widget); + break; } releaseSequence(swipeSequence, points, &widget); -- cgit v1.2.3 From 2bfee10f3ab8e8e33b2169d735baedcdd9f2b584 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 22 Oct 2014 13:47:55 +0200 Subject: QMainWindow: respect the maximum size of the central widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure the dock widgets get the available space when the central widget cannot expand any more. [ChangeLog][QtWidgets][QMainWindow] Dock widgets will now be resized properly when the central widget has a fixed size. Task-number: QTBUG-40410 Change-Id: Id06c07b79aa3102aa41212fa2c621f5fa426fe02 Reviewed-by: Friedemann Kleint Reviewed-by: Jan Arve Sæther --- .../widgets/qmainwindow/tst_qmainwindow.cpp | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index ebda07ee0c..27c803b43d 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -137,6 +137,7 @@ private slots: #endif void addToolbarAfterShow(); void centralWidgetSize(); + void fixedSizeCentralWidget(); void dockWidgetSize(); void QTBUG2774_stylechange(); void QTBUG15080_restoreState(); @@ -1737,6 +1738,50 @@ void tst_QMainWindow::centralWidgetSize() QTRY_COMPARE(widget.size(), widget.sizeHint()); } +void tst_QMainWindow::fixedSizeCentralWidget() +{ + // QTBUG-40410: dock widgets does not get all the available space when + // central widget is fixed size + QMainWindow mainWindow; + mainWindow.setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); + + MyWidget widget; + widget.setFixedSize(100,100); + mainWindow.setCentralWidget(&widget); + + QDockWidget dock("D1"); + QWidget *child = new MyWidget; + dock.setWidget(child); + mainWindow.addDockWidget(Qt::TopDockWidgetArea, &dock); + + QDockWidget dock2("D2"); + dock2.setWidget(new MyWidget); + mainWindow.addDockWidget(Qt::LeftDockWidgetArea, &dock2); + + QSize sizeH = mainWindow.sizeHint(); + QSize mwSize = QSize(sizeH.width(), sizeH.height() * 2); + mainWindow.resize(mwSize); + mainWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&mainWindow)); + if (mainWindow.height() < mwSize.height()) + QSKIP("The screen is too small for this test"); + + // first, check that we get more than the size hint when we have more space + QTRY_VERIFY(child->height() > child->sizeHint().height()); + int childHeight = child->height(); + + if (qGuiApp->styleHints()->showIsFullScreen()) + QSKIP("The platform is auto maximizing, so we cannot resize the window"); + + // then, check that we get nothing when there is no space + mainWindow.resize(100,100); + QTRY_COMPARE(child->height(), 0); + + // finally verify that we get the space back when we resize to the old size + mainWindow.resize(mwSize); + QTRY_COMPARE(child->height(), childHeight); +} + void tst_QMainWindow::dockWidgetSize() { QMainWindow mainWindow; -- cgit v1.2.3 From c4430ed02301c456dd591c88049ee22bc7dd9725 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 21 Oct 2014 10:01:58 +0200 Subject: Correctly update QComboBox appearance on editable change The updateDelegate() function checks isEditable() which in turn checks if d->lineEdit != 0, so we need to make the call after the lineEdit has actually been set/unset, otherwise the change to the delegate will not come until the next time you update the delegate. [ChangeLog][QComboBox] Fixed updating appearance of popup menu when changing the editable state of the combo box. Change-Id: Ib32f36cabd53c2c30d6256484a1eae131419960a Task-number: QTBUG-33537 Reviewed-by: Friedemann Kleint Reviewed-by: Mitch Curtis --- .../widgets/widgets/qcombobox/tst_qcombobox.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index f6928f0b35..ac32ee4968 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -160,6 +160,7 @@ private slots: void task_QTBUG_31146_popupCompletion(); void keyboardSelection(); void setCustomModelAndView(); + void updateDelegateOnEditableChange(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -3049,5 +3050,32 @@ void tst_QComboBox::keyboardSelection() QCOMPARE(comboBox.currentText(), list.at(1)); } +void tst_QComboBox::updateDelegateOnEditableChange() +{ + + QComboBox box; + box.addItem(QStringLiteral("Foo")); + box.addItem(QStringLiteral("Bar")); + box.setEditable(false); + + QComboBoxPrivate *d = static_cast(QComboBoxPrivate::get(&box)); + + { + bool menuDelegateBefore = qobject_cast(box.itemDelegate()) != 0; + d->updateDelegate(); + bool menuDelegateAfter = qobject_cast(box.itemDelegate()) != 0; + QCOMPARE(menuDelegateAfter, menuDelegateBefore); + } + + box.setEditable(true); + + { + bool menuDelegateBefore = qobject_cast(box.itemDelegate()) != 0; + d->updateDelegate(); + bool menuDelegateAfter = qobject_cast(box.itemDelegate()) != 0; + QCOMPARE(menuDelegateAfter, menuDelegateBefore); + } +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" -- cgit v1.2.3 From 3fd2d9eff8c1f948306ee5fbfe364ccded1c4b84 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 21 Oct 2014 15:44:43 +0200 Subject: Update QSsl::SecureProtocols to not include Sslv3 After the poodle vulnerability SSLv3 should like SSLv2 no longer be considered safe, so when a user request a safe protocol we should only allow TLS versions. [ChangeLog][QtNetwork][QSsl] QSsl::SecureProtocols now also excludes SSLv3 Change-Id: If825f6beb599294b028d706903b39db6b20be519 Reviewed-by: Richard J. Moore --- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 6e915f89fb..aa954429de 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1088,7 +1088,7 @@ void tst_QSslSocket::protocolServerSide_data() #endif QTest::newRow("ssl3-tls1.0") << QSsl::SslV3 << QSsl::TlsV1_0 << false; QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << true; - QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << true; + QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << false; #ifndef OPENSSL_NO_SSL2 QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << false; // we won't set a SNI header here because we connect to a // numerical IP, so OpenSSL will send a SSL 2 handshake @@ -1120,7 +1120,7 @@ void tst_QSslSocket::protocolServerSide_data() #ifndef OPENSSL_NO_SSL2 QTest::newRow("secure-ssl2") << QSsl::SecureProtocols << QSsl::SslV2 << false; #endif - QTest::newRow("secure-ssl3") << QSsl::SecureProtocols << QSsl::SslV3 << true; + QTest::newRow("secure-ssl3") << QSsl::SecureProtocols << QSsl::SslV3 << false; QTest::newRow("secure-tls1.0") << QSsl::SecureProtocols << QSsl::TlsV1_0 << true; QTest::newRow("secure-tls1ssl3") << QSsl::SecureProtocols << QSsl::TlsV1SslV3 << true; QTest::newRow("secure-any") << QSsl::SecureProtocols << QSsl::AnyProtocol << true; @@ -2300,28 +2300,28 @@ void tst_QSslSocket::sslOptions() #ifdef SSL_OP_NO_COMPRESSION QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSslConfigurationPrivate::defaultSslOptions), - long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_COMPRESSION)); + long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_COMPRESSION)); #else QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSslConfigurationPrivate::defaultSslOptions), - long(SSL_OP_ALL|SSL_OP_NO_SSLv2)); + long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3)); #endif QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSsl::SslOptionDisableEmptyFragments |QSsl::SslOptionDisableLegacyRenegotiation), - long(SSL_OP_ALL|SSL_OP_NO_SSLv2)); + long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3)); #ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSsl::SslOptionDisableEmptyFragments), - long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION))); + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION))); #endif #ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSsl::SslOptionDisableLegacyRenegotiation), - long((SSL_OP_ALL|SSL_OP_NO_SSLv2) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); #endif #ifdef SSL_OP_NO_TICKET @@ -2329,7 +2329,7 @@ void tst_QSslSocket::sslOptions() QSsl::SslOptionDisableEmptyFragments |QSsl::SslOptionDisableLegacyRenegotiation |QSsl::SslOptionDisableSessionTickets), - long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET))); + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET))); #endif #ifdef SSL_OP_NO_TICKET @@ -2339,7 +2339,7 @@ void tst_QSslSocket::sslOptions() |QSsl::SslOptionDisableLegacyRenegotiation |QSsl::SslOptionDisableSessionTickets |QSsl::SslOptionDisableCompression), - long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION))); + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION))); #endif #endif } -- cgit v1.2.3 From 8c4deff51c8064f5a15cae0342bfa66b6663662b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 21 Oct 2014 17:08:57 +0200 Subject: Fix QVariant associative container conversion from built-in types. Task-number: QTBUG-41403 Change-Id: I9dab0f9450cac11678eb6d20abd2dd08e86e0900 Reviewed-by: Stephen Kelly --- .../auto/corelib/kernel/qvariant/tst_qvariant.cpp | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index b3e683a29b..4264c96745 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -208,6 +209,7 @@ private slots: void convertBoolToByteArray_data() const; void convertByteArrayToBool() const; void convertByteArrayToBool_data() const; + void convertIterables() const; void toIntFromQString() const; void toIntFromDouble() const; void setValue(); @@ -2838,6 +2840,49 @@ void tst_QVariant::convertByteArrayToBool_data() const << QByteArray("true"); } +void tst_QVariant::convertIterables() const +{ + { + QStringList list; + list.append("Hello"); + QCOMPARE(QVariant::fromValue(list).value().count(), list.count()); + } + { + QByteArrayList list; + list.append("Hello"); + QCOMPARE(QVariant::fromValue(list).value().count(), list.count()); + } + { + QVariantList list; + list.append("World"); + QCOMPARE(QVariant::fromValue(list).value().count(), list.count()); + } + { + QMap map; + map.insert("3", 4); + QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); + QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); + } + { + QVariantMap map; + map.insert("3", 4); + QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); + QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); + } + { + QHash hash; + hash.insert("3", 4); + QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); + QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); + } + { + QVariantHash hash; + hash.insert("3", 4); + QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); + QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); + } +} + /*! We verify that: 1. Converting the string "9.9" to int fails. This is the behavior of -- cgit v1.2.3 From 929509ea03b116588bdae38391377ec1ec976845 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Mon, 20 Oct 2014 18:44:13 +0200 Subject: QStyleSheetStyle: Don't interfere with QFontDialog The sample lineedit in Qt's own font dialog shouldn't have its font affected by stylesheets. Not only does this hampers the ability to preview the font, it actually overrides the font selection as that one is taken directly from the widget. Task-number: QTBUG-41513 Change-Id: I11d0bef8c7bf7bdae4cc08b6b9276d0fc14a75fb Reviewed-by: Olivier Goffart Reviewed-by: Frederik Gladhorn --- tests/auto/gui/text/qglyphrun/qglyphrun.pro | 9 +++---- tests/auto/gui/text/qglyphrun/test.ttf | Bin 2008 -> 0 bytes tests/auto/gui/text/qglyphrun/testdata.qrc | 2 +- tests/auto/gui/text/qrawfont/qrawfont.pro | 8 ++---- tests/auto/gui/text/qrawfont/testdata.qrc | 2 +- tests/auto/gui/text/qrawfont/testfont.ttf | Bin 63212 -> 0 bytes tests/auto/shared/resources/test.ttf | Bin 0 -> 2008 bytes tests/auto/shared/resources/testfont.ttf | Bin 0 -> 63212 bytes .../widgets/dialogs/qfontdialog/qfontdialog.pro | 2 ++ .../auto/widgets/dialogs/qfontdialog/testfonts.qrc | 6 +++++ .../dialogs/qfontdialog/tst_qfontdialog.cpp | 30 +++++++++++++++++++++ 11 files changed, 46 insertions(+), 13 deletions(-) delete mode 100644 tests/auto/gui/text/qglyphrun/test.ttf delete mode 100644 tests/auto/gui/text/qrawfont/testfont.ttf create mode 100644 tests/auto/shared/resources/test.ttf create mode 100644 tests/auto/shared/resources/testfont.ttf create mode 100644 tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qglyphrun/qglyphrun.pro b/tests/auto/gui/text/qglyphrun/qglyphrun.pro index 0993a5c49c..b7d9f164c9 100644 --- a/tests/auto/gui/text/qglyphrun/qglyphrun.pro +++ b/tests/auto/gui/text/qglyphrun/qglyphrun.pro @@ -8,14 +8,13 @@ linux: CONFIG += insignificant_test SOURCES += \ tst_qglyphrun.cpp -android { - RESOURCES += \ - testdata.qrc -} wince* { additionalFiles.files = test.ttf - additionalFiles.path = . + additionalFiles.path = ../../../shared/resources/ DEPLOYMENT += additionalFiles +} else { + RESOURCES += \ + testdata.qrc } diff --git a/tests/auto/gui/text/qglyphrun/test.ttf b/tests/auto/gui/text/qglyphrun/test.ttf deleted file mode 100644 index 382b2547b0..0000000000 Binary files a/tests/auto/gui/text/qglyphrun/test.ttf and /dev/null differ diff --git a/tests/auto/gui/text/qglyphrun/testdata.qrc b/tests/auto/gui/text/qglyphrun/testdata.qrc index c4e237ad2f..25cadc477e 100644 --- a/tests/auto/gui/text/qglyphrun/testdata.qrc +++ b/tests/auto/gui/text/qglyphrun/testdata.qrc @@ -1,5 +1,5 @@ - test.ttf + ../../../shared/resources/test.ttf diff --git a/tests/auto/gui/text/qrawfont/qrawfont.pro b/tests/auto/gui/text/qrawfont/qrawfont.pro index 1891e7a9bf..20da2e9a22 100644 --- a/tests/auto/gui/text/qrawfont/qrawfont.pro +++ b/tests/auto/gui/text/qrawfont/qrawfont.pro @@ -7,9 +7,5 @@ QT = core core-private gui gui-private testlib SOURCES += \ tst_qrawfont.cpp -TESTDATA += testfont_bold_italic.ttf testfont.ttf - -android { - RESOURCES += \ - testdata.qrc -} +RESOURCES += \ + testdata.qrc diff --git a/tests/auto/gui/text/qrawfont/testdata.qrc b/tests/auto/gui/text/qrawfont/testdata.qrc index 7bea0d5a39..8f8e32ed24 100644 --- a/tests/auto/gui/text/qrawfont/testdata.qrc +++ b/tests/auto/gui/text/qrawfont/testdata.qrc @@ -1,6 +1,6 @@ testfont_bold_italic.ttf - testfont.ttf + ../../../shared/resources/testfont.ttf diff --git a/tests/auto/gui/text/qrawfont/testfont.ttf b/tests/auto/gui/text/qrawfont/testfont.ttf deleted file mode 100644 index d6042d2e58..0000000000 Binary files a/tests/auto/gui/text/qrawfont/testfont.ttf and /dev/null differ diff --git a/tests/auto/shared/resources/test.ttf b/tests/auto/shared/resources/test.ttf new file mode 100644 index 0000000000..382b2547b0 Binary files /dev/null and b/tests/auto/shared/resources/test.ttf differ diff --git a/tests/auto/shared/resources/testfont.ttf b/tests/auto/shared/resources/testfont.ttf new file mode 100644 index 0000000000..d6042d2e58 Binary files /dev/null and b/tests/auto/shared/resources/testfont.ttf differ diff --git a/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro b/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro index 8116fe379a..dc1702971e 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro +++ b/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro @@ -7,6 +7,8 @@ QT += core-private gui-private SOURCES += tst_qfontdialog.cpp +RESOURCES += testfonts.qrc + mac { # ### fixme # OBJECTIVE_SOURCES += tst_qfontdialog_mac_helpers.mm diff --git a/tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc b/tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc new file mode 100644 index 0000000000..cdfa287b39 --- /dev/null +++ b/tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc @@ -0,0 +1,6 @@ + + + ../../../shared/resources/test.ttf + ../../../shared/resources/testfont.ttf + + diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp index 22c84c2244..92ea7e5e57 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp @@ -36,6 +36,7 @@ #include +#include #include #include #include @@ -70,6 +71,10 @@ private slots: void setFont(); void task256466_wrongStyle(); void setNonStandardFontSize(); +#ifndef QT_NO_STYLE_STYLESHEET + void qtbug_41513_stylesheetStyle(); +#endif + private: void runSlotWithFailsafeTimer(const char *member); @@ -201,6 +206,31 @@ void tst_QFontDialog::setNonStandardFontSize() { runSlotWithFailsafeTimer(SLOT(testNonStandardFontSize())); } +#ifndef QT_NO_STYLE_STYLESHEET +static const QString offendingStyleSheet = QStringLiteral("* { font-family: \"QtBidiTestFont\"; }"); + +void tst_QFontDialog::qtbug_41513_stylesheetStyle() +{ + if (QFontDatabase::addApplicationFont(QFINDTESTDATA("test.ttf")) < 0) + QSKIP("Test fonts not found."); + if (QFontDatabase::addApplicationFont(QFINDTESTDATA("testfont.ttf")) < 0) + QSKIP("Test fonts not found."); + QFont testFont = QFont(QStringLiteral("QtsSpecialTestFont")); + qApp->setStyleSheet(offendingStyleSheet); + bool accepted = false; + QTimer::singleShot(2000, this, SLOT(postKeyReturn())); + QFont resultFont = QFontDialog::getFont(&accepted, testFont, + QApplication::activeWindow(), + QLatin1String("QFontDialog - Stylesheet Test"), + QFontDialog::DontUseNativeDialog); + QVERIFY(accepted); + + QCOMPARE(resultFont, testFont); + + // reset stylesheet + qApp->setStyleSheet(QString()); +} +#endif // QT_NO_STYLE_STYLESHEET void tst_QFontDialog::testNonStandardFontSize() { -- cgit v1.2.3 From 74a51d590f4acd189f8d0594a5a706cbf97c805b Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 17 Mar 2014 17:59:55 +0100 Subject: QPrinter - Fix DuplexMode on all platforms Add support to get/set the DuplexMode on Windows and Mac, improve the CUPS duplex handling, ensure support is the same on all platforms. [ChangeLog][QtPrintSupport][QPrinter] Added duplex support for Windows and OS X. Task-number: QTBUG-11332 Change-Id: I9d61d63233d828c3b1fd6df54072c6049f3c6298 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- .../printsupport/kernel/qprinter/tst_qprinter.cpp | 46 ++++++++++++---------- .../kernel/qprinterinfo/tst_qprinterinfo.cpp | 8 ++++ 2 files changed, 34 insertions(+), 20 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index c42450607d..1be570e4b8 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -1022,9 +1022,9 @@ void tst_QPrinter::duplex() { // duplex()) / setDuplex() / PPK_Duplex // PdfFormat: Supported, default QPrinter::DuplexNone - // NativeFormat, Cups: Supported, default QPrinter::DuplexNone - // NativeFormat, Win: Unsupported, always QPrinter::DuplexNone - // NativeFormat, Mac: Unsupported, always QPrinter::DuplexNone + // NativeFormat, Cups: Supported, default to printer default + // NativeFormat, Win: Supported, default to printer default + // NativeFormat, Mac: Supported, default to printer default QPrinter pdf; pdf.setOutputFormat(QPrinter::PdfFormat); @@ -1035,15 +1035,17 @@ void tst_QPrinter::duplex() QPrinter native; if (native.outputFormat() == QPrinter::NativeFormat) { // Test default - // TODO Printer specific, need QPrinterInfo::duplex() - //QCOMPARE(native.duplex(), QPrinter::DuplexNone); - - // Test set/get - QPrinter::DuplexMode expected = QPrinter::DuplexAuto; + QPrinterInfo printerInfo = QPrinterInfo::defaultPrinter(); + QPrinter::DuplexMode expected = printerInfo.defaultDuplexMode(); + QCOMPARE(native.duplex(), expected); + // Test set/get (skipping Auto as that will return something different) + foreach (QPrinter::DuplexMode mode, printerInfo.supportedDuplexModes()) { + if (mode != expected && mode != QPrinter::DuplexAuto) { + expected = mode; + break; + } + } native.setDuplex(expected); -#if defined Q_OS_MAC || defined Q_OS_WIN - expected = QPrinter::DuplexNone; -#endif // Q_OS_MAC || Q_OS_WIN QCOMPARE(native.duplex(), expected); // Test value preservation @@ -1051,6 +1053,12 @@ void tst_QPrinter::duplex() QCOMPARE(native.duplex(), expected); native.setOutputFormat(QPrinter::NativeFormat); QCOMPARE(native.duplex(), expected); + + // Test setting invalid option + if (!printerInfo.supportedDuplexModes().contains(QPrinter::DuplexLongSide)) { + native.setDuplex(QPrinter::DuplexLongSide); + QCOMPARE(native.duplex(), expected); + } } else { QSKIP("No printers installed, cannot test NativeFormat, please install printers to test"); } @@ -1059,9 +1067,9 @@ void tst_QPrinter::duplex() void tst_QPrinter::doubleSidedPrinting() { // PdfFormat: Supported, default false - // NativeFormat, Cups: Supported, default false - // NativeFormat, Win: Unsupported, always false - // NativeFormat, Mac: Unsupported, always false + // NativeFormat, Cups: Supported, default to printer default + // NativeFormat, Win: Supported, default to printer default + // NativeFormat, Mac: Supported, default to printer default QPrinter pdf; pdf.setOutputFormat(QPrinter::PdfFormat); @@ -1072,15 +1080,13 @@ void tst_QPrinter::doubleSidedPrinting() QPrinter native; if (native.outputFormat() == QPrinter::NativeFormat) { // Test default - // TODO Printer specific, need QPrinterInfo::duplex() - //QCOMPARE(native.doubleSidedPrinting(), false); + QPrinterInfo printerInfo; + bool expected = (printerInfo.defaultDuplexMode() != QPrinter::DuplexNone); + QCOMPARE(native.doubleSidedPrinting(), false); // Test set/get - bool expected = true; + expected = (printerInfo.supportedDuplexModes().count() > 1); native.setDoubleSidedPrinting(expected); -#if defined Q_OS_MAC || defined Q_OS_WIN - expected = false; -#endif // Q_OS_MAC || Q_OS_WIN QCOMPARE(native.doubleSidedPrinting(), expected); // Test value preservation diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp index 88a526ba17..f3e8b9209d 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -298,6 +298,8 @@ void tst_QPrinterInfo::testConstructors() QCOMPARE(copy1.supportedPaperSizes(), printers.at(i).supportedPaperSizes()); QCOMPARE(copy1.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames()); QCOMPARE(copy1.supportedResolutions(), printers.at(i).supportedResolutions()); + QCOMPARE(copy1.defaultDuplexMode(), printers.at(i).defaultDuplexMode()); + QCOMPARE(copy1.supportedDuplexModes(), printers.at(i).supportedDuplexModes()); QPrinter printer(printers.at(i)); QPrinterInfo copy2(printer); @@ -317,6 +319,8 @@ void tst_QPrinterInfo::testConstructors() QCOMPARE(copy2.supportedPaperSizes(), printers.at(i).supportedPaperSizes()); QCOMPARE(copy2.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames()); QCOMPARE(copy2.supportedResolutions(), printers.at(i).supportedResolutions()); + QCOMPARE(copy2.defaultDuplexMode(), printers.at(i).defaultDuplexMode()); + QCOMPARE(copy2.supportedDuplexModes(), printers.at(i).supportedDuplexModes()); } } @@ -347,6 +351,8 @@ void tst_QPrinterInfo::testAssignment() QCOMPARE(copy.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize()); QCOMPARE(copy.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize()); QCOMPARE(copy.supportedResolutions(), printers.at(i).supportedResolutions()); + QCOMPARE(copy.defaultDuplexMode(), printers.at(i).defaultDuplexMode()); + QCOMPARE(copy.supportedDuplexModes(), printers.at(i).supportedDuplexModes()); } } @@ -371,6 +377,8 @@ void tst_QPrinterInfo::namedPrinter() QCOMPARE(pi2.minimumPhysicalPageSize(), pi.minimumPhysicalPageSize()); QCOMPARE(pi2.maximumPhysicalPageSize(), pi.maximumPhysicalPageSize()); QCOMPARE(pi2.supportedResolutions(), pi.supportedResolutions()); + QCOMPARE(pi2.defaultDuplexMode(), pi.defaultDuplexMode()); + QCOMPARE(pi2.supportedDuplexModes(), pi.supportedDuplexModes()); } } #endif // QT_NO_PRINTER -- cgit v1.2.3 From 9911550fa7fa58cfef66a33ccd8b1d0c531f848e Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 20 Oct 2014 14:09:58 +0200 Subject: Fix rubberband selection in rotated GraphicsView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Selection rectangle was incorrectly mapped to scene space when the view was rotated. It became a rotated rectangle instead of the correct polygon (rhombus). Task-number: QTBUG-42008 Change-Id: Ib7b366bec7e1f83109e03c434268ad6897138f30 Reviewed-by: Thorbjørn Lund Martsum --- .../qgraphicsview/tst_qgraphicsview.cpp | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index d38bb86487..afd8be71e8 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -160,6 +160,7 @@ private slots: void dragMode_scrollHand(); void dragMode_rubberBand(); void rubberBandSelectionMode(); + void rotated_rubberBand(); void backgroundBrush(); void foregroundBrush(); void matrix(); @@ -935,6 +936,48 @@ void tst_QGraphicsView::rubberBandSelectionMode() QCOMPARE(scene.selectedItems(), QList() << rect); } +void tst_QGraphicsView::rotated_rubberBand() +{ + QWidget toplevel; + setFrameless(&toplevel); + + QGraphicsScene scene; + const int dim = 3; + for (int i = 0; i < dim; i++) { + for (int j = 0; j < dim; j ++) { + QGraphicsRectItem *rect = new QGraphicsRectItem(i * 20, j * 20, 10, 10); + rect->setFlag(QGraphicsItem::ItemIsSelectable); + rect->setData(0, (i == j)); + scene.addItem(rect); + } + } + + QGraphicsView view(&scene, &toplevel); + QCOMPARE(view.rubberBandSelectionMode(), Qt::IntersectsItemShape); + view.setDragMode(QGraphicsView::RubberBandDrag); + view.resize(120, 120); + view.rotate(45); + toplevel.show(); + QVERIFY(QTest::qWaitForWindowExposed(&toplevel)); + + // Disable mouse tracking to prevent the window system from sending mouse + // move events to the viewport while we are synthesizing events. If + // QGraphicsView gets a mouse move event with no buttons down, it'll + // terminate the rubber band. + view.viewport()->setMouseTracking(false); + + QCOMPARE(scene.selectedItems(), QList()); + int midWidth = view.viewport()->width() / 2; + sendMousePress(view.viewport(), QPoint(midWidth - 2, 0), Qt::LeftButton); + sendMouseMove(view.viewport(), QPoint(midWidth + 2, view.viewport()->height()), + Qt::LeftButton, Qt::LeftButton); + QCOMPARE(scene.selectedItems().count(), dim); + foreach (const QGraphicsItem *item, scene.items()) { + QCOMPARE(item->isSelected(), item->data(0).toBool()); + } + sendMouseRelease(view.viewport(), QPoint(), Qt::LeftButton); +} + void tst_QGraphicsView::backgroundBrush() { QGraphicsScene scene; -- cgit v1.2.3 From 6841dd6eccda88f08ad4c424fc9d5f9e400aaf43 Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 21 Oct 2014 12:21:06 +0200 Subject: QGraphicsScene: stabilize stacking order of toplevel items Removing and adding toplevel items could result in invalid stacking order (not corresponding to insertion order). Task-number: QTBUG-19316 Change-Id: Ia8646784a2181cfa936b101e2adaf7e7e73bb83d Reviewed-by: Andreas Aardal Hanssen --- .../qgraphicsscene/tst_qgraphicsscene.cpp | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 70448f9813..bd1c6a0dc5 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -242,6 +242,7 @@ private slots: void style(); void sorting_data(); void sorting(); + void insertionOrder(); void changedSignal_data(); void changedSignal(); void stickyFocus_data(); @@ -3633,6 +3634,42 @@ void tst_QGraphicsScene::sorting() << t_1); } +void tst_QGraphicsScene::insertionOrder() +{ + QGraphicsScene scene; + const int numItems = 5; + QList items; + + for (int i = 0; i < numItems; ++i) { + QGraphicsRectItem* item = new QGraphicsRectItem(i * 20, i * 20, 200, 200); + item->setData(0, i); + items.append(item); + scene.addItem(item); + } + + { + QList itemList = scene.items(); + QCOMPARE(itemList.count(), numItems); + for (int i = 0; i < itemList.count(); ++i) { + QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt()); + } + } + + for (int i = 0; i < items.size(); ++i) + { + scene.removeItem(items.at(i)); + scene.addItem(items.at(i)); + } + + { + QList itemList = scene.items(); + QCOMPARE(itemList.count(), numItems); + for (int i = 0; i < itemList.count(); ++i) { + QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt()); + } + } +} + class ChangedListener : public QObject { Q_OBJECT -- cgit v1.2.3 From 7645b64d896330885a2afcbb996b677730151570 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 20 Oct 2014 16:31:34 +0400 Subject: Add support for "Apple Roman" encoding Substitute this encoding by "macintosh" when Qt is built with ICU. It is for compatibility with Qt 4.x. Change-Id: I70c51cba7d473ac81e25862736cb71a2f6894055 Reviewed-by: Lars Knoll --- tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index 7c154575d0..24487aa7cc 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -196,6 +196,7 @@ void tst_QTextCodec::fromUnicode_data() QTest::newRow("windows-1257") << "windows-1257" << true; QTest::newRow("windows-1258") << "windows-1258" << true; + QTest::newRow("Apple Roman") << "Apple Roman" << true; QTest::newRow("macintosh") << "macintosh" << true; //QTest::newRow("WINSAMI2") << "WINSAMI2" << true; QTest::newRow("TIS-620") << "TIS-620" << true; -- cgit v1.2.3 From 3903aee91bb4bca618593cf4c856edc0be2a17d8 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 22 Oct 2014 16:35:43 +0400 Subject: Fix doc about the list of supported codecs Replace "Apple Roman" by "Macintosh" which is registered by IANA: http://tools.ietf.org/html/rfc1345. Replace unsupported "GB18030-0" by "GB18030". Remove "JIS X 0201" and "JIS X 0208" as they are supported as parts of other Japanese encodings but not directly. Add "HP-ROMAN8" which is supported by both Qt and ICU. Also clean the codecs test. Change-Id: Iaf8e8ff1900d3f92ea0e0df75c60fe1534de23ac Reviewed-by: Lars Knoll --- tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index 24487aa7cc..4e3d5c64bc 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -197,10 +197,8 @@ void tst_QTextCodec::fromUnicode_data() QTest::newRow("windows-1258") << "windows-1258" << true; QTest::newRow("Apple Roman") << "Apple Roman" << true; - QTest::newRow("macintosh") << "macintosh" << true; //QTest::newRow("WINSAMI2") << "WINSAMI2" << true; QTest::newRow("TIS-620") << "TIS-620" << true; -// QTest::newRow("hp-roman8") << "hp-roman8" << true; QTest::newRow("SJIS") << "SJIS" << false; // all codecs from documentation @@ -210,20 +208,17 @@ void tst_QTextCodec::fromUnicode_data() QTest::newRow("windows-949") << "windows-949" << false; QTest::newRow("EUC-JP") << "EUC-JP" << false; QTest::newRow("EUC-KR") << "EUC-KR" << false; - //QTest::newRow("GB18030-0") << "GB18030-0" << false; // only GB18030 works QTest::newRow("GB18030") << "GB18030" << false; + QTest::newRow("HP-ROMAN8") << "HP-ROMAN8" << false; QTest::newRow("IBM 850") << "IBM 850" << false; QTest::newRow("IBM 866") << "IBM 866" << false; QTest::newRow("IBM 874") << "IBM 874" << false; QTest::newRow("ISO 2022-JP") << "ISO 2022-JP" << false; //ISO 8859-1 to 10 and ISO 8859-13 to 16 tested previously // Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml tested in Iscii test - //QTest::newRow("JIS X 0201") << "JIS X 0201" << false; // actually not there - //QTest::newRow("JIS X 0208") << "JIS X 0208" << false; // actually not there QTest::newRow("KOI8-R") << "KOI8-R" << false; QTest::newRow("KOI8-U") << "KOI8-U" << false; - //QTest::newRow("MuleLao-1") << "MuleLao-1" << false; //only on x11 - QTest::newRow("ROMAN8") << "ROMAN8" << false; + QTest::newRow("Macintosh") << "Macintosh" << true; QTest::newRow("Shift-JIS") << "Shift-JIS" << false; QTest::newRow("TIS-620") << "TIS-620" << false; QTest::newRow("TSCII") << "TSCII" << false; -- cgit v1.2.3 From 3f9dbc0ec82e1c7c823707668fcd326d8a1dd82b Mon Sep 17 00:00:00 2001 From: Samuel Nevala Date: Wed, 22 Oct 2014 14:49:33 +0300 Subject: Android: Keyboard doesn't hide from done button QLineEdit commits and hides QInputMethod on enter key press. When Qt::ImhMultiLine input method hint is set, virtual keyboard is not hidden. Task-number: QTBUG-37850 Change-Id: I018351caa18bd2116665771e5f024a57182a01b9 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/shared/platforminputcontext.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h index fc415d833b..22b7ad6610 100644 --- a/tests/auto/shared/platforminputcontext.h +++ b/tests/auto/shared/platforminputcontext.h @@ -56,6 +56,8 @@ public: virtual void reset() { m_resetCallCount++; } virtual void commit() { m_commitCallCount++; + if (m_commitString.isEmpty()) + return; QInputMethodEvent commitEvent; commitEvent.setCommitString(m_commitString); if (qGuiApp->focusObject()) -- cgit v1.2.3 From e859de3fb5203579fbb4a6774bcdf59dc00404f9 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 24 Oct 2014 10:53:01 +0200 Subject: Add extra declarations to make rcc output pass -Wmissing-declarations The previously produced code was valid C++. Add the declaration nevertheless to help people who want to use the switch in their own code. Task-number: QTBUG-42119 Change-Id: Ia47cf3930684474ff65e5cf37335d7d7f57a1d31 Reviewed-by: Olivier Goffart --- tests/auto/tools/rcc/data/images/images.expected | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected index ae470db336..1f0157d51c 100644 --- a/tests/auto/tools/rcc/data/images/images.expected +++ b/tests/auto/tools/rcc/data/images/images.expected @@ -116,6 +116,7 @@ bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, } #endif +int QT_RCC_MANGLE_NAMESPACE(qInitResources)(); int QT_RCC_MANGLE_NAMESPACE(qInitResources)() { QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData) @@ -123,6 +124,7 @@ int QT_RCC_MANGLE_NAMESPACE(qInitResources)() return 1; } +int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)() { QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData) -- cgit v1.2.3