diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-10-20 14:01:15 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-10-20 14:01:15 (GMT) |
commit | 393db7ada80e803c73fa65f68f5dd037c16ed836 (patch) | |
tree | 0f047d6127e36d23dd0e0d214b2d887038d483c5 /tests | |
parent | d4dd08918082372d3df7be2d3a6671cbd7bc7fd3 (diff) | |
parent | cbca69bb0c7e3c42bf7d2d964057f38263de0553 (diff) | |
download | Qt-393db7ada80e803c73fa65f68f5dd037c16ed836.zip Qt-393db7ada80e803c73fa65f68f5dd037c16ed836.tar.gz Qt-393db7ada80e803c73fa65f68f5dd037c16ed836.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-widget-team into 4.6
Diffstat (limited to 'tests')
18 files changed, 548 insertions, 60 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index e76f0f7..0d3469d 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -151,6 +151,7 @@ private slots: void subControlRectsWithOffset_data(); void subControlRectsWithOffset(); void task260974_menuItemRectangleForComboBoxPopup(); + void removeItem(); protected slots: void onEditTextChanged( const QString &newString ); @@ -2398,5 +2399,22 @@ void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup() #endif } +void tst_QComboBox::removeItem() +{ + QComboBox cb; + cb.removeItem(-1); + cb.removeItem(1); + cb.removeItem(0); + QCOMPARE(cb.count(), 0); + + cb.addItem("foo"); + cb.removeItem(-1); + QCOMPARE(cb.count(), 1); + cb.removeItem(1); + QCOMPARE(cb.count(), 1); + cb.removeItem(0); + QCOMPARE(cb.count(), 0); +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 2426ce9..9269164 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -2007,8 +2007,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() edit1->setText("QLineEdit 1"); QLineEdit *edit2 = new QLineEdit; edit2->setText("QLineEdit 2"); + QFontComboBox *fontComboBox = new QFontComboBox; QVBoxLayout *vlayout = new QVBoxLayout; vlayout->addWidget(edit1); + vlayout->addWidget(fontComboBox); vlayout->addWidget(edit2); QGroupBox *box = new QGroupBox("QGroupBox"); @@ -2020,8 +2022,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() edit1_2->setText("QLineEdit 1_2"); QLineEdit *edit2_2 = new QLineEdit; edit2_2->setText("QLineEdit 2_2"); + QFontComboBox *fontComboBox2 = new QFontComboBox; vlayout = new QVBoxLayout; vlayout->addWidget(edit1_2); + vlayout->addWidget(fontComboBox2); vlayout->addWidget(edit2_2); QGroupBox *box_2 = new QGroupBox("QGroupBox 2"); @@ -2062,8 +2066,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() EventSpy eventSpy(edit1); EventSpy eventSpy2(edit2); + EventSpy eventSpy3(fontComboBox); EventSpy eventSpy1_2(edit1_2); EventSpy eventSpy2_2(edit2_2); + EventSpy eventSpy2_3(fontComboBox2); EventSpy eventSpyBox(box); // Tab into group box @@ -2084,11 +2090,24 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy.counts[QEvent::FocusOut], 0); + // Tab to the font combobox + QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); + QApplication::processEvents(); + fontComboBox->hasFocus(); + QVERIFY(!edit2->hasFocus()); + QCOMPARE(eventSpy3.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 0); + QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1); + // Tab into line edit 2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); QApplication::processEvents(); edit2->hasFocus(); QVERIFY(!edit1->hasFocus()); + QCOMPARE(eventSpy2.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy2.counts[QEvent::FocusOut], 0); + QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 1); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1); @@ -2106,6 +2125,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 0); + // Tab into right font combobox + QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); + QApplication::processEvents(); + QVERIFY(!edit1_2->hasFocus()); + fontComboBox2->hasFocus(); + QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1); + QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 0); + // Tab into right bottom line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); QApplication::processEvents(); @@ -2113,6 +2142,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() edit2_2->hasFocus(); QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1); + QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 1); QCOMPARE(eventSpy2_2.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy2_2.counts[QEvent::FocusOut], 0); @@ -2129,6 +2160,12 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QVERIFY(!rightDial->hasFocus()); edit2_2->hasFocus(); + // Backtab into the right font combobox + QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); + QApplication::processEvents(); + QVERIFY(!edit2_2->hasFocus()); + fontComboBox2->hasFocus(); + // Backtab into line edit 1 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); QApplication::processEvents(); @@ -2147,10 +2184,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QVERIFY(!rightDial->hasFocus()); edit2->hasFocus(); - // Backtab into line edit 1 + // Backtab into the font combobox QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); QApplication::processEvents(); QVERIFY(!edit2->hasFocus()); + fontComboBox->hasFocus(); + + // Backtab into line edit 1 + QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); + QApplication::processEvents(); + QVERIFY(!fontComboBox->hasFocus()); edit1->hasFocus(); // Backtab into line box diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp index 920231d..3286768 100644 --- a/tests/auto/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/qheaderview/tst_qheaderview.cpp @@ -1836,7 +1836,7 @@ void tst_QHeaderView::preserveHiddenSectionWidth() model.insertRow(1); view.showSection(2); QCOMPARE(view.sectionSize(0), 100); - QCOMPARE(view.sectionSize(1), 30); + QCOMPARE(view.sectionSize(1), view.defaultSectionSize()); QCOMPARE(view.sectionSize(2), 50); } diff --git a/tests/auto/qlabel/qlabel.pro b/tests/auto/qlabel/qlabel.pro index 6d55c13..297f868 100644 --- a/tests/auto/qlabel/qlabel.pro +++ b/tests/auto/qlabel/qlabel.pro @@ -1,19 +1,10 @@ load(qttest_p4) -SOURCES += tst_qlabel.cpp - -wince*:{ - DEFINES += SRCDIR=\\\"\\\" -} else:!symbian { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} - -wince*|symbian { - addFiles.sources = *.png testdata +SOURCES += tst_qlabel.cpp +wince*::DEFINES += SRCDIR=\\\"\\\" +else:!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\" +wince*|symbian { + addFiles.sources = *.png \ + testdata addFiles.path = . DEPLOYMENT += addFiles } - - - - - diff --git a/tests/auto/qlabel/tst_qlabel.cpp b/tests/auto/qlabel/tst_qlabel.cpp index dd03ef3..9eae9c9 100644 --- a/tests/auto/qlabel/tst_qlabel.cpp +++ b/tests/auto/qlabel/tst_qlabel.cpp @@ -50,6 +50,7 @@ #include <qlineedit.h> #include <qmovie.h> #include <qpicture.h> +#include <qmessagebox.h> //TESTED_CLASS= //TESTED_FILES= @@ -112,6 +113,9 @@ private slots: void task226479_movieResize(); void emptyPixmap(); + void unicodeText_data(); + void unicodeText(); + private: QLabel *testWidget; QPointer<Widget> test_box; @@ -451,5 +455,59 @@ void tst_QLabel::emptyPixmap() QCOMPARE(label1.sizeHint(), label4.sizeHint()); } +/** + Test for QTBUG-4848 - unicode data corrupting QLabel display +*/ +void tst_QLabel::unicodeText_data() +{ + QTest::addColumn<QString>("text"); + QTest::addColumn<QString>("languageName"); + + /* + The "glass" phrase in Thai was the initial report for bug QTBUG-4848, was + originally found on http://www.columbia.edu/kermit/utf8.html. + + The phrase is from an internet tradition regarding a striking phrase + that is translated into many different languages. The utf8 strings + below were generated by using http://translate.google.com. + + The glass phrase in Thai contains the ้ว character which manifests bug + QTBUG-4848 + + The last long phrase is an excerpt from Churchills "on the beaches" + speech, also translated using http://translate.google.com. + */ + + QTest::newRow("english") << QString::fromUtf8("I can eat glass and it doesn't hurt me.") << QString("english"); + QTest::newRow("thai") << QString::fromUtf8("ฉันจะกินแก้วและไม่เจ็บฉัน") << QString("thai"); + QTest::newRow("chinese") << QString::fromUtf8("我可以吃玻璃,并没有伤害我。") << QString("chinese"); + QTest::newRow("arabic") << QString::fromUtf8("أستطيع أكل الزجاج ، وأنه لا يؤذيني.") << QString("arabic"); + QTest::newRow("russian") << QString::fromUtf8("Я могу есть стекло, и не больно.") << QString("russian"); + QTest::newRow("korean") << QString::fromUtf8("유리를 먹을 수있는, 그리고 그게 날 다치게하지 않습니다.") << QString("korean"); + QTest::newRow("greek") << QString::fromUtf8("Μπορώ να φάτε γυαλί και δεν μου κάνει κακό.") << QString("greek"); + QTest::newRow("german") << QString::fromUtf8("Ich kann Glas essen und es macht mich nicht heiß.") << QString("german"); + + QTest::newRow("thai_long") << QString::fromUtf8("เราจะต่อสู้ในทะเลและมหาสมุทร. เราจะต่อสู้ด้วยความมั่นใจเติบโตและความเจริญเติบโตในอากาศเราจะปกป้องเกาะของเราค่าใช้จ่ายใดๆอาจ." + "เราจะต่อสู้บนชายหาดเราจะต่อสู้ในบริเวณเชื่อมโยงไปถึงเราจะต่อสู้ในช่องและในถนนที่เราจะต่อสู้ในภูเขานั้นเราจะไม่ยอม.") + << QString("thai_long"); +} + +void tst_QLabel::unicodeText() +{ + const QString testDataPath("testdata/unicodeText"); + QFETCH(QString, text); + QFETCH(QString, languageName); + QFrame frame; + QVBoxLayout *layout = new QVBoxLayout(); + QLabel *label = new QLabel(text, &frame); + layout->addWidget(label); + layout->setMargin(8); + frame.setLayout(layout); + frame.show(); + QTest::qWaitForWindowShown(&frame); + QVERIFY(frame.isVisible()); // was successfully sized and shown + testWidget->show(); +} + QTEST_MAIN(tst_QLabel) #include "tst_qlabel.moc" diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 7599ce6a06..ed02317 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -116,6 +116,8 @@ private slots: void keyboardSearch(); void shiftSelectionWithNonUniformItemSizes(); void clickOnViewportClearsSelection(); + void task262152_setModelColumnNavigate(); + void taskQTBUG_2233_scrollHiddenRows(); }; // Testing get/set functions @@ -1767,6 +1769,53 @@ void tst_QListView::clickOnViewportClearsSelection() } +void tst_QListView::task262152_setModelColumnNavigate() +{ + QListView view; + QStandardItemModel model(3,2); + model.setItem(0,1,new QStandardItem("[0,1]")); + model.setItem(1,1,new QStandardItem("[1,1]")); + model.setItem(2,1,new QStandardItem("[2,1]")); + + view.setModel(&model); + view.setModelColumn(1); + + view.show(); + QTest::qWait(30); + QTest::keyClick(&view, Qt::Key_Down); + QTest::qWait(10); + QCOMPARE(view.currentIndex(), model.index(1,1)); + QTest::keyClick(&view, Qt::Key_Down); + QTest::qWait(10); + QCOMPARE(view.currentIndex(), model.index(2,1)); + +} + +void tst_QListView::taskQTBUG_2233_scrollHiddenRows() +{ + const int rowCount = 200; + + QListView view; + QStringListModel model(&view); + QStringList list; + for (int i = 0; i < rowCount; ++i) + list << QString::fromAscii("Item %1").arg(i); + + model.setStringList(list); + view.setModel(&model); + view.setViewMode(QListView::ListMode); + view.setFlow(QListView::TopToBottom); + for (int i = 0; i < rowCount / 2; ++i) + view.setRowHidden(2 * i, true); + view.resize(250, 130); + + for (int i = 0; i < 10; ++i) { + view.verticalScrollBar()->setValue(i); + QModelIndex index = view.indexAt(QPoint(20,0)); + QVERIFY(index.isValid()); + QCOMPARE(index.row(), 2 * i + 1); + } +} QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 4eb149f..f12fa92 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -675,7 +675,13 @@ void tst_QMenu::activeSubMenuPosition() #ifdef Q_OS_WINCE_WM QSKIP("Not true for Windows Mobile Soft Keys", SkipSingle); #endif + +#ifdef Q_OS_SYMBIAN + // On Symbian, QS60Style::pixelMetric(QStyle::PM_SubMenuOverlap) is different with other styles. + QVERIFY(sub->pos().x() < main->pos().x()); +#else QVERIFY(sub->pos().x() > main->pos().x()); +#endif QCOMPARE(sub->activeAction(), subAction); } @@ -778,6 +784,11 @@ void tst_QMenu::menuSizeHint() int maxWidth =0; QRect result; foreach(QAction *action, menu.actions()) { +#ifdef QT_SOFTKEYS_ENABLED + // Softkey actions are not widgets and have no geometry. + if (menu.actionGeometry(action).topLeft() == QPoint(0,0)) + continue; +#endif maxWidth = qMax(maxWidth, menu.actionGeometry(action).width()); result |= menu.actionGeometry(action); QCOMPARE(result.x(), left + hmargin + panelWidth); @@ -816,6 +827,9 @@ void tst_QMenu::task258920_mouseBorder() QSKIP("Mouse move related signals for Windows Mobile unavailable", SkipAll); #endif Menu258920 menu; + // On Symbian, styleHint(QStyle::SH_Menu_MouseTracking) in QS60Style is false. + // For other styles which inherit from QWindowsStyle, the value is true. + menu.setMouseTracking(true); QAction *action = menu.addAction("test"); menu.popup(QApplication::desktop()->availableGeometry().center()); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index e4f267d..8ed83cb 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -238,6 +238,8 @@ private slots: void taskQT4444_dontOverflowDashOffset(); + void painterBegin(); + private: void fillData(); QColor baseColor( int k, int intensity=255 ); @@ -4312,5 +4314,43 @@ void tst_QPainter::taskQT4444_dontOverflowDashOffset() QVERIFY(true); // Don't crash } +void tst_QPainter::painterBegin() +{ + QImage nullImage; + QImage indexed8Image(16, 16, QImage::Format_Indexed8); + QImage rgb32Image(16, 16, QImage::Format_RGB32); + QImage argb32Image(16, 16, QImage::Format_ARGB32_Premultiplied); + + QPainter p; + + // Painting on null image should fail. + QVERIFY(!p.begin(&nullImage)); + + // Check that the painter is not messed up by using it on another image. + QVERIFY(p.begin(&rgb32Image)); + QVERIFY(p.end()); + + // If painting on indexed8 image fails, the painter state should still be OK. + if (p.begin(&indexed8Image)) + QVERIFY(p.end()); + QVERIFY(p.begin(&rgb32Image)); + QVERIFY(p.end()); + + // Try opening a painter on the two different images. + QVERIFY(p.begin(&rgb32Image)); + QVERIFY(!p.begin(&argb32Image)); + QVERIFY(p.end()); + + // Try opening two painters on the same image. + QVERIFY(p.begin(&rgb32Image)); + QPainter q; + QVERIFY(!q.begin(&rgb32Image)); + QVERIFY(!q.end()); + QVERIFY(p.end()); + + // Try ending an inactive painter. + QVERIFY(!p.end()); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp index 62b43c4..b11efa0 100644 --- a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp @@ -169,7 +169,7 @@ void tst_QPauseAnimation::noTimerUpdates() animation.start(); QTest::qWait(animation.totalDuration() + 100); QVERIFY(animation.state() == QAbstractAnimation::Stopped); - QCOMPARE(animation.m_updateCurrentTimeCount, 2); + QCOMPARE(animation.m_updateCurrentTimeCount, 1 + loopCount); timer->setConsistentTiming(false); } @@ -399,6 +399,7 @@ void tst_QPauseAnimation::multipleSequentialGroups() void tst_QPauseAnimation::zeroDuration() { TestablePauseAnimation animation; + animation.setDuration(0); animation.start(); QTest::qWait(animation.totalDuration() + 100); QVERIFY(animation.state() == QAbstractAnimation::Stopped); diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 51ef2da..7dd17e5 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -130,6 +130,7 @@ private slots: void valueChanged(); void twoAnimations(); void deletedInUpdateCurrentTime(); + void totalDuration(); }; tst_QPropertyAnimation::tst_QPropertyAnimation() @@ -1199,5 +1200,18 @@ void tst_QPropertyAnimation::deletedInUpdateCurrentTime() QCOMPARE(o.value(), 1000); } +void tst_QPropertyAnimation::totalDuration() +{ + QPropertyAnimation anim; + QCOMPARE(anim.totalDuration(), 250); + anim.setLoopCount(2); + QCOMPARE(anim.totalDuration(), 2*250); + anim.setLoopCount(-1); + QCOMPARE(anim.totalDuration(), -1); + anim.setDuration(0); + QCOMPARE(anim.totalDuration(), 0); +} + + QTEST_MAIN(tst_QPropertyAnimation) #include "tst_qpropertyanimation.moc" diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index 283e489..82c8ccd 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -109,6 +109,7 @@ private slots: void extension_invoctaion(); void extension(); void isEvaluatingInExtension(); + void hasUncaughtException(); private: double m_testProperty; @@ -2182,5 +2183,42 @@ void tst_QScriptEngineAgent::isEvaluatingInExtension() QVERIFY(spy->wasEvaluating); } +class NewSpy :public QScriptEngineAgent +{ + bool m_result; +public: + NewSpy(QScriptEngine* eng) : QScriptEngineAgent(eng), m_result(false) {} + void functionExit (qint64, const QScriptValue &scriptValue) + { + if (engine()->hasUncaughtException()) m_result = true; + } + + bool isPass() { return m_result; } + void reset() { m_result = false; } +}; + +void tst_QScriptEngineAgent::hasUncaughtException() +{ + QScriptEngine eng; + NewSpy* spy = new NewSpy(&eng); + eng.setAgent(spy); + QScriptValue scriptValue; + + // Check unhandled exception. + eng.evaluate("function init () {Unknown.doSth ();}"); + scriptValue = QScriptValue(eng.globalObject().property("init")).call(); + QVERIFY(eng.hasUncaughtException()); + QVERIFY2(spy->isPass(), "At least one of a functionExit event should set hasUncaughtException flag."); + spy->reset(); + + // Check catched exception. + eng.evaluate("function innerFoo() { throw new Error('ciao') }"); + eng.evaluate("function foo() {try { innerFoo() } catch (e) {} }"); + scriptValue = QScriptValue(eng.globalObject().property("foo")).call(); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY2(spy->isPass(), "At least one of a functionExit event should set hasUncaughtException flag."); +} + + QTEST_MAIN(tst_QScriptEngineAgent) #include "tst_qscriptengineagent.moc" diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp index 832605e..6efa85b 100644 --- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp +++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp @@ -43,9 +43,15 @@ #include "qevent.h" #include "qdialog.h" +#include "qpushbutton.h" #include "qdialogbuttonbox.h" #include "private/qsoftkeymanager_p.h" +#ifdef Q_WS_S60 +static const int s60CommandStart = 6000; +#endif + + class tst_QSoftKeyManager : public QObject { Q_OBJECT @@ -171,22 +177,52 @@ void tst_QSoftKeyManager::handleCommand() } /* - This tests that softkey enable state follows the state of widget that owns the action - to which the softkey is related to. + This tests that the state of a widget that owns softkey action is respected when handling the softkey + command. */ void tst_QSoftKeyManager::checkSoftkeyEnableStates() { - QWidget w1, w2; - w1.setEnabled(false); - w2.setEnabled(true); + QDialog w; + QDialogButtonBox *buttons = new QDialogButtonBox( + QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Help, + Qt::Horizontal, + &w); + QPushButton *pBDefaults = buttons->button(QDialogButtonBox::RestoreDefaults); + QPushButton *pBHelp = buttons->button(QDialogButtonBox::Help); + pBHelp->setEnabled(false); + w.show(); + QApplication::processEvents(); - QAction *disabledAction = QSoftKeyManager::createAction(QSoftKeyManager::OkSoftKey, &w1); - QAction *enabledAction = QSoftKeyManager::createAction(QSoftKeyManager::OkSoftKey, &w2); + QSignalSpy spy0(w.actions()[0], SIGNAL(triggered())); //restore defaults action + QSignalSpy spy1(w.actions()[1], SIGNAL(triggered())); //disabled help action - QVERIFY(disabledAction->isEnabled()==false); - QVERIFY(enabledAction->isEnabled()==true); + //Verify that enabled button gets all the action trigger signals and + //disabled button gets none. + for (int i = 0; i < 10; i++) { + //simulate "Restore Defaults" softkey press + qApp->symbianHandleCommand(s60CommandStart); + //simulate "help" softkey press + qApp->symbianHandleCommand(s60CommandStart + 1); + } + QApplication::processEvents(); + QCOMPARE(spy0.count(), 10); + QCOMPARE(spy1.count(), 0); + spy0.clear(); + spy1.clear(); + + for (int i = 0; i < 10; i++) { + //simulate "Restore Defaults" softkey press + qApp->symbianHandleCommand(s60CommandStart); + //simulate "help" softkey press + qApp->symbianHandleCommand(s60CommandStart + 1); + //switch enabled button to disabled and vice versa + pBHelp->setEnabled(!pBHelp->isEnabled()); + pBDefaults->setEnabled(!pBDefaults->isEnabled()); + } + QApplication::processEvents(); + QCOMPARE(spy0.count(), 5); + QCOMPARE(spy1.count(), 5); } - QTEST_MAIN(tst_QSoftKeyManager) #include "tst_qsoftkeymanager.moc" diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 13d68ff..82b6066 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -1072,17 +1072,20 @@ void tst_QSqlDatabase::recordMySQL() int revision = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 2, 2 ).toInt(); int vernum = (major << 16) + (minor << 8) + revision; -#ifdef QT3_SUPPORT /* The below is broken in mysql below 5.0.15 see http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html specifically: Before MySQL 5.0.15, the pad value is space. Values are right-padded with space on insert, and trailing spaces are removed on select. */ if( vernum >= ((5 << 16) + 15) ) { +#ifdef QT3_SUPPORT bin10 = FieldDef("binary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abc "))); varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abcv "))); - } +#else + bin10 = FieldDef("binary(10)", QVariant::ByteArray, QString("123abc ")); + varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QString("123abcv ")); #endif + } static QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0)); static const FieldDef fieldDefs[] = { @@ -2468,7 +2471,7 @@ void tst_QSqlDatabase::mysql_savepointtest() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 1 ).toInt()<4.1 ) + if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 1 ).toDouble()<4.1 ) QSKIP( "Test requires MySQL >= 4.1", SkipSingle ); QSqlQuery q(db); diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 546c105..98030d1 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -194,7 +194,6 @@ private slots: void sqlServerReturn0_data() { generic_data(); } void sqlServerReturn0(); - private: // returns all database connections void generic_data(const QString &engine=QString()); @@ -510,9 +509,7 @@ void tst_QSqlQuery::mysqlOutValues() QVERIFY_SQL( q, exec( "create procedure " + qTableName( "qtestproc" ) + " () " "BEGIN select * from " + qTableName( "qtest" ) + " order by id; END" ) ); QVERIFY_SQL( q, exec( "call " + qTableName( "qtestproc" ) + "()" ) ); - QEXPECT_FAIL("", "There's a mysql bug that means only selects think they return data when running in prepared mode", Continue); QVERIFY_SQL( q, next() ); - QEXPECT_FAIL("", "There's a mysql bug that means only selects think they return data when running in prepared mode", Continue); QCOMPARE( q.value( 1 ).toString(), QString( "VarChar1" ) ); QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) ); diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 91b2cc5..da58725 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -172,6 +172,7 @@ private slots: void expandAndCollapse_data(); void expandAndCollapse(); void expandAndCollapseAll(); + void expandWithNoChildren(); void keyboardNavigation(); void headerSections(); void moveCursor_data(); @@ -1548,6 +1549,19 @@ void tst_QTreeView::expandAndCollapseAll() // QCOMPARE(collapsedSpy.count(), count); } +void tst_QTreeView::expandWithNoChildren() +{ + QTreeView tree; + QStandardItemModel model(1,1); + tree.setModel(&model); + tree.setAnimated(true); + tree.doItemsLayout(); + //this test should not output warnings + tree.expand(model.index(0,0)); +} + + + void tst_QTreeView::keyboardNavigation() { const int rows = 10; diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp index 11c4543..6defd7b 100644 --- a/tests/auto/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp @@ -49,6 +49,9 @@ #include <qheaderview.h> #include <qlineedit.h> #include <QScrollBar> +#include <QStyledItemDelegate> + +#include "../../shared/util.h" //TESTED_CLASS= @@ -163,6 +166,7 @@ private slots: void task217309(); void setCurrentItemExpandsParent(); void task239150_editorWidth(); + void setTextUpdate(); public slots: void itemSelectionChanged(); @@ -3233,6 +3237,41 @@ void tst_QTreeWidget::task239150_editorWidth() +void tst_QTreeWidget::setTextUpdate() +{ + QTreeWidget treeWidget; + treeWidget.setColumnCount(2); + + class MyItemDelegate : public QStyledItemDelegate + { + public: + MyItemDelegate() : numPaints(0) { } + void paint(QPainter *painter, + const QStyleOptionViewItem &option, const QModelIndex &index) const + { + numPaints++; + QStyledItemDelegate::paint(painter, option, index); + } + + mutable int numPaints; + } delegate; + + treeWidget.setItemDelegate(&delegate); + treeWidget.show(); + QStringList strList; + strList << "variable1" << "0"; + QTreeWidgetItem *item = new QTreeWidgetItem(strList); + treeWidget.insertTopLevelItem(0, item); + QTest::qWait(50); + QTRY_VERIFY(delegate.numPaints > 0); + delegate.numPaints = 0; + + item->setText(1, "42"); + QApplication::processEvents(); + QTRY_VERIFY(delegate.numPaints > 0); +} + + QTEST_MAIN(tst_QTreeWidget) #include "tst_qtreewidget.moc" diff --git a/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp index bc6fe68..9623e80 100644 --- a/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp +++ b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp @@ -120,7 +120,7 @@ void tst_QVideoSurfaceFormat::constructNull() QCOMPARE(format.frameHeight(), -1); QCOMPARE(format.viewport(), QRect()); QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); - QCOMPARE(format.frameRate(), QVideoSurfaceFormat::FrameRate()); + QCOMPARE(format.frameRate(), 0.0); QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); QCOMPARE(format.yuvColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); } @@ -159,7 +159,7 @@ void tst_QVideoSurfaceFormat::construct() QCOMPARE(format.frameHeight(), frameSize.height()); QCOMPARE(format.viewport(), viewport); QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); - QCOMPARE(format.frameRate(), QVideoSurfaceFormat::FrameRate()); + QCOMPARE(format.frameRate(), 0.0); QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); QCOMPARE(format.yuvColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); } @@ -315,21 +315,21 @@ void tst_QVideoSurfaceFormat::scanLineDirection() void tst_QVideoSurfaceFormat::frameRate_data() { - QTest::addColumn<QVideoSurfaceFormat::FrameRate>("frameRate"); + QTest::addColumn<qreal>("frameRate"); QTest::newRow("null") - << QVideoSurfaceFormat::FrameRate(0, 0); + << 0.0; QTest::newRow("1/1") - << QVideoSurfaceFormat::FrameRate(1, 1); + << 1.0; QTest::newRow("24/1") - << QVideoSurfaceFormat::FrameRate(24, 1); + << 24.0; QTest::newRow("15/2") - << QVideoSurfaceFormat::FrameRate(15, 2); + << 7.5; } void tst_QVideoSurfaceFormat::frameRate() { - QFETCH(QVideoSurfaceFormat::FrameRate, frameRate); + QFETCH(qreal, frameRate); { QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); @@ -337,29 +337,16 @@ void tst_QVideoSurfaceFormat::frameRate() format.setFrameRate(frameRate); QCOMPARE(format.frameRate(), frameRate); - QCOMPARE(qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")), - frameRate); - } - { - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - - format.setFrameRate(frameRate.first, frameRate.second); - - QCOMPARE(format.frameRate(), frameRate); - QCOMPARE( - qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")), - frameRate); + QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate); } { QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); format.setFrameRate(frameRate); - format.setProperty( - "frameRate", qVariantFromValue<QVideoSurfaceFormat::FrameRate>(frameRate)); + format.setProperty("frameRate", frameRate); QCOMPARE(format.frameRate(), frameRate); - QCOMPARE(qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")), - frameRate); + QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate); } } @@ -609,13 +596,13 @@ void tst_QVideoSurfaceFormat::compare() QCOMPARE(format1 == format2, true); QCOMPARE(format1 != format2, false); - format1.setFrameRate(QVideoSurfaceFormat::FrameRate(15, 2)); + format1.setFrameRate(7.5); // Not equal frame rate differs. QCOMPARE(format1 == format2, false); QCOMPARE(format1 != format2, true); - format2.setFrameRate(15, 2); + format2.setFrameRate(7.50001); // Equal. QCOMPARE(format1 == format2, true); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 4cb9f72..a03f112 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -242,7 +242,12 @@ private slots: void setFixedSize(); void ensureCreated(); + void winIdChangeEvent(); +#ifdef Q_OS_SYMBIAN + void reparentCausesChildWinIdChange(); +#else void persistentWinId(); +#endif void qobject_castInDestroyedSlot(); void showHideEvent_data(); @@ -4352,6 +4357,146 @@ void tst_QWidget::ensureCreated() } } +class WinIdChangeWidget : public QWidget { +public: + WinIdChangeWidget(QWidget *p = 0) + : QWidget(p) + , m_winIdChangeEventCount(0) + { + + } +protected: + bool event(QEvent *e) + { + if (e->type() == QEvent::WinIdChange) { + ++m_winIdChangeEventCount; + return true; + } + return QWidget::event(e); + } +public: + int m_winIdChangeEventCount; +}; + +void tst_QWidget::winIdChangeEvent() +{ + { + // Transforming an alien widget into a native widget + WinIdChangeWidget widget; + const WId winIdBefore = widget.internalWinId(); + const WId winIdAfter = widget.winId(); + QVERIFY(winIdBefore != winIdAfter); + QCOMPARE(widget.m_winIdChangeEventCount, 1); + } + + { + // Changing parent of a native widget + QWidget parent1, parent2; + WinIdChangeWidget child(&parent1); + const WId winIdBefore = child.winId(); + QCOMPARE(child.m_winIdChangeEventCount, 1); + child.setParent(&parent2); + const WId winIdAfter = child.internalWinId(); +#ifdef Q_OS_SYMBIAN + QVERIFY(winIdBefore != winIdAfter); + QCOMPARE(child.m_winIdChangeEventCount, 2); +#else + QCOMPARE(winIdBefore, winIdAfter); + QCOMPARE(child.m_winIdChangeEventCount, 1); +#endif + } + + { + // Changing parent of an alien widget + QWidget parent1, parent2; + WinIdChangeWidget child(&parent1); + const WId winIdBefore = child.internalWinId(); + child.setParent(&parent2); + const WId winIdAfter = child.internalWinId(); + QCOMPARE(winIdBefore, winIdAfter); + QCOMPARE(child.m_winIdChangeEventCount, 0); + } + + { + // Making native child widget into a top-level window + QWidget parent; + WinIdChangeWidget child(&parent); + child.winId(); + const WId winIdBefore = child.internalWinId(); + QCOMPARE(child.m_winIdChangeEventCount, 1); + const Qt::WindowFlags flags = child.windowFlags(); + child.setWindowFlags(flags | Qt::Window); + const WId winIdAfter = child.internalWinId(); + QVERIFY(winIdBefore != winIdAfter); + QCOMPARE(child.m_winIdChangeEventCount, 2); + } +} + +#ifdef Q_OS_SYMBIAN +void tst_QWidget::reparentCausesChildWinIdChange() +{ + QWidget *parent = new QWidget; + QWidget *w1 = new QWidget; + QWidget *w2 = new QWidget; + QWidget *w3 = new QWidget; + w1->setParent(parent); + w2->setParent(w1); + w3->setParent(w2); + + WId winId1 = w1->winId(); + WId winId2 = w2->winId(); + WId winId3 = w3->winId(); + + // reparenting causes winIds of the widget being reparented, and all of its children, to change + w1->setParent(0); + QVERIFY(w1->winId() != winId1); + winId1 = w1->winId(); + QVERIFY(w2->winId() != winId2); + winId2 = w2->winId(); + QVERIFY(w3->winId() != winId3); + winId3 = w3->winId(); + + w1->setParent(parent); + QVERIFY(w1->winId() != winId1); + winId1 = w1->winId(); + QVERIFY(w2->winId() != winId2); + winId2 = w2->winId(); + QVERIFY(w3->winId() != winId3); + winId3 = w3->winId(); + + w2->setParent(0); + QVERIFY(w2->winId() != winId2); + winId2 = w2->winId(); + QVERIFY(w3->winId() != winId3); + winId3 = w3->winId(); + + w2->setParent(parent); + QVERIFY(w2->winId() != winId2); + winId2 = w2->winId(); + QVERIFY(w3->winId() != winId3); + winId3 = w3->winId(); + + w2->setParent(w1); + QVERIFY(w2->winId() != winId2); + winId2 = w2->winId(); + QVERIFY(w3->winId() != winId3); + winId3 = w3->winId(); + + w3->setParent(0); + QVERIFY(w3->winId() != winId3); + winId3 = w3->winId(); + + w3->setParent(w1); + QVERIFY(w3->winId() != winId3); + winId3 = w3->winId(); + + w3->setParent(w2); + QVERIFY(w3->winId() != winId3); + winId3 = w3->winId(); + + delete parent; +} +#else void tst_QWidget::persistentWinId() { QWidget *parent = new QWidget; @@ -4408,6 +4553,7 @@ void tst_QWidget::persistentWinId() delete parent; } +#endif // Q_OS_SYMBIAN class ShowHideEventWidget : public QWidget { |