diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-22 03:36:20 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-22 03:36:20 (GMT) |
commit | adb16277869ad4d588ef7b3c7112f94abdeb9b8b (patch) | |
tree | 3771da3cc65a12bd5642736c16651483c2255add /tests | |
parent | 47862497693ffac597557f940535909df549d897 (diff) | |
parent | 5ea1f7d58ad19a2917308050b5bf42fd310b4a5c (diff) | |
download | Qt-adb16277869ad4d588ef7b3c7112f94abdeb9b8b.zip Qt-adb16277869ad4d588ef7b3c7112f94abdeb9b8b.tar.gz Qt-adb16277869ad4d588ef7b3c7112f94abdeb9b8b.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 38 | ||||
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 28 | ||||
-rw-r--r-- | tests/auto/qicon/tst_qicon.cpp | 23 | ||||
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 31 | ||||
-rw-r--r-- | tests/benchmarks/corelib/kernel/qobject/main.cpp | 9 | ||||
-rw-r--r-- | tests/benchmarks/corelib/kernel/qobject/object.cpp | 3 | ||||
-rw-r--r-- | tests/benchmarks/corelib/kernel/qobject/object.h | 1 |
7 files changed, 131 insertions, 2 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 03ce45a..e2f7f18 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -62,6 +62,7 @@ #include <QVBoxLayout> #include <QGraphicsEffect> #include <QInputContext> +#include <QPushButton> #include "../../shared/util.h" @@ -426,6 +427,7 @@ private slots: void itemIsInFront(); void scenePosChange(); void updateMicroFocus(); + void textItem_shortcuts(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -10060,6 +10062,42 @@ void tst_QGraphicsItem::updateMicroFocus() QTRY_COMPARE(ic2.nbUpdates, 0); } +void tst_QGraphicsItem::textItem_shortcuts() +{ + QWidget w; + QVBoxLayout l; + w.setLayout(&l); + QGraphicsScene scene; + QGraphicsView view(&scene); + l.addWidget(&view); + QPushButton b("Push Me"); + l.addWidget(&b); + + QGraphicsTextItem *item = scene.addText("Troll Text"); + item->setFlag(QGraphicsItem::ItemIsFocusable); + item->setTextInteractionFlags(Qt::TextEditorInteraction); + w.show(); + QTest::qWaitForWindowShown(&w); + + item->setFocus(); + QTRY_VERIFY(item->hasFocus()); + QVERIFY(item->textCursor().selectedText().isEmpty()); + + // Shortcut should work (select all) + QTest::keyClick(&view, Qt::Key_A, Qt::ControlModifier); + QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText()); + QTextCursor tc = item->textCursor(); + tc.clearSelection(); + item->setTextCursor(tc); + QVERIFY(item->textCursor().selectedText().isEmpty()); + + // Shortcut should also work if the text item has the focus and another widget + // has the same shortcut. + b.setShortcut(QKeySequence("CTRL+A")); + QTest::keyClick(&view, Qt::Key_A, Qt::ControlModifier); + QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText()); +} + void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() { struct Item : public QGraphicsTextItem diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 1c19fab..5e889f4 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -239,6 +239,7 @@ private slots: void QTBUG_4151_clipAndIgnore_data(); void QTBUG_4151_clipAndIgnore(); void QTBUG_5859_exposedRect(); + void QTBUG_7438_cursor(); }; void tst_QGraphicsView::initTestCase() @@ -4063,5 +4064,32 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect() QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect); } +void tst_QGraphicsView::QTBUG_7438_cursor() +{ +#ifndef QT_NO_CURSOR +#if defined(Q_OS_WINCE) + QSKIP("Qt/CE does not have regular cursor support", SkipAll); +#endif + QGraphicsScene scene; + QGraphicsItem *item = scene.addRect(QRectF(-10, -10, 20, 20)); + item->setFlag(QGraphicsItem::ItemIsMovable); + + QGraphicsView view(&scene); + view.setFixedSize(400, 400); + view.show(); + QTest::qWaitForWindowShown(&view); + + QCOMPARE(view.viewport()->cursor().shape(), QCursor().shape()); + view.viewport()->setCursor(Qt::PointingHandCursor); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + sendMouseMove(view.viewport(), view.mapFromScene(0, 0)); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + sendMousePress(view.viewport(), view.mapFromScene(0, 0)); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + sendMouseRelease(view.viewport(), view.mapFromScene(0, 0)); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); +#endif +} + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp index fae9cc0..e68664c 100644 --- a/tests/auto/qicon/tst_qicon.cpp +++ b/tests/auto/qicon/tst_qicon.cpp @@ -76,6 +76,7 @@ private slots: void svg(); void addFile(); void availableSizes(); + void name(); void streamAvailableSizes_data(); void streamAvailableSizes(); void fromTheme(); @@ -550,6 +551,28 @@ void tst_QIcon::availableSizes() } } +void tst_QIcon::name() +{ + { + // No name if icon does not come from a theme + QIcon icon(":/image.png"); + QString name = icon.name(); + QVERIFY(name.isEmpty()); + } + + { + // Getting the name of an icon coming from a theme should work + QString searchPath = QLatin1String(":/icons"); + QIcon::setThemeSearchPaths(QStringList() << searchPath); + QString themeName("testtheme"); + QIcon::setThemeName(themeName); + + QIcon icon = QIcon::fromTheme("appointment-new"); + QString name = icon.name(); + QCOMPARE(name, QLatin1String("appointment-new")); + } +} + void tst_QIcon::streamAvailableSizes_data() { QTest::addColumn<QIcon>("icon"); diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index f5c32cd..330f803 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -124,6 +124,7 @@ private slots: void taskQTBUG_2678_spacingAndWrappedText(); void taskQTBUG_5877_skippingItemInPageDownUp(); void taskQTBUG_9455_wrongScrollbarRanges(); + void styleOptionViewItem(); }; // Testing get/set functions @@ -1971,5 +1972,35 @@ void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges() QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height()); } +void tst_QListView::styleOptionViewItem() +{ + class MyDelegate : public QStyledItemDelegate + { + public: + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const + { + QVERIFY(qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option)); + QStyleOptionViewItemV4 opt(option); + initStyleOption(&opt, index); + + QCOMPARE(opt.index, index); + + QStyledItemDelegate::paint(painter, option, index); + } + }; + + QListView view; + QStandardItemModel model; + view.setModel(&model); + MyDelegate delegate; + view.setItemDelegate(&delegate); + model.appendRow(QList<QStandardItem*>() + << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + + // Run test + view.showMaximized(); + QApplication::processEvents(); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" diff --git a/tests/benchmarks/corelib/kernel/qobject/main.cpp b/tests/benchmarks/corelib/kernel/qobject/main.cpp index 7f24ebd..8d05fcd 100644 --- a/tests/benchmarks/corelib/kernel/qobject/main.cpp +++ b/tests/benchmarks/corelib/kernel/qobject/main.cpp @@ -69,6 +69,7 @@ void QObjectBenchmark::signal_slot_benchmark_data() QTest::newRow("simple function") << 0; QTest::newRow("single signal/slot") << 1; QTest::newRow("multi signal/slot") << 2; + QTest::newRow("unconnected signal") << 3; } void QObjectBenchmark::signal_slot_benchmark() @@ -110,9 +111,13 @@ void QObjectBenchmark::signal_slot_benchmark() QBENCHMARK { singleObject.emitSignal0(); } - } else { + } else if (type == 2) { QBENCHMARK { - multiObject.emitSignal0(); + multiObject.emitSignal0(); + } + } else if (type == 3) { + QBENCHMARK { + singleObject.emitSignal1(); } } } diff --git a/tests/benchmarks/corelib/kernel/qobject/object.cpp b/tests/benchmarks/corelib/kernel/qobject/object.cpp index d775a32..3920e97 100644 --- a/tests/benchmarks/corelib/kernel/qobject/object.cpp +++ b/tests/benchmarks/corelib/kernel/qobject/object.cpp @@ -42,6 +42,9 @@ void Object::emitSignal0() { emit signal0(); } +void Object::emitSignal1() +{ emit signal1(); } + void Object::slot0() { } diff --git a/tests/benchmarks/corelib/kernel/qobject/object.h b/tests/benchmarks/corelib/kernel/qobject/object.h index 7e4933f..8f8fbe9 100644 --- a/tests/benchmarks/corelib/kernel/qobject/object.h +++ b/tests/benchmarks/corelib/kernel/qobject/object.h @@ -48,6 +48,7 @@ class Object : public QObject Q_OBJECT public: void emitSignal0(); + void emitSignal1(); signals: void signal0(); void signal1(); |