summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-06 13:04:47 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-06 20:12:27 +0200
commitef25620ac1acbe7a723b6b213d7d50468a748119 (patch)
treeabdff2aed36655dfb0305d232b0ac48f8ad67391 /tests/auto/widgets
parent669add92d9adc15ecfa0b2d62dd90ea9066d401e (diff)
parent6feec9da93032d11a768802ac2187d9d4153b1ec (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: mkspecs/features/mac/default_pre.prf mkspecs/features/qpa/genericunixfontdatabase.prf mkspecs/features/uikit/default_post.prf mkspecs/features/uikit/resolve_config.prf mkspecs/macx-ios-clang/features/default_post.prf mkspecs/macx-ios-clang/features/resolve_config.prf src/corelib/io/qiodevice.cpp Change-Id: I6f210f71f177a3c3278a4f380542195e14e4b491
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp1
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp6
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp4
-rw-r--r--tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp11
-rw-r--r--tests/auto/widgets/util/qundostack/tst_qundostack.cpp53
-rw-r--r--tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp48
6 files changed, 55 insertions, 68 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index e13e0201bc..741b5e8aae 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -1357,6 +1357,7 @@ void tst_QFiledialog::widgetlessNativeDialog()
QVERIFY(!model);
QPushButton *button = fd.findChild<QPushButton*>();
QVERIFY(!button);
+ QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, true);
}
void tst_QFiledialog::selectedFilesWithoutWidgets()
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index b95a17bd4e..d8c70a0cc1 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -488,12 +488,12 @@ void tst_QStyleSheetStyle::widgetStyle()
window1->setStyleSheet(""); // remove stylesheet
QCOMPARE(window1->style(), qApp->style()); // is this cool or what
QCOMPARE(widget1->style(), qApp->style()); // annoying child follows...
- QStyle *wndStyle = QStyleFactory::create("Windows");
- window1->setStyle(wndStyle);
+ QScopedPointer<QStyle> wndStyle(QStyleFactory::create("Windows"));
+ window1->setStyle(wndStyle.data());
QCOMPARE(window1->style()->metaObject()->className(), "QStyleSheetStyle"); // auto wraps it
QCOMPARE(widget1->style(), window1->style()); // and auto propagates to child
qApp->setStyleSheet(""); // remove the app stylesheet
- QCOMPARE(window1->style(), wndStyle); // auto dewrap
+ QCOMPARE(window1->style(), wndStyle.data()); // auto dewrap
QCOMPARE(widget1->style(), qApp->style()); // and child state is restored
window1->setStyle(0); // let sanity prevail
qApp->setStyle(0);
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 0098c5d884..92a8dff218 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -1217,7 +1217,7 @@ void tst_QCompleter::task178797_activatedOnReturn()
words << "foobar1" << "foobar2";
QLineEdit ledit;
setFrameless(&ledit);
- QCompleter *completer = new QCompleter(words);
+ QCompleter *completer = new QCompleter(words, &ledit);
ledit.setCompleter(completer);
QSignalSpy spy(completer, SIGNAL(activated(QString)));
QCOMPARE(spy.count(), 0);
@@ -1324,7 +1324,7 @@ public:
task250064_TextEdit()
{
- completer = new QCompleter;
+ completer = new QCompleter(this);
completer->setWidget(this);
}
diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
index 02ed912323..99d067b7d7 100644
--- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
+++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
@@ -377,8 +377,8 @@ static QString glue(const QString &s1, const QString &s2)
void tst_QUndoGroup::checkSignals()
{
QUndoGroup group;
- QAction *undo_action = group.createUndoAction(0, QString("foo"));
- QAction *redo_action = group.createRedoAction(0, QString("bar"));
+ const QScopedPointer<QAction> undo_action(group.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redo_action(group.createRedoAction(0, QString("bar")));
QSignalSpy indexChangedSpy(&group, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&group, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&group, SIGNAL(canUndoChanged(bool)));
@@ -590,9 +590,6 @@ void tst_QUndoGroup::checkSignals()
true, // indexChanged
true, // undoChanged
true) // redoChanged
-
- delete undo_action;
- delete redo_action;
}
void tst_QUndoGroup::addStackAndDie()
@@ -629,8 +626,8 @@ void tst_QUndoGroup::commandTextFormat()
qApp->installTranslator(&translator);
QUndoGroup group;
- QAction *undo_action = group.createUndoAction(0);
- QAction *redo_action = group.createRedoAction(0);
+ const QScopedPointer<QAction> undo_action(group.createUndoAction(0));
+ const QScopedPointer<QAction> redo_action(group.createRedoAction(0));
QCOMPARE(undo_action->text(), QString("Undo-default-text"));
QCOMPARE(redo_action->text(), QString("Redo-default-text"));
diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp
index f21780c2c2..8573cea35f 100644
--- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp
+++ b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp
@@ -257,8 +257,8 @@ static QString glue(const QString &s1, const QString &s2)
static void checkState(QSignalSpy &redoTextChangedSpy,
QSignalSpy &canRedoChangedSpy,
QSignalSpy &undoTextChangedSpy,
- QAction *const redoAction,
- QAction *const undoAction,
+ const QScopedPointer<QAction> &redoAction,
+ const QScopedPointer<QAction> &undoAction,
QSignalSpy &canUndoChangedSpy,
QSignalSpy &cleanChangedSpy,
QSignalSpy &indexChangedSpy,
@@ -327,8 +327,8 @@ static void checkState(QSignalSpy &redoTextChangedSpy,
void tst_QUndoStack::undoRedo()
{
QUndoStack stack;
- QAction *undoAction = stack.createUndoAction(0, QString("foo"));
- QAction *redoAction = stack.createRedoAction(0, QString("bar"));
+ const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
@@ -688,8 +688,8 @@ void tst_QUndoStack::undoRedo()
void tst_QUndoStack::setIndex()
{
QUndoStack stack;
- QAction *undoAction = stack.createUndoAction(0, QString("foo"));
- QAction *redoAction = stack.createRedoAction(0, QString("bar"));
+ const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
@@ -952,8 +952,8 @@ void tst_QUndoStack::setIndex()
void tst_QUndoStack::setClean()
{
QUndoStack stack;
- QAction *undoAction = stack.createUndoAction(0, QString("foo"));
- QAction *redoAction = stack.createRedoAction(0, QString("bar"));
+ const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
@@ -1205,8 +1205,8 @@ void tst_QUndoStack::setClean()
void tst_QUndoStack::clear()
{
QUndoStack stack;
- QAction *undoAction = stack.createUndoAction(this, QString("foo"));
- QAction *redoAction = stack.createRedoAction(this, QString("bar"));
+ const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
@@ -1403,8 +1403,8 @@ void tst_QUndoStack::clear()
void tst_QUndoStack::childCommand()
{
QUndoStack stack;
- QAction *undoAction = stack.createUndoAction(0, QString("foo"));
- QAction *redoAction = stack.createRedoAction(0, QString("bar"));
+ const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
@@ -1508,16 +1508,13 @@ void tst_QUndoStack::childCommand()
true, // indexChanged
true, // undoChanged
true); // redoChanged
-
- delete undoAction;
- delete redoAction;
}
void tst_QUndoStack::macroBeginEnd()
{
QUndoStack stack;
- QAction *undoAction = stack.createUndoAction(0, QString("foo"));
- QAction *redoAction = stack.createRedoAction(0, QString("bar"));
+ const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
@@ -1978,16 +1975,13 @@ void tst_QUndoStack::macroBeginEnd()
true, // indexChanged
true, // undoChanged
true); // redoChanged
-
- delete undoAction;
- delete redoAction;
}
void tst_QUndoStack::compression()
{
QUndoStack stack;
- QAction *undoAction = stack.createUndoAction(0, QString("foo"));
- QAction *redoAction = stack.createRedoAction(0, QString("bar"));
+ const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
@@ -2423,16 +2417,13 @@ void tst_QUndoStack::compression()
true, // indexChanged
true, // undoChanged
true); // redoChanged
-
- delete undoAction;
- delete redoAction;
}
void tst_QUndoStack::undoLimit()
{
QUndoStack stack;
- QAction *undoAction = stack.createUndoAction(0, QString("foo"));
- QAction *redoAction = stack.createRedoAction(0, QString("bar"));
+ const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
@@ -2972,8 +2963,8 @@ void tst_QUndoStack::commandTextFormat()
qApp->installTranslator(&translator);
QUndoStack stack;
- QAction *undo_action = stack.createUndoAction(0);
- QAction *redo_action = stack.createRedoAction(0);
+ const QScopedPointer<QAction> undo_action(stack.createUndoAction(0));
+ const QScopedPointer<QAction> redo_action(stack.createRedoAction(0));
QCOMPARE(undo_action->text(), QString("Undo-default-text"));
QCOMPARE(redo_action->text(), QString("Redo-default-text"));
@@ -3000,8 +2991,8 @@ void tst_QUndoStack::commandTextFormat()
void tst_QUndoStack::separateUndoText()
{
QUndoStack stack;
- QAction *undo_action = stack.createUndoAction(0);
- QAction *redo_action = stack.createRedoAction(0);
+ const QScopedPointer<QAction> undo_action(stack.createUndoAction(0));
+ const QScopedPointer<QAction> redo_action(stack.createRedoAction(0));
QUndoCommand *command1 = new IdleCommand();
QUndoCommand *command2 = new IdleCommand();
diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
index e68463a00e..17a5320433 100644
--- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
+++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
@@ -702,8 +702,8 @@ void tst_QAbstractSlider::wheelEvent_data()
QTest::addColumn<int>("wheelScrollLines");
QTest::addColumn<bool>("withModifiers"); // use keyboard modifiers while scrolling? (CTRL and SHIFT)
QTest::addColumn<int>("deltaMultiple"); // multiples of WHEEL_DELTA
- QTest::addColumn<int>("sliderOrientation");
- QTest::addColumn<int>("wheelOrientation");
+ QTest::addColumn<Qt::Orientation>("sliderOrientation");
+ QTest::addColumn<Qt::Orientation>("wheelOrientation");
QTest::addColumn<int>("expectedSliderPosition");
QTest::addColumn<QPoint>("distanceFromBottomRight"); // mpointer's distance from bottom-right corner of widget
@@ -716,8 +716,8 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 20 // wheel scroll lines
<< false // with modifiers
<< 1 // delta
- << int(Qt::Vertical) // orientation of slider
- << int(Qt::Vertical) // orientation of wheel
+ << Qt::Vertical // orientation of slider
+ << Qt::Vertical // orientation of wheel
<< 20 // expected position after
<< QPoint(0,0);
@@ -730,8 +730,8 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 20 // wheel scroll lines
<< false // with modifiers
<< 1 // delta
- << int(Qt::Vertical) // orientation of slider
- << int(Qt::Vertical) // orientation of wheel
+ << Qt::Vertical // orientation of slider
+ << Qt::Vertical // orientation of wheel
#ifndef Q_OS_MAC
<< 1 // expected position after
#else
@@ -748,8 +748,8 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 20 // wheel scroll lines
<< false // with modifiers
<< 1 // delta
- << int(Qt::Horizontal) // orientation of slider
- << int(Qt::Vertical) // orientation of wheel
+ << Qt::Horizontal // orientation of slider
+ << Qt::Vertical // orientation of wheel
#ifndef Q_OS_MAC
<< 1 // expected position after
#else
@@ -767,8 +767,8 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 20 // wheel scroll lines
<< false // with modifiers
<< 1 // delta
- << int(Qt::Horizontal) // orientation of slider
- << int(Qt::Vertical) // orientation of wheel
+ << Qt::Horizontal // orientation of slider
+ << Qt::Vertical // orientation of wheel
#ifndef Q_OS_MAC
<< 1 // expected position after
#else
@@ -786,8 +786,8 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 20 // wheel scroll lines
<< false // with modifiers
<< -1 // delta
- << int(Qt::Horizontal) // orientation of slider
- << int(Qt::Horizontal) // orientation of wheel
+ << Qt::Horizontal // orientation of slider
+ << Qt::Horizontal // orientation of wheel
<< 30 // expected position after
<< QPoint(1,1);
@@ -800,8 +800,8 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 1 // wheel scroll lines
<< false // with modifiers
<< -2 // delta
- << int(Qt::Horizontal) // orientation of slider
- << int(Qt::Horizontal) // orientation of wheel
+ << Qt::Horizontal // orientation of slider
+ << Qt::Horizontal // orientation of wheel
<< 100 // expected position after
<< QPoint(0,0);
@@ -814,8 +814,8 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 1 // wheel scroll lines
<< false // with modifiers
<< 2 // delta
- << int(Qt::Horizontal) // orientation of slider
- << int(Qt::Horizontal) // orientation of wheel
+ << Qt::Horizontal // orientation of slider
+ << Qt::Horizontal // orientation of wheel
<< 0 // expected position after
<< QPoint(0,0);
@@ -828,8 +828,8 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 20 // wheel scroll lines
<< true // with modifiers
<< -1 // delta
- << int(Qt::Horizontal) // orientation of slider
- << int(Qt::Horizontal) // orientation of wheel
+ << Qt::Horizontal // orientation of slider
+ << Qt::Horizontal // orientation of wheel
<< 90 // expected position after
<< QPoint(0,0);
@@ -846,8 +846,8 @@ void tst_QAbstractSlider::wheelEvent()
QFETCH(int,wheelScrollLines);
QFETCH(bool,withModifiers);
QFETCH(int,deltaMultiple);
- QFETCH(int,sliderOrientation);
- QFETCH(int,wheelOrientation);
+ QFETCH(Qt::Orientation, sliderOrientation);
+ QFETCH(Qt::Orientation, wheelOrientation);
QFETCH(int,expectedSliderPosition);
QFETCH(QPoint,distanceFromBottomRight);
@@ -855,18 +855,16 @@ void tst_QAbstractSlider::wheelEvent()
QVERIFY(applicationInstance != 0);
QApplication::setWheelScrollLines(wheelScrollLines);
- Qt::Orientation orientation = *reinterpret_cast<Qt::Orientation*>(&sliderOrientation);
slider->setRange(minimum,maximum);
slider->setSliderPosition(initialSliderPosition);
slider->setSingleStep(singleStep);
slider->setPageStep(pageStep);
slider->setInvertedControls(invertedControls);
- slider->setOrientation(orientation);
+ slider->setOrientation(sliderOrientation);
Qt::KeyboardModifier k = withModifiers ? Qt::ControlModifier : Qt::NoModifier;
- orientation = *reinterpret_cast<Qt::Orientation*>(&wheelOrientation);
QWheelEvent event(slider->rect().bottomRight() + distanceFromBottomRight, WHEEL_DELTA * deltaMultiple,
- Qt::NoButton, k, orientation);
+ Qt::NoButton, k, wheelOrientation);
QVERIFY(applicationInstance->sendEvent(slider,&event));
#ifdef Q_OS_MAC
QEXPECT_FAIL("Normal data page", "QTBUG-23679", Continue);
@@ -878,7 +876,7 @@ void tst_QAbstractSlider::wheelEvent()
slider->setSliderPosition(initialSliderPosition);
k = withModifiers ? Qt::ShiftModifier : Qt::NoModifier;
event = QWheelEvent(slider->rect().bottomRight() + distanceFromBottomRight, WHEEL_DELTA * deltaMultiple,
- Qt::NoButton, k, orientation);
+ Qt::NoButton, k, wheelOrientation);
QSignalSpy spy1(slider, SIGNAL(actionTriggered(int)));
QSignalSpy spy2(slider, SIGNAL(valueChanged(int)));
QVERIFY(applicationInstance->sendEvent(slider,&event));