summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp6
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp11
-rw-r--r--tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp2
-rw-r--r--tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp3
-rw-r--r--tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp22
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp8
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp6
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp9
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp41
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp10
13 files changed, 86 insertions, 38 deletions
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index 9e0648d194..cf4c4e1bdb 100644
--- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -441,10 +441,8 @@ void tst_QPropertyAnimation::noStartValue()
a.setDuration(250);
a.start();
- QTest::qWait(300);
-
- QTRY_COMPARE(o.values.first(), 42);
- QCOMPARE(o.values.last(), 420);
+ QTRY_COMPARE(o.values.value(o.values.size() - 1, -1), 420);
+ QCOMPARE(o.values.first(), 42);
}
void tst_QPropertyAnimation::noStartValueWithLoop()
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 75fa424ab1..3a51e67768 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -400,6 +400,17 @@ void tst_QVariant::isNull()
QVERIFY( !varLL.isNull() );
QVariant var7(QString::null);
QVERIFY(var7.isNull());
+ var7 = QVariant::fromValue<QString>(QString::null);
+ QVERIFY(var7.isNull());
+
+ QVariant var8(QMetaType::Nullptr, nullptr);
+ QVERIFY(var8.isNull());
+ var8 = QVariant::fromValue<std::nullptr_t>(nullptr);
+ QVERIFY(var8.isNull());
+ QVariant var9 = QVariant(QJsonValue(QJsonValue::Null));
+ QVERIFY(var9.isNull());
+ var9 = QVariant::fromValue<QJsonValue>(QJsonValue(QJsonValue::Null));
+ QVERIFY(var9.isNull());
}
void tst_QVariant::swap()
diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
index 383f357206..b68c582732 100644
--- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
@@ -189,7 +189,7 @@ void tst_QTimeLine::frameRate()
void tst_QTimeLine::value()
{
- QTimeLine timeLine(5000);
+ QTimeLine timeLine(4500); // Should be at least 5% under 5000ms
QCOMPARE(timeLine.currentValue(), 0.0);
// Default speed
diff --git a/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp b/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp
index cb1c9401ba..a4afae4b46 100644
--- a/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp
+++ b/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp
@@ -370,8 +370,7 @@ void tst_QDBusMetaObject::types()
QDBusError error;
- QMetaObject *result = QDBusMetaObject::createMetaObject("local.Interface", xml,
- map, error);
+ const QScopedPointer<QDBusMetaObject> result(QDBusMetaObject::createMetaObject("local.Interface", xml, map, error));
QVERIFY2(result, qPrintable(error.message()));
QCOMPARE(result->enumeratorCount(), 0);
diff --git a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
index ad5ba6affb..173e137d17 100644
--- a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
+++ b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
@@ -59,6 +59,28 @@ void tst_QInputControl::isAcceptableInput_data()
QTest::newRow("printable-hebrew") << QString(QChar(0x2135)) << Qt::KeyboardModifiers() << true;
QTest::newRow("private-use-area") << QString(QChar(0xE832)) << Qt::KeyboardModifiers() << true;
QTest::newRow("multiple-printable") << QStringLiteral("foobar") << Qt::KeyboardModifiers() << true;
+ QTest::newRow("rlm") << QString(QChar(0x200F)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("rlm-with-ctrl") << QString(QChar(0x200F)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("rlm-with-ctrl-shift") << QString(QChar(0x200F)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("lrm") << QString(QChar(0x200E)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("lrm-with-ctrl") << QString(QChar(0x200E)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("lrm-with-ctrl-shift") << QString(QChar(0x200E)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("rlo") << QString(QChar(0x202E)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("rlo-with-ctrl") << QString(QChar(0x202E)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("rlo-with-ctrl-shift") << QString(QChar(0x202E)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("lro") << QString(QChar(0x202D)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("lro-with-ctrl") << QString(QChar(0x202D)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("lro-with-ctrl-shift") << QString(QChar(0x202D)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("lre") << QString(QChar(0x202B)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("lre-with-ctrl") << QString(QChar(0x202B)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("lre-with-ctrl-shift") << QString(QChar(0x202B)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("rle") << QString(QChar(0x202A)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("rle-with-ctrl") << QString(QChar(0x202A)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("rle-with-ctrl-shift") << QString(QChar(0x202A)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("pdf") << QString(QChar(0x202C)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("pdf-with-ctrl") << QString(QChar(0x202C)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("pdf-with-ctrl-shift") << QString(QChar(0x202C)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+
}
void tst_QInputControl::isAcceptableInput()
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index bd6733e2d0..426db265ae 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -1567,7 +1567,7 @@ void tst_QAbstractItemView::testChangeEditorState()
QTableView view;
view.setEditTriggers(QAbstractItemView::CurrentChanged);
- view.setItemDelegate(new StateChangeDelegate);
+ view.setItemDelegate(new StateChangeDelegate(&view));
view.setModel(&model);
centerOnScreen(&view);
moveCursorAway(&view);
@@ -1941,7 +1941,8 @@ void tst_QAbstractItemView::QTBUG50102_SH_ItemView_ScrollMode()
QCOMPARE(view.horizontalScrollMode(), styleScrollMode);
// Change style, get new value
- view.setStyle(new ScrollModeProxyStyle(styleScrollMode));
+ ScrollModeProxyStyle proxyStyle1(styleScrollMode);
+ view.setStyle(&proxyStyle1);
auto proxyScrollMode = static_cast<QAbstractItemView::ScrollMode>(view.style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, &view, 0));
QVERIFY(styleScrollMode != proxyScrollMode);
QCOMPARE(view.verticalScrollMode(), proxyScrollMode);
@@ -1953,7 +1954,8 @@ void tst_QAbstractItemView::QTBUG50102_SH_ItemView_ScrollMode()
QCOMPARE(view.horizontalScrollMode(), proxyScrollMode);
// Change style, won't change value for vertical, will change for horizontal
- view.setStyle(new ScrollModeProxyStyle(proxyScrollMode));
+ ScrollModeProxyStyle proxyStyle2(proxyScrollMode);
+ view.setStyle(&proxyStyle2);
QCOMPARE(view.verticalScrollMode(), proxyScrollMode);
QCOMPARE(view.horizontalScrollMode(), styleScrollMode);
}
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 1078dcc2e9..7bfec2831d 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -2523,7 +2523,8 @@ void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_compare
const bool sanity_checks = true;
if (sanity_checks) {
QString msg = QString("sanity problem at ") + sline;
- char *verifytext = QTest::toString(msg);
+ const QScopedArrayPointer<char> holder(QTest::toString(msg));
+ const auto verifytext = holder.data();
QVERIFY2(m_tableview->model()->rowCount() == view->count() , verifytext);
QVERIFY2(view->visualIndex(lastindex + 1) <= 0, verifytext); // there is no such index in model
@@ -2555,7 +2556,8 @@ void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_compare
msg += istr(chk_visual) + istr(chk_logical) + istr(chk_sizes) + istr(chk_hidden_size)
+ istr(chk_lookup_visual) + istr(chk_lookup_logical) + istr(header_lenght, false) + "};";
- char *verifytext = QTest::toString(msg);
+ const QScopedArrayPointer<char> holder(QTest::toString(msg));
+ const auto verifytext = holder.data();
QVERIFY2(chk_visual == x[0], verifytext);
QVERIFY2(chk_logical == x[1], verifytext);
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 0720a4f766..5b353bb2ae 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -1350,7 +1350,7 @@ void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
}
QTableView view;
view.setModel(&model);
- view.setItemDelegate(new TestItemDelegate);
+ view.setItemDelegate(new TestItemDelegate(&view));
view.show();
view.selectAll();
QVERIFY(QTest::qWaitForWindowExposed(&view));
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 8c7c5f1050..29e4bbfe29 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -1489,7 +1489,7 @@ void tst_QListView::task203585_selectAll()
//we make sure that "select all" doesn't select the hidden items
QListView view;
view.setSelectionMode(QAbstractItemView::ExtendedSelection);
- view.setModel(new QStringListModel( QStringList() << "foo"));
+ view.setModel(new QStringListModel(QStringList() << "foo", &view));
view.setRowHidden(0, true);
view.selectAll();
QVERIFY(view.selectionModel()->selectedIndexes().isEmpty());
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index eb93e4c167..6547bb8985 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -1629,7 +1629,7 @@ void tst_QListWidget::QTBUG14363_completerWithAnyKeyPressedEditTriggers()
{
QListWidget listWidget;
listWidget.setEditTriggers(QAbstractItemView::AnyKeyPressed);
- listWidget.setItemDelegate(new ItemDelegate);
+ listWidget.setItemDelegate(new ItemDelegate(&listWidget));
QListWidgetItem *item = new QListWidgetItem(QLatin1String("select an item (don't start editing)"), &listWidget);
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable);
new QListWidgetItem(QLatin1String("try to type the letter 'c'"), &listWidget);
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 80ef0879cc..e2886cfcfe 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -3796,25 +3796,24 @@ void tst_QTreeView::task248022_changeSelection()
void tst_QTreeView::task245654_changeModelAndExpandAll()
{
QTreeView view;
- QStandardItemModel *model = new QStandardItemModel;
+ QScopedPointer<QStandardItemModel> model(new QStandardItemModel);
QStandardItem *top = new QStandardItem("top");
QStandardItem *sub = new QStandardItem("sub");
top->appendRow(sub);
model->appendRow(top);
- view.setModel(model);
+ view.setModel(model.data());
view.expandAll();
QApplication::processEvents();
QVERIFY(view.isExpanded(top->index()));
//now let's try to delete the model
//then repopulate and expand again
- delete model;
- model = new QStandardItemModel;
+ model.reset(new QStandardItemModel);
top = new QStandardItem("top");
sub = new QStandardItem("sub");
top->appendRow(sub);
model->appendRow(top);
- view.setModel(model);
+ view.setModel(model.data());
view.expandAll();
QApplication::processEvents();
QVERIFY(view.isExpanded(top->index()));
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index fcffaa0eb9..f20805f97e 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -554,16 +554,16 @@ void tst_QTreeWidget::removeChild()
QFETCH(int, childCount);
QFETCH(int, removeAt);
- QTreeWidgetItem *root = new QTreeWidgetItem;
+ const QScopedPointer<QTreeWidgetItem> root(new QTreeWidgetItem);
for (int i = 0; i < childCount; ++i)
- new QTreeWidgetItem(root, QStringList(QString::number(i)));
+ new QTreeWidgetItem(root.data(), QStringList(QString::number(i)));
QCOMPARE(root->childCount(), childCount);
for (int j = 0; j < childCount; ++j)
QCOMPARE(root->child(j)->text(0), QString::number(j));
- QTreeWidgetItem *remove = root->child(removeAt);
- root->removeChild(remove);
+ const QScopedPointer<QTreeWidgetItem> remove(root->child(removeAt));
+ root->removeChild(remove.data());
QCOMPARE(root->childCount(), childCount - 1);
for (int k = 0; k < childCount; ++k) {
@@ -574,7 +574,6 @@ void tst_QTreeWidget::removeChild()
else if (k > removeAt)
QCOMPARE(root->child(k - 1)->text(0), QString::number(k));
}
- delete root;
}
void tst_QTreeWidget::setItemHidden()
@@ -1954,9 +1953,9 @@ void tst_QTreeWidget::itemData()
void tst_QTreeWidget::enableDisable()
{
- QTreeWidgetItem *itm = new QTreeWidgetItem();
+ const QScopedPointer<QTreeWidgetItem> itm(new QTreeWidgetItem);
for (int i = 0; i < 10; ++i)
- new QTreeWidgetItem(itm);
+ new QTreeWidgetItem(itm.data());
// make sure all items are enabled
QVERIFY(itm->flags() & Qt::ItemIsEnabled);
@@ -2720,7 +2719,10 @@ void tst_QTreeWidget::setDisabled()
children.append(new QTreeWidgetItem());
children.append(new QTreeWidgetItem());
children.append(new QTreeWidgetItem());
- i1 = top->takeChild(0);
+ {
+ const QScopedPointer<QTreeWidgetItem> taken(top->takeChild(0));
+ QCOMPARE(taken.data(), i1);
+ }
top->addChildren(children);
QCOMPARE(top->child(0)->isDisabled(), false);
@@ -2732,16 +2734,21 @@ void tst_QTreeWidget::setDisabled()
QCOMPARE(top->child(1)->isDisabled(), true);
QCOMPARE(top->child(1)->isDisabled(), true);
- children = top->takeChildren();
- QCOMPARE(children.at(0)->isDisabled(), false);
- QCOMPARE(children.at(1)->isDisabled(), false);
- QCOMPARE(children.at(1)->isDisabled(), false);
+ struct Deleter {
+ QList<QTreeWidgetItem *> items;
+ explicit Deleter(QList<QTreeWidgetItem *> items) : items(std::move(items)) {}
+ ~Deleter() { qDeleteAll(items); }
+ };
+ const Deleter takenChildren(top->takeChildren());
+ QCOMPARE(takenChildren.items[0]->isDisabled(), false);
+ QCOMPARE(takenChildren.items[1]->isDisabled(), false);
+ QCOMPARE(takenChildren.items[1]->isDisabled(), false);
}
void tst_QTreeWidget::removeSelectedItem()
{
- QTreeWidget *w = new QTreeWidget();
+ const QScopedPointer <QTreeWidget> w(new QTreeWidget);
w->setSortingEnabled(true);
QTreeWidgetItem *first = new QTreeWidgetItem();
@@ -2767,15 +2774,13 @@ void tst_QTreeWidget::removeSelectedItem()
QCOMPARE(selModel->hasSelection(), true);
QCOMPARE(selModel->selectedRows().count(), 1);
- QTreeWidgetItem *taken = w->takeTopLevelItem(2);
+ const QScopedPointer<QTreeWidgetItem> taken(w->takeTopLevelItem(2));
QCOMPARE(taken->text(0), QLatin1String("C"));
QCOMPARE(selModel->hasSelection(), false);
QCOMPARE(selModel->selectedRows().count(), 0);
QItemSelection sel = selModel->selection();
QCOMPARE(selModel->isSelected(w->model()->index(0,0)), false);
-
- delete w;
}
class AnotherTreeWidget : public QTreeWidget
@@ -2934,11 +2939,11 @@ void tst_QTreeWidget::sortAndSelect()
void tst_QTreeWidget::defaultRowSizes()
{
- QTreeWidget *tw = new QTreeWidget();
+ const QScopedPointer<QTreeWidget> tw(new QTreeWidget);
tw->setIconSize(QSize(50, 50));
tw->setColumnCount(6);
for (int i=0; i<10; ++i) {
- QTreeWidgetItem *it = new QTreeWidgetItem(tw);
+ auto it = new QTreeWidgetItem(tw.data());
for (int j=0; j<tw->columnCount() - 1; ++j) {
it->setText(j, "This is a test");
}
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index f8dc5d91a2..4d57b85f9a 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -137,6 +137,7 @@ private slots:
void QTBUG_57404_existingMenuItemException();
#endif
void taskQTBUG55966_subMenuRemoved();
+ void QTBUG_58344_invalidIcon();
void platformMenu();
@@ -1635,5 +1636,14 @@ void tst_QMenuBar::taskQTBUG55966_subMenuRemoved()
QTest::qWait(500);
}
+void tst_QMenuBar::QTBUG_58344_invalidIcon()
+{
+ QMenuBar menuBar;
+ QMenu menu("menu");
+ menu.addAction(QIcon("crash.png"), "crash");
+ menuBar.addMenu(&menu);
+ // No crash, all fine.
+}
+
QTEST_MAIN(tst_QMenuBar)
#include "tst_qmenubar.moc"