diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-03-24 20:37:33 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-03-24 20:37:33 +0100 |
commit | 487844fc62bdf048224d6fc3b7eaae6347d4457b (patch) | |
tree | 763dc03ad77fd5b43ef74e817423540caa015e4b /tests/auto | |
parent | 4ed048dded34dbe2ce2842f0d40d9f54cd7571b0 (diff) | |
parent | 6cacd19db56b632964c3b2453bc273dac50446c9 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I13c7ea6a74eb98606cf45702ae068101943bec6a
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/auto.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp | 93 | ||||
-rw-r--r-- | tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 20 | ||||
-rw-r--r-- | tests/auto/other/other.pro | 4 | ||||
-rw-r--r-- | tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp | 108 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp | 11 |
6 files changed, 141 insertions, 97 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index ad7998a198..dd70d78ae5 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -24,7 +24,7 @@ ios: SUBDIRS = corelib gui wince: SUBDIRS -= printsupport cross_compile: SUBDIRS -= tools cmake installed_cmake !qtHaveModule(opengl): SUBDIRS -= opengl -!qtHaveModule(gui): SUBDIRS -= gui cmake +!qtHaveModule(gui): SUBDIRS -= gui cmake installed_cmake !qtHaveModule(widgets): SUBDIRS -= widgets !qtHaveModule(printsupport): SUBDIRS -= printsupport !qtHaveModule(concurrent): SUBDIRS -= concurrent diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp index fe465df395..5f5252aa96 100644 --- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp +++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp @@ -174,9 +174,6 @@ private Q_SLOTS: void fetchAndSub_data() { addData(); } void fetchAndSub(); - void addSub_data() { addData(); } - void addSub(); - void fetchAndOr_data() { addData(); } void fetchAndOr(); @@ -656,96 +653,6 @@ void tst_QAtomicIntegerXX::fetchAndSub() } } -void tst_QAtomicIntegerXX::addSub() -{ - QFETCH(LargeInt, value); - QAtomicInteger<T> atomic(value); - - // note: this test has undefined behavior for signed max and min - T parcel1 = 42; - T parcel2 = T(0-parcel1); - T newValue1 = T(value) + parcel1; - T newValue2 = T(value) - parcel1; - - QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), newValue1); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), newValue1); - QCOMPARE(atomic.load(), T(value)); - - QCOMPARE(atomic.fetchAndAddAcquire(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndSubAcquire(parcel1), newValue1); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubAcquire(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndAddAcquire(parcel1), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndAddAcquire(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndSubAcquire(parcel2), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubAcquire(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndAddAcquire(parcel2), newValue1); - QCOMPARE(atomic.load(), T(value)); - - QCOMPARE(atomic.fetchAndAddRelease(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndSubRelease(parcel1), newValue1); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubRelease(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndAddRelease(parcel1), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndAddRelease(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndSubRelease(parcel2), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubRelease(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndAddRelease(parcel2), newValue1); - QCOMPARE(atomic.load(), T(value)); - - QCOMPARE(atomic.fetchAndAddOrdered(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndSubOrdered(parcel1), newValue1); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubOrdered(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndAddOrdered(parcel1), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndAddOrdered(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); - QCOMPARE(atomic.fetchAndSubOrdered(parcel2), newValue2); - QCOMPARE(atomic.load(), T(value)); - QCOMPARE(atomic.fetchAndSubOrdered(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue1); - QCOMPARE(atomic.fetchAndAddOrdered(parcel2), newValue1); - QCOMPARE(atomic.load(), T(value)); - - // operator+= and operator-= - QCOMPARE(atomic += parcel1, newValue1); - QCOMPARE(atomic -= parcel1, T(value)); - QCOMPARE(atomic -= parcel1, newValue2); - QCOMPARE(atomic += parcel1, T(value)); - QCOMPARE(atomic += parcel2, newValue2); - QCOMPARE(atomic -= parcel2, T(value)); - QCOMPARE(atomic -= parcel2, newValue1); - QCOMPARE(atomic += parcel2, T(value)); -} - void tst_QAtomicIntegerXX::fetchAndOr() { QFETCH(LargeInt, value); diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 123fbfeb2a..d553854cb2 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -97,7 +97,10 @@ private slots: void multiConnect(); void writeOnlySocket(); + + void writeToClientAndDisconnect_data(); void writeToClientAndDisconnect(); + void debug(); void bytesWrittenSignal(); void syncDisconnectNotify(); @@ -1026,8 +1029,16 @@ void tst_QLocalSocket::writeOnlySocket() QCOMPARE(client.state(), QLocalSocket::ConnectedState); } +void tst_QLocalSocket::writeToClientAndDisconnect_data() +{ + QTest::addColumn<int>("chunks"); + QTest::newRow("one chunk") << 1; + QTest::newRow("several chunks") << 20; +} + void tst_QLocalSocket::writeToClientAndDisconnect() { + QFETCH(int, chunks); QLocalServer server; QLocalSocket client; QSignalSpy readChannelFinishedSpy(&client, SIGNAL(readChannelFinished())); @@ -1041,14 +1052,17 @@ void tst_QLocalSocket::writeToClientAndDisconnect() char buffer[100]; memset(buffer, 0, sizeof(buffer)); - QCOMPARE(clientSocket->write(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); - clientSocket->waitForBytesWritten(); + for (int i = 0; i < chunks; ++i) + QCOMPARE(clientSocket->write(buffer, sizeof(buffer)), qint64(sizeof(buffer))); + while (clientSocket->bytesToWrite()) + QVERIFY(clientSocket->waitForBytesWritten()); clientSocket->close(); server.close(); client.waitForDisconnected(); QCOMPARE(readChannelFinishedSpy.count(), 1); - QCOMPARE(client.read(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); + const QByteArray received = client.readAll(); + QCOMPARE(received.size(), qint64(sizeof(buffer) * chunks)); QCOMPARE(client.state(), QLocalSocket::UnconnectedState); } diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 673e922fdd..0e9f054a01 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -24,6 +24,10 @@ SUBDIRS=\ windowsmobile \ toolsupport \ +!qtHaveModule(gui): SUBDIRS -= \ + qcomplextext \ + qprocess_and_guieventloop \ + !qtHaveModule(widgets): SUBDIRS -= \ gestures \ lancelot \ diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 2dd0337117..89fb30557b 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -32,6 +32,7 @@ #include <qabstractitemview.h> #include <qstandarditemmodel.h> #include <qapplication.h> +#include <qevent.h> #include <qlistview.h> #include <qlistwidget.h> #include <qtableview.h> @@ -248,6 +249,8 @@ private slots: void shiftSelectionAfterChangingModelContents(); void QTBUG48968_reentrant_updateEditorGeometries(); void QTBUG50102_SH_ItemView_ScrollMode(); + void QTBUG50535_update_on_new_selection_model(); + void testSelectionModelInSyncWithView(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -2067,6 +2070,111 @@ void tst_QAbstractItemView::QTBUG50102_SH_ItemView_ScrollMode() QCOMPARE(view.horizontalScrollMode(), styleScrollMode); } +void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model() +{ + QStandardItemModel model; + for (int i = 0; i < 10; ++i) + model.appendRow(new QStandardItem(QStringLiteral("%1").arg(i))); + + class ListView : public QListView + { + public: + ListView() + : m_paintEventsCount(0) + { + } + + int m_paintEventsCount; + + protected: + bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE + { + if (event->type() == QEvent::Paint) + ++m_paintEventsCount; + return QListView::viewportEvent(event); + } + }; + + // keep the current/selected row in the "low range", i.e. be sure it's visible, otherwise we + // don't get updates and the test fails. + + ListView view; + view.setModel(&model); + view.selectionModel()->setCurrentIndex(model.index(1, 0), QItemSelectionModel::SelectCurrent); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + + QItemSelectionModel selectionModel(&model); + selectionModel.setCurrentIndex(model.index(2, 0), QItemSelectionModel::Current); + + int oldPaintEventsCount = view.m_paintEventsCount; + view.setSelectionModel(&selectionModel); + QTRY_VERIFY(view.m_paintEventsCount > oldPaintEventsCount); + + + QItemSelectionModel selectionModel2(&model); + selectionModel2.select(model.index(0, 0), QItemSelectionModel::ClearAndSelect); + selectionModel2.setCurrentIndex(model.index(1, 0), QItemSelectionModel::Current); + + oldPaintEventsCount = view.m_paintEventsCount; + view.setSelectionModel(&selectionModel2); + QTRY_VERIFY(view.m_paintEventsCount > oldPaintEventsCount); +} + +void tst_QAbstractItemView::testSelectionModelInSyncWithView() +{ + QStandardItemModel model; + for (int i = 0; i < 10; ++i) + model.appendRow(new QStandardItem(QStringLiteral("%1").arg(i))); + + class ListView : public QListView + { + public: + using QListView::selectedIndexes; + }; + + ListView view; + QVERIFY(!view.selectionModel()); + + view.setModel(&model); + QVERIFY(view.selectionModel()); + QVERIFY(view.selectedIndexes().isEmpty()); + QVERIFY(view.selectionModel()->selection().isEmpty()); + + view.setCurrentIndex(model.index(0, 0)); + QCOMPARE(view.currentIndex(), model.index(0, 0)); + QCOMPARE(view.selectionModel()->currentIndex(), model.index(0, 0)); + + view.selectionModel()->setCurrentIndex(model.index(1, 0), QItemSelectionModel::SelectCurrent); + QCOMPARE(view.currentIndex(), model.index(1, 0)); + QCOMPARE(view.selectedIndexes(), QModelIndexList() << model.index(1, 0)); + QCOMPARE(view.selectionModel()->currentIndex(), model.index(1, 0)); + QCOMPARE(view.selectionModel()->selection().indexes(), QModelIndexList() << model.index(1, 0)); + + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + QItemSelectionModel selectionModel(&model); + selectionModel.setCurrentIndex(model.index(2, 0), QItemSelectionModel::Current); + + view.setSelectionModel(&selectionModel); + QCOMPARE(view.currentIndex(), model.index(2, 0)); + QCOMPARE(view.selectedIndexes(), QModelIndexList()); + QCOMPARE(view.selectionModel()->currentIndex(), model.index(2, 0)); + QCOMPARE(view.selectionModel()->selection().indexes(), QModelIndexList()); + + + QItemSelectionModel selectionModel2(&model); + selectionModel2.select(model.index(0, 0), QItemSelectionModel::ClearAndSelect); + selectionModel2.setCurrentIndex(model.index(1, 0), QItemSelectionModel::Current); + + view.setSelectionModel(&selectionModel2); + QCOMPARE(view.currentIndex(), model.index(1, 0)); + QCOMPARE(view.selectedIndexes(), QModelIndexList() << model.index(0, 0)); + QCOMPARE(view.selectionModel()->currentIndex(), model.index(1, 0)); + QCOMPARE(view.selectionModel()->selection().indexes(), QModelIndexList() << model.index(0, 0)); +} QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp index a8b0d45ffa..700fa505c1 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp @@ -83,6 +83,7 @@ private slots: void clearHistory(); void sourceInsideLoadResource(); void textInteractionFlags_vs_readOnly(); + void inputMethodAttribute_vs_readOnly(); void anchorsWithSelfBuiltHtml(); void relativeNonLocalUrls(); void adjacentAnchors(); @@ -438,6 +439,16 @@ void tst_QTextBrowser::textInteractionFlags_vs_readOnly() QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction); } +void tst_QTextBrowser::inputMethodAttribute_vs_readOnly() +{ + QVERIFY(browser->isReadOnly()); + QVERIFY(!browser->testAttribute(Qt::WA_InputMethodEnabled)); + browser->setReadOnly(false); + QVERIFY(browser->testAttribute(Qt::WA_InputMethodEnabled)); + browser->setReadOnly(true); + QVERIFY(!browser->testAttribute(Qt::WA_InputMethodEnabled)); +} + void tst_QTextBrowser::anchorsWithSelfBuiltHtml() { browser->setHtml("<p>Hello <a href=\"#anchor\">Link</a>" |