summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp30
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp210
-rw-r--r--tests/auto/widgets/kernel/qapplication/test/test.pro2
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp4
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro1
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp49
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp175
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro1
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp37
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp8
-rw-r--r--tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp2
-rw-r--r--tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp12
-rw-r--r--tests/auto/widgets/util/qundostack/tst_qundostack.cpp861
-rw-r--r--tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro2
-rw-r--r--tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp88
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp75
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp63
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp61
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm34
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp2
-rw-r--r--tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp196
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp2
-rw-r--r--tests/auto/widgets/widgets/widgets.pro1
24 files changed, 1714 insertions, 210 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index c9aef497af..44cb5a5bf8 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -119,6 +119,8 @@ private slots:
void selectFilter();
void viewMode();
void proxymodel();
+ void setMimeTypeFilters_data();
+ void setMimeTypeFilters();
void setNameFilter_data();
void setNameFilter();
void setEmptyNameFilter();
@@ -1039,6 +1041,34 @@ void tst_QFiledialog::proxymodel()
QCOMPARE(fd.proxyModel(), nullptr);
}
+void tst_QFiledialog::setMimeTypeFilters_data()
+{
+ QTest::addColumn<QStringList>("mimeTypeFilters");
+ QTest::addColumn<QString>("targetMimeTypeFilter");
+ QTest::addColumn<QString>("expectedSelectedMimeTypeFilter");
+
+ const auto headerMime = QStringLiteral("text/x-chdr");
+ const auto jsonMime = QStringLiteral("application/json");
+ const auto zipMime = QStringLiteral("application/zip");
+
+ QTest::newRow("single mime filter (C header file)") << QStringList {headerMime} << headerMime << headerMime;
+ QTest::newRow("single mime filter (JSON file)") << QStringList {jsonMime} << jsonMime << jsonMime;
+ QTest::newRow("multiple mime filters") << QStringList {jsonMime, zipMime} << jsonMime << jsonMime;
+}
+
+void tst_QFiledialog::setMimeTypeFilters()
+{
+ QFETCH(QStringList, mimeTypeFilters);
+ QFETCH(QString, targetMimeTypeFilter);
+ QFETCH(QString, expectedSelectedMimeTypeFilter);
+
+ QFileDialog fd;
+ fd.setMimeTypeFilters(mimeTypeFilters);
+ fd.selectMimeTypeFilter(targetMimeTypeFilter);
+
+ QCOMPARE(fd.selectedMimeTypeFilter(), expectedSelectedMimeTypeFilter);
+}
+
void tst_QFiledialog::setEmptyNameFilter()
{
QFileDialog fd;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index c8bdcbde09..5ab24d6878 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -2885,7 +2885,7 @@ public:
void tst_QGraphicsView::scrollBarRanges()
{
- QFETCH(QString, style);
+ QFETCH(QByteArray, style);
QFETCH(QSize, viewportSize);
QFETCH(QRectF, sceneRect);
QFETCH(ScrollBarCount, sceneRectOffsetFactors);
@@ -2898,7 +2898,7 @@ void tst_QGraphicsView::scrollBarRanges()
QFETCH(ExpectedValueDescription, vmax);
QFETCH(bool, useStyledPanel);
- if (useStyledPanel && style == QStringLiteral("Macintosh") && platformName == QStringLiteral("cocoa"))
+ if (useStyledPanel && style == "Macintosh" && platformName == QStringLiteral("cocoa"))
QSKIP("Insignificant on OSX");
QScopedPointer<QStyle> stylePtr;
@@ -2909,10 +2909,10 @@ void tst_QGraphicsView::scrollBarRanges()
view.setTransform(transform);
view.setFrameStyle(useStyledPanel ? QFrame::StyledPanel : QFrame::NoFrame);
- if (style == QString("motif"))
+ if (style == "motif")
stylePtr.reset(new FauxMotifStyle);
else
- stylePtr.reset(QStyleFactory::create(style));
+ stylePtr.reset(QStyleFactory::create(QLatin1String(style)));
view.setStyle(stylePtr.data());
view.setStyleSheet(" "); // enables style propagation ;-)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp
index 875f671e76..9550655868 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp
@@ -44,9 +44,8 @@ Q_DECLARE_METATYPE(QPainterPath)
Q_DECLARE_METATYPE(Qt::ScrollBarPolicy)
Q_DECLARE_METATYPE(ScrollBarCount)
-static void _scrollBarRanges_addTestData(const QString &style, bool styled)
+static void _scrollBarRanges_addTestData(const QByteArray &style, bool styled)
{
- const QString styleString = styled ? style + ", Styled" : style;
const int viewWidth = 250;
const int viewHeight = 100;
@@ -59,7 +58,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription hmin, hmax, vmin, vmax;
} data [] = {
{
- ", 1",
+ "1",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -71,7 +70,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 2",
+ "2",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -83,7 +82,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1, 1),
},
{
- ", 3",
+ "3",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -95,7 +94,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(100, 1, 1),
},
{
- ", 4",
+ "4",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -107,7 +106,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 5",
+ "5",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -119,7 +118,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 6",
+ "6",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -131,7 +130,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1, 1),
},
{
- ", 7",
+ "7",
QRectF(0, 0, viewWidth + 1, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -143,7 +142,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(1, 1, 1),
},
{
- ", 8",
+ "8",
QRectF(0, 0, viewWidth + 51, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -155,7 +154,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(1, 1, 1),
},
{
- ", 9",
+ "9",
QRectF(0, 0, viewWidth + 51, viewHeight + 101),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -167,7 +166,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(101, 1, 1),
},
{
- ", 10",
+ "10",
QRectF(-101, -101, viewWidth + 1, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -179,7 +178,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 11",
+ "11",
QRectF(-101, -101, viewWidth + 51, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -191,7 +190,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 12",
+ "12",
QRectF(-101, -101, viewWidth + 51, viewHeight + 101),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -203,7 +202,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1, 1),
},
{
- ", 13",
+ "13",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -215,7 +214,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 2, 1),
},
{
- ", 14",
+ "14",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -227,7 +226,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 2, 1),
},
{
- ", 15",
+ "15",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -239,7 +238,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(100, 2, 1),
},
{
- ", 16",
+ "16",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -251,7 +250,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 17",
+ "17",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -263,7 +262,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 18",
+ "18",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -275,7 +274,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1, 1),
},
{
- ", 1 x2",
+ "1 x2",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -287,7 +286,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight, 1, 1),
},
{
- ", 2 x2",
+ "2 x2",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -299,7 +298,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight, 1, 1),
},
{
- ", 3 x2",
+ "3 x2",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -311,7 +310,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight + 200, 1, 1),
},
{
- ", 4 x2",
+ "4 x2",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -323,7 +322,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight - 200, 1, 1),
},
{
- ", 5 x2",
+ "5 x2",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -335,7 +334,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight - 200, 1, 1),
},
{
- ", 6 x2",
+ "6 x2",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -347,7 +346,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight, 1, 1),
},
{
- ", 1 No ScrollBars",
+ "1 No ScrollBars",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -359,7 +358,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 2 No ScrollBars",
+ "2 No ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -371,7 +370,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 3 No ScrollBars",
+ "3 No ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -383,7 +382,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(100),
},
{
- ", 4 No ScrollBars",
+ "4 No ScrollBars",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -395,7 +394,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 5 No ScrollBars",
+ "5 No ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -407,7 +406,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 6 No ScrollBars",
+ "6 No ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -419,7 +418,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 7 No ScrollBars",
+ "7 No ScrollBars",
QRectF(0, 0, viewWidth + 1, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -431,7 +430,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(1),
},
{
- ", 8 No ScrollBars",
+ "8 No ScrollBars",
QRectF(0, 0, viewWidth + 51, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -443,7 +442,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(1),
},
{
- ", 9 No ScrollBars",
+ "9 No ScrollBars",
QRectF(0, 0, viewWidth + 51, viewHeight + 101),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -455,7 +454,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(101),
},
{
- ", 10 No ScrollBars",
+ "10 No ScrollBars",
QRectF(-101, -101, viewWidth + 1, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -467,7 +466,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100),
},
{
- ", 11 No ScrollBars",
+ "11 No ScrollBars",
QRectF(-101, -101, viewWidth + 51, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -479,7 +478,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100),
},
{
- ", 12 No ScrollBars",
+ "12 No ScrollBars",
QRectF(-101, -101, viewWidth + 51, viewHeight + 101),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -491,7 +490,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 13 No ScrollBars",
+ "13 No ScrollBars",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -503,7 +502,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1),
},
{
- ", 14 No ScrollBars",
+ "14 No ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -515,7 +514,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1),
},
{
- ", 15 No ScrollBars",
+ "15 No ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -527,7 +526,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(100, 1),
},
{
- ", 16 No ScrollBars",
+ "16 No ScrollBars",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -539,7 +538,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100),
},
{
- ", 17 No ScrollBars",
+ "17 No ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -551,7 +550,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100),
},
{
- ", 18 No ScrollBars",
+ "18 No ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -563,7 +562,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 1 x2 No ScrollBars",
+ "1 x2 No ScrollBars",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -575,7 +574,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight),
},
{
- ", 2 x2 No ScrollBars",
+ "2 x2 No ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -587,7 +586,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight),
},
{
- ", 3 x2 No ScrollBars",
+ "3 x2 No ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -599,7 +598,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight + 200),
},
{
- ", 4 x2 No ScrollBars",
+ "4 x2 No ScrollBars",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -611,7 +610,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight - 200),
},
{
- ", 5 x2 No ScrollBars",
+ "5 x2 No ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -623,7 +622,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight - 200),
},
{
- ", 6 x2 No ScrollBars",
+ "6 x2 No ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -635,7 +634,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight),
},
{
- ", 1 Always ScrollBars",
+ "1 Always ScrollBars",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -647,7 +646,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1, 1),
},
{
- ", 2 Always ScrollBars",
+ "2 Always ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -659,7 +658,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1, 1),
},
{
- ", 3 Always ScrollBars",
+ "3 Always ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -671,7 +670,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(100, 1, 1),
},
{
- ", 4 Always ScrollBars",
+ "4 Always ScrollBars",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -683,7 +682,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 5 Always ScrollBars",
+ "5 Always ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -695,7 +694,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 6 Always ScrollBars",
+ "6 Always ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -707,7 +706,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1, 1),
},
{
- ", 7 Always ScrollBars",
+ "7 Always ScrollBars",
QRectF(0, 0, viewWidth + 1, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -719,7 +718,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(1, 1, 1),
},
{
- ", 8 Always ScrollBars",
+ "8 Always ScrollBars",
QRectF(0, 0, viewWidth + 51, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -731,7 +730,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(1, 1, 1),
},
{
- ", 9 Always ScrollBars",
+ "9 Always ScrollBars",
QRectF(0, 0, viewWidth + 51, viewHeight + 101),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -743,7 +742,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(101, 1, 1),
},
{
- ", 10 Always ScrollBars",
+ "10 Always ScrollBars",
QRectF(-101, -101, viewWidth + 1, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -755,7 +754,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 11 Always ScrollBars",
+ "11 Always ScrollBars",
QRectF(-101, -101, viewWidth + 51, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -767,7 +766,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 12 Always ScrollBars",
+ "12 Always ScrollBars",
QRectF(-101, -101, viewWidth + 51, viewHeight + 101),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -779,7 +778,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1, 1),
},
{
- ", 13 Always ScrollBars",
+ "13 Always ScrollBars",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -791,7 +790,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 2, 1),
},
{
- ", 14 Always ScrollBars",
+ "14 Always ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -803,7 +802,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 2, 1),
},
{
- ", 15 Always ScrollBars",
+ "15 Always ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -815,7 +814,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(100, 2, 1),
},
{
- ", 16 Always ScrollBars",
+ "16 Always ScrollBars",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -827,7 +826,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 17 Always ScrollBars",
+ "17 Always ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -839,7 +838,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100, 1, 1),
},
{
- ", 18 Always ScrollBars",
+ "18 Always ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -851,7 +850,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1, 1),
},
{
- ", 1 x2 Always ScrollBars",
+ "1 x2 Always ScrollBars",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -863,7 +862,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight, 1, 1),
},
{
- ", 2 x2 Always ScrollBars",
+ "2 x2 Always ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -875,7 +874,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight, 1, 1),
},
{
- ", 3 x2 Always ScrollBars",
+ "3 x2 Always ScrollBars",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -887,7 +886,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight + 200, 1, 1),
},
{
- ", 4 x2 Always ScrollBars",
+ "4 x2 Always ScrollBars",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -899,7 +898,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight - 200, 1, 1),
},
{
- ", 5 x2 Always ScrollBars",
+ "5 x2 Always ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -911,7 +910,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight - 200, 1, 1),
},
{
- ", 6 x2 Always ScrollBars",
+ "6 x2 Always ScrollBars",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -923,7 +922,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight, 1, 1),
},
{
- ", 1 Vertical Only",
+ "1 Vertical Only",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -935,7 +934,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 2 Vertical Only",
+ "2 Vertical Only",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -947,7 +946,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 3 Vertical Only",
+ "3 Vertical Only",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -959,7 +958,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(100),
},
{
- ", 4 Vertical Only",
+ "4 Vertical Only",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -971,7 +970,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 5 Vertical Only",
+ "5 Vertical Only",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -983,7 +982,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 6 Vertical Only",
+ "6 Vertical Only",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -995,7 +994,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 7 Vertical Only",
+ "7 Vertical Only",
QRectF(0, 0, viewWidth + 1, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -1007,7 +1006,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(1),
},
{
- ", 8 Vertical Only",
+ "8 Vertical Only",
QRectF(0, 0, viewWidth + 51, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -1019,7 +1018,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(1),
},
{
- ", 9 Vertical Only",
+ "9 Vertical Only",
QRectF(0, 0, viewWidth + 51, viewHeight + 101),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -1031,7 +1030,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(101),
},
{
- ", 10 Vertical Only",
+ "10 Vertical Only",
QRectF(-101, -101, viewWidth + 1, viewHeight +1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -1043,7 +1042,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100),
},
{
- ", 11 Vertical Only",
+ "11 Vertical Only",
QRectF(-101, -101, viewWidth + 51, viewHeight + 1),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -1055,7 +1054,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100),
},
{
- ", 12 Vertical Only",
+ "12 Vertical Only",
QRectF(-101, -101, viewWidth + 51, viewHeight + 101),
ScrollBarCount(0, 0, 0, 0),
1,
@@ -1067,7 +1066,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 13 Vertical Only",
+ "13 Vertical Only",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -1079,7 +1078,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1),
},
{
- ", 14 Vertical Only",
+ "14 Vertical Only",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -1091,7 +1090,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(0, 1),
},
{
- ", 15 Vertical Only",
+ "15 Vertical Only",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 1, 1),
1,
@@ -1103,7 +1102,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(100, 1),
},
{
- ", 16 Vertical Only",
+ "16 Vertical Only",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -1115,7 +1114,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100),
},
{
- ", 17 Vertical Only",
+ "17 Vertical Only",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -1127,7 +1126,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(-100),
},
{
- ", 18 Vertical Only",
+ "18 Vertical Only",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(-1, -1, 1, 1),
1,
@@ -1139,7 +1138,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(),
},
{
- ", 1 x2 Vertical Only",
+ "1 x2 Vertical Only",
QRectF(0, 0, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -1151,7 +1150,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight),
},
{
- ", 2 x2 Vertical Only",
+ "2 x2 Vertical Only",
QRectF(0, 0, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -1163,7 +1162,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight),
},
{
- ", 3 x2 Vertical Only",
+ "3 x2 Vertical Only",
QRectF(0, 0, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -1175,7 +1174,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight + 200),
},
{
- ", 4 x2 Vertical Only",
+ "4 x2 Vertical Only",
QRectF(-100, -100, viewWidth, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -1187,7 +1186,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight - 200),
},
{
- ", 5 x2 Vertical Only",
+ "5 x2 Vertical Only",
QRectF(-100, -100, viewWidth + 50, viewHeight),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -1199,7 +1198,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
ExpectedValueDescription(viewHeight - 200),
},
{
- ", 6 x2 Vertical Only",
+ "6 x2 Vertical Only",
QRectF(-100, -100, viewWidth + 50, viewHeight + 100),
ScrollBarCount(0, 0, 0, 0),
2,
@@ -1215,7 +1214,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
const QSize viewSize(viewWidth, viewHeight);
for (const Data &e : data) {
- QTest::newRow(qPrintable(styleString + QLatin1String(e.name)))
+ QTest::addRow("%s%s, %s", style.data(), styled ? ", Styled" : "", e.name)
<< style << viewSize
<< e.sceneRect
<< e.sceneRectOffsetFactors
@@ -1229,7 +1228,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled)
void _scrollBarRanges_data()
{
- QTest::addColumn<QString>("style");
+ QTest::addColumn<QByteArray>("style");
QTest::addColumn<QSize>("viewportSize");
QTest::addColumn<QRectF>("sceneRect");
QTest::addColumn<ScrollBarCount>("sceneRectOffsetFactors");
@@ -1242,14 +1241,15 @@ void _scrollBarRanges_data()
QTest::addColumn<ExpectedValueDescription>("vmax");
QTest::addColumn<bool>("useStyledPanel");
- foreach (const QString &style, QStyleFactory::keys()) {
- _scrollBarRanges_addTestData(style, false);
- _scrollBarRanges_addTestData(style, true);
+ const auto styles = QStyleFactory::keys();
+ for (const QString &style : styles) {
+ _scrollBarRanges_addTestData(style.toLatin1(), false);
+ _scrollBarRanges_addTestData(style.toLatin1(), true);
}
const QScreen *screen = QGuiApplication::primaryScreen();
if (screen && qFuzzyCompare((double)screen->logicalDotsPerInchX(), 96.0)) {
- _scrollBarRanges_addTestData(QString("motif"), false);
- _scrollBarRanges_addTestData(QString("motif"), true);
+ _scrollBarRanges_addTestData("motif", false);
+ _scrollBarRanges_addTestData("motif", true);
}
}
diff --git a/tests/auto/widgets/kernel/qapplication/test/test.pro b/tests/auto/widgets/kernel/qapplication/test/test.pro
index 92409e4bfe..7f75501474 100644
--- a/tests/auto/widgets/kernel/qapplication/test/test.pro
+++ b/tests/auto/widgets/kernel/qapplication/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT += widgets widgets-private testlib
QT += core-private gui-private
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 62c75cadf3..9d0c939d84 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -701,14 +701,14 @@ void tst_QShortcut::disabledItems()
sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 );
QCOMPARE( currentResult, NoResult );
if (over_330)
- QCOMPARE( sbText, QString::null );
+ QCOMPARE( sbText, QString() );
currentResult = NoResult;
sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 );
sendKeyEvents( Qt::CTRL+Qt::Key_L, 0 );
QCOMPARE( currentResult, Slot1Triggered );
if (over_330)
- QCOMPARE( sbText, QString::null );
+ QCOMPARE( sbText, QString() );
#endif
clearAllShortcuts();
cut1 = 0;
diff --git a/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro b/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro
index 84629c7c0a..d325bc4aeb 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro
+++ b/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro
@@ -1,4 +1,5 @@
CONFIG += testcase
+contains(QT_CONFIG, c++14): CONFIG += c++14
TARGET = tst_qsizepolicy
QT += widgets widgets-private testlib
diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
index 9e5fc55379..d50f46cc16 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
+++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
@@ -41,9 +41,12 @@ class tst_QSizePolicy : public QObject
private Q_SLOTS:
void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void qtest();
+ void constExpr();
void defaultValues();
void getSetCheck_data() { data(); }
void getSetCheck();
+ void transposed_data() { data(); }
+ void transposed();
void dataStream();
void horizontalStretch();
void verticalStretch();
@@ -102,6 +105,24 @@ void tst_QSizePolicy::qtest()
#undef CHECK2
}
+void tst_QSizePolicy::constExpr()
+{
+/* gcc < 4.8.0 has problems with init'ing variant members in constexpr ctors */
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 */
+#if !defined(Q_CC_GNU) || defined(Q_CC_INTEL) || defined(Q_CC_CLANG) || Q_CC_GNU >= 408
+ // check that certain ctors are constexpr (compile-only):
+ { Q_CONSTEXPR QSizePolicy sp; Q_UNUSED(sp); }
+ { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(); Q_UNUSED(sp); }
+ { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); Q_UNUSED(sp); }
+ { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding, QSizePolicy::DefaultType);
+ Q_CONSTEXPR QSizePolicy tp = sp.transposed(); Q_UNUSED(tp); }
+ { Q_RELAXED_CONSTEXPR auto sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::CheckBox);
+ Q_RELAXED_CONSTEXPR auto tp = sp.transposed(); Q_UNUSED(tp); }
+#else
+ QSKIP("QSizePolicy cannot be constexpr with this version of the compiler.");
+#endif
+}
+
void tst_QSizePolicy::defaultValues()
{
{
@@ -147,14 +168,34 @@ void tst_QSizePolicy::getSetCheck()
QCOMPARE(sp.expandingDirections(), ed);
}
+void tst_QSizePolicy::transposed()
+{
+ FETCH_TEST_DATA;
+
+ const QSizePolicy tr = sp.transposed();
+
+ QCOMPARE(tr.horizontalPolicy(), vp); // swapped
+ QCOMPARE(tr.verticalPolicy(), hp); // swapped
+ QCOMPARE(tr.horizontalStretch(), vst); // swapped
+ QCOMPARE(tr.verticalStretch(), hst); // swapped
+ QCOMPARE(tr.controlType(), ct); // not swapped
+ QCOMPARE(tr.hasHeightForWidth(), hfw); // not swapped (historic behavior)
+ QCOMPARE(tr.hasWidthForHeight(), wfh); // not swapped (historic behavior)
+ QCOMPARE(tr.expandingDirections(), ed); // swapped
+
+ // destructive test - keep last:
+ sp.transpose();
+ QCOMPARE(sp, tr);
+}
+
static void makeRow(QSizePolicy sp, QSizePolicy::Policy hp, QSizePolicy::Policy vp,
int hst, int vst, QSizePolicy::ControlType ct, bool hfw, bool wfh,
Qt::Orientations orients)
{
- QTest::newRow(qPrintable(QString::asprintf("%s-%s-%d-%d-%s-%s-%s",
- PrettyPrint(hp).s(), PrettyPrint(vp).s(), hst, vst,
- PrettyPrint(ct).s(),
- hfw ? "true" : "false", wfh ? "true" : "false")))
+ QTest::addRow("%s-%s-%d-%d-%s-%s-%s",
+ PrettyPrint(hp).s(), PrettyPrint(vp).s(), hst, vst,
+ PrettyPrint(ct).s(),
+ hfw ? "true" : "false", wfh ? "true" : "false")
<< sp << hp << vp << hst << vst << ct << hfw << wfh << orients;
}
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 731a8c5d91..5715505fd6 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -407,6 +407,8 @@ private slots:
void testForOutsideWSRangeFlag();
+ void tabletTracking();
+
private:
bool ensureScreenSize(int width, int height);
@@ -4243,12 +4245,14 @@ void tst_QWidget::update()
}
}
+#ifndef Q_OS_OSX
static inline bool isOpaque(QWidget *widget)
{
if (!widget)
return false;
return qt_widget_private(widget)->isOpaque;
}
+#endif
void tst_QWidget::isOpaque()
{
@@ -5214,16 +5218,40 @@ protected:
widgetDuringFocusAboutToChange = qApp->focusWidget();
return QWidget::event(ev);
}
+ virtual void focusInEvent(QFocusEvent *)
+ {
+ foucsObjectDuringFocusIn = qApp->focusObject();
+ detectedBadEventOrdering = foucsObjectDuringFocusIn != mostRecentFocusObjectChange;
+ }
virtual void focusOutEvent(QFocusEvent *)
{
+ foucsObjectDuringFocusOut = qApp->focusObject();
widgetDuringFocusOut = qApp->focusWidget();
+ detectedBadEventOrdering = foucsObjectDuringFocusOut != mostRecentFocusObjectChange;
+ }
+
+ void focusObjectChanged(QObject *focusObject)
+ {
+ mostRecentFocusObjectChange = focusObject;
}
public:
- FocusWidget(QWidget *parent) : QWidget(parent), widgetDuringFocusAboutToChange(0), widgetDuringFocusOut(0) {}
+ FocusWidget(QWidget *parent) : QWidget(parent),
+ widgetDuringFocusAboutToChange(0), widgetDuringFocusOut(0),
+ foucsObjectDuringFocusIn(0), foucsObjectDuringFocusOut(0),
+ mostRecentFocusObjectChange(0), detectedBadEventOrdering(false)
+ {
+ connect(qGuiApp, &QGuiApplication::focusObjectChanged, this, &FocusWidget::focusObjectChanged);
+ }
QWidget *widgetDuringFocusAboutToChange;
QWidget *widgetDuringFocusOut;
+
+ QObject *foucsObjectDuringFocusIn;
+ QObject *foucsObjectDuringFocusOut;
+
+ QObject *mostRecentFocusObjectChange;
+ bool detectedBadEventOrdering;
};
void tst_QWidget::setFocus()
@@ -5424,6 +5452,40 @@ void tst_QWidget::setFocus()
QCOMPARE(window.focusWidget(), nullptr);
QCOMPARE(QApplication::focusWidget(), nullptr);
}
+
+ {
+ QWidget window;
+ window.resize(m_testWidgetSize);
+ window.move(windowPos);
+
+ FocusWidget child1(&window);
+ QWidget child2(&window);
+
+ window.show();
+ window.activateWindow();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QTRY_VERIFY(QApplication::focusWindow());
+
+ QCOMPARE(QApplication::focusObject(), &window);
+
+ child1.setFocus();
+ QTRY_VERIFY(child1.hasFocus());
+ QCOMPARE(window.focusWidget(), &child1);
+ QCOMPARE(QApplication::focusWidget(), &child1);
+ QCOMPARE(QApplication::focusObject(), &child1);
+ QCOMPARE(child1.foucsObjectDuringFocusIn, &child1);
+ QVERIFY2(!child1.detectedBadEventOrdering,
+ "focusObjectChanged should be delivered before widget focus events on setFocus");
+
+ child1.clearFocus();
+ QTRY_VERIFY(!child1.hasFocus());
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusObject(), &window);
+ QVERIFY(child1.foucsObjectDuringFocusOut != &child1);
+ QVERIFY2(!child1.detectedBadEventOrdering,
+ "focusObjectChanged should be delivered before widget focus events on clearFocus");
+ }
}
template<class T> class EventSpy : public QObject
@@ -8119,7 +8181,7 @@ void tst_QWidget::customDpi()
custom->logicalDpiX();
QCOMPARE(custom->metricCallCount, 1);
child->logicalDpiX();
- QCOMPARE(custom->metricCallCount, 2);
+ QCOMPARE(custom->metricCallCount, 1);
}
void tst_QWidget::customDpiProperty()
@@ -8957,8 +9019,13 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
void tst_QWidget::windowFlags()
{
QWidget w;
+ const auto baseFlags = w.windowFlags();
w.setWindowFlags(w.windowFlags() | Qt::FramelessWindowHint);
QVERIFY(w.windowFlags() & Qt::FramelessWindowHint);
+ w.setWindowFlag(Qt::WindowStaysOnTopHint, true);
+ QCOMPARE(w.windowFlags(), baseFlags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
+ w.setWindowFlag(Qt::FramelessWindowHint, false);
+ QCOMPARE(w.windowFlags(), baseFlags | Qt::WindowStaysOnTopHint);
}
void tst_QWidget::initialPosForDontShowOnScreenWidgets()
@@ -10464,5 +10531,109 @@ void tst_QWidget::testForOutsideWSRangeFlag()
}
}
+class TabletWidget : public QWidget
+{
+public:
+ TabletWidget(QWidget *parent) : QWidget(parent) { }
+
+ int tabletEventCount = 0;
+ int pressEventCount = 0;
+ int moveEventCount = 0;
+ int releaseEventCount = 0;
+ int trackingChangeEventCount = 0;
+ qint64 uid = -1;
+
+protected:
+ void tabletEvent(QTabletEvent *event) override {
+ ++tabletEventCount;
+ uid = event->uniqueId();
+ switch (event->type()) {
+ case QEvent::TabletMove:
+ ++moveEventCount;
+ break;
+ case QEvent::TabletPress:
+ ++pressEventCount;
+ break;
+ case QEvent::TabletRelease:
+ ++releaseEventCount;
+ break;
+ default:
+ break;
+ }
+ }
+
+ bool event(QEvent *ev) override {
+ if (ev->type() == QEvent::TabletTrackingChange)
+ ++trackingChangeEventCount;
+ return QWidget::event(ev);
+ }
+};
+
+void tst_QWidget::tabletTracking()
+{
+ QWidget parent;
+ parent.resize(200,200);
+ // QWidgetWindow::handleTabletEvent doesn't deliver tablet events to the window's widget, only to a child.
+ // So it doesn't do any good to show a TabletWidget directly: it needs a parent.
+ TabletWidget widget(&parent);
+ widget.resize(200,200);
+ parent.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&parent));
+ widget.setAttribute(Qt::WA_TabletTracking);
+ QTRY_COMPARE(widget.trackingChangeEventCount, 1);
+ QVERIFY(widget.hasTabletTracking());
+
+ QWindow *window = parent.windowHandle();
+ QPointF local(10, 10);
+ QPointF global = window->mapToGlobal(local.toPoint());
+ QPointF deviceLocal = QHighDpi::toNativeLocalPosition(local, window);
+ QPointF deviceGlobal = QHighDpi::toNativePixels(global, window->screen());
+ qint64 uid = 1234UL;
+
+ QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal,
+ QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(widget.moveEventCount, 1);
+ QCOMPARE(widget.uid, uid);
+
+ local += QPoint(10, 10);
+ deviceLocal += QPoint(10, 10);
+ deviceGlobal += QPoint(10, 10);
+ QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal,
+ QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(widget.moveEventCount, 2);
+
+ widget.setTabletTracking(false);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(widget.trackingChangeEventCount, 2);
+
+ QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal,
+ QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(widget.pressEventCount, 1);
+
+ local += QPoint(10, 10);
+ deviceLocal += QPoint(10, 10);
+ deviceGlobal += QPoint(10, 10);
+ QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal,
+ QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(widget.moveEventCount, 3);
+
+ QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal,
+ QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(widget.releaseEventCount, 1);
+
+ local += QPoint(10, 10);
+ deviceLocal += QPoint(10, 10);
+ deviceGlobal += QPoint(10, 10);
+ QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal,
+ QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(widget.moveEventCount, 3);
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro b/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro
index 17fc1d28b5..50069b7e3e 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro
+++ b/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-mac:CONFIG -= app_bundle
TARGET = tst_qwindowcontainer
QT += widgets testlib
SOURCES += tst_qwindowcontainer.cpp
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 5e3868ea8f..6ec1b754d0 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -37,6 +37,7 @@
#include <qmainwindow.h>
#include <qscreen.h>
#include <qscopedpointer.h>
+#include <qevent.h>
class Window : public QWindow
@@ -77,6 +78,7 @@ private slots:
void testAncestorChange();
void testDockWidget();
void testNativeContainerParent();
+ void testPlatformSurfaceEvent();
void cleanup();
private:
@@ -343,6 +345,41 @@ void tst_QWindowContainer::testNativeContainerParent()
QTRY_COMPARE(window->parent(), container->windowHandle());
}
+class EventWindow : public QWindow
+{
+public:
+ EventWindow(bool *surfaceDestroyFlag) : m_surfaceDestroyFlag(surfaceDestroyFlag) { }
+ bool event(QEvent *e) override;
+
+private:
+ bool *m_surfaceDestroyFlag;
+};
+
+bool EventWindow::event(QEvent *e)
+{
+ if (e->type() == QEvent::PlatformSurface) {
+ if (static_cast<QPlatformSurfaceEvent *>(e)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed)
+ *m_surfaceDestroyFlag = true;
+ }
+ return QWindow::event(e);
+}
+
+void tst_QWindowContainer::testPlatformSurfaceEvent()
+{
+ // Verify that SurfaceAboutToBeDestroyed is delivered and the
+ // window subclass still gets a chance to process it.
+
+ bool ok = false;
+ QPointer<EventWindow> window(new EventWindow(&ok));
+ window->create();
+ QWidget *container = QWidget::createWindowContainer(window);
+
+ delete container;
+
+ QCOMPARE(window.data(), nullptr);
+ QVERIFY(ok);
+}
+
QTEST_MAIN(tst_QWindowContainer)
#include "tst_qwindowcontainer.moc"
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 92a8dff218..937be944a1 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -1193,7 +1193,7 @@ void tst_QCompleter::disabledItems()
model->appendRow(suggestions);
model->appendRow(new QStandardItem("suggestions Enabled"));
QCompleter *completer = new QCompleter(model, &lineEdit);
- QSignalSpy spy(completer, SIGNAL(activated(QString)));
+ QSignalSpy spy(completer, QOverload<const QString &>::of(&QCompleter::activated));
lineEdit.setCompleter(completer);
lineEdit.move(200, 200);
lineEdit.show();
@@ -1219,7 +1219,7 @@ void tst_QCompleter::task178797_activatedOnReturn()
setFrameless(&ledit);
QCompleter *completer = new QCompleter(words, &ledit);
ledit.setCompleter(completer);
- QSignalSpy spy(completer, SIGNAL(activated(QString)));
+ QSignalSpy spy(completer, QOverload<const QString &>::of(&QCompleter::activated));
QCOMPARE(spy.count(), 0);
ledit.move(200, 200);
ledit.show();
@@ -1287,7 +1287,7 @@ public:
if (completer()) {
completer()->setCompletionMode(QCompleter::PopupCompletion);
completer()->setCompletionRole(Qt::DisplayRole);
- connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix()));
+ connect(lineEdit(), &QLineEdit::editingFinished, this, &task246056_ComboBox::setCompletionPrefix);
}
}
private slots:
@@ -1306,7 +1306,7 @@ void tst_QCompleter::task246056_setCompletionPrefix()
comboBox.show();
QApplication::setActiveWindow(&comboBox);
QVERIFY(QTest::qWaitForWindowActive(&comboBox));
- QSignalSpy spy(comboBox.completer(), SIGNAL(activated(QModelIndex)));
+ QSignalSpy spy(comboBox.completer(), QOverload<const QModelIndex &>::of(&QCompleter::activated));
QTest::keyPress(&comboBox, 'a');
QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Down);
QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Down);
diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
index 616898c4c5..5acaf49e6c 100644
--- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
+++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
@@ -118,7 +118,7 @@ void tst_QSystemTrayIcon::supportsMessages()
void tst_QSystemTrayIcon::lastWindowClosed()
{
- QSignalSpy spy(qApp, SIGNAL(lastWindowClosed()));
+ QSignalSpy spy(qApp, &QApplication::lastWindowClosed);
QWidget window;
QSystemTrayIcon icon;
icon.setIcon(QIcon("whatever.png"));
diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
index 2c3eb66384..62c3469447 100644
--- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
+++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
@@ -379,12 +379,12 @@ void tst_QUndoGroup::checkSignals()
QUndoGroup group;
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)));
- QSignalSpy undoTextChangedSpy(&group, SIGNAL(undoTextChanged(QString)));
- QSignalSpy canRedoChangedSpy(&group, SIGNAL(canRedoChanged(bool)));
- QSignalSpy redoTextChangedSpy(&group, SIGNAL(redoTextChanged(QString)));
+ QSignalSpy indexChangedSpy(&group, &QUndoGroup::indexChanged);
+ QSignalSpy cleanChangedSpy(&group, &QUndoGroup::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&group, &QUndoGroup::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&group, &QUndoGroup::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&group, &QUndoGroup::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&group, &QUndoGroup::redoTextChanged);
QString str;
diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp
index ba3d80bbe4..f3185086b8 100644
--- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp
+++ b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp
@@ -95,6 +95,23 @@ public:
virtual void redo();
};
+class MoveMouseCommand : public QUndoCommand
+{
+public:
+ MoveMouseCommand(QPoint *mouse, QPoint oldPoint, QPoint newPoint, QUndoCommand *parent = 0);
+ ~MoveMouseCommand();
+
+ virtual void undo();
+ virtual void redo();
+ virtual int id() const;
+ virtual bool mergeWith(const QUndoCommand *other);
+
+private:
+ QPoint *m_mouse;
+ QPoint m_oldPoint;
+ QPoint m_newPoint;
+};
+
InsertCommand::InsertCommand(QString *str, int idx, const QString &text,
QUndoCommand *parent)
: QUndoCommand(parent)
@@ -215,6 +232,48 @@ void IdleCommand::undo()
{
}
+MoveMouseCommand::MoveMouseCommand(QPoint *mouse, QPoint oldPoint, QPoint newPoint, QUndoCommand *parent)
+ : QUndoCommand(parent)
+{
+ setText("move mouse");
+
+ m_mouse = mouse;
+ m_oldPoint = oldPoint;
+ m_newPoint = newPoint;
+
+ if (m_oldPoint == m_newPoint)
+ setObsolete(true);
+}
+
+MoveMouseCommand::~MoveMouseCommand()
+{
+}
+
+void MoveMouseCommand::redo()
+{
+ *m_mouse = m_newPoint;
+}
+
+void MoveMouseCommand::undo()
+{
+ *m_mouse = m_oldPoint;
+}
+
+int MoveMouseCommand::id() const
+{
+ return 2;
+}
+
+bool MoveMouseCommand::mergeWith(const QUndoCommand *other)
+{
+ m_newPoint = static_cast<const MoveMouseCommand*>(other)->m_newPoint;
+
+ if (m_newPoint == m_oldPoint)
+ setObsolete(true);
+
+ return true;
+}
+
/******************************************************************************
** tst_QUndoStack
*/
@@ -233,6 +292,7 @@ private slots:
void childCommand();
void macroBeginEnd();
void compression();
+ void obsolete();
void undoLimit();
void commandTextFormat();
void separateUndoText();
@@ -329,12 +389,12 @@ void tst_QUndoStack::undoRedo()
QUndoStack stack;
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)));
- QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString)));
- QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool)));
- QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString)));
+ QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
+ QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
QString str;
// push, undo, redo
@@ -690,12 +750,12 @@ void tst_QUndoStack::setIndex()
QUndoStack stack;
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)));
- QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString)));
- QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool)));
- QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString)));
+ QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
+ QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
QString str;
stack.setIndex(10); // should do nothing
@@ -954,12 +1014,12 @@ void tst_QUndoStack::setClean()
QUndoStack stack;
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)));
- QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString)));
- QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool)));
- QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString)));
+ QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
+ QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
QString str;
QCOMPARE(stack.cleanIndex(), 0);
@@ -1351,12 +1411,12 @@ void tst_QUndoStack::clear()
QUndoStack stack;
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)));
- QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString)));
- QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool)));
- QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString)));
+ QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
+ QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
QString str;
stack.clear();
@@ -1549,12 +1609,12 @@ void tst_QUndoStack::childCommand()
QUndoStack stack;
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)));
- QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString)));
- QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool)));
- QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString)));
+ QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
+ QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
QString str;
stack.push(new InsertCommand(&str, 0, "hello"));
@@ -1659,12 +1719,12 @@ void tst_QUndoStack::macroBeginEnd()
QUndoStack stack;
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)));
- QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString)));
- QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool)));
- QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString)));
+ QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
+ QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
QString str;
stack.beginMacro("ding");
@@ -2126,12 +2186,12 @@ void tst_QUndoStack::compression()
QUndoStack stack;
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)));
- QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString)));
- QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool)));
- QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString)));
+ QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
+ QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
QString str;
AppendCommand::delete_cnt = 0;
@@ -2563,17 +2623,722 @@ void tst_QUndoStack::compression()
true); // redoChanged
}
+void tst_QUndoStack::obsolete()
+{
+ QUndoStack stack;
+ const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
+ const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
+ QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
+ QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
+ QPoint mouse(0, 0);
+ QString str;
+ MoveMouseCommand *cmd1 = 0;
+ MoveMouseCommand *cmd2 = 0;
+
+ stack.resetClean();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 0, // count
+ 0, // index
+ false, // canUndo
+ "", // undoText
+ false, // canRedo
+ "", // redoText
+ true, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+
+ stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(0, 0))); // #1 should not merge but will be deleted (b/c oldPoint == newPoint)
+ QCOMPARE(mouse, QPoint(0, 0));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 0, // count
+ 0, // index
+ false, // canUndo
+ "", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+
+ stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(12, 0))); // #2 should not merge or be deleted (b/c oldPoint != newPoint)
+ QCOMPARE(mouse, QPoint(12, 0));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 1, // count
+ 1, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(8, 2))); // #3 should merge and not be deleted (b/c oldPoint != newPoint)
+ QCOMPARE(mouse, QPoint(8, 2));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 1, // count
+ 1, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(0, 0))); // #4 should merge and be deleted (b/c oldPoint == newPoint)
+ QCOMPARE(mouse, QPoint(0, 0));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 0, // count
+ 0, // index
+ false, // canUndo
+ "", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+
+
+
+ stack.push(new InsertCommand(&str, 0, "ene")); // #5 should not merge or be deleted
+ QCOMPARE(str, QString("ene"));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 1, // count
+ 1, // index
+ true, // canUndo
+ "insert", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ cmd1 = new MoveMouseCommand(&mouse, mouse, QPoint(6, 5));
+ stack.push(cmd1); // #6 should not merge or be deleted (b/c oldPoint != newPoint)
+ QCOMPARE(mouse, QPoint(6, 5));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 2, // count
+ 2, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ stack.push(new InsertCommand(&str, 3, "ma")); // #7 should not merge or be deleted
+ QCOMPARE(str, QString("enema"));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 3, // count
+ 3, // index
+ true, // canUndo
+ "insert", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ cmd2 = new MoveMouseCommand(&mouse, mouse, QPoint(12, 4));
+ stack.push(cmd2); // #8 should not merge or be deleted (b/c oldPoint != newPoint)
+ QCOMPARE(mouse, QPoint(12, 4));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 4, // count
+ 4, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ stack.setClean();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ true, // clean
+ 4, // count
+ 4, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ true, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+ QCOMPARE(stack.cleanIndex(), 4);
+
+ cmd2->setObsolete(true);
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ true, // clean
+ 4, // count
+ 4, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+
+ stack.undo();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 3, // count
+ 3, // index
+ true, // canUndo
+ "insert", // undoText
+ false, // canRedo
+ "", // redoText
+ true, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+ QCOMPARE(stack.cleanIndex(), -1);
+
+ stack.undo();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 3, // count
+ 2, // index
+ true, // canUndo
+ "move mouse", // undoText
+ true, // canRedo
+ "insert", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ stack.setClean();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ true, // clean
+ 3, // count
+ 2, // index
+ true, // canUndo
+ "move mouse", // undoText
+ true, // canRedo
+ "insert", // redoText
+ true, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+ QCOMPARE(stack.cleanIndex(), 2);
+
+ stack.undo();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 3, // count
+ 1, // index
+ true, // canUndo
+ "insert", // undoText
+ true, // canRedo
+ "move mouse", // redoText
+ true, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ cmd1->setObsolete(true);
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 3, // count
+ 1, // index
+ true, // canUndo
+ "insert", // undoText
+ true, // canRedo
+ "move mouse", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+
+ stack.redo();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 2, // count
+ 1, // index
+ true, // canUndo
+ "insert", // undoText
+ true, // canRedo
+ "insert", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+ QCOMPARE(stack.cleanIndex(), -1);
+
+ stack.redo();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 2, // count
+ 2, // index
+ true, // canUndo
+ "insert", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+ QCOMPARE(stack.cleanIndex(), -1);
+
+ cmd1 = new MoveMouseCommand(&mouse, mouse, QPoint(13, 2));
+ stack.push(cmd1); // #9 should not merge or be deleted (b/c oldPoint != newPoint)
+ QCOMPARE(mouse, QPoint(13, 2));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 3, // count
+ 3, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ stack.push(new InsertCommand(&str, 3, "ma")); // #10 should not merge or be deleted
+ QCOMPARE(str, QString("enemama"));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 4, // count
+ 4, // index
+ true, // canUndo
+ "insert", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ cmd2 = new MoveMouseCommand(&mouse, mouse, QPoint(6, 20));
+ stack.push(cmd2); // #11 should not merge or be deleted (b/c oldPoint != newPoint)
+ QCOMPARE(mouse, QPoint(6, 20));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 5, // count
+ 5, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ cmd1->setObsolete(true);
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 5, // count
+ 5, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+
+ stack.setClean();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ true, // clean
+ 5, // count
+ 5, // index
+ true, // canUndo
+ "move mouse", // undoText
+ false, // canRedo
+ "", // redoText
+ true, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+ QCOMPARE(stack.cleanIndex(), 5);
+
+ stack.setIndex(0);
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 4, // count
+ 0, // index
+ false, // canUndo
+ "", // undoText
+ true, // canRedo
+ "insert", // redoText
+ true, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+ QCOMPARE(stack.cleanIndex(), -1);
+
+ cmd2->setObsolete(true);
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 4, // count
+ 0, // index
+ false, // canUndo
+ "", // undoText
+ true, // canRedo
+ "insert", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+
+ stack.setIndex(stack.count());
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 3, // count
+ 3, // index
+ true, // canUndo
+ "insert", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ mouse = QPoint(0, 0); // Reset mouse position
+ stack.beginMacro("ding");
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 4, // count
+ 3, // index
+ false, // canUndo
+ "", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+
+ stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(7, 7))); // #12 should not merge or be deleted (b/c oldPoint != newPoint & in macro)
+ QCOMPARE(mouse, QPoint(7, 7));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 4, // count
+ 3, // index
+ false, // canUndo
+ "", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+
+ stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(0, 0))); // #13 should merge and be deleted (b/c oldPoint = newPoint)
+ QCOMPARE(mouse, QPoint(0, 0));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 4, // count
+ 3, // index
+ false, // canUndo
+ "", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+
+ stack.endMacro();
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 4, // count
+ 4, // index
+ true, // canUndo
+ "ding", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+}
+
void tst_QUndoStack::undoLimit()
{
QUndoStack stack;
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)));
- QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString)));
- QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool)));
- QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString)));
+ QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
+ QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
+ QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
+ QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged);
+ QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged);
+ QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
AppendCommand::delete_cnt = 0;
QString str;
diff --git a/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro b/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro
index f9b601228e..be758a8bdd 100644
--- a/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro
+++ b/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro
@@ -4,7 +4,7 @@
CONFIG += testcase
TARGET = tst_qabstractspinbox
-QT += widgets testlib
+QT += widgets gui-private core-private testlib
SOURCES += tst_qabstractspinbox.cpp
diff --git a/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp
index 36f5df4649..3fb4863b0e 100644
--- a/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp
+++ b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp
@@ -35,6 +35,20 @@
#include <qlineedit.h>
#include <qspinbox.h>
+#include "../../../shared/platforminputcontext.h"
+#include <private/qinputmethod_p.h>
+
+static inline void centerOnScreen(QWidget *w, const QSize &size)
+{
+ const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
+ w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset);
+}
+
+static inline void centerOnScreen(QWidget *w)
+{
+ centerOnScreen(w, w->geometry().size());
+}
+
class tst_QAbstractSpinBox : public QObject
{
Q_OBJECT
@@ -44,11 +58,19 @@ public:
virtual ~tst_QAbstractSpinBox();
private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
void getSetCheck();
// task-specific tests below me:
void task183108_clear();
void task228728_cssselector();
+
+ void inputMethodUpdate();
+
+private:
+ PlatformInputContext m_platformInputContext;
};
tst_QAbstractSpinBox::tst_QAbstractSpinBox()
@@ -67,6 +89,18 @@ public:
void setLineEdit(QLineEdit *le) { QAbstractSpinBox::setLineEdit(le); }
};
+void tst_QAbstractSpinBox::initTestCase()
+{
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &m_platformInputContext;
+}
+
+void tst_QAbstractSpinBox::cleanupTestCase()
+{
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = 0;
+}
+
// Testing get/set functions
void tst_QAbstractSpinBox::getSetCheck()
{
@@ -141,6 +175,60 @@ void tst_QAbstractSpinBox::task228728_cssselector()
QSpinBox box;
}
+void tst_QAbstractSpinBox::inputMethodUpdate()
+{
+ QSpinBox box;
+
+ QSpinBox *testWidget = &box;
+ testWidget->setRange(0, 1);
+
+ centerOnScreen(testWidget);
+ testWidget->clear();
+ testWidget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(testWidget));
+
+ testWidget->activateWindow();
+ testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
+ QTRY_COMPARE(qApp->focusObject(), testWidget);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event("1", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant());
+ QInputMethodEvent event("1", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event("", attributes);
+ event.setCommitString("1");
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+ QCOMPARE(testWidget->value(), 1);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant());
+ QInputMethodEvent event("", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+}
+
QTEST_MAIN(tst_QAbstractSpinBox)
#include "tst_qabstractspinbox.moc"
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 3afdc0a12a..b882055888 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -64,6 +64,9 @@
#include <qproxystyle.h>
#include <qfont.h>
+#include "../../../shared/platforminputcontext.h"
+#include <private/qinputmethod_p.h>
+
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
@@ -80,6 +83,8 @@ public:
tst_QComboBox() {}
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void getSetCheck();
void ensureReturnIsIgnored();
void setEditable();
@@ -162,6 +167,10 @@ private slots:
void task_QTBUG_39088_inputMethodHints();
void task_QTBUG_49831_scrollerNotActivated();
void task_QTBUG_56693_itemFontFromModel();
+ void inputMethodUpdate();
+
+private:
+ PlatformInputContext m_platformInputContext;
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -207,6 +216,18 @@ protected:
QRegion visualRegionForSelection(const QItemSelection &) const { return QRegion(); }
};
+void tst_QComboBox::initTestCase()
+{
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &m_platformInputContext;
+}
+
+void tst_QComboBox::cleanupTestCase()
+{
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = 0;
+}
+
// Testing get/set functions
void tst_QComboBox::getSetCheck()
{
@@ -3324,5 +3345,59 @@ void tst_QComboBox::task_QTBUG_56693_itemFontFromModel()
box.hidePopup();
}
+void tst_QComboBox::inputMethodUpdate()
+{
+ TestWidget topLevel;
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QComboBox *testWidget = topLevel.comboBox();
+ // make sure we have no lineedit
+ QVERIFY(!testWidget->lineEdit());
+ // test setEditable(true)
+ testWidget->setEditable(true);
+ QVERIFY(testWidget->lineEdit());
+
+ testWidget->activateWindow();
+ testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
+ QTRY_COMPARE(qApp->focusObject(), testWidget);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event("preedit text", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant());
+ QInputMethodEvent event("preedit text", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event("", attributes);
+ event.setCommitString("preedit text");
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+ QCOMPARE(testWidget->lineEdit()->text(), QString("preedit text"));
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant());
+ QInputMethodEvent event("", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index a4614d0a9d..330ce3a836 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -294,6 +294,8 @@ private slots:
void inputMethodQueryImHints_data();
void inputMethodQueryImHints();
+ void inputMethodUpdate();
+
void undoRedoAndEchoModes_data();
void undoRedoAndEchoModes();
@@ -711,8 +713,8 @@ void tst_QLineEdit::clearInputMask()
{
QLineEdit *testWidget = ensureTestWidget();
testWidget->setInputMask("000.000.000.000");
- QVERIFY(testWidget->inputMask() != QString::null);
- testWidget->setInputMask(QString::null);
+ QVERIFY(!testWidget->inputMask().isNull());
+ testWidget->setInputMask(QString());
QCOMPARE(testWidget->inputMask(), QString());
}
@@ -2275,7 +2277,7 @@ void tst_QLineEdit::textChangedAndTextEdited()
changed_count = 0;
edited_count = 0;
- changed_string = QString::null;
+ changed_string.clear();
testWidget->setText("foo");
QCOMPARE(changed_count, 1);
@@ -2284,7 +2286,7 @@ void tst_QLineEdit::textChangedAndTextEdited()
changed_count = 0;
edited_count = 0;
- changed_string = QString::null;
+ changed_string.clear();
testWidget->setText("");
QCOMPARE(changed_count, 1);
@@ -3106,7 +3108,7 @@ void tst_QLineEdit::maxLengthAndInputMask()
QVERIFY(testWidget->inputMask().isNull());
testWidget->setMaxLength(10);
QCOMPARE(testWidget->maxLength(), 10);
- testWidget->setInputMask(QString::null);
+ testWidget->setInputMask(QString());
QVERIFY(testWidget->inputMask().isNull());
QCOMPARE(testWidget->maxLength(), 10);
}
@@ -4184,6 +4186,57 @@ void tst_QLineEdit::inputMethodQueryImHints()
QCOMPARE(static_cast<Qt::InputMethodHints>(value.toInt()), hints);
}
+void tst_QLineEdit::inputMethodUpdate()
+{
+ QLineEdit *testWidget = ensureTestWidget();
+
+ centerOnScreen(testWidget);
+ testWidget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(testWidget));
+
+ testWidget->setText("");
+ testWidget->activateWindow();
+ testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
+ QTRY_COMPARE(qApp->focusObject(), testWidget);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event("preedit text", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant());
+ QInputMethodEvent event("preedit text", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event("", attributes);
+ event.setCommitString("preedit text");
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+ QCOMPARE(testWidget->text(), QString("preedit text"));
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant());
+ QInputMethodEvent event("", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+}
+
void tst_QLineEdit::undoRedoAndEchoModes_data()
{
QTest::addColumn<int>("echoMode");
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index e3af0135e7..4d57b85f9a 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -119,6 +119,7 @@ private slots:
#if !defined(Q_OS_DARWIN)
void check_shortcutPress();
void check_menuPosition();
+ void taskQTBUG46812_doNotLeaveMenubarHighlighted();
#endif
void task223138_triggered();
void task256322_highlight();
@@ -231,9 +232,14 @@ TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb, bool forceNonNative) {
menu = mb->addMenu(QStringLiteral("accel1"));
action = menu->addAction(QStringLiteral("&Open...") );
action->setShortcut(Qt::Key_O);
+ result.actions << action;
+
+ action = menu->addAction(QStringLiteral("action"));
+ action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Z));
+ result.actions << action;
+
result.menus << menu;
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*)));
- result.actions << action;
m_lastSimpleAcceleratorId = 0;
m_simpleActivatedCount = 0;
@@ -319,7 +325,7 @@ inline TestMenu tst_QMenuBar::initWindowWithComplexMenuBar(QMainWindow &w)
return initComplexMenuBar(w.menuBar());
}
-// On Mac/WinCE, native key events are needed to test menu action activation
+// On Mac native key events are needed to test menu action activation
#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::accel()
{
@@ -337,7 +343,7 @@ void tst_QMenuBar::accel()
}
#endif
-// On Mac/WinCE, native key events are needed to test menu action activation
+// On Mac native key events are needed to test menu action activation
#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::activatedCount()
{
@@ -536,7 +542,7 @@ void tst_QMenuBar::insertItem_QString_QObject()
QVERIFY(actions.size() < 4); // there is no menu 4!
}
-// On Mac/WinCE, native key events are needed to test menu action activation
+// On Mac native key events are needed to test menu action activation
#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::check_accelKeys()
{
@@ -609,7 +615,7 @@ void tst_QMenuBar::check_accelKeys()
}
#endif
-// On Mac/WinCE, native key events are needed to test menu action activation
+// On Mac native key events are needed to test menu action activation
#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::check_cursorKeys1()
{
@@ -643,7 +649,7 @@ void tst_QMenuBar::check_cursorKeys1()
}
#endif
-// Qt/Mac,WinCE does not use the native popups/menubar
+// Qt/Mac does not use the native popups/menubar
#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::check_cursorKeys2()
{
@@ -676,7 +682,7 @@ void tst_QMenuBar::check_cursorKeys2()
/*!
If a popupmenu is active you can use Left to move to the menu to the left of it.
*/
-// Qt/Mac,WinCE does not use the native popups/menubar
+// Qt/Mac does not use the native popups/menubar
#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::check_cursorKeys3()
{
@@ -791,7 +797,7 @@ void tst_QMenuBar::check_endKey()
If Down is pressed next the popup is activated again.
*/
-// Qt/Mac,WinCE does not use the native popups/menubar
+// Qt/Mac does not use the native popups/menubar
#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::check_escKey()
{
@@ -1025,7 +1031,7 @@ void tst_QMenuBar::check_altClosePress()
QTRY_VERIFY(!w.menuBar()->activeAction());
}
-// Qt/Mac,WinCE does not use the native popups/menubar
+// Qt/Mac does not use the native popups/menubar
#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::check_shortcutPress()
{
@@ -1068,7 +1074,7 @@ private:
const Qt::LayoutDirection m_oldDirection;
};
-// Qt/Mac,WinCE does not use the native popups/menubar
+// Qt/Mac does not use the native popups/menubar
#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::check_menuPosition()
{
@@ -1530,6 +1536,41 @@ void tst_QMenuBar::slotForTaskQTBUG53205()
taskQTBUG53205MenuBar->setParent(parent);
}
+// Qt/Mac does not use the native popups/menubar
+#if !defined(Q_OS_DARWIN)
+void tst_QMenuBar::taskQTBUG46812_doNotLeaveMenubarHighlighted()
+{
+ QMainWindow mainWindow;
+ QWidget *centralWidget = new QWidget;
+ centralWidget->setFocusPolicy(Qt::StrongFocus);
+ mainWindow.setCentralWidget(centralWidget);
+ initWindowWithSimpleMenuBar(mainWindow);
+
+ mainWindow.show();
+ QApplication::setActiveWindow(&mainWindow);
+ QVERIFY(QTest::qWaitForWindowActive(&mainWindow));
+
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 0);
+
+ QTest::keyPress(&mainWindow, Qt::Key_Alt, Qt::AltModifier);
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 0);
+
+ QTest::keyPress(&mainWindow, Qt::Key_Z, Qt::AltModifier);
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 2); // the action AND the menu will activate
+
+ QTest::keyRelease(&mainWindow, Qt::Key_Alt, Qt::NoModifier);
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 2);
+
+ QTest::keyRelease(&mainWindow, Qt::Key_Z, Qt::NoModifier);
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 2);
+}
+#endif
+
#ifdef Q_OS_MACOS
extern bool tst_qmenubar_taskQTBUG56275(QMenuBar *);
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm
index 4645de4d7a..af93c18712 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index 31bbcf9c7f..af0ad1a601 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -362,7 +362,7 @@ void tst_QPlainTextEdit::emptyAppend()
{
ed->appendPlainText("Blah");
QCOMPARE(blockCount(), 1);
- ed->appendPlainText(QString::null);
+ ed->appendPlainText(QString());
QCOMPARE(blockCount(), 2);
ed->appendPlainText(QString(" "));
QCOMPARE(blockCount(), 3);
diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
index f490446c8a..72e6ffdeb5 100644
--- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
@@ -77,6 +77,11 @@ private slots:
void rubberBandNotInSplitter();
void saveAndRestoreStateOfNotYetShownSplitter();
void saveAndRestoreHandleWidth();
+ void replaceWidget_data();
+ void replaceWidget();
+ void replaceWidgetWithSplitterChild_data();
+ void replaceWidgetWithSplitterChild();
+ void handleMinimumWidth();
// task-specific tests below me:
void task187373_addAbstractScrollAreas();
@@ -645,9 +650,200 @@ public:
MyFriendlySplitter(QWidget *parent = 0) : QSplitter(parent) {}
void setRubberBand(int pos) { QSplitter::setRubberBand(pos); }
+ void moveSplitter(int pos, int index) { QSplitter::moveSplitter(pos, index); }
+
friend class tst_QSplitter;
};
+class EventCounterSpy : public QObject
+{
+public:
+ EventCounterSpy(QWidget *parentWidget) : QObject(parentWidget)
+ { }
+
+ bool eventFilter(QObject *watched, QEvent *event) override
+ {
+ // Watch for events in the parent widget and all its children
+ if (watched == parent() || watched->parent() == parent()) {
+ if (event->type() == QEvent::Resize)
+ resizeCount++;
+ else if (event->type() == QEvent::Paint)
+ paintCount++;
+ }
+
+ return QObject::eventFilter(watched, event);
+ }
+
+ int resizeCount = 0;
+ int paintCount = 0;
+};
+
+void tst_QSplitter::replaceWidget_data()
+{
+ QTest::addColumn<int>("index");
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("collapsed");
+
+ QTest::newRow("negative index") << -1 << true << false;
+ QTest::newRow("index too large") << 80 << true << false;
+ QTest::newRow("visible, not collapsed") << 3 << true << false;
+ QTest::newRow("visible, collapsed") << 3 << true << true;
+ QTest::newRow("not visible, not collapsed") << 3 << false << false;
+ QTest::newRow("not visible, collapsed") << 3 << false << true;
+}
+
+void tst_QSplitter::replaceWidget()
+{
+ QFETCH(int, index);
+ QFETCH(bool, visible);
+ QFETCH(bool, collapsed);
+
+ // Setup
+ MyFriendlySplitter sp;
+ const int count = 7;
+ for (int i = 0; i < count; i++) {
+ // We use labels instead of plain widgets to
+ // make it easier to fix eventual regressions.
+ QLabel *w = new QLabel(QString::asprintf("WIDGET #%d", i));
+ sp.addWidget(w);
+ }
+ sp.setWindowTitle(QString::asprintf("index %d, visible %d, collapsed %d", index, visible, collapsed));
+ sp.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&sp));
+
+ // Configure splitter
+ QWidget *oldWidget = sp.widget(index);
+ const QRect oldGeom = oldWidget ? oldWidget->geometry() : QRect();
+ if (oldWidget) {
+ // Collapse first, then hide, if necessary
+ if (collapsed) {
+ sp.setCollapsible(index, true);
+ sp.moveSplitter(oldWidget->x() + 1, index + 1);
+ }
+ if (!visible)
+ oldWidget->hide();
+ }
+
+ // Replace widget
+ QTest::qWait(100); // Flush event queue
+ const QList<int> sizes = sp.sizes();
+ // Shorter label: The important thing is to ensure we can set
+ // the same size on the new widget. Because of QLabel's sizing
+ // constraints (they can expand but not shrink) the easiest is
+ // to set a shorter label.
+ QLabel *newWidget = new QLabel(QLatin1String("<b>NEW</b>"));
+
+ EventCounterSpy *ef = new EventCounterSpy(&sp);
+ qApp->installEventFilter(ef);
+ const QWidget *res = sp.replaceWidget(index, newWidget);
+ QTest::qWait(100); // Give visibility and resizing some time
+ qApp->removeEventFilter(ef);
+
+ // Check
+ if (index < 0 || index >= count) {
+ QVERIFY(!res);
+ QVERIFY(!newWidget->parentWidget());
+ QCOMPARE(ef->resizeCount, 0);
+ QCOMPARE(ef->paintCount, 0);
+ } else {
+ QCOMPARE(res, oldWidget);
+ QVERIFY(!res->parentWidget());
+ QVERIFY(!res->isVisible());
+ QCOMPARE(newWidget->parentWidget(), &sp);
+ QCOMPARE(newWidget->isVisible(), visible);
+ if (visible && !collapsed)
+ QCOMPARE(newWidget->geometry(), oldGeom);
+ QCOMPARE(newWidget->size().isEmpty(), !visible || collapsed);
+ const int expectedResizeCount = visible ? 1 : 0; // new widget only
+ const int expectedPaintCount = visible && !collapsed ? 2 : 0; // splitter and new widget
+ QCOMPARE(ef->resizeCount, expectedResizeCount);
+ QCOMPARE(ef->paintCount, expectedPaintCount);
+ delete res;
+ }
+ QCOMPARE(sp.count(), count);
+ QCOMPARE(sp.sizes(), sizes);
+}
+
+void tst_QSplitter::replaceWidgetWithSplitterChild_data()
+{
+ QTest::addColumn<int>("srcIndex");
+ QTest::addColumn<int>("dstIndex");
+
+ QTest::newRow("replace with null widget") << -2 << 3;
+ QTest::newRow("replace with itself") << 3 << 3;
+ QTest::newRow("replace with sibling, after recalc") << 1 << 4;
+ QTest::newRow("replace with sibling, before recalc") << -1 << 4;
+}
+
+void tst_QSplitter::replaceWidgetWithSplitterChild()
+{
+ QFETCH(int, srcIndex);
+ QFETCH(int, dstIndex);
+
+ // Setup
+ MyFriendlySplitter sp;
+ const int count = 7;
+ for (int i = 0; i < count; i++) {
+ // We use labels instead of plain widgets to
+ // make it easier to fix eventual regressions.
+ QLabel *w = new QLabel(QString::asprintf("WIDGET #%d", i));
+ sp.addWidget(w);
+ }
+ sp.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag()));
+ sp.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&sp));
+
+ QTest::qWait(100); // Flush event queue before new widget creation
+ const QList<int> sizes = sp.sizes();
+ QWidget *sibling = srcIndex == -1 ? (new QLabel("<b>NEW</b>", &sp)) : sp.widget(srcIndex);
+
+ EventCounterSpy *ef = new EventCounterSpy(&sp);
+ qApp->installEventFilter(ef);
+ const QWidget *res = sp.replaceWidget(dstIndex, sibling);
+ QTest::qWait(100); // Give visibility and resizing some time
+ qApp->removeEventFilter(ef);
+
+ QVERIFY(!res);
+ if (srcIndex == -1) {
+ // Create and replace before recalc. The sibling is scheduled to be
+ // added after replaceWidget(), when QSplitter receives a child event.
+ QVERIFY(ef->resizeCount > 0);
+ QVERIFY(ef->paintCount > 0);
+ QCOMPARE(sp.count(), count + 1);
+ QCOMPARE(sp.sizes().mid(0, count), sizes);
+ QCOMPARE(sp.sizes().last(), sibling->width());
+ } else {
+ // No-op for the rest
+ QCOMPARE(ef->resizeCount, 0);
+ QCOMPARE(ef->paintCount, 0);
+ QCOMPARE(sp.count(), count);
+ QCOMPARE(sp.sizes(), sizes);
+ }
+}
+
+void tst_QSplitter::handleMinimumWidth()
+{
+ MyFriendlySplitter split;
+ split.addWidget(new QLabel("Number Wan"));
+ split.addWidget(new QLabel("Number Too"));
+
+ split.show();
+ QTest::qWaitForWindowExposed(&split);
+ for (int i = 0; i < 10; i++) {
+ split.setHandleWidth(i);
+ QTest::qWait(100); // resizing
+ QCOMPARE(split.handle(1)->width(), qMax(4 + (i & 1), i));
+ }
+
+ split.setOrientation(Qt::Vertical);
+ QTest::qWait(100);
+ for (int i = 0; i < 10; i++) {
+ split.setHandleWidth(i);
+ QTest::qWait(100); // resizing
+ QCOMPARE(split.handle(1)->height(), qMax(4 + (i & 1), i));
+ }
+}
+
void tst_QSplitter::rubberBandNotInSplitter()
{
MyFriendlySplitter split;
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index cecec48113..b9ea310d80 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -676,7 +676,7 @@ void tst_QTextEdit::emptyAppend()
{
ed->append("Blah");
QCOMPARE(blockCount(), 1);
- ed->append(QString::null);
+ ed->append(QString());
QCOMPARE(blockCount(), 2);
ed->append(QString(" "));
QCOMPARE(blockCount(), 3);
diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro
index a8e8f6d865..c098108edc 100644
--- a/tests/auto/widgets/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets/widgets.pro
@@ -49,6 +49,7 @@ SUBDIRS=\
# The following tests depend on private API:
!qtConfig(private_tests): SUBDIRS -= \
+ qabstractspinbox \
qcombobox \
qmainwindow \
qtextedit \