From b72fd8482e9bfbf924fe05e6efdb58a6bb25b887 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 13 Mar 2012 15:18:48 +1000 Subject: Uncomment disabled code in QSettings autotest. The code in question was already commented out before the test was added to the Qt repository in 2006. After changing the code to use QFile::rename() for portability, the test appears to pass. Change-Id: I52a8578a47da419cabf5826b633cc4f2ac2c5218 Reviewed-by: Rohan McGovern --- tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index d294eec248..dbb844d204 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -1486,11 +1486,9 @@ void tst_QSettings::sync() settings1.sync(); QCOMPARE(settings1.allKeys().count(), 0); -/* - // Now "some other app" will change software.org.conf - unlink((userConfDir + "software.org.ini").toLatin1()); - rename((userConfDir + "other.software.org.ini").toLatin1(), - (userConfDir + "software.org.ini").toLatin1()); + // Now "some other app" will change software.org.ini + QVERIFY(QFile::rename((userConfDir + "other.software.org.ini").toLatin1(), + (userConfDir + "software.org.ini").toLatin1())); settings1.sync(); QCOMPARE(settings1.value("alpha/beta/geometry").toInt(), -7); @@ -1505,7 +1503,6 @@ void tst_QSettings::sync() QCOMPARE(settings1.value("moo/beta/geometry/height").toInt(), 4); QCOMPARE(settings1.value("moo/gamma/splitter").toInt(), 5); QCOMPARE(settings1.allKeys().count(), 11); -*/ } void tst_QSettings::setFallbacksEnabled_data() -- cgit v1.2.3 From 7ecbc49c55c531875d98103609e025dd1ad5c44f Mon Sep 17 00:00:00 2001 From: Alexei Rousskikh Date: Tue, 13 Mar 2012 10:10:12 -0400 Subject: QJsonParseError improvements - added human-readable error message - improved enum value names Change-Id: I86d4bb419f9581f85d61b6e090048f1943017f9e Reviewed-by: Lars Knoll --- tests/auto/corelib/json/tst_qtjson.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 87820d2e78..8a206dd6f9 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -1186,7 +1186,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n 11111"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::EndOfNumber); + QCOMPARE(error.error, QJsonParseError::TerminationByNumber); QCOMPARE(error.offset, 11); } { @@ -1210,7 +1210,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"\\u12\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::StringEscapeSequence); + QCOMPARE(error.error, QJsonParseError::IllegalEscapeSequence); QCOMPARE(error.offset, 11); } { @@ -1218,7 +1218,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"foo" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); + QCOMPARE(error.error, QJsonParseError::IllegalUTF8String); QCOMPARE(error.offset, 13); } { @@ -1226,7 +1226,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \""; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::EndOfString); + QCOMPARE(error.error, QJsonParseError::UnterminatedString); QCOMPARE(error.offset, 8); } { @@ -1234,7 +1234,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"c" UNICODE_DJE "a\\u12\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::StringEscapeSequence); + QCOMPARE(error.error, QJsonParseError::IllegalEscapeSequence); QCOMPARE(error.offset, 15); } { @@ -1242,7 +1242,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"c" UNICODE_DJE "a" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); + QCOMPARE(error.error, QJsonParseError::IllegalUTF8String); QCOMPARE(error.offset, 14); } { @@ -1250,7 +1250,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"c" UNICODE_DJE "a ]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::EndOfString); + QCOMPARE(error.error, QJsonParseError::UnterminatedString); QCOMPARE(error.offset, 14); } } -- cgit v1.2.3 From 8d28f263aa14cc450085c9df3623a483b6021c56 Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Tue, 27 Mar 2012 07:09:22 +0200 Subject: Fix IAccessible2 for Windows, enable MSAA/IAccessible for MinGW. Commit 5e9089135bfe7db7d7a43c9ee4d4c24ab8f6458d had some problems: * It left out the cast to IServiceProvider in the refactoring of QueryInterface. This broke IAccessible2. * It also failed to enable the codepath for MinGW inside wrap(), which effectively caused MSAA for MinGW to be disabled. It also adds an autotest to the bridge (finally). It is simple, but it should help avoiding committing stuff that completely breaks the bridge. Change-Id: I459d89c3bdb93e54ddea85872b50fc1dba0fe4a0 Reviewed-by: Friedemann Kleint --- tests/auto/other/qaccessibility/qaccessibility.pro | 5 + .../other/qaccessibility/tst_qaccessibility.cpp | 108 +++++++++++++++++++++ 2 files changed, 113 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index 0019cc94c8..388e6ab29d 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -13,3 +13,8 @@ wince*: { } mac: CONFIG += insignificant_test # QTBUG-22812 + +win32 { + !*g++: include(../../../../src/3rdparty/iaccessible2/iaccessible2.pri) + LIBS += -loleacc -loleaut32 -lole32 +} diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 5f0539a5af..fa8d45c203 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -40,6 +40,18 @@ ****************************************************************************/ +#include +#ifdef Q_OS_WIN +# include +# include +# include +# include +# ifndef Q_CC_MINGW +# include +# include +# include +# endif +#endif #include #include #include @@ -270,6 +282,7 @@ private slots: void accessibleName(); void labelTest(); void accelerators(); + void bridgeTest(); protected slots: void onClicked(); @@ -2942,5 +2955,100 @@ void tst_QAccessibility::accelerators() QTestAccessibility::clearEvents(); } +void tst_QAccessibility::bridgeTest() +{ + // For now this is a simple test to see if the bridge is working at all. + // Ideally it should be extended to test all aspects of the bridge. +#ifdef Q_OS_WIN + // First, test MSAA part of bridge + QWidget *window = new QWidget; + QVBoxLayout *lay = new QVBoxLayout(window); + QPushButton *button = new QPushButton(tr("Push me"), window); + QLineEdit *le = new QLineEdit(window); + lay->addWidget(button); + lay->addWidget(le); + + window->show(); + QTest::qWaitForWindowShown(window); + + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(button); + QPoint buttonPos = button->mapToGlobal(QPoint(0,0)); + QRect buttonRect = iface->rect(); + QCOMPARE(buttonRect.topLeft(), buttonPos); + + + // All set, now test the bridge. + POINT pt; + pt.x = buttonRect.center().x(); + pt.y = buttonRect.center().y(); + IAccessible *iacc; + + VARIANT varChild; + HRESULT hr = ::AccessibleObjectFromPoint(pt, &iacc, &varChild); + QVERIFY(SUCCEEDED(hr)); + VARIANT varSELF; + varSELF.vt = VT_I4; + varSELF.lVal = 0; + + // **** Test get_accRole **** + VARIANT varRole; + hr = iacc->get_accRole(varSELF, &varRole); + QVERIFY(SUCCEEDED(hr)); + + QCOMPARE(varRole.vt, (VARTYPE)VT_I4); + QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_PUSHBUTTON); + + // **** Test accLocation **** + long x, y, w, h; + hr = iacc->accLocation(&x, &y, &w, &h, varSELF); + QCOMPARE(buttonRect, QRect(x, y, w, h)); + +#ifndef Q_CC_MINGW + // Test IAccessible2 part of bridge + IServiceProvider *pService = 0; + hr = iacc->QueryInterface(IID_IServiceProvider, (void **)&pService); + if (SUCCEEDED(hr)) { + IAccessible2 *pIA2 = 0; + hr = pService->QueryService(IID_IAccessible, IID_IAccessible2, (void**)&pIA2); + if (SUCCEEDED(hr) && pIA2) { + // The control supports IAccessible2. + // pIA2 is the reference to the accessible object's IAccessible2 interface. + + /***** Test IAccessibleComponent *****/ + IAccessibleComponent *ia2Component = 0; + hr = pIA2->QueryInterface(IID_IAccessibleComponent, (void**)&ia2Component); + QVERIFY(SUCCEEDED(hr)); + long x, y; + hr = ia2Component->get_locationInParent(&x, &y); + QVERIFY(SUCCEEDED(hr)); + QCOMPARE(button->pos(), QPoint(x, y)); + ia2Component->Release(); + + /***** Test IAccessibleAction *****/ + IAccessibleAction *ia2Action = 0; + hr = pIA2->QueryInterface(IID_IAccessibleAction, (void**)&ia2Action); + QVERIFY(SUCCEEDED(hr)); + QVERIFY(ia2Action); + long nActions; + ia2Action->nActions(&nActions); + QVERIFY(nActions >= 1); // "Press" and "SetFocus" + BSTR actionName; + ia2Action->get_name(0, &actionName); + QString name((QChar*)actionName); + QCOMPARE(name, QAccessibleActionInterface::pressAction()); + ia2Action->Release(); + + // Done testing + pIA2->Release(); + } + pService->Release(); + } +#endif + iacc->Release(); + + QTestAccessibility::clearEvents(); +#endif +} + QTEST_MAIN(tst_QAccessibility) #include "tst_qaccessibility.moc" -- cgit v1.2.3 From 0ee1b4a1dea8b587a5d39bfeb7e18c97f13dd877 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Tue, 28 Feb 2012 13:35:17 +0200 Subject: Reverted use of tentative commit use in QWidget editors Feature to be reimplemented simplified. Cases when input method needs to be reset with possibility to commit use QInputMethod::commit() again. Change-Id: Ibfe7aecc0799e7a76c7ac4f5d860971cfe6e97ca Reviewed-by: Joona Petrell --- tests/auto/shared/platforminputcontext.h | 15 ++++- .../qgraphicsscene/tst_qgraphicsscene.cpp | 3 +- .../qgraphicsview/tst_qgraphicsview.cpp | 13 +++-- .../widgets/widgets/qlineedit/tst_qlineedit.cpp | 64 ++++++++++------------ tests/auto/widgets/widgets/qtextedit/qtextedit.pro | 2 +- .../widgets/widgets/qtextedit/tst_qtextedit.cpp | 42 ++++++++++++-- 6 files changed, 89 insertions(+), 50 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h index cddeca3945..2c1a3bcb25 100644 --- a/tests/auto/shared/platforminputcontext.h +++ b/tests/auto/shared/platforminputcontext.h @@ -61,7 +61,19 @@ public: virtual QRectF keyboardRect() const { return m_keyboardRect; } virtual bool isAnimating() const { return m_animating; } virtual void reset() { m_resetCallCount++; } - virtual void commit() { m_commitCallCount++; } + virtual void commit() { + m_commitCallCount++; + QInputMethodEvent commitEvent; + commitEvent.setCommitString(m_commitString); + if (qGuiApp->focusObject()) + qGuiApp->sendEvent(qGuiApp->focusObject(), &commitEvent); + else + qWarning("Test input context to commit without focused object"); + } + void setCommitString(const QString &commitString) + { + m_commitString = commitString; + } virtual void update(Qt::InputMethodQueries queries) { @@ -105,6 +117,7 @@ public: int m_updateCallCount; int m_resetCallCount; int m_commitCallCount; + QString m_commitString; mutable int m_localeCallCount; mutable int m_inputDirectionCallCount; Qt::InputMethodQueries m_lastQueries; diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index daa06d0762..8772fb1e7e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -3784,6 +3784,7 @@ void tst_QGraphicsScene::inputMethod() QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); inputContext.m_resetCallCount = 0; + inputContext.m_commitCallCount = 0; scene.addItem(item); QInputMethodEvent event; @@ -3802,7 +3803,7 @@ void tst_QGraphicsScene::inputMethod() scene.setFocusItem(0); // the input context is reset twice, once because an item has lost focus and again because // the Qt::WA_InputMethodEnabled flag is cleared because no item has focus. - QCOMPARE(inputContext.m_resetCallCount, callFocusItem ? 2 : 0); + QCOMPARE(inputContext.m_resetCallCount + inputContext.m_commitCallCount, callFocusItem ? 2 : 0); QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); // verify that value is unaffected item->eventCalls = 0; diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index ee7ec7ba57..19532a0e37 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -4187,21 +4187,22 @@ void tst_QGraphicsView::inputContextReset() item1->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod); inputContext.m_resetCallCount = 0; + inputContext.m_commitCallCount = 0; scene.addItem(item1); QCOMPARE(inputContext.m_resetCallCount, 0); + QCOMPARE(inputContext.m_commitCallCount, 0); - inputContext.m_resetCallCount = 0; scene.setFocusItem(item1); QCOMPARE(scene.focusItem(), (QGraphicsItem *)item1); QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); QCOMPARE(inputContext.m_resetCallCount, 0); + QCOMPARE(inputContext.m_commitCallCount, 0); - inputContext.m_resetCallCount = 0; scene.setFocusItem(0); // the input context is reset twice, once because an item has lost focus and again because // the Qt::WA_InputMethodEnabled flag is cleared because no item has focus. // QEXPECT_FAIL("", "QTBUG-22454", Abort); - QCOMPARE(inputContext.m_resetCallCount, 2); + QCOMPARE(inputContext.m_resetCallCount + inputContext.m_commitCallCount, 2); // introduce another item that is focusable but does not accept input methods QGraphicsItem *item2 = new QGraphicsRectItem; @@ -4209,17 +4210,19 @@ void tst_QGraphicsView::inputContextReset() scene.addItem(item2); inputContext.m_resetCallCount = 0; + inputContext.m_commitCallCount = 0; scene.setFocusItem(item2); QCOMPARE(inputContext.m_resetCallCount, 0); + QCOMPARE(inputContext.m_commitCallCount, 0); - inputContext.m_resetCallCount = 0; scene.setFocusItem(item1); QCOMPARE(inputContext.m_resetCallCount, 0); + QCOMPARE(inputContext.m_commitCallCount, 0); // test changing between between items that accept input methods. item2->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod); scene.setFocusItem(item2); - QCOMPARE(inputContext.m_resetCallCount, 1); + QCOMPARE(inputContext.m_resetCallCount + inputContext.m_commitCallCount, 1); } void tst_QGraphicsView::indirectPainting() diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index a6860006c2..384c5c2861 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -72,6 +72,10 @@ #include "qplatformdefs.h" +#include "../../../shared/platforminputcontext.h" +#include + + QT_BEGIN_NAMESPACE class QPainter; QT_END_NAMESPACE @@ -275,7 +279,6 @@ private slots: void selectAndCursorPosition(); void inputMethod(); void inputMethodSelection(); - void inputMethodTentativeCommit(); protected slots: void editingFinished(); @@ -301,6 +304,7 @@ private: int newCursorPos; QLineEdit *testWidget; int m_keyboardScheme; + PlatformInputContext m_platformInputContext; }; typedef QList IntList; @@ -357,21 +361,23 @@ void tst_QLineEdit::initTestCase() testWidget->resize(200,50); testWidget->show(); + QTest::qWaitForWindowShown(testWidget); QApplication::setActiveWindow(testWidget); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(testWidget); -#endif QTRY_VERIFY(testWidget->hasFocus()); changed_count = 0; edited_count = 0; selection_count = 0; + + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &m_platformInputContext; } void tst_QLineEdit::cleanupTestCase() { delete testWidget; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; } void tst_QLineEdit::init() @@ -3828,6 +3834,23 @@ void tst_QLineEdit::inputMethod() testWidget->setEnabled(false); QApplication::sendEvent(testWidget, &queryEvent); QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), false); + testWidget->setEnabled(true); + + // removing focus allows input method to commit preedit + testWidget->setText(""); + testWidget->activateWindow(); + QTRY_VERIFY(testWidget->hasFocus()); + QTRY_COMPARE(qApp->focusObject(), testWidget); + + m_platformInputContext.setCommitString("text"); + m_platformInputContext.m_commitCallCount = 0; + QList attributes; + QInputMethodEvent preeditEvent("preedit text", attributes); + QApplication::sendEvent(testWidget, &preeditEvent); + + testWidget->clearFocus(); + QCOMPARE(m_platformInputContext.m_commitCallCount, 1); + QCOMPARE(testWidget->text(), QString("text")); } void tst_QLineEdit::inputMethodSelection() @@ -3866,37 +3889,6 @@ void tst_QLineEdit::inputMethodSelection() QCOMPARE(selectionSpy.count(), 3); } -void tst_QLineEdit::inputMethodTentativeCommit() -{ - // test that basic tentative commit gets to text property on preedit state - QList attributes; - QInputMethodEvent event("test", attributes); - event.setTentativeCommitString("test"); - QApplication::sendEvent(testWidget, &event); - QCOMPARE(testWidget->text(), QString("test")); - - // tentative commit not allowed present in surrounding text - QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText); - QApplication::sendEvent(testWidget, &queryEvent); - QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString("")); - - // if text with tentative commit does not validate, not allowed to be part of text property - testWidget->setText(""); // ensure input state is reset - QValidator *validator = new QIntValidator(0, 100); - testWidget->setValidator(validator); - QApplication::sendEvent(testWidget, &event); - QCOMPARE(testWidget->text(), QString("")); - testWidget->setValidator(0); - delete validator; - - // text remains when focus is removed - testWidget->setText(""); // ensure input state is reset - QApplication::sendEvent(testWidget, &event); - QFocusEvent lostFocus(QEvent::FocusOut); - QApplication::sendEvent(testWidget, &lostFocus); - QCOMPARE(testWidget->text(), QString("test")); -} - QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" diff --git a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro index 85658c222e..1c2821b289 100644 --- a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro +++ b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qtextedit -QT += widgets widgets-private gui-private testlib +QT += widgets widgets-private gui-private core-private testlib INCLUDEPATH += ../ HEADERS += diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 249e9d7fbe..9c5a3dbed7 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -62,6 +62,10 @@ #include #include +#include "../../../shared/platforminputcontext.h" +#include + + //Used in copyAvailable typedef QPair keyPairType; typedef QList pairListType; @@ -96,6 +100,8 @@ public: tst_QTextEdit(); public slots: + void initTestCase(); + void cleanupTestCase(); void init(); void cleanup(); private slots: @@ -211,6 +217,7 @@ private: QTextEdit *ed; qreal rootFrameMargin; + PlatformInputContext m_platformInputContext; }; bool tst_QTextEdit::nativeClipboardWorking() @@ -372,6 +379,18 @@ public: tst_QTextEdit::tst_QTextEdit() {} +void tst_QTextEdit::initTestCase() +{ + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &m_platformInputContext; +} + +void tst_QTextEdit::cleanupTestCase() +{ + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; +} + void tst_QTextEdit::init() { #ifdef Q_OS_WINCE //disable magic for WindowsCE @@ -2360,6 +2379,8 @@ void tst_QTextEdit::bidiLogicalMovement() void tst_QTextEdit::inputMethodEvent() { + ed->show(); + // test that text change with an input method event triggers change signal QSignalSpy spy(ed, SIGNAL(textChanged())); @@ -2367,14 +2388,23 @@ void tst_QTextEdit::inputMethodEvent() event.setCommitString("text"); QApplication::sendEvent(ed, &event); QCOMPARE(spy.count(), 1); - spy.clear(); + QCOMPARE(ed->toPlainText(), QString("text")); + // test that input method gets chance to commit preedit when removing focus + ed->setText(""); + QApplication::setActiveWindow(ed); + QTRY_VERIFY(QApplication::focusWindow()); + QCOMPARE(qApp->focusObject(), ed); + + m_platformInputContext.setCommitString("text"); + m_platformInputContext.m_commitCallCount = 0; QList attributes; - QInputMethodEvent event2("preedit", attributes); - event2.setTentativeCommitString("string"); - QApplication::sendEvent(ed, &event2); - QCOMPARE(spy.count(), 1); - QCOMPARE(ed->toPlainText(), QString("textstring")); + QInputMethodEvent preeditEvent("preedit text", attributes); + QApplication::sendEvent(ed, &preeditEvent); + + ed->clearFocus(); + QCOMPARE(m_platformInputContext.m_commitCallCount, 1); + QCOMPARE(ed->toPlainText(), QString("text")); } void tst_QTextEdit::inputMethodSelection() -- cgit v1.2.3 From 2c4845ce331e5dfaf5e106f74871ce16721a1358 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Mar 2012 11:44:19 +0100 Subject: Fix some compiler warnings in tests. - Unused variables - Deprecated conversion from const char * to char *. Change-Id: Iea0b9c4613ea74cead6d95ba12ad1028f531cbff Reviewed-by: Jason McDonald --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 9 +++++++++ tests/auto/network/socket/qlocalsocket/example/server/main.cpp | 2 +- tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp | 2 +- tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp | 6 +++--- tests/auto/tools/qmake/testcompiler.cpp | 2 +- .../graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp | 8 +++----- .../itemviews/qabstractitemview/tst_qabstractitemview.cpp | 3 +-- tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp | 2 +- 8 files changed, 20 insertions(+), 14 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index f007d44262..4eabd61025 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -718,6 +718,11 @@ void tst_QString::acc_01() } } +#ifdef Q_CC_GNU +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-security" +#endif + void tst_QString::isNull() { QString a; @@ -728,6 +733,10 @@ void tst_QString::isNull() QVERIFY(!a.isNull()); } +#ifdef Q_CC_GNU +# pragma GCC diagnostic pop +#endif + void tst_QString::isEmpty() { QString a; diff --git a/tests/auto/network/socket/qlocalsocket/example/server/main.cpp b/tests/auto/network/socket/qlocalsocket/example/server/main.cpp index d066e4ef51..909bb6856f 100644 --- a/tests/auto/network/socket/qlocalsocket/example/server/main.cpp +++ b/tests/auto/network/socket/qlocalsocket/example/server/main.cpp @@ -72,7 +72,7 @@ public: if (n == 0) break; qDebug() << "Read" << str; - if ("exit" == str) + if (!qstrcmp(str, "exit")) qApp->quit(); if (socket->write(str, 100) < 0) { diff --git a/tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp b/tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp index 91b14e5051..f32a5e7cd5 100644 --- a/tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp +++ b/tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp @@ -76,7 +76,7 @@ private slots: int main() { - char *argv[] = {"appName", "slotName"}; + char *argv[] = { const_cast("appName"), const_cast("slotName") }; int argc = 2; tst_TestA testA; diff --git a/tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp b/tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp index 20bfc2228a..73de6df5f3 100644 --- a/tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp +++ b/tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp @@ -65,7 +65,7 @@ void tst_StrCmp::compareCharStars() const QCOMPARE(str1, "foo"); QCOMPARE(str1, str1); - char *str2 = "foo"; + char *str2 = const_cast("foo"); QCOMPARE("foo", str2); QCOMPARE(str2, "foo"); QCOMPARE(str2, str2); @@ -88,8 +88,8 @@ void tst_StrCmp::compareByteArray() const QCOMPARE(ba.constData(), "bar"); QCOMPARE(ba.constData(), "foo"); - char *bar = "bar"; - char *foo = "foo"; + char *bar = const_cast("bar"); + char *foo = const_cast("foo"); QEXPECT_FAIL("", "Next test should fail", Continue); QCOMPARE(ba.data(), bar); diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index 4e5dc26eac..3b77b1ec63 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -128,7 +128,7 @@ TestCompiler::~TestCompiler() bool TestCompiler::errorOut() { - qDebug(qPrintable(testOutput_.join("\n"))); + qDebug("%s", qPrintable(testOutput_.join(QStringLiteral("\n")))); return false; } diff --git a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp index acb9155ca8..4f15f96cba 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp @@ -287,17 +287,15 @@ void tst_QGraphicsLayoutItem::setMaximumSize() void tst_QGraphicsLayoutItem::setMinimumSize_data() { QTest::addColumn("size"); - QTest::addColumn("outputSize"); - QTest::newRow("-1") << QSizeF(-1, -1) << QSizeF(0, 0); - QTest::newRow("0") << QSizeF(0, 0) << QSizeF(0, 0); - QTest::newRow("10") << QSizeF(10, 10) << QSizeF(10, 10); + QTest::newRow("-1") << QSizeF(-1, -1); + QTest::newRow("0") << QSizeF(0, 0); + QTest::newRow("10") << QSizeF(10, 10); } // void setMinimumSize(QSizeF const& size) public void tst_QGraphicsLayoutItem::setMinimumSize() { QFETCH(QSizeF, size); - QFETCH(QSizeF, outputSize); SubQGraphicsLayoutItem layoutItem; QSizeF oldSize = layoutItem.minimumSize(); diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index be7c58f20b..c6c8131422 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -238,10 +238,9 @@ public: openedEditor = new QWidget(parent); return openedEditor; } - void destroyEditor(QWidget *editor, const QModelIndex &index) const + void destroyEditor(QWidget *editor, const QModelIndex &) const { calledVirtualDtor = true; - // QAbstractItemDelegate::destroyEditor(editor,index); editor->deleteLater(); } diff --git a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp index f93d979169..d8b193f5c8 100644 --- a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp +++ b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp @@ -118,9 +118,9 @@ class ServerAndClient : public QObject public: ServerAndClient(QEventLoop &ev) : success(false) , eventLoop(ev) - , isBody(false) , bodyBytesRead(0) , bodyLength(-1) + , isBody(false) { setObjectName("serverAndClient"); tcpServer = new QTcpServer(this); -- cgit v1.2.3 From 27441054197d0ecff6b83e7e6511e0d6955f4593 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Thu, 8 Dec 2011 14:52:19 +0200 Subject: Protect QAbstractTextDocumentLayout::anchorAt() from preedit Previously the method didn't take into account that hitTest() returns visual index, i.e. containing the preedit, and thus was easily hitting assertion. Need to compensate for that before checking for actual link. Change-Id: I119e7f91088b4db9d347a3da338f6df915ce9719 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../tst_qabstracttextdocumentlayout.cpp | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp index c609b4a1ed..a33e3cd13b 100644 --- a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp +++ b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp @@ -47,6 +47,7 @@ #include #include #include +#include class tst_QAbstractTextDocumentLayout : public QObject { @@ -59,6 +60,7 @@ public: private slots: void getSetCheck(); void maximumBlockCount(); + void anchorAt(); }; tst_QAbstractTextDocumentLayout::tst_QAbstractTextDocumentLayout() @@ -152,5 +154,35 @@ void tst_QAbstractTextDocumentLayout::maximumBlockCount() QCOMPARE(layout.blockCount, 10); } +void tst_QAbstractTextDocumentLayout::anchorAt() +{ + QTextDocument doc; + doc.setHtml("foo"); + QAbstractTextDocumentLayout *documentLayout = doc.documentLayout(); + QTextBlock firstBlock = doc.begin(); + QTextLayout *layout = firstBlock.layout(); + layout->setPreeditArea(doc.toPlainText().length(), "xxx"); + + doc.setPageSize(QSizeF(1000, 1000)); + QFontMetrics metrics(layout->font()); + QPointF blockStart = documentLayout->blockBoundingRect(firstBlock).topLeft(); + + // anchorAt on start returns link + QRect linkBr = metrics.boundingRect("foo"); + QPointF linkPoint(linkBr.width() + blockStart.x(), (linkBr.height() / 2) + blockStart.y()); + QCOMPARE(documentLayout->anchorAt(linkPoint), QString("link")); + + // anchorAt() on top of preedit at end should not assert + QRect preeditBr = metrics.boundingRect(doc.toPlainText() + "xx"); + QPointF preeditPoint(preeditBr.width() + blockStart.x(), (preeditBr.height() / 2) + blockStart.y()); + QCOMPARE(documentLayout->anchorAt(preeditPoint), QString()); + + // preedit at start should not return link + layout->setPreeditArea(0, "xxx"); + preeditBr = metrics.boundingRect("xx"); + preeditPoint = QPointF(preeditBr.width() + blockStart.x(), (preeditBr.height() / 2) + blockStart.y()); + QCOMPARE(documentLayout->anchorAt(preeditPoint), QString()); +} + QTEST_MAIN(tst_QAbstractTextDocumentLayout) #include "tst_qabstracttextdocumentlayout.moc" -- cgit v1.2.3 From e5d549552614f89dd73b29fc3ee4710f65bb1e57 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 20 Mar 2012 18:01:20 +0100 Subject: Make QCoreApplication::applicationName() default to argv[0] This makes it more useful in all the Qt apps that don't set it, given that it's used internally by QTemporaryFile, QTemporaryDir, QStandardPaths, QDBus, QAccessibleApplication, etc. Qt4 compatibility in the deprecated QDesktopServices is preserved, no fallback there. Change-Id: I584463507cf917a3720793c6bd45d07c60f8356c Reviewed-by: Thiago Macieira --- .../auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp | 14 ++++---------- .../kernel/qcoreapplication/tst_qcoreapplication.cpp | 3 ++- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index a6eabbbed6..e9af29494b 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -186,18 +186,12 @@ void tst_qstandardpaths::testDataLocation() { // On all platforms, DataLocation should be GenericDataLocation / organization name / app name // This allows one app to access the data of another app. - { - const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); - const QString app = QStandardPaths::writableLocation(QStandardPaths::DataLocation); - QCOMPARE(base, app); - } + const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/tst_qstandardpaths"); QCoreApplication::instance()->setOrganizationName("Qt"); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/tst_qstandardpaths"); QCoreApplication::instance()->setApplicationName("QtTest"); - { - const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); - const QString app = QStandardPaths::writableLocation(QStandardPaths::DataLocation); - QCOMPARE(app, base + "/Qt/QtTest"); - } + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/QtTest"); #ifdef Q_XDG_PLATFORM setDefaultLocations(); diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 84d723ca61..f4aefb2726 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -121,7 +121,8 @@ void tst_QCoreApplication::qAppName() int argc = 1; char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); - QVERIFY(!::qAppName().isEmpty()); + QCOMPARE(::qAppName(), QString::fromLatin1("tst_qcoreapplication")); + QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1("tst_qcoreapplication")); } void tst_QCoreApplication::argc() -- cgit v1.2.3 From 32068cb707bc60d6a74697beaea6fb7cab399bb8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 28 Mar 2012 00:32:02 +0200 Subject: Remove comment about QVariantList and QVariantMap. They predate Qt 4.5, but it looks like the comments are indicating that QVariantList and QVariantMap types will use the basic template, but that is not the case. Instead they will use the compare specializations for QList and QMap respectively. Change-Id: Iebf7e9b8aaa8a699ea720090fbf641dfecde0ff7 Reviewed-by: Thiago Macieira --- tests/auto/dbus/qdbusmarshall/common.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/dbus/qdbusmarshall/common.h b/tests/auto/dbus/qdbusmarshall/common.h index 025641531d..f4c10c467d 100644 --- a/tests/auto/dbus/qdbusmarshall/common.h +++ b/tests/auto/dbus/qdbusmarshall/common.h @@ -350,8 +350,6 @@ QT_END_NAMESPACE #endif -//bool compare(const QVariantList &l1, const QVariantList &l2); -//bool compare(const QVariantMap &m1, const QVariantMap &m2); template bool compare(const T &t1, const T &t2) { return t1 == t2; } -- cgit v1.2.3 From 6d13e9f29597e0d557857e3f80173faba5368424 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 26 Mar 2012 09:16:03 +0200 Subject: Use "qt-project.org" instead of "trolltech" in the resource system Task-number: QTBUG-23272 Change-Id: Idcdb9620910577b3c0fc9a792a0446665bd2eab6 Reviewed-by: Lars Knoll --- tests/auto/tools/uic/baseline/tabbedbrowser.ui | 8 +++--- tests/auto/tools/uic/baseline/tabbedbrowser.ui.h | 8 +++--- tests/auto/widgets/kernel/qicon/tst_qicon.cpp | 36 ++++++++++++------------ 3 files changed, 26 insertions(+), 26 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/tools/uic/baseline/tabbedbrowser.ui b/tests/auto/tools/uic/baseline/tabbedbrowser.ui index 7164fb7271..382f49fe5e 100644 --- a/tests/auto/tools/uic/baseline/tabbedbrowser.ui +++ b/tests/auto/tools/uic/baseline/tabbedbrowser.ui @@ -99,7 +99,7 @@ - :/trolltech/assistant/images/close.png + :/qt-project.org/assistant/images/close.png true @@ -130,7 +130,7 @@ Previous - :/trolltech/assistant/images/win/previous.png + :/qt-project.org/assistant/images/win/previous.png Qt::ToolButtonTextBesideIcon @@ -152,7 +152,7 @@ Next - :/trolltech/assistant/images/win/next.png + :/qt-project.org/assistant/images/win/next.png Qt::ToolButtonTextBesideIcon @@ -194,7 +194,7 @@ - <img src=":/trolltech/assistant/images/wrap.png">&nbsp;Search wrapped + <img src=":/qt-project.org/assistant/images/wrap.png">&nbsp;Search wrapped Qt::RichText diff --git a/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h b/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h index 1e99c41312..f2c1f1e3e5 100644 --- a/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h +++ b/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h @@ -125,7 +125,7 @@ public: hboxLayout->setObjectName(QStringLiteral("hboxLayout")); toolClose = new QToolButton(frameFind); toolClose->setObjectName(QStringLiteral("toolClose")); - const QIcon icon = QIcon(QString::fromUtf8(":/trolltech/assistant/images/close.png")); + const QIcon icon = QIcon(QString::fromUtf8(":/qt-project.org/assistant/images/close.png")); toolClose->setIcon(icon); toolClose->setAutoRaise(true); @@ -144,7 +144,7 @@ public: toolPrevious = new QToolButton(frameFind); toolPrevious->setObjectName(QStringLiteral("toolPrevious")); - const QIcon icon1 = QIcon(QString::fromUtf8(":/trolltech/assistant/images/win/previous.png")); + const QIcon icon1 = QIcon(QString::fromUtf8(":/qt-project.org/assistant/images/win/previous.png")); toolPrevious->setIcon(icon1); toolPrevious->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolPrevious->setAutoRaise(true); @@ -154,7 +154,7 @@ public: toolNext = new QToolButton(frameFind); toolNext->setObjectName(QStringLiteral("toolNext")); toolNext->setMinimumSize(QSize(0, 0)); - const QIcon icon2 = QIcon(QString::fromUtf8(":/trolltech/assistant/images/win/next.png")); + const QIcon icon2 = QIcon(QString::fromUtf8(":/qt-project.org/assistant/images/win/next.png")); toolNext->setIcon(icon2); toolNext->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolNext->setAutoRaise(true); @@ -204,7 +204,7 @@ public: toolNext->setText(QApplication::translate("TabbedBrowser", "Next", 0, QApplication::UnicodeUTF8)); checkCase->setText(QApplication::translate("TabbedBrowser", "Case Sensitive", 0, QApplication::UnicodeUTF8)); checkWholeWords->setText(QApplication::translate("TabbedBrowser", "Whole words", 0, QApplication::UnicodeUTF8)); - labelWrapped->setText(QApplication::translate("TabbedBrowser", " Search wrapped", 0, QApplication::UnicodeUTF8)); + labelWrapped->setText(QApplication::translate("TabbedBrowser", " Search wrapped", 0, QApplication::UnicodeUTF8)); } // retranslateUi }; diff --git a/tests/auto/widgets/kernel/qicon/tst_qicon.cpp b/tests/auto/widgets/kernel/qicon/tst_qicon.cpp index 4a9ab93921..cca0887a21 100644 --- a/tests/auto/widgets/kernel/qicon/tst_qicon.cpp +++ b/tests/auto/widgets/kernel/qicon/tst_qicon.cpp @@ -374,32 +374,32 @@ void tst_QIcon::detach() void tst_QIcon::addFile() { QIcon icon; - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png")); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png")); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png"), QSize(), QIcon::Selected); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png"), QSize(), QIcon::Selected); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png")); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png")); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png"), QSize(), QIcon::Selected); #ifndef Q_OS_WINCE QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png")).toImage()); QVERIFY(icon.pixmap(128, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png")).toImage()); QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); QVERIFY(icon.pixmap(32, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png")).toImage()); QVERIFY(icon.pixmap(128, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png")).toImage()); #else // WinCE only includes the 16x16 images for size reasons QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); #endif } @@ -436,7 +436,7 @@ void tst_QIcon::availableSizes() { // we try to load an icon from resources - QIcon icon(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + QIcon icon(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); QList availableSizes = icon.availableSizes(); QCOMPARE(availableSizes.size(), 1); QCOMPARE(availableSizes.at(0), QSize(16, 16)); @@ -445,7 +445,7 @@ void tst_QIcon::availableSizes() { // load an icon from binary data. QPixmap pix; - QFile file(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + QFile file(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); QVERIFY(file.open(QIODevice::ReadOnly)); uchar *data = file.map(0, file.size()); QVERIFY(data != 0); @@ -617,12 +617,12 @@ void tst_QIcon::fromTheme() void tst_QIcon::task223279_inconsistentAddFile() { QIcon icon1; - icon1.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + icon1.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); icon1.addFile(QLatin1String("IconThatDoesntExist"), QSize(32, 32)); QPixmap pm1 = icon1.pixmap(32, 32); QIcon icon2; - icon2.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + icon2.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); icon2.addFile(QLatin1String("IconThatDoesntExist")); QPixmap pm2 = icon1.pixmap(32, 32); -- cgit v1.2.3 From 5185a28139800a9fef49dabc6c110e017f83cdd6 Mon Sep 17 00:00:00 2001 From: Jonas Rabbe Date: Wed, 28 Mar 2012 12:07:19 +1000 Subject: Fix a crash in QFactoryLoader The change in plugin loading has meant that different plugins in the same plugin folder will not be handled properly when loaded with different instances of QFactoryLoader. A solution is to only unload compatability plugins from QFactoryLoader::update() since they are the only plugins that are actually loaded in that method. This auto test shows the error on the current version of QFactoryLoader and passes with the fix described above. Change-Id: I12001525d51bb631d6742c5965357598322f247c Reviewed-by: Lars Knoll --- tests/auto/corelib/plugin/plugin.pro | 1 + .../plugin/qfactoryloader/plugin1/plugin1.cpp | 47 +++++++++++ .../plugin/qfactoryloader/plugin1/plugin1.h | 58 ++++++++++++++ .../plugin/qfactoryloader/plugin1/plugin1.pro | 10 +++ .../qfactoryloader/plugin1/plugininterface1.h | 59 ++++++++++++++ .../plugin/qfactoryloader/plugin2/plugin2.cpp | 47 +++++++++++ .../plugin/qfactoryloader/plugin2/plugin2.h | 58 ++++++++++++++ .../plugin/qfactoryloader/plugin2/plugin2.pro | 10 +++ .../qfactoryloader/plugin2/plugininterface2.h | 59 ++++++++++++++ .../plugin/qfactoryloader/qfactoryloader.pro | 15 ++++ .../corelib/plugin/qfactoryloader/test/test.pro | 21 +++++ .../plugin/qfactoryloader/tst_qfactoryloader.cpp | 91 ++++++++++++++++++++++ 12 files changed, 476 insertions(+) create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.cpp create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin1/plugininterface1.h create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.cpp create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.h create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin2/plugininterface2.h create mode 100644 tests/auto/corelib/plugin/qfactoryloader/qfactoryloader.pro create mode 100644 tests/auto/corelib/plugin/qfactoryloader/test/test.pro create mode 100644 tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp (limited to 'tests/auto') diff --git a/tests/auto/corelib/plugin/plugin.pro b/tests/auto/corelib/plugin/plugin.pro index 24de36e4ec..506f6abaeb 100644 --- a/tests/auto/corelib/plugin/plugin.pro +++ b/tests/auto/corelib/plugin/plugin.pro @@ -1,5 +1,6 @@ TEMPLATE=subdirs SUBDIRS=\ + qfactoryloader \ qlibrary \ qplugin \ qpluginloader \ diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.cpp b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.cpp new file mode 100644 index 0000000000..542b58a5bf --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "plugin1.h" + +QString Plugin1::pluginName() const +{ + return QLatin1String("Plugin1 ok"); +} diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h new file mode 100644 index 0000000000..02d814e1fa --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef THEPLUGIN_H +#define THEPLUGIN_H + +#include +#include +#include "plugininterface1.h" + +class Plugin1 : public QObject, public PluginInterface1 +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface1") + Q_INTERFACES(PluginInterface1) + +public: + virtual QString pluginName() const; +}; + +#endif // THEPLUGIN_H diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro new file mode 100644 index 0000000000..1d578c0b2e --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro @@ -0,0 +1,10 @@ +TEMPLATE = lib +CONFIG += plugin +HEADERS = plugin1.h +SOURCES = plugin1.cpp +TARGET = $$qtLibraryTarget(plugin1) +DESTDIR = ../bin + +# This is testdata for the tst_qpluginloader test. +target.path = $$[QT_INSTALL_TESTS]/tst_qfactoryloader/bin +INSTALLS += target diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugininterface1.h b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugininterface1.h new file mode 100644 index 0000000000..37f53c9c89 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugininterface1.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PLUGININTERFACE1_H +#define PLUGININTERFACE1_H + +#include + +struct PluginInterface1 { + virtual ~PluginInterface1() {} + virtual QString pluginName() const = 0; +}; + +QT_BEGIN_NAMESPACE + +#define PluginInterface1_iid "org.qt-project.Qt.autotests.plugininterface1" + +Q_DECLARE_INTERFACE(PluginInterface1, PluginInterface1_iid) + +QT_END_NAMESPACE + +#endif // PLUGININTERFACE1_H diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.cpp b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.cpp new file mode 100644 index 0000000000..b0a8f08495 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "plugin2.h" + +QString Plugin2::pluginName() const +{ + return QLatin1String("Plugin2 ok"); +} diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.h b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.h new file mode 100644 index 0000000000..f5741246ab --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef THEPLUGIN_H +#define THEPLUGIN_H + +#include +#include +#include "plugininterface2.h" + +class Plugin2 : public QObject, public PluginInterface2 +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface2") + Q_INTERFACES(PluginInterface2) + +public: + virtual QString pluginName() const; +}; + +#endif // THEPLUGIN_H diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro new file mode 100644 index 0000000000..1a8bd3a721 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro @@ -0,0 +1,10 @@ +TEMPLATE = lib +CONFIG += plugin +HEADERS = plugin2.h +SOURCES = plugin2.cpp +TARGET = $$qtLibraryTarget(plugin2) +DESTDIR = ../bin + +# This is testdata for the tst_qpluginloader test. +target.path = $$[QT_INSTALL_TESTS]/tst_qfactoryloader/bin +INSTALLS += target diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugininterface2.h b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugininterface2.h new file mode 100644 index 0000000000..3fc57f1df2 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugininterface2.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PLUGININTERFACE2_H +#define PLUGININTERFACE2_H + +#include + +struct PluginInterface2 { + virtual ~PluginInterface2() {} + virtual QString pluginName() const = 0; +}; + +QT_BEGIN_NAMESPACE + +#define PluginInterface2_iid "org.qt-project.Qt.autotests.plugininterface2" + +Q_DECLARE_INTERFACE(PluginInterface2, PluginInterface2_iid) + +QT_END_NAMESPACE + +#endif // PLUGININTERFACE2_H diff --git a/tests/auto/corelib/plugin/qfactoryloader/qfactoryloader.pro b/tests/auto/corelib/plugin/qfactoryloader/qfactoryloader.pro new file mode 100644 index 0000000000..42bc01e2ed --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/qfactoryloader.pro @@ -0,0 +1,15 @@ +QT = core-private +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = \ + plugin1 \ + plugin2 \ + test + +TARGET = tst_qpluginloader + +# no special install rule for subdir +INSTALLS = + + +CONFIG += parallel_test diff --git a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro new file mode 100644 index 0000000000..d03af231aa --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro @@ -0,0 +1,21 @@ +CONFIG += testcase +TARGET = ../tst_qfactoryloader +QT = core-private testlib + +SOURCES = \ + ../tst_qfactoryloader.cpp + +HEADERS = \ + ../plugin1/plugininterface1.h \ + ../plugin2/plugininterface2.h + +win32 { + CONFIG(debug, debug|release) { + TARGET = ../../debug/tst_qfactoryloader + } else { + TARGET = ../../release/tst_qfactoryloader + } +} + +mac: CONFIG -= app_bundle +mac: CONFIG += insignificant_test # QTBUG-22765 diff --git a/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp new file mode 100644 index 0000000000..d4ed63dc37 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include "plugin1/plugininterface1.h" +#include "plugin2/plugininterface2.h" + +class tst_QFactoryLoader : public QObject +{ + Q_OBJECT +public slots: + void initTestCase(); + +private slots: + void usingTwoFactoriesFromSameDir(); +}; + +static const char binFolderC[] = "bin"; + +void tst_QFactoryLoader::initTestCase() +{ + const QString binFolder = QFINDTESTDATA(binFolderC); + QVERIFY2(!binFolder.isEmpty(), "Unable to locate 'bin' folder"); + + QCoreApplication::setLibraryPaths(QStringList(QFileInfo(binFolder).absolutePath())); +} + +void tst_QFactoryLoader::usingTwoFactoriesFromSameDir() +{ + const QString suffix = QLatin1Char('/') + QLatin1String(binFolderC); + QFactoryLoader loader1(PluginInterface1_iid, suffix); + + PluginInterface1 *plugin1 = qobject_cast(loader1.instance(0)); + QVERIFY2(plugin1, + qPrintable(QString::fromLatin1("Cannot load plugin '%1'") + .arg(QLatin1String(PluginInterface1_iid)))); + + QFactoryLoader loader2(PluginInterface2_iid, suffix); + + PluginInterface2 *plugin2 = qobject_cast(loader2.instance(0)); + QVERIFY2(plugin2, + qPrintable(QString::fromLatin1("Cannot load plugin '%1'") + .arg(QLatin1String(PluginInterface2_iid)))); + + QCOMPARE(plugin1->pluginName(), QLatin1String("Plugin1 ok")); + QCOMPARE(plugin2->pluginName(), QLatin1String("Plugin2 ok")); +} + +QTEST_MAIN(tst_QFactoryLoader) +#include "tst_qfactoryloader.moc" -- cgit v1.2.3 From 698b33fccebbd1cb4094fdf8dc681108824530f5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 29 Mar 2012 12:25:09 +0200 Subject: Properly detach when the modified object is a sub object The clone() method didn't detach if we had enough memory allocated, but didn't consider that the object being modified is not the root object of the binary blob. Change-Id: I9a479ae1c873b7fe9cff7e13c539e7a41961bf68 Reviewed-by: Cristiano di Flora Reviewed-by: abcd Reviewed-by: Jamey Hicks --- tests/auto/corelib/json/tst_qtjson.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 8a206dd6f9..4ab4b78da1 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -122,6 +122,7 @@ private Q_SLOTS: void assignArrays(); void testTrailingComma(); + void testDetachBug(); private: QString testDataDir; }; @@ -1820,5 +1821,29 @@ void TestQtJson::testTrailingComma() } } +void TestQtJson::testDetachBug() +{ + QJsonObject dynamic; + QJsonObject embedded; + + QJsonObject local; + + embedded.insert("Key1", QString("Value1")); + embedded.insert("Key2", QString("Value2")); + dynamic.insert(QStringLiteral("Bogus"), QString("bogusValue")); + dynamic.insert("embedded", embedded); + local = dynamic.value("embedded").toObject(); + + dynamic.remove("embedded"); + + QCOMPARE(local.keys().size(),2); + local.remove("Key1"); + local.remove("Key2"); + QCOMPARE(local.keys().size(), 0); + + local.insert("Key1", QString("anotherValue")); + QCOMPARE(local.keys().size(), 1); +} + QTEST_MAIN(TestQtJson) #include "tst_qtjson.moc" -- cgit v1.2.3 From cff46983a8823fda13cafa2c8774153525f0d4d1 Mon Sep 17 00:00:00 2001 From: Matt Newell Date: Mon, 26 Mar 2012 10:46:22 -0700 Subject: Allow named bind values to be used multiple times per query Prepared queries should be able to use a name parameter more than once. Currently this will result in undefined behavior and crashes. This patch fixes the bug and implements the needed test case. Task-number: QTBUG-6420 Change-Id: I07d6537e432a9b2781e9ef3d9f597bceb054527e Reviewed-by: Andy Shaw Reviewed-by: Honglei Zhang --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 584fcb045a..dab34a89ed 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -1683,11 +1683,11 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec("set client_min_messages='warning'")); if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) ) - createQuery = "create table " + qtest_prepare + " (id int primary key, name nvarchar(200) null)"; + createQuery = "create table " + qtest_prepare + " (id int primary key, name nvarchar(200) null, name2 nvarchar(200) null)"; else if ( tst_Databases::isMySQL(db) && useUnicode ) - createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200) character set utf8)"; + createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200) character set utf8, name2 varchar(200) character set utf8)"; else - createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200))"; + createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200), name2 varchar(200))"; QVERIFY_SQL( q, exec( createQuery ) ); @@ -1756,7 +1756,7 @@ void tst_QSqlQuery::prepare_bind_exec() QCOMPARE( q.value( 0 ).toInt(), i ); QCOMPARE( q.value( 1 ).toString().trimmed(), values[ i ] ); QSqlRecord rInf = q.record(); - QCOMPARE(( int )rInf.count(), 2 ); + QCOMPARE(( int )rInf.count(), 3 ); QCOMPARE( rInf.field( 0 ).name().toUpper(), QString( "ID" ) ); QCOMPARE( rInf.field( 1 ).name().toUpper(), QString( "NAME" ) ); QVERIFY( !q.next() ); @@ -1839,6 +1839,20 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY( !q.isActive() ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name, name2) values (:id, :name, :name)" ) ); + for ( i = 101; i < 103; ++i ) { + q.bindValue( ":id", i ); + q.bindValue( ":name", "name" ); + QVERIFY( q.exec() ); + } + + // Test for QTBUG-6420 + QVERIFY( q.exec( "select * from " + qtest_prepare + " where id > 100 order by id" ) ); + QVERIFY( q.next() ); + QCOMPARE( q.value(0).toInt(), 101 ); + QCOMPARE( q.value(1).toString(), QString("name") ); + QCOMPARE( q.value(2).toString(), QString("name") ); + } // end of SQLite scope } -- cgit v1.2.3 From 06001ce0085c5fd47bbcc3c7ab151f7c0ac2f0ed Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Wed, 7 Mar 2012 18:54:58 +0200 Subject: Fix crash when an invalid filter is set QSqlTableModel::headerData() generates a crash if an invalid filter is set. QSqlQueryModel::indexInQuery() should check the index value before applied to d->colOffsets[]. QSqlQueryModel::initRecordAndPrimaryIndex() is updated to sync the size of rec and colOffsets. Task-number: QTBUG-23879 Change-Id: Ic9f88bb288592aa6fb3c1415cc818632dadaab56 Reviewed-by: Michael Goddard Reviewed-by: Mark Brand --- .../models/qsqltablemodel/tst_qsqltablemodel.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index afe2c59144..2cea8b3546 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -133,6 +133,9 @@ private slots: void insertBeforeDelete_data() { generic_data(); } void insertBeforeDelete(); + + void invalidFilterAndHeaderData_data() { generic_data(); } + void invalidFilterAndHeaderData(); //QTBUG-23879 private: void generic_data(const QString& engine=QString()); void generic_data_with_strategies(const QString& engine=QString()); @@ -1681,5 +1684,25 @@ void tst_QSqlTableModel::insertBeforeDelete() QCOMPARE(model.rowCount(), 5); } +void tst_QSqlTableModel::invalidFilterAndHeaderData() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlTableModel model(0, db); + model.setTable(test); + model.setEditStrategy(QSqlTableModel::OnManualSubmit); + QVERIFY_SQL(model, select()); + QVERIFY_SQL(model, setHeaderData(0, Qt::Horizontal, "id")); + QVERIFY_SQL(model, setHeaderData(1, Qt::Horizontal, "name")); + QVERIFY_SQL(model, setHeaderData(2, Qt::Horizontal, "title")); + + model.setFilter("some nonsense"); + + QVariant v = model.headerData(0, Qt::Horizontal, Qt::SizeHintRole); + QVERIFY(!v.isValid()); +} + QTEST_MAIN(tst_QSqlTableModel) #include "tst_qsqltablemodel.moc" -- cgit v1.2.3 From aea684506945a12312fc05fb3bb4f549da93f7f5 Mon Sep 17 00:00:00 2001 From: Matt Newell Date: Thu, 22 Mar 2012 10:42:56 -0700 Subject: Fix postgres notification support in the QPSQLDriver. This patch fixes a critical bug in the qsqlpsql driver where notifications aren't delivered when received. Any blocking libpq function(specifically PQexec) will read all the incoming data from the socket, including any pending notifications. This would cause the socket notifier to never be fired for incoming notifications that are already queued inside libpq. The qsqldriver test case was skipping the postgres notification test because of this bug, now its enabled and passing. In order to fix this bug I made a wrapper function for PQexec in QPSQLDriverPrivate that calls _q_handleNotification via QMetaObject::callMethod QueuedConnection in order to deliver pending notifications when control returns to the event loop. I also added a flag to ensure only one call is made each time the event loop is entered. Change-Id: I19f5297094ae7ae46bfb0717e4fca744d69f7b92 Reviewed-by: Honglei Zhang Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 7acbf816f1..992df6e0b6 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -54,6 +54,8 @@ #include "tst_databases.h" +Q_DECLARE_METATYPE(QSqlDriver::NotificationSource) + QT_FORWARD_DECLARE_CLASS(QSqlDatabase) struct FieldDef; @@ -385,6 +387,7 @@ void tst_QSqlDatabase::populateTestTables(QSqlDatabase db) void tst_QSqlDatabase::initTestCase() { + qRegisterMetaType("QSqlDriver::NotificationSource"); dbs.open(); for (QStringList::ConstIterator it = dbs.dbNames.begin(); it != dbs.dbNames.end(); ++it) { @@ -2064,21 +2067,17 @@ void tst_QSqlDatabase::eventNotificationPSQL() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); -#if defined(Q_OS_LINUX) - QSKIP( "Event support doesn't work on linux"); -#endif - QSqlQuery query(db); QString procedureName = qTableName("posteventProc", __FILE__); - QSqlDriver &driver=*(db.driver()); QVERIFY_SQL(driver, subscribeToNotification(procedureName)); - QSignalSpy spy(db.driver(), SIGNAL(notification(const QString&))); + QSignalSpy spy(db.driver(), SIGNAL(notification(const QString&,QSqlDriver::NotificationSource))); query.exec(QString("NOTIFY \"%1\"").arg(procedureName)); QCoreApplication::processEvents(); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toString() == procedureName); + QVERIFY(qVariantValue(arguments.at(1)) == QSqlDriver::SelfSource); QVERIFY_SQL(driver, unsubscribeFromNotification(procedureName)); } -- cgit v1.2.3 From 9b423b6e6920250f97b74aeb86f609cf55a5ee22 Mon Sep 17 00:00:00 2001 From: Matt Newell Date: Mon, 5 Mar 2012 23:24:54 +0100 Subject: Expand QtSql tests covering boundValues and boundValueName Tests added that cover boundValues with positional binding, and boundValueName. Change-Id: I2962d76607b716d19d3e0be958109be2f032f2d9 Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 87 +++++++++++++++++++---- 1 file changed, 75 insertions(+), 12 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index dab34a89ed..3de65d00ad 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -1651,6 +1651,24 @@ void tst_QSqlQuery::synonyms() QCOMPARE( rec.field( 2 ).name().toLower(), QString( "t_varchar" ) ); } +// This class is used to test protected QSqlResult methods +class ResultHelper: public QSqlResult +{ + +public: + ResultHelper(): QSqlResult( 0 ) {} // don't call, it's only for stupid compilers + + bool execBatch( bool bindArray = false ) + { + return QSqlResult::execBatch( bindArray ); + } + + QString boundValueName( int pos ) const + { + return QSqlResult::boundValueName( pos ); + } +}; + // It doesn't make sense to split this into several tests void tst_QSqlQuery::prepare_bind_exec() { @@ -1764,33 +1782,90 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec( "DELETE FROM " + qtest_prepare ) ); + /*** Below we test QSqlQuery::boundValues() with position arguments. + * Due to the fact that the name of a positional argument is not + * specified by the Qt docs, we only test that the QMap contains + * the correct values and that QSqlResult::boundValueName returns + * the key that corrosponds to the correct value. ***/ QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, ?)" ) ); q.bindValue( 0, 0 ); q.bindValue( 1, values[ 0 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 0 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[0] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 0 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[0] ); + q.addBindValue( 1 ); q.addBindValue( values[ 1 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 1 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[1] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 1 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[1] ); + q.addBindValue( 2 ); q.addBindValue( values[ 2 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[2] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[2] ); + q.addBindValue( 3 ); q.addBindValue( values[ 3 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 3 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[3] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 3 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[3] ); + q.addBindValue( 4 ); q.addBindValue( values[ 4 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 4 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[4] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 4 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[4] ); + q.bindValue( 1, values[ 5 ] ); q.bindValue( 0, 5 ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 5 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[5] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 5 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[5] ); + q.bindValue( 0, 6 ); q.bindValue( 1, QString() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 6 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), QString() ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 6 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), QString() ); if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) { q.bindValue( 0, 7 ); q.bindValue( 1, utf8str ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 7 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), utf8str ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 7 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), utf8str ); } QVERIFY_SQL( q, exec( "SELECT * FROM " + qtest_prepare + " order by id" ) ); @@ -1961,18 +2036,6 @@ void tst_QSqlQuery::invalidQuery() QVERIFY( !q.next() ); } -class ResultHelper: public QSqlResult -{ - -public: - ResultHelper(): QSqlResult( 0 ) {} // don't call, it's only for stupid compilers - - bool execBatch( bool bindArray = false ) - { - return QSqlResult::execBatch( bindArray ); - } -}; - void tst_QSqlQuery::batchExec() { QFETCH( QString, dbName ); -- cgit v1.2.3 From d5e9616e399e68838f99ae4c123930b330bc4221 Mon Sep 17 00:00:00 2001 From: Matt Newell Date: Thu, 22 Mar 2012 10:42:56 -0700 Subject: Add payload to QSqlDriver notification with PSQL implementation. Postgres async notifications can contain a payload parameter that is currently discarded. This patch provides the QSqlDriver api change necessary to deliver a payload with each emitted notification by adding a QVariant parameter to the notification signal. It also provides the implementation for the qsqlpsql driver. The qsql_ibase driver has been updated to reflect the change to the notification signal signature. The eventNotificationPSQL test in the qsqldatabase test has been expanded to test proper payload sending and receiving. All tests/auto/sql/kernel tests have been run with sqllite and postgres with no regressions. Task-number: QTBUG-13500 Change-Id: I9137f6acc8cfca93f45791ca930e0287d93d5d0d Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 992df6e0b6..626c5049f0 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -2069,15 +2069,17 @@ void tst_QSqlDatabase::eventNotificationPSQL() QSqlQuery query(db); QString procedureName = qTableName("posteventProc", __FILE__); + QString payload = "payload"; QSqlDriver &driver=*(db.driver()); QVERIFY_SQL(driver, subscribeToNotification(procedureName)); - QSignalSpy spy(db.driver(), SIGNAL(notification(const QString&,QSqlDriver::NotificationSource))); - query.exec(QString("NOTIFY \"%1\"").arg(procedureName)); + QSignalSpy spy(db.driver(), SIGNAL(notification(const QString&,QSqlDriver::NotificationSource,const QVariant&))); + query.exec(QString("NOTIFY \"%1\", '%2'").arg(procedureName).arg(payload)); QCoreApplication::processEvents(); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); - QVERIFY(arguments.at(0).toString() == procedureName); - QVERIFY(qVariantValue(arguments.at(1)) == QSqlDriver::SelfSource); + QCOMPARE(arguments.at(0).toString(), procedureName); + QCOMPARE(qVariantValue(arguments.at(1)), QSqlDriver::SelfSource); + QCOMPARE(qvariant_cast(arguments.at(2)).toString(), payload); QVERIFY_SQL(driver, unsubscribeFromNotification(procedureName)); } -- cgit v1.2.3 From 99715fcfc937635475da3a884f4f9bae74b3c62f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 30 Mar 2012 12:54:34 +0200 Subject: Enable Windows font tests.. Application fonts have been added in 4f1820e3a77b3fdda32a1b935502b187e73059cf Task-number: QTBUG-24193 Task-number: QTBUG-24195 Task-number: QTBUG-24196 Change-Id: I45d0bbb183562b7355e07ce7fa93b0046dfd4665 Reviewed-by: Miikka Heikkinen Reviewed-by: Friedemann Kleint --- tests/auto/gui/text/qfontdatabase/qfontdatabase.pro | 1 - tests/auto/gui/text/qfontmetrics/qfontmetrics.pro | 2 -- tests/auto/gui/text/qglyphrun/qglyphrun.pro | 2 -- 3 files changed, 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro index 034d08fc8f..c853aaa100 100644 --- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro +++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro @@ -11,4 +11,3 @@ wince* { } mac: CONFIG += insignificant_test # QTBUG-23062 -win32:CONFIG += insignificant_test # QTBUG-24193 diff --git a/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro b/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro index bb0d8e3c4a..f5cf957722 100644 --- a/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro +++ b/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro @@ -3,5 +3,3 @@ TARGET = tst_qfontmetrics QT += testlib SOURCES += tst_qfontmetrics.cpp RESOURCES += testfont.qrc - -win32:CONFIG += insignificant_test # QTBUG-24195 diff --git a/tests/auto/gui/text/qglyphrun/qglyphrun.pro b/tests/auto/gui/text/qglyphrun/qglyphrun.pro index 97b9806c11..acdff0584f 100644 --- a/tests/auto/gui/text/qglyphrun/qglyphrun.pro +++ b/tests/auto/gui/text/qglyphrun/qglyphrun.pro @@ -10,5 +10,3 @@ wince* { } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } - -win32:CONFIG += insignificant_test # QTBUG-24196 -- cgit v1.2.3 From f2c5d38c32768058827045eb780458f0f92df2b2 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 30 Mar 2012 15:27:59 +0300 Subject: Windows: Make tst_qprinter significant again since the test is passing The commit b188221fee0eaacec115b514185a0508ef655897 fixed the test. Change-Id: I630ede91ad6050b6a22d2b65947dd341ce7d9aa9 Reviewed-by: Friedemann Kleint --- tests/auto/printsupport/kernel/qprinter/qprinter.pro | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/printsupport/kernel/qprinter/qprinter.pro b/tests/auto/printsupport/kernel/qprinter/qprinter.pro index 7543e91f8c..ebf8edea32 100644 --- a/tests/auto/printsupport/kernel/qprinter/qprinter.pro +++ b/tests/auto/printsupport/kernel/qprinter/qprinter.pro @@ -4,4 +4,3 @@ QT += printsupport widgets testlib SOURCES += tst_qprinter.cpp mac*:CONFIG+=insignificant_test -win32:CONFIG += insignificant_test # QTBUG-24191 -- cgit v1.2.3 From c039ad21b5b4435c657a18ffe1d940067e01bf7d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Mar 2012 13:48:02 +0100 Subject: Fix inputMask accessor of QLineControl. Do not append blank character if it is the default. Task-number: QTBUG-20834 Change-Id: I17f6ac4058f295f25ff49f33c41bd9ee40b75811 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 384c5c2861..f2a37d81b5 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -665,14 +665,14 @@ void tst_QLineEdit::inputMask_data() QTest::newRow("nul 2") << QString() << QString(); // try different masks - QTest::newRow("mask 1") << QString("000.000.000.000") << QString("000.000.000.000; "); + QTest::newRow("mask 1") << QString("000.000.000.000") << QString("000.000.000.000"); QTest::newRow("mask 2") << QString("000.000.000.000;#") << QString("000.000.000.000;#"); - QTest::newRow("mask 3") << QString("AAA.aa.999.###;") << QString("AAA.aa.999.###; "); - QTest::newRow("mask 4") << QString(">abcdefabcdefabcdefabcdef Date: Tue, 27 Mar 2012 17:14:24 +0200 Subject: QNetworkAccessFtpBackend: remove entry from QNetworkAccessCache When FTP login fails we fail to remove the entry from the cache. This is because the cache key is created from the url with the userInfo. So this needs to be set again to match the key used when inserted. Task-number: QTBUG-11824 Change-Id: Ib3fd2d737581653ae59c56d0810d42e2d8dc2176 Reviewed-by: Shane Kearns --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 438cf866aa..e93b226b04 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -401,6 +401,9 @@ private Q_SLOTS: void closeDuringDownload_data(); void closeDuringDownload(); + void ftpAuthentication_data(); + void ftpAuthentication(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); private: @@ -6776,6 +6779,35 @@ void tst_QNetworkReply::closeDuringDownload() QTest::qWait(1000); //cancelling ftp takes some time, this avoids a warning caused by test's cleanup() destroying the connection cache before the abort is finished } + +void tst_QNetworkReply::ftpAuthentication_data() +{ + QTest::addColumn("referenceName"); + QTest::addColumn("url"); + QTest::addColumn("error"); + + QTest::newRow("invalidPassword") << (testDataDir + "/rfc3252.txt") << "ftp://ftptest:invalid@" + QtNetworkSettings::serverName() + "/home/qt-test-server/ftp/qtest/rfc3252.txt" << int(QNetworkReply::AuthenticationRequiredError); + QTest::newRow("validPassword") << (testDataDir + "/rfc3252.txt") << "ftp://ftptest:password@" + QtNetworkSettings::serverName() + "/home/qt-test-server/ftp/qtest/rfc3252.txt" << int(QNetworkReply::NoError); +} + +void tst_QNetworkReply::ftpAuthentication() +{ + QFETCH(QString, referenceName); + QFETCH(QString, url); + QFETCH(int, error); + + QFile reference(referenceName); + QVERIFY(reference.open(QIODevice::ReadOnly)); + + QNetworkRequest request(url); + QNetworkReplyPtr reply; + runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply); + + QCOMPARE(reply->url(), request.url()); + QCOMPARE(reply->error(), QNetworkReply::NetworkError(error)); +} + + // NOTE: This test must be last testcase in tst_qnetworkreply! void tst_QNetworkReply::parentingRepliesToTheApp() { -- cgit v1.2.3 From 1f5e058f79f95e869d8de300596137463492056c Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Fri, 16 Mar 2012 14:08:13 +0200 Subject: Testability for password mask delay Unit test to override mask delay value so running it is not dependent on platform style hint. Change-Id: Ic5cc12d32cf97e64729b3af54250bdc05c0c95ad Reviewed-by: Joona Petrell --- tests/auto/widgets/widgets/qlineedit/qlineedit.pro | 2 +- tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro index 83f93f0ba0..74e2333801 100644 --- a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro +++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qlineedit -QT += gui-private core-private widgets testlib +QT += gui-private core-private widgets widgets-private testlib SOURCES += tst_qlineedit.cpp # QTBUG-24518 - unstable test diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index f2a37d81b5..06bf929e4b 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -62,6 +62,8 @@ #endif #include +#include +#include #include #include #include @@ -1670,8 +1672,16 @@ void tst_QLineEdit::passwordEchoOnEdit() void tst_QLineEdit::passwordEchoDelay() { - if (qGuiApp->styleHints()->passwordMaskDelay() <= 0) - QSKIP("No mask delay in use"); + int delay = qGuiApp->styleHints()->passwordMaskDelay(); +#if defined QT_BUILD_INTERNAL + QLineEditPrivate *priv = QLineEditPrivate::get(testWidget); + QWidgetLineControl *control = priv->control; + control->m_passwordMaskDelayOverride = 200; + delay = 200; +#endif + if (delay <= 0) + QSKIP("Platform not defining echo delay and overriding only possible in internal build"); + QStyleOptionFrameV2 opt; QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget); @@ -1691,7 +1701,7 @@ void tst_QLineEdit::passwordEchoDelay() QCOMPARE(testWidget->displayText(), QString(4, fillChar)); QTest::keyPress(testWidget, '4'); QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4')); - QTest::qWait(qGuiApp->styleHints()->passwordMaskDelay()); + QTest::qWait(delay); QTRY_COMPARE(testWidget->displayText(), QString(5, fillChar)); QTest::keyPress(testWidget, '5'); QCOMPARE(testWidget->displayText(), QString(5, fillChar) + QLatin1Char('5')); -- cgit v1.2.3 From 6a4bf73c07b034a0f9d07cb617d23e92ca778dd1 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Thu, 23 Feb 2012 15:57:14 +0200 Subject: Added some convenience API for platform input contexts QPlatformInputContext now gets notified on changed focus and has inputMethodAccepted() telling whether current focus object accepts input method events. Also adapted IBus plugin to use this. Key event filtering for focused objects without input method support got fixed by the change. Change-Id: I6910aa6af2459d752a5763f0ae88fa8c34e5b165 Reviewed-by: Joona Petrell --- .../gui/kernel/qinputmethod/tst_qinputmethod.cpp | 20 ++++++++++++++++++++ tests/auto/shared/platforminputcontext.h | 9 ++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index 3810546146..cfe26d23e7 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -122,6 +122,8 @@ private slots: void update(); void query(); void inputDirection(); + void inputMethodAccepted(); + private: InputItem m_inputItem; PlatformInputContext m_platformInputContext; @@ -304,5 +306,23 @@ void tst_qinputmethod::inputDirection() QCOMPARE(m_platformInputContext.m_localeCallCount, 1); } +void tst_qinputmethod::inputMethodAccepted() +{ + InputItem disabledItem; + disabledItem.setEnabled(false); + + DummyWindow window; + window.show(); + QTest::qWaitForWindowShown(&window); + window.requestActivateWindow(); + QTRY_COMPARE(qApp->focusWindow(), &window); + window.setFocusObject(&disabledItem); + + QCOMPARE(m_platformInputContext.inputMethodAccepted(), false); + + window.setFocusObject(&m_inputItem); + QCOMPARE(m_platformInputContext.inputMethodAccepted(), true); +} + QTEST_MAIN(tst_qinputmethod) #include "tst_qinputmethod.moc" diff --git a/tests/auto/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h index 2c1a3bcb25..2049ec7d61 100644 --- a/tests/auto/shared/platforminputcontext.h +++ b/tests/auto/shared/platforminputcontext.h @@ -55,7 +55,8 @@ public: m_lastQueries(Qt::ImhNone), m_action(QInputMethod::Click), m_cursorPosition(0), - m_lastEventType(QEvent::None) + m_lastEventType(QEvent::None), + m_setFocusObjectCallCount(0) {} virtual QRectF keyboardRect() const { return m_keyboardRect; } @@ -111,6 +112,11 @@ public: m_inputDirectionCallCount++; return Qt::LeftToRight; } + virtual void setFocusObject(QObject *object) + { + Q_UNUSED(object); + m_setFocusObjectCallCount++; + } bool m_animating; bool m_visible; @@ -125,4 +131,5 @@ public: int m_cursorPosition; int m_lastEventType; QRectF m_keyboardRect; + int m_setFocusObjectCallCount; }; -- cgit v1.2.3 From c82d40749dc1ce816333e84d7f3232e59fbe2058 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 30 Mar 2012 16:23:24 +0200 Subject: Fix multicast join/leave when binding to QHostAddress::Any. On OS X and Windows, this was not working, because the socket was being bound in v6 mode (due to ::Any being for dual mode), but the address passed was a v4 address, meaning it took the wrong codepath. Linux, strangely, apparently works anyway. This is fixable in OS X (by using the v6 join path when bound in v6/dual mode), but the same fix doesn't work on Windows, failing with WSAEADDRNOTAVAIL. Don't allow this behaviour, and provide a sane error message telling the user what to do instead. Done-with: Shane Kearns Task-number: QTBUG-25047 Change-Id: Iaf5bbee82e13ac92e11b60c558f5af9ce26f474b Reviewed-by: Shane Kearns --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index c53450eec6..f63c593f91 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1202,6 +1202,7 @@ void tst_QUdpSocket::multicast_data() QHostAddress groupAddress = QHostAddress("239.255.118.62"); QHostAddress any6Address = QHostAddress(QHostAddress::AnyIPv6); QHostAddress group6Address = QHostAddress("FF01::114"); + QHostAddress dualAddress = QHostAddress(QHostAddress::Any); QTest::addColumn("bindAddress"); QTest::addColumn("bindResult"); @@ -1213,6 +1214,8 @@ void tst_QUdpSocket::multicast_data() QTest::newRow("valid bind, group ipv6 address") << any6Address << true << group6Address << true; QTest::newRow("valid bind, invalid group ipv6 address") << any6Address << true << any6Address << false; QTest::newRow("same bind, group ipv6 address") << group6Address << true << group6Address << true; + QTest::newRow("dual bind, group ipv4 address") << dualAddress << true << groupAddress << false; + QTest::newRow("dual bind, group ipv6 address") << dualAddress << true << group6Address << true; } void tst_QUdpSocket::multicast() -- cgit v1.2.3 From 97282527ae7f1c97d6ca3cfeee61c4bacb30832f Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Wed, 14 Mar 2012 15:49:07 +0000 Subject: Harfbuzz-thai - fix buffer overflow when setting item attributes Reviewed-by: Eskil Abrahamsen Blomfeldt Change-Id: I92de853b57e2e06211193a2b30ac7c308374c961 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../qtextscriptengine/tst_qtextscriptengine.cpp | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index a88e93c93e..d566f0a20d 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -105,7 +105,7 @@ private slots: void thaiIsolatedSaraAm(); void thaiWithZWJ(); - + void thaiMultipleVowels(); private: bool haveTestFonts; }; @@ -1325,5 +1325,27 @@ void tst_QTextScriptEngine::thaiWithZWJ() QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3)); } +void tst_QTextScriptEngine::thaiMultipleVowels() +{ + QString s(QString::fromUtf8("ส")); + for (int i = 0; i < 100; i++) + s += QChar(0x0E47); // Add lots of "VOWEL SIGN MAI TAI KHU N/S-T" stacked on top of the character + s += QChar(0x200D); // Now add a zero width joiner (which adds a circle which is hidden) + for (int i = 0; i < 100; i++) + s += QChar(0x0E47); //Add lots of "VOWEL SIGN MAI TAI KHU N/S-T" stacked on top of the ZWJ + + for (int i = 0; i < 10; i++) + s += s; //Repeat the string to make it more likely to crash if we have a buffer overflow + QTextLayout layout(s); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QTextEngine *e = layout.engine(); + e->width(0, s.length()); //force itemize and shape + + // If we haven't crashed at this point, then the test has passed. +} + QTEST_MAIN(tst_QTextScriptEngine) #include "tst_qtextscriptengine.moc" -- cgit v1.2.3 From a84b42e6194be0f40bd8f961effef9947c07c832 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 30 Mar 2012 21:21:40 +0200 Subject: Fix QTcpServer::listen() returning true when the port is in use on OS X. Way back in the mists of time, someone added SO_REUSEPORT to socket binding, which was great, because otherwise it meant that multiple UDP sockets couldn't share the same port on OS X (as platforms with SO_REUSEPORT apparently don't support rebinding with SO_REUSEADDR). However: SO_REUSEPORT also means that *any* bind on a port will succeed, which is most definitely not wanted in the case of TCP sockets, so check the socket type before performing the actual bind. Also test that multiple listens don't take effect. Change-Id: I2f8d450bcfb8a7f3abd8918a4e789a850281dd13 Done-with: Thiago Macieira Done-with: Shane Kearns Task-number: QTBUG-6305 Reviewed-by: Thiago Macieira Reviewed-by: Shane Kearns --- .../network/socket/qtcpserver/tst_qtcpserver.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index ac27a621bb..1f68608542 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -115,6 +115,10 @@ private slots: void serverAddress_data(); void serverAddress(); + + void qtbug6305_data() { serverAddress_data(); } + void qtbug6305(); + private: #ifndef QT_NO_BEARERMANAGEMENT QNetworkSession *networkSession; @@ -828,10 +832,28 @@ void tst_QTcpServer::serverAddress() QFETCH(QHostAddress, listenAddress); QFETCH(QHostAddress, serverAddress); QTcpServer server; + + // TODO: why does this QSKIP? if (!server.listen(listenAddress)) QSKIP(qPrintable(server.errorString())); QCOMPARE(server.serverAddress(), serverAddress); } +// on OS X, calling listen() multiple times would succeed each time, which is +// most definitely not wanted. +void tst_QTcpServer::qtbug6305() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + QFETCH(QHostAddress, listenAddress); + QTcpServer server; + QVERIFY2(server.listen(listenAddress), qPrintable(server.errorString())); + + QTcpServer server2; + QVERIFY(!server2.listen(listenAddress, server.serverPort())); // second listen should fail +} + QTEST_MAIN(tst_QTcpServer) #include "tst_qtcpserver.moc" -- cgit v1.2.3 From 8f2a088028cf074a08e5252509c60e0f1021c43f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 2 Apr 2012 14:22:04 +0200 Subject: Fix MSVC warnings in tests. - Unused variables - conversion truncations - Overflow in expressions like '-1 + sizeof()' Change-Id: Ibbd18497951e9e7e9dccaf596cb4e864b69ec02c Reviewed-by: Jason McDonald --- .../qtconcurrentrun/tst_qtconcurrentrun.cpp | 4 +- tests/auto/corelib/codecs/utf8/tst_utf8.cpp | 2 +- tests/auto/corelib/io/qdir/tst_qdir.cpp | 2 +- .../io/qprocess/testProcessEchoGui/main_win.cpp | 10 ++-- .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 2 +- .../auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp | 17 ++++--- .../gui/kernel/qkeysequence/tst_qkeysequence.cpp | 4 +- tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp | 2 +- tests/auto/gui/qopengl/tst_qopengl.cpp | 1 + .../network/socket/qudpsocket/tst_qudpsocket.cpp | 5 +- .../other/networkselftest/tst_networkselftest.cpp | 55 +++++++++++++--------- .../kernel/qprinterinfo/tst_qprinterinfo.cpp | 3 +- tests/auto/testlib/selftests/tst_selftests.cpp | 7 +-- .../qgraphicsview/tst_qgraphicsview.cpp | 2 +- 14 files changed, 69 insertions(+), 47 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index 86e3433c12..81084dbaf4 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -381,7 +381,7 @@ void tst_QtConcurrentRun::exceptions() bool caught = false; try { QtConcurrent::run(throwFunction).waitForFinished(); - } catch (Exception &e) { + } catch (Exception &) { caught = true; } if (!caught) @@ -390,7 +390,7 @@ void tst_QtConcurrentRun::exceptions() caught = false; try { QtConcurrent::run(throwFunctionReturn).waitForFinished(); - } catch (Exception &e) { + } catch (Exception &) { caught = true; } if (!caught) diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp index dd6774e101..b80ba8e665 100644 --- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp +++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp @@ -185,7 +185,7 @@ void tst_Utf8::charByChar() } if (encoded.startsWith(utf8bom)) - encoded = encoded.mid(strlen(utf8bom)); + encoded = encoded.mid(int(strlen(utf8bom))); QCOMPARE(encoded, utf8); } { diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index b7fc366a39..250575bea0 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -53,7 +53,7 @@ #include "../../../network-settings.h" #endif -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(_WIN32_WINNT) #define _WIN32_WINNT 0x500 #endif diff --git a/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp b/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp index a8a17b6951..3bae41e83e 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp @@ -42,10 +42,10 @@ #include -int APIENTRY WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) +int APIENTRY WinMain(HINSTANCE /* hInstance */, + HINSTANCE /* hPrevInstance */, + LPSTR /* lpCmdLine */, + int /* nCmdShow */) { HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); @@ -64,4 +64,4 @@ int APIENTRY WinMain(HINSTANCE hInstance, WriteFile(hStderr, &c, 1, &wrote, 0); } return 0; -} \ No newline at end of file +} diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index d93e00eed8..09bd9fe445 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -429,7 +429,7 @@ template<> struct TestValueFactory { static uchar *create() { return new uchar('u'); } }; template<> struct TestValueFactory { - static float *create() { return new float(3.14); } + static float *create() { return new float(3.14f); } }; template<> struct TestValueFactory { static QObject * *create() { return new QObject *(0); } diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp index bd9fa2a8db..8a60bb1876 100644 --- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp @@ -984,7 +984,7 @@ void tst_QXmlStream::writeAttributesWithSpace() const QXmlStreamWriter writer(&buffer); writer.writeStartDocument(); writer.writeEmptyElement("A"); - writer.writeAttribute("attribute", QString("value")+QChar::Nbsp); + writer.writeAttribute("attribute", QStringLiteral("value") + QChar(QChar::Nbsp)); writer.writeEndDocument(); QString s = QString("\n").arg(QChar(QChar::Nbsp)); QCOMPARE(buffer.buffer().data(), s.toUtf8().data()); @@ -1512,35 +1512,38 @@ void tst_QXmlStream::hasError() const // Failure caused by write(QString) FakeBuffer fb; QVERIFY(fb.open(QBuffer::ReadWrite)); - fb.setCapacity(strlen(" #include -#include +#include #include Q_DECLARE_METATYPE(QRect) diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index e8374b0cae..38208d27c8 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -118,6 +118,7 @@ struct SharedResource : public QOpenGLSharedResource void freeResource(QOpenGLContext *context) { Q_ASSERT(context == QOpenGLContext::currentContext()); + Q_UNUSED(context) resource = 0; if (tracker) tracker->freeResourceCalls++; diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index f63c593f91..cab3d56d32 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -309,9 +309,10 @@ void tst_QUdpSocket::broadcasting() QByteArray arr; arr.resize(serverSocket.pendingDatagramSize() + 1); QHostAddress host; quint16 port; + const int messageLength = int(strlen(message[i])); QCOMPARE((int) serverSocket.readDatagram(arr.data(), arr.size() - 1, &host, &port), - (int) strlen(message[i])); - arr.resize(strlen(message[i])); + messageLength); + arr.resize(messageLength); QCOMPARE(arr, QByteArray(message[i])); } while (serverSocket.hasPendingDatagrams()); } diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index ebb8443748..3c0c4406fe 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -863,7 +863,7 @@ static const char connect2[] = "\5\1\0\3\11localhost\0\25"; // Connect hostname static const char connect2a[] = "\5\1\0\3"; // just "Connect to hostname" static const char connected[] = "\5\0\0"; -#define QBA(x) (QByteArray::fromRawData(x, -1 + sizeof(x))) +#define QBA(x) (QByteArray::fromRawData(x, int(sizeof(x)) - 1)) void tst_NetworkSelfTest::socks5Proxy() { @@ -873,42 +873,48 @@ void tst_NetworkSelfTest::socks5Proxy() } ip4Address; ip4Address.data = qToBigEndian(serverIpAddress().toIPv4Address()); + const QByteArray handshakeNoAuthData = QByteArray(handshakeNoAuth, int(sizeof handshakeNoAuth) - 1); + const QByteArray handshakeOkNoAuthData = QByteArray(handshakeOkNoAuth, int(sizeof handshakeOkNoAuth) - 1); + const QByteArray connect1Data = QByteArray(connect1, int(sizeof connect1) - 1); + const QByteArray connectedData = QByteArray(connected, int(sizeof connected) - 1); + const QByteArray connect2Data = QByteArray(connect2, int(sizeof connect2) - 1); + netChat(1080, QList() // IP address connection - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) - << Chat::send(QByteArray(connect1, -1 + sizeof connect1)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeOkNoAuthData) + << Chat::send(connect1Data) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() // connect by IP << Chat::Reconnect - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeOkNoAuthData) << Chat::send(QBA(connect1a) + QByteArray::fromRawData(ip4Address.buf, 4) + QBA(connect1b)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() // connect to "localhost" by hostname << Chat::Reconnect - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) - << Chat::send(QByteArray(connect2, -1 + sizeof connect2)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeOkNoAuthData) + << Chat::send(connect2Data) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() // connect to server by its official name << Chat::Reconnect - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeOkNoAuthData) << Chat::send(QBA(connect2a) + char(QtNetworkSettings::serverName().size()) + QtNetworkSettings::serverName().toLatin1() + QBA(connect1b)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() @@ -917,18 +923,25 @@ void tst_NetworkSelfTest::socks5Proxy() void tst_NetworkSelfTest::socks5ProxyAuth() { + const QByteArray handshakeNoAuthData = QByteArray(handshakeNoAuth, int(sizeof handshakeNoAuth) - 1); + const QByteArray connect1Data = QByteArray(connect1, int(sizeof connect1) - 1); + const QByteArray connectedData = QByteArray(connected, int(sizeof connected) - 1); + const QByteArray handshakeAuthNotOkData = QByteArray(handshakeAuthNotOk, int(sizeof(handshakeAuthNotOk)) - 1); + const QByteArray handshakeAuthPasswordData = QByteArray(handshakeAuthPassword, int(sizeof(handshakeAuthPassword)) - 1); + const QByteArray handshakeOkPasswdAuthData = QByteArray(handshakeOkPasswdAuth, int(sizeof(handshakeOkPasswdAuth)) - 1); + netChat(1081, QList() // unauthenticated connect -- will get error - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeAuthNotOk, -1 + sizeof handshakeAuthNotOk)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeAuthNotOkData) << Chat::RemoteDisconnect // now try to connect with authentication << Chat::Reconnect - << Chat::send(QByteArray(handshakeAuthPassword, -1 + sizeof handshakeAuthPassword)) - << Chat::expect(QByteArray(handshakeOkPasswdAuth, -1 + sizeof handshakeOkPasswdAuth)) - << Chat::send(QByteArray(connect1, -1 + sizeof connect1)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::send(handshakeAuthPasswordData) + << Chat::expect(handshakeOkPasswdAuthData) + << Chat::send(connect1Data) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp index 48d38a8146..404aa06399 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -199,7 +199,8 @@ QString tst_QPrinterInfo::getOutputFromCommand(const QStringList& command) return QString(array); } #else - return QString(); + Q_UNUSED(command) + return QString(); #endif } diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 97458abfbf..26ccd826ca 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -135,7 +135,7 @@ static QList splitLines(QByteArray ba) if (index == -1) { continue; } - int end = line.indexOf('"', index + strlen(markers[j][0])); + const int end = line.indexOf('"', index + int(strlen(markers[j][0]))); if (end == -1) { continue; } @@ -686,11 +686,12 @@ QString extractXmlAttribute(const QString &line, const char *attribute) int index = line.indexOf(attribute); if (index == -1) return QString(); - int end = line.indexOf('"', index + strlen(attribute)); + const int attributeLength = int(strlen(attribute)); + const int end = line.indexOf('"', index + attributeLength); if (end == -1) return QString(); - QString result = line.mid(index + strlen(attribute), end - index - strlen(attribute)); + const QString result = line.mid(index + attributeLength, end - index - attributeLength); if (result.isEmpty()) return ""; // ensure empty but not null return result; diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 19532a0e37..1838977749 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -3712,7 +3712,7 @@ void tst_QGraphicsView::render() view.show(); QTest::qWaitForWindowShown(&view); QApplication::processEvents(); - QTRY_VERIFY(view.painted > 0); + QTRY_VERIFY(view.painted); RenderTester *r1 = new RenderTester(QRectF(0, 0, 50, 50)); RenderTester *r2 = new RenderTester(QRectF(50, 50, 50, 50)); -- cgit v1.2.3 From 50ad785bdd38fcff9c47125fc545762435aaa158 Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Wed, 7 Mar 2012 12:02:02 +0200 Subject: Convert Boolean value into integer According to documentation, SQLite doesn't have a separate Boolean storage class. Instead, values are stored as integers 0(false) and 1(true). In QSqlQuery::bindValue(), if a boolean value is bound to a placeholder, it is converted to text true and false. This fix converts boolean value to integer 0 and 1. Task-number: QTBUG-23895 Change-Id: I4945971172f0b5e5819446700390033a1a4ce301 Reviewed-by: Michael Goddard Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 61 +++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 3de65d00ad..559afc4ef4 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -215,6 +215,8 @@ private slots: void QTBUG_21884(); void QTBUG_16967_data() { generic_data("QSQLITE"); } void QTBUG_16967(); //clean close + void QTBUG_23895_data() { generic_data("QSQLITE"); } + void QTBUG_23895(); //sqlite boolean type void sqlite_constraint_data() { generic_data("QSQLITE"); } void sqlite_constraint(); @@ -331,6 +333,7 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) << qTableName("bug5765", __FILE__) << qTableName("bug6852", __FILE__) << qTableName("bug21884", __FILE__) + << qTableName("bug23895", __FILE__) << qTableName( "qtest_lockedtable", __FILE__ ) << qTableName( "Planet", __FILE__ ) << qTableName( "task_250026", __FILE__ ) @@ -3264,6 +3267,64 @@ void tst_QSqlQuery::QTBUG_16967() } } +/** + * In SQLite when a boolean value is bound to a placeholder, it should be converted + * into integer 0/1 rather than text "false"/"true". According to documentation, + * SQLite does not have separate Boolean storage class. Instead, Boolean values are + * stored as integers. + */ +void tst_QSqlQuery::QTBUG_23895() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + + QString tableName(qTableName("bug23895", __FILE__ )); + q.prepare("create table " + tableName + "(id integer primary key, val1 bool, val2 boolean)"); + QVERIFY_SQL(q, exec()); + q.prepare("insert into " + tableName + "(id, val1, val2) values(?, ?, ?);"); + q.addBindValue(1); + q.addBindValue(true); + q.addBindValue(false); + QVERIFY_SQL(q, exec()); + + QString sql="select * from " + tableName; + QVERIFY_SQL(q, exec(sql)); + QVERIFY_SQL(q, next()); + + QCOMPARE(q.record().field(0).type(), QVariant::Int); + QCOMPARE(q.value(0).type(), QVariant::LongLong); + QCOMPARE(q.value(0).toInt(), 1); + QCOMPARE(q.record().field(1).type(), QVariant::Bool); + QCOMPARE(q.value(1).type(), QVariant::LongLong); + QCOMPARE(q.value(1).toBool(), true); + QCOMPARE(q.record().field(2).type(), QVariant::Bool); + QCOMPARE(q.value(2).type(), QVariant::LongLong); + QCOMPARE(q.value(2).toBool(), false); + + q.prepare("insert into " + tableName + "(id, val1, val2) values(?, ?, ?);"); + q.addBindValue(2); + q.addBindValue(false); + q.addBindValue(false); + QVERIFY_SQL(q, exec()); + + sql="select * from " + tableName + " where val1"; + QVERIFY_SQL(q, exec(sql)); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 1); + QVERIFY(!q.next()); + + sql="select * from " + tableName + " where not val2"; + QVERIFY_SQL(q, exec(sql)); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 1); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 2); + QVERIFY(!q.next()); +} + void tst_QSqlQuery::oraOCINumber() { QFETCH( QString, dbName ); -- cgit v1.2.3 From e09fc38a3624f372c9f0b7339b460468961e918b Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 14 Mar 2012 13:22:01 +0000 Subject: Don't require exact IMAP server version in autotests The string from the server should begin with "* OK" and end with "\r\n" according to the IMAP specification. Still have a check for "server ready" as this does not change between cyrus versions. Change-Id: Ia01ed8aa054e5726bba8b411d30edc6205cc8465 Reviewed-by: Thiago Macieira --- tests/auto/network-settings.h | 46 +++++++------------------------------------ 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index f2c12bc092..4c36e2d308 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -78,24 +78,12 @@ public: static bool compareReplyIMAP(QByteArray const& actual) { - QList expected; - - // Mandriva; old test server - expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] " ) - .append(QtNetworkSettings::serverName().toAscii()) - .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); - - // Ubuntu 10.04; new test server - expected << QByteArray( "* OK " ) - .append(QtNetworkSettings::serverLocalName().toAscii()) - .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"); - - // Feel free to add more as needed - - Q_FOREACH (QByteArray const& ba, expected) { - if (ba == actual) { - return true; - } + // Server greeting may contain capability, version and server name + // But spec only requires "* OK" and "\r\n" + // Match against a prefix and postfix that covers all Cyrus versions + if (actual.startsWith("* OK ") + && actual.endsWith("server ready\r\n")) { + return true; } return false; @@ -103,27 +91,7 @@ public: static bool compareReplyIMAPSSL(QByteArray const& actual) { - QList expected; - - // Mandriva; old test server - expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] " ) - .append(QtNetworkSettings::serverName().toAscii()) - .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); - - // Ubuntu 10.04; new test server - expected << QByteArray( "* OK " ) - .append(QtNetworkSettings::serverLocalName().toAscii()) - .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"); - - // Feel free to add more as needed - - Q_FOREACH (QByteArray const& ba, expected) { - if (ba == actual) { - return true; - } - } - - return false; + return compareReplyIMAP(actual); } static bool compareReplyFtp(QByteArray const& actual) -- cgit v1.2.3 From 779c7c327915b38eeac38486c8d9e7894fd3aed2 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 4 Apr 2012 12:11:40 +0200 Subject: Add tst_QWindow::windowModality() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This tests that we get the windowModalityChanged() signal as needed, but not unnecessarily either. Change-Id: I2232fa9d45c72e472b324b681859b4b0d574b467 Reviewed-by: João Abecasis Reviewed-by: Robin Burchell --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index dc17ec653c..a75e1cb054 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -67,6 +67,7 @@ private slots: void close(); void activateAndClose(); void mouseEventSequence(); + void windowModality(); void initTestCase() { @@ -758,5 +759,36 @@ void tst_QWindow::mouseEventSequence() QCOMPARE(window.mouseSequenceSignature, QLatin1String("prprprpr")); } +void tst_QWindow::windowModality() +{ + qRegisterMetaType("Qt::WindowModality"); + + QWindow window; + QSignalSpy spy(&window, SIGNAL(windowModalityChanged(Qt::WindowModality))); + + QCOMPARE(window.windowModality(), Qt::NonModal); + window.setWindowModality(Qt::NonModal); + QCOMPARE(window.windowModality(), Qt::NonModal); + QCOMPARE(spy.count(), 0); + + window.setWindowModality(Qt::WindowModal); + QCOMPARE(window.windowModality(), Qt::WindowModal); + QCOMPARE(spy.count(), 1); + window.setWindowModality(Qt::WindowModal); + QCOMPARE(window.windowModality(), Qt::WindowModal); + QCOMPARE(spy.count(), 1); + + window.setWindowModality(Qt::ApplicationModal); + QCOMPARE(window.windowModality(), Qt::ApplicationModal); + QCOMPARE(spy.count(), 2); + window.setWindowModality(Qt::ApplicationModal); + QCOMPARE(window.windowModality(), Qt::ApplicationModal); + QCOMPARE(spy.count(), 2); + + window.setWindowModality(Qt::NonModal); + QCOMPARE(window.windowModality(), Qt::NonModal); + QCOMPARE(spy.count(), 3); +} + #include QTEST_MAIN(tst_QWindow) -- cgit v1.2.3 From 6dbaf9f536a3b02f371bdb4ce6302232f1789172 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 4 Apr 2012 12:16:40 +0200 Subject: Don't ignore tst_QWindow on Mac OS X QTBUG-23059 only affects 2 test functions, not the whole test. XFAIL the 2 failing tests. Change-Id: I87086a9ec573362625bc090038dfd7c79aeb9426 Reviewed-by: Jason McDonald --- tests/auto/gui/kernel/qwindow/qwindow.pro | 3 --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index 363f7dd92e..e419a10440 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -4,6 +4,3 @@ TARGET = tst_qwindow QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp - -mac: CONFIG += insignificant_test # QTBUG-23059 - diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index a75e1cb054..7bbcb8db7d 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -139,6 +139,9 @@ void tst_QWindow::positioning() QCOMPARE(window.geometry(), geometry); window.show(); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "This test fails on Mac OS X, see QTBUG-23059", Abort); +#endif QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_COMPARE(window.received(QEvent::Map), 1); @@ -188,6 +191,9 @@ void tst_QWindow::isActive() window.setGeometry(80, 80, 40, 40); window.show(); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "This test fails on Mac OS X, see QTBUG-23059", Abort); +#endif QTRY_COMPARE(window.received(QEvent::Map), 1); QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_VERIFY(QGuiApplication::focusWindow() == &window); -- cgit v1.2.3