diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-19 10:53:10 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-19 10:53:42 (GMT) |
commit | 80dfb33cc5fec8fd19e78a959e02588ce58736ee (patch) | |
tree | d9afe6da9127c63409862623b5a4ffa4598e1bf2 /tests | |
parent | a73e660fd05bafc402d63d71e811a621e46f452d (diff) | |
parent | 1b14c3d33dea0fe4814f2749c49cf916ca13e012 (diff) | |
download | Qt-80dfb33cc5fec8fd19e78a959e02588ce58736ee.zip Qt-80dfb33cc5fec8fd19e78a959e02588ce58736ee.tar.gz Qt-80dfb33cc5fec8fd19e78a959e02588ce58736ee.tar.bz2 |
Merge oslo-staging-2/4.6 into upstream/4.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qalgorithms/tst_qalgorithms.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qcombobox/tst_qcombobox.cpp | 15 | ||||
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 24 | ||||
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 42 | ||||
-rw-r--r-- | tests/auto/qmenu/tst_qmenu.cpp | 26 | ||||
-rw-r--r-- | tests/auto/qstatemachine/tst_qstatemachine.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qtableview/tst_qtableview.cpp | 27 | ||||
-rw-r--r-- | tests/manual/keypadnavigation/keypadnavigation.ui | 157 | ||||
-rw-r--r-- | tests/manual/keypadnavigation/main.cpp | 8 |
10 files changed, 228 insertions, 99 deletions
diff --git a/tests/auto/qalgorithms/tst_qalgorithms.cpp b/tests/auto/qalgorithms/tst_qalgorithms.cpp index 176a451..1e24efe 100644 --- a/tests/auto/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/qalgorithms/tst_qalgorithms.cpp @@ -620,8 +620,8 @@ void tst_QAlgorithms::test_qBinaryFind() //-42 means not found if (resultValue == -42) { - QVERIFY(qBinaryFind(data.constBegin(), data.constEnd(), resultValue) == data.end()); - QVERIFY(qBinaryFind(data, resultValue) == data.end()); + QVERIFY(qBinaryFind(data.constBegin(), data.constEnd(), resultValue) == data.constEnd()); + QVERIFY(qBinaryFind(data, resultValue) == data.constEnd()); QVERIFY(qBinaryFind(data.begin(), data.end(), resultValue) == data.end()); QVERIFY(qBinaryFind(data.begin(), data.end(), resultValue, qLess<int>()) == data.end()); return; diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index e903ab5..af71961 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2290,11 +2290,8 @@ void tst_QComboBox::setItemDelegate() QComboBox comboBox; QStyledItemDelegate *itemDelegate = new QStyledItemDelegate; comboBox.setItemDelegate(itemDelegate); -#ifdef Q_CC_MWERKS + // the cast is a workaround for the XLC and Metrowerks compilers QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); -#else - QCOMPARE(comboBox.itemDelegate(), itemDelegate); -#endif } void tst_QComboBox::task253944_itemDelegateIsReset() @@ -2303,19 +2300,13 @@ void tst_QComboBox::task253944_itemDelegateIsReset() QStyledItemDelegate *itemDelegate = new QStyledItemDelegate; comboBox.setItemDelegate(itemDelegate); + // the casts are workarounds for the XLC and Metrowerks compilers + comboBox.setEditable(true); -#ifdef Q_CC_MWERKS QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); -#else - QCOMPARE(comboBox.itemDelegate(), itemDelegate); -#endif comboBox.setStyleSheet("QComboBox { border: 1px solid gray; }"); -#ifdef Q_CC_MWERKS QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); -#else - QCOMPARE(comboBox.itemDelegate(), itemDelegate); -#endif } diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index a49c2c1..20d9eb8 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -276,6 +276,7 @@ private slots: void task176178_itemIndexMethodBreaksSceneRect(); void task160653_selectionChanged(); void task250680_childClip(); + void taskQTBUG_5904_crashWithDeviceCoordinateCache(); }; void tst_QGraphicsScene::initTestCase() @@ -4180,5 +4181,20 @@ void tst_QGraphicsScene::isActive() } +void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() +{ + QGraphicsScene scene; + QGraphicsRectItem *rectItem = scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green)); + + rectItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + + QPixmap pixmap(100,200); + QPainter painter(&pixmap); + painter.setRenderHint(QPainter::Antialiasing); + scene.render(&painter); + painter.end(); + // No crash, then it passed! +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 829e55c..3b98c2f 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -161,6 +161,7 @@ private slots: void respectHFW(); void addChildInpolishEvent(); void polishEvent(); + void polishEvent2(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2796,6 +2797,29 @@ void tst_QGraphicsWidget::polishEvent() QCOMPARE(widget->events.at(0), QEvent::Polish); } +void tst_QGraphicsWidget::polishEvent2() +{ + class MyGraphicsWidget : public QGraphicsWidget + { public: + void polishEvent() + { events << QEvent::Polish; } + QList<QEvent::Type> events; + }; + + QGraphicsScene scene; + + MyGraphicsWidget *widget = new MyGraphicsWidget; + widget->hide(); + scene.addItem(widget); + + widget->events.clear(); + + QApplication::processEvents(); + + // Make sure the item got polish event. + QVERIFY(widget->events.contains(QEvent::Polish)); +} + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 1c8fecf..596ac9b 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -122,6 +122,7 @@ private slots: void taskQTBUG_633_changeModelData(); void taskQTBUG_435_deselectOnViewportClick(); void taskQTBUG_2678_spacingAndWrappedText(); + void taskQTBUG_5877_skippingItemInPageDownUp(); }; // Testing get/set functions @@ -509,9 +510,7 @@ void tst_QListView::moveCursor2() QModelIndex idx = vu.moveCursor(QMoveCursorListView::MoveHome, Qt::NoModifier); QCOMPARE(idx, model.index(0,0)); idx = vu.moveCursor(QMoveCursorListView::MoveDown, Qt::NoModifier); - QModelIndex p = model.index(8,0); QCOMPARE(idx, model.index(8,0)); - } void tst_QListView::moveCursor3() @@ -605,7 +604,6 @@ void tst_QListView::indexAt() QVERIFY(view2.m_index.isValid()); QVERIFY(view2.m_index.row() != 0); - } void tst_QListView::clicked() @@ -703,7 +701,6 @@ void tst_QListView::modelColumn() view.setModel(&model); - // // Set and get with a valid model // @@ -743,7 +740,6 @@ void tst_QListView::modelColumn() } } - void tst_QListView::hideFirstRow() { QStringList items; @@ -814,7 +810,6 @@ void tst_QListView::batchedMode() ba.setBit(idx.row(), true); } QCOMPARE(ba.size(), 3); - } void tst_QListView::setCurrentIndex() @@ -1146,7 +1141,6 @@ void tst_QListView::selection() for (int i = 0; i < selected.count(); ++i) { QVERIFY(expectedItems.contains(selected.at(i).row())); } - } void tst_QListView::scrollTo() @@ -1251,7 +1245,6 @@ void tst_QListView::scrollTo() QTest::keyClick(lv.viewport(), Qt::Key_Up, Qt::NoModifier); QCOMPARE(lv.visualRect(index).y(), 0); - } @@ -1772,7 +1765,6 @@ void tst_QListView::clickOnViewportClearsSelection() QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, point); //now the selection should be cleared QVERIFY(!view.selectionModel()->hasSelection()); - } void tst_QListView::task262152_setModelColumnNavigate() @@ -1795,7 +1787,6 @@ void tst_QListView::task262152_setModelColumnNavigate() QTest::keyClick(&view, Qt::Key_Down); QTest::qWait(30); QTRY_COMPARE(view.currentIndex(), model.index(2,1)); - } void tst_QListView::taskQTBUG_2233_scrollHiddenItems_data() @@ -1891,5 +1882,36 @@ void tst_QListView::taskQTBUG_2678_spacingAndWrappedText() QCOMPARE(w.horizontalScrollBar()->minimum(), w.horizontalScrollBar()->maximum()); } +void tst_QListView::taskQTBUG_5877_skippingItemInPageDownUp() +{ + QList<int> currentItemIndexes; + QtTestModel model(0); + model.colCount = 1; + model.rCount = 100; + + currentItemIndexes << 0 << 6 << 16 << 25 << 34 << 42 << 57 << 68 << 77 + << 83 << 91 << 94; + QMoveCursorListView vu; + vu.setModel(&model); + vu.show(); + + int itemHeight = vu.visualRect(model.index(0, 0)).height(); + int visibleRowCount = vu.height() / itemHeight; + int scrolledRowCount = visibleRowCount - 1; + + for (int i = 0; i < currentItemIndexes.size(); ++i) { + vu.selectionModel()->setCurrentIndex(model.index(currentItemIndexes[i], 0), + QItemSelectionModel::SelectCurrent); + + QModelIndex idx = vu.moveCursor(QMoveCursorListView::MovePageDown, Qt::NoModifier); + int newCurrent = qMin(currentItemIndexes[i] + scrolledRowCount, 99); + QCOMPARE(idx, model.index(newCurrent, 0)); + + idx = vu.moveCursor(QMoveCursorListView::MovePageUp, Qt::NoModifier); + newCurrent = qMax(currentItemIndexes[i] - scrolledRowCount, 0); + QCOMPARE(idx, model.index(newCurrent, 0)); + } +} + 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 f0f69a4..7cdfe46 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -87,6 +87,7 @@ private slots: void widgetActionFocus(); void mouseActivation(); void tearOff(); + void layoutDirection(); #if defined(QT3_SUPPORT) void indexBasedInsertion_data(); @@ -596,6 +597,31 @@ void tst_QMenu::tearOff() QVERIFY(!torn->isVisible()); } +void tst_QMenu::layoutDirection() +{ + QMainWindow win; + win.setLayoutDirection(Qt::RightToLeft); + + QMenu menu(&win); + menu.show(); + QTest::qWaitForWindowShown(&menu); + QCOMPARE(menu.layoutDirection(), Qt::RightToLeft); + menu.close(); + + menu.setParent(0); + menu.show(); + QTest::qWaitForWindowShown(&menu); + QCOMPARE(menu.layoutDirection(), QApplication::layoutDirection()); + menu.close(); + + //now the menubar + QAction *action = win.menuBar()->addMenu(&menu); + win.menuBar()->setActiveAction(action); + QTest::qWaitForWindowShown(&menu); + QCOMPARE(menu.layoutDirection(), Qt::RightToLeft); +} + + #if defined(QT3_SUPPORT) void tst_QMenu::indexBasedInsertion_data() diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index fd39515..a13bb0d 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -209,6 +209,7 @@ private slots: void task260403_clonedSignals(); void postEventFromOtherThread(); void eventFilterForApplication(); + void eventClassesExported(); }; tst_QStateMachine::tst_QStateMachine() @@ -4307,5 +4308,12 @@ void tst_QStateMachine::eventFilterForApplication() QVERIFY(machine.configuration().contains(s2)); } +void tst_QStateMachine::eventClassesExported() +{ + // make sure this links + QStateMachine::WrappedEvent *wrappedEvent = new QStateMachine::WrappedEvent(0, 0); + QStateMachine::SignalEvent *signalEvent = new QStateMachine::SignalEvent(0, 0, QList<QVariant>()); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index f571e8a..46c3fb6 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -198,6 +198,7 @@ private slots: void task191545_dragSelectRows(); void taskQTBUG_5062_spansInconsistency(); void taskQTBUG_4516_clickOnRichTextLabel(); + void taskQTBUG_5237_wheelEventOnHeader(); void mouseWheel_data(); void mouseWheel(); @@ -3613,17 +3614,9 @@ void tst_QTableView::mouseWheel_data() QTest::newRow("scroll down per item") << int(QAbstractItemView::ScrollPerItem) << -120 << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines(); -#ifdef Q_WS_MAC - // On Mac, we always scroll one pixel per 120 delta (rather than multiplying with - // singleStep) since wheel events are accelerated by the OS. - QTest::newRow("scroll down per pixel") - << int(QAbstractItemView::ScrollPerPixel) << -120 - << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines(); -#else QTest::newRow("scroll down per pixel") << int(QAbstractItemView::ScrollPerPixel) << -120 << 10 + qApp->wheelScrollLines() * 89 << 10 + qApp->wheelScrollLines() * 28; -#endif } void tst_QTableView::mouseWheel() @@ -3913,7 +3906,7 @@ void tst_QTableView::changeHeaderData() QTest::qWaitForWindowShown(&view); QString text = "long long long text"; - const int textWidth = view.fontMetrics().width(text); + const int textWidth = view.verticalHeader()->fontMetrics().width(text); QVERIFY(view.verticalHeader()->width() < textWidth); model.setHeaderData(2, Qt::Vertical, text); @@ -3922,6 +3915,22 @@ void tst_QTableView::changeHeaderData() QVERIFY(view.verticalHeader()->width() > textWidth); } +void tst_QTableView::taskQTBUG_5237_wheelEventOnHeader() +{ + QTableView view; + QStandardItemModel model(500,5); + view.setModel(&model); + view.show(); + QTest::qWaitForWindowShown(&view); + + int sbValueBefore = view.verticalScrollBar()->value(); + QHeaderView *header = view.verticalHeader(); + QTest::mouseMove(header); + QWheelEvent wheelEvent(header->geometry().center(), -720, 0, 0); + QApplication::sendEvent(header->viewport(), &wheelEvent); + int sbValueAfter = view.verticalScrollBar()->value(); + QVERIFY(sbValueBefore != sbValueAfter); +} QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" diff --git a/tests/manual/keypadnavigation/keypadnavigation.ui b/tests/manual/keypadnavigation/keypadnavigation.ui index 039889b..8b456d9 100644 --- a/tests/manual/keypadnavigation/keypadnavigation.ui +++ b/tests/manual/keypadnavigation/keypadnavigation.ui @@ -1060,75 +1060,100 @@ As a reward you can try out the QDial, below.</string> </widget> <widget class="QWidget" name="m_pageDialogs"> <layout class="QVBoxLayout" name="verticalLayout_13"> + <property name="margin"> + <number>0</number> + </property> <item> - <widget class="QPushButton" name="m_buttonGetOpenFileName"> - <property name="text"> - <string>getOpenFileName()</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="m_buttonGetSaveFileName"> - <property name="text"> - <string>getSaveFileName()</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="m_buttonGetExistingDirectory"> - <property name="text"> - <string>getExistingDirectory()</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="m_buttonGetColor"> - <property name="text"> - <string>getColor()</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="m_buttonGetFont"> - <property name="text"> - <string>getFont()</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="m_buttonQuestion"> - <property name="text"> - <string>question()</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="m_buttonAboutQt"> - <property name="text"> - <string>aboutQt()</string> + <widget class="QScrollArea" name="scrollArea_5"> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="m_buttonGetItem"> - <property name="text"> - <string>getItem()</string> + <property name="widgetResizable"> + <bool>true</bool> </property> + <widget class="QWidget" name="scrollAreaWidgetContents_5"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>264</width> + <height>356</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_14"> + <item> + <widget class="QPushButton" name="m_buttonGetOpenFileName"> + <property name="text"> + <string>getOpenFileName()</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="m_buttonGetSaveFileName"> + <property name="text"> + <string>getSaveFileName()</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="m_buttonGetExistingDirectory"> + <property name="text"> + <string>getExistingDirectory()</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="m_buttonGetColor"> + <property name="text"> + <string>getColor()</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="m_buttonGetFont"> + <property name="text"> + <string>getFont()</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="m_buttonQuestion"> + <property name="text"> + <string>question()</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="m_buttonAboutQt"> + <property name="text"> + <string>aboutQt()</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="m_buttonGetItem"> + <property name="text"> + <string>getItem()</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>103</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> </widget> </item> - <item> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>104</height> - </size> - </property> - </spacer> - </item> </layout> </widget> </widget> @@ -1155,7 +1180,7 @@ As a reward you can try out the QDial, below.</string> <addaction name="m_actionLayoutChaos"/> <addaction name="m_actionLayoutDialogs"/> </widget> - <widget class="QMenu" name="menuNavigation_mode"> + <widget class="QMenu" name="m_menuNavigation_mode"> <property name="title"> <string>Navigation mode</string> </property> @@ -1166,7 +1191,7 @@ As a reward you can try out the QDial, below.</string> <addaction name="m_actionModeCursorForceVisible"/> </widget> <addaction name="menuUi_layout"/> - <addaction name="menuNavigation_mode"/> + <addaction name="m_menuNavigation_mode"/> </widget> <action name="m_actionLayoutVerticalSimple"> <property name="text"> diff --git a/tests/manual/keypadnavigation/main.cpp b/tests/manual/keypadnavigation/main.cpp index d1cc8a7..84b3d78 100644 --- a/tests/manual/keypadnavigation/main.cpp +++ b/tests/manual/keypadnavigation/main.cpp @@ -70,6 +70,7 @@ public: } connect(&m_layoutSignalMapper, SIGNAL(mapped(QWidget*)), ui->m_stackWidget, SLOT(setCurrentWidget(QWidget*))); +#ifdef QT_KEYPAD_NAVIGATION const struct { QObject *action; Qt::NavigationMode mode; @@ -85,6 +86,9 @@ public: m_modeSignalMapper.setMapping(modeMappings[i].action, int(modeMappings[i].mode)); } connect(&m_modeSignalMapper, SIGNAL(mapped(int)), SLOT(setNavigationMode(int))); +#else // QT_KEYPAD_NAVIGATION + ui->m_menuNavigation_mode->deleteLater(); +#endif // QT_KEYPAD_NAVIGATION const struct { QObject *button; @@ -112,10 +116,12 @@ public: } protected slots: +#ifdef QT_KEYPAD_NAVIGATION void setNavigationMode(int mode) { QApplication::setNavigationMode(Qt::NavigationMode(mode)); } +#endif // QT_KEYPAD_NAVIGATION void openDialog(int dialog) { @@ -163,7 +169,9 @@ private: Ui_KeypadNavigation *ui; QSignalMapper m_layoutSignalMapper; +#ifdef QT_KEYPAD_NAVIGATION QSignalMapper m_modeSignalMapper; +#endif // QT_KEYPAD_NAVIGATION QSignalMapper m_dialogSignalMapper; }; |