diff options
author | Liang Qi <liang.qi@qt.io> | 2016-11-01 10:27:41 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-11-02 09:24:11 +0100 |
commit | d7e4980132057aa10e54137114bf65e06c455030 (patch) | |
tree | 9d6ae36efa0cf84a612bfec6cf3dd2ea7f7e3446 /tests/auto/widgets/kernel | |
parent | 44c402b4bfba44480382244b8409fb3cf34d7ac1 (diff) | |
parent | a732576a66ff2bbd9c0b41cd5f3505a4d2fbf043 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Blacklist tst_QMenuBar::taskQTBUG46812_doNotLeaveMenubarHighlighted() on macOS.
Conflicts:
mkspecs/features/mac/default_post.prf
mkspecs/features/mac/sdk.prf
mkspecs/features/uikit/default_post.prf
mkspecs/features/uikit/sdk.prf
src/angle/src/libEGL/libEGL.pro
src/platformsupport/fontdatabases/fontdatabases.pro
src/platformsupport/platformsupport.pro
src/plugins/platforms/cocoa/qnswindowdelegate.mm
src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
src/plugins/platforms/ios/ios.pro
src/plugins/platforms/ios/kernel.pro
tests/auto/widgets/widgets/qmenubar/BLACKLIST
tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
Task-number: QTBUG-56853
Change-Id: If58785210feee3550892fc7768cce90e75a2416c
Diffstat (limited to 'tests/auto/widgets/kernel')
4 files changed, 65 insertions, 25 deletions
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 7796627bd9..83e1850524 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -315,7 +315,7 @@ void tst_QAction::enabledVisibleInteraction() void tst_QAction::task200823_tooltip() { - QAction *action = new QAction("foo", 0); + const QScopedPointer<QAction> action(new QAction("foo", Q_NULLPTR)); QString shortcut("ctrl+o"); action->setShortcut(shortcut); @@ -329,8 +329,8 @@ void tst_QAction::task200823_tooltip() void tst_QAction::task229128TriggeredSignalWithoutActiongroup() { // test without a group - QAction *actionWithoutGroup = new QAction("Test", qApp); - QSignalSpy spyWithoutGroup(actionWithoutGroup, SIGNAL(triggered(bool))); + const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", Q_NULLPTR)); + QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), SIGNAL(triggered(bool))); QCOMPARE(spyWithoutGroup.count(), 0); actionWithoutGroup->trigger(); // signal should be emitted diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 411b925adb..d6f3728663 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -2155,8 +2155,8 @@ void tst_QApplication::noQuitOnHide() { int argc = 0; QApplication app(argc, 0); - QWidget *window1 = new NoQuitOnHideWidget; - window1->show(); + NoQuitOnHideWidget window1; + window1.show(); QCOMPARE(app.exec(), 1); } @@ -2190,12 +2190,12 @@ void tst_QApplication::abortQuitOnShow() { int argc = 0; QApplication app(argc, 0); - QWidget *window1 = new ShowCloseShowWidget(false); - window1->show(); + ShowCloseShowWidget window1(false); + window1.show(); QCOMPARE(app.exec(), 0); - QWidget *window2 = new ShowCloseShowWidget(true); - window2->show(); + ShowCloseShowWidget window2(true); + window2.show(); QCOMPARE(app.exec(), 1); } diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index b7ca5d21c7..01e3d7bac0 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -51,6 +51,44 @@ static inline void setFrameless(QWidget *w) w->setWindowFlags(flags); } +struct QFormLayoutTakeRowResultHolder { + QFormLayoutTakeRowResultHolder(QFormLayout::TakeRowResult result) Q_DECL_NOTHROW + : labelItem(result.labelItem), + fieldItem(result.fieldItem) + { + } + ~QFormLayoutTakeRowResultHolder() + { + // re-use a QFormLayout to recursively reap the QLayoutItems: + QFormLayout disposer; + if (labelItem) + disposer.setItem(0, QFormLayout::LabelRole, labelItem); + if (fieldItem) + disposer.setItem(0, QFormLayout::FieldRole, fieldItem); + } + QFormLayoutTakeRowResultHolder(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW + : labelItem(other.labelItem), + fieldItem(other.fieldItem) + { + other.labelItem = nullptr; + other.fieldItem = nullptr; + } + QFormLayoutTakeRowResultHolder &operator=(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW + { + swap(other); + return *this; + } + + void swap(QFormLayoutTakeRowResultHolder &other) Q_DECL_NOTHROW + { + qSwap(labelItem, other.labelItem); + qSwap(fieldItem, other.fieldItem); + } + + QLayoutItem *labelItem; + QLayoutItem *fieldItem; +}; + class tst_QFormLayout : public QObject { Q_OBJECT @@ -396,7 +434,8 @@ void tst_QFormLayout::setFormStyle() QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows); #endif - widget.setStyle(QStyleFactory::create("windows")); + const QScopedPointer<QStyle> windowsStyle(QStyleFactory::create("windows")); + widget.setStyle(windowsStyle.data()); QCOMPARE(layout.labelAlignment(), Qt::AlignLeft); QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop)); @@ -407,14 +446,16 @@ void tst_QFormLayout::setFormStyle() this test is cross platform.. so create dummy styles that return all the right stylehints. */ - widget.setStyle(new DummyMacStyle()); + DummyMacStyle macStyle; + widget.setStyle(&macStyle); QCOMPARE(layout.labelAlignment(), Qt::AlignRight); QVERIFY(layout.formAlignment() == (Qt::AlignHCenter | Qt::AlignTop)); QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::FieldsStayAtSizeHint); QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows); - widget.setStyle(new DummyQtopiaStyle()); + DummyQtopiaStyle qtopiaStyle; + widget.setStyle(&qtopiaStyle); QCOMPARE(layout.labelAlignment(), Qt::AlignRight); QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop)); @@ -814,7 +855,7 @@ void tst_QFormLayout::takeRow() QCOMPARE(layout->count(), 3); QCOMPARE(layout->rowCount(), 2); - QFormLayout::TakeRowResult result = layout->takeRow(1); + QFormLayoutTakeRowResultHolder result = layout->takeRow(1); QVERIFY(w2); QVERIFY(result.fieldItem); @@ -853,7 +894,7 @@ void tst_QFormLayout::takeRow_QWidget() QCOMPARE(layout->count(), 3); QCOMPARE(layout->rowCount(), 2); - QFormLayout::TakeRowResult result = layout->takeRow(w1); + QFormLayoutTakeRowResultHolder result = layout->takeRow(w1); QVERIFY(w1); QVERIFY(result.fieldItem); @@ -898,7 +939,7 @@ void tst_QFormLayout::takeRow_QLayout() QCOMPARE(layout->count(), 3); QCOMPARE(layout->rowCount(), 2); - QFormLayout::TakeRowResult result = layout->takeRow(l1); + QFormLayoutTakeRowResultHolder result = layout->takeRow(l1); QVERIFY(l1); QVERIFY(w1); @@ -1123,7 +1164,7 @@ void tst_QFormLayout::takeAt() QCOMPARE(layout->count(), 7); for (int i = 6; i >= 0; --i) { - layout->takeAt(0); + delete layout->takeAt(0); QCOMPARE(layout->count(), i); } } @@ -1215,7 +1256,7 @@ void tst_QFormLayout::replaceWidget() QFormLayout::ItemRole role; // replace editor - layout->replaceWidget(edit1, edit3); + delete layout->replaceWidget(edit1, edit3); edit1->hide(); // Not strictly needed for the test, but for normal usage it is. QCOMPARE(layout->indexOf(edit1), -1); QCOMPARE(layout->indexOf(edit3), editIndex); @@ -1226,7 +1267,7 @@ void tst_QFormLayout::replaceWidget() QCOMPARE(rownum, 0); QCOMPARE(role, QFormLayout::FieldRole); - layout->replaceWidget(label1, label2); + delete layout->replaceWidget(label1, label2); label1->hide(); QCOMPARE(layout->indexOf(label1), -1); QCOMPARE(layout->indexOf(label2), labelIndex); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 5f3fed1f66..0c25a01ba0 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -10245,14 +10245,13 @@ public slots: bool eventFilter(QObject *o, QEvent *e) { - if (modal && modal->button && o == modal->button) { - switch (e->type()) { - case QEvent::Enter: + switch (e->type()) { + case QEvent::Enter: + if (modal && modal->button && o == modal->button) enters++; - break; - default: - break; - } + break; + default: + break; } return QDialog::eventFilter(o, e); } |