summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-03-16 10:31:07 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-03-16 10:31:07 +0100
commit198606f6dbca95ba3a170fff387327d8271018cd (patch)
tree79e8c632f5277fc7f0ae30ae7fb1e1c41745c815 /tests
parent77c0c1ca6505eb66bd75b3766f9a498574822bd1 (diff)
parent0d5ffd67a4748bcbf19dc3a4b9a36ae6314e58a6 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/plugins/platforms/xcb/qxcbnativeinterface.cpp src/plugins/platforms/xcb/qxcbnativeinterface.h Change-Id: I31b38ba439b9341d51a01c0fd54bea33f7410076
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/cmake/test_add_resource_options/CMakeLists.txt3
-rw-r--r--tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp4
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp11
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp5
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp30
-rw-r--r--tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp4
-rw-r--r--tests/auto/corelib/tools/qpointf/tst_qpointf.cpp4
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp2
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp6
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp45
-rw-r--r--tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp8
-rw-r--r--tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp96
-rw-r--r--tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp11
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp2
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp50
-rw-r--r--tests/benchmarks/corelib/tools/qregexp/main.cpp54
-rw-r--r--tests/benchmarks/corelib/tools/qregexp/qregexp.pro8
-rw-r--r--tests/manual/cocoa/popups/main.cpp152
-rw-r--r--tests/manual/cocoa/popups/popups.pro4
19 files changed, 378 insertions, 121 deletions
diff --git a/tests/auto/cmake/test_add_resource_options/CMakeLists.txt b/tests/auto/cmake/test_add_resource_options/CMakeLists.txt
index a358094546..5fcae59dfe 100644
--- a/tests/auto/cmake/test_add_resource_options/CMakeLists.txt
+++ b/tests/auto/cmake/test_add_resource_options/CMakeLists.txt
@@ -20,6 +20,9 @@ qt5_wrap_cpp(moc_files myobject.h)
# in the add_executable call.
qt5_add_resources(rcc_files "test_macro_options.qrc" OPTIONS -binary)
+# Test if OPTIONS can handle a quoted parameter. CMake would fail immediately!
+qt5_add_resources(rcc_files_quoted_option "test_macro_options.qrc" OPTIONS -root "/")
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
add_executable(myobject myobject.cpp ${moc_files} ${rcc_files})
diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
index 3d0b102b1c..8ffe4d8dfe 100644
--- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
+++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
@@ -385,14 +385,14 @@ void tst_QtConcurrentRun::recursive()
count.store(0);
QThreadPool::globalInstance()->setMaxThreadCount(i);
recursiveRun(levels);
- QCOMPARE(count.load(), (int)pow(2.0, levels) - 1);
+ QCOMPARE(count.load(), (int)std::pow(2.0, levels) - 1);
}
for (int i = 0; i < QThread::idealThreadCount(); ++i) {
count.store(0);
QThreadPool::globalInstance()->setMaxThreadCount(i);
recursiveResult(levels);
- QCOMPARE(count.load(), (int)pow(2.0, levels) - 1);
+ QCOMPARE(count.load(), (int)std::pow(2.0, levels) - 1);
}
}
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 2015629a59..7579c6713d 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Copyright (C) 2012 Intel Corporation.
+** Copyright (C) 2015 Intel Corporation.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -1248,6 +1248,10 @@ void tst_QUrl::fromLocalFile_data()
<< QString::fromLatin1("/a%25.txt");
QTest::newRow("data10") << QString::fromLatin1("/%80.txt") << QString::fromLatin1("file:///%2580.txt")
<< QString::fromLatin1("/%80.txt");
+ QTest::newRow("data11") << QString::fromLatin1("./a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt");
+ QTest::newRow("data12") << QString::fromLatin1("././a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt");
+ QTest::newRow("data13") << QString::fromLatin1("b/../a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt");
+ QTest::newRow("data14") << QString::fromLatin1("/b/../a.txt") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt");
}
void tst_QUrl::fromLocalFile()
@@ -2012,6 +2016,11 @@ void tst_QUrl::isValid()
QVERIFY(url.toString().isEmpty());
QVERIFY(url.errorString().contains("':' before any '/'"));
}
+
+ {
+ QUrl url("file://./localfile.html");
+ QVERIFY(!url.isValid());
+ }
}
void tst_QUrl::schemeValidator_data()
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 449ae947cf..6da8f55e61 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -48,6 +48,7 @@
#include <limits.h>
#include <float.h>
+#include <cmath>
#include <QLinkedList>
#include <QRegularExpression>
@@ -3373,10 +3374,10 @@ void tst_QVariant::numericalConvert()
switch (v.userType())
{
case QVariant::Double:
- QCOMPARE(v.toString() , QString::number(num, 'g', DBL_MANT_DIG * log10(2.) + 2));
+ QCOMPARE(v.toString() , QString::number(num, 'g', DBL_MANT_DIG * std::log10(2.) + 2));
break;
case QMetaType::Float:
- QCOMPARE(v.toString() , QString::number(float(num), 'g', FLT_MANT_DIG * log10(2.) + 2));
+ QCOMPARE(v.toString() , QString::number(float(num), 'g', FLT_MANT_DIG * std::log10(2.) + 2));
break;
}
}
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 446e56e936..4ab79909e3 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -611,13 +611,11 @@ void tst_QDateTime::setMSecsSinceEpoch()
dt2.setTimeZone(europe);
dt2.setMSecsSinceEpoch(msecs);
QCOMPARE(dt2.date(), european.date());
-#ifdef Q_OS_MAC
- // NSTimeZone doesn't apply DST to high values
- if (msecs < (Q_INT64_C(123456) << 32))
-#else
- // Linux and Win are OK except when they overflow
- if (msecs != std::numeric_limits<qint64>::max())
-#endif
+
+ // don't compare the time if the date is too early or too late: prior
+ // to 1916, timezones in Europe were not standardised and some OS APIs
+ // have hard limits. Let's restrict it to the 32-bit Unix range
+ if (dt2.date().year() >= 1970 && dt2.date().year() <= 2037)
QCOMPARE(dt2.time(), european.time());
QCOMPARE(dt2.timeSpec(), Qt::TimeZone);
QCOMPARE(dt2.timeZone(), europe);
@@ -2634,10 +2632,10 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 10, 28));
QCOMPARE(test.time(), QTime(2, 0, 0));
-#if !defined(Q_OS_MAC) && !defined(Q_OS_QNX)
- // Linux mktime bug uses last calculation
+#ifdef Q_OS_WIN
+ // Windows uses SecondOccurrence
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
-#endif // Q_OS_MAC
+#endif // Q_OS_WIN
QCOMPARE(test.toMSecsSinceEpoch(), standard2012 - msecsOneHour);
// Add year to get to after tran FirstOccurrence
@@ -2676,10 +2674,10 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 10, 28));
QCOMPARE(test.time(), QTime(2, 0, 0));
-#if !defined(Q_OS_MAC) && !defined(Q_OS_QNX)
- // Linux mktime bug uses last calculation
+#ifdef Q_OS_WIN
+ // Windows uses SecondOccurrence
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
-#endif // Q_OS_MAC
+#endif // Q_OS_WIN
QCOMPARE(test.toMSecsSinceEpoch(), standard2012 - msecsOneHour);
// Add month to get to after tran FirstOccurrence
@@ -2718,10 +2716,10 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 10, 28));
QCOMPARE(test.time(), QTime(2, 0, 0));
-#if !defined(Q_OS_MAC) && !defined(Q_OS_QNX)
- // Linux mktime bug uses last calculation
+#ifdef Q_OS_WIN
+ // Windows uses SecondOccurrence
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
-#endif // Q_OS_MAC
+#endif // Q_OS_WIN
QCOMPARE(test.toMSecsSinceEpoch(), standard2012 - msecsOneHour);
// Add day to get to after tran FirstOccurrence
diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
index b33982695b..8726f77e58 100644
--- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
@@ -753,7 +753,7 @@ void tst_QEasingCurve::testCbrtDouble()
if (f != 0.0)
t = t * (t_cubic + d + d) / f;
- double expected = pow(d, 1.0/3.0);
+ double expected = std::pow(d, 1.0/3.0);
const qreal error = qAbs(expected - t);
@@ -779,7 +779,7 @@ void tst_QEasingCurve::testCbrtFloat()
if (fac != 0.0f)
t = t * (t_cubic + f + f) / fac;
- float expected = pow(f, float(1.0/3.0));
+ float expected = std::pow(f, float(1.0/3.0));
const qreal error = qAbs(expected - t);
diff --git a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
index 436cedcca7..ff58c9b181 100644
--- a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
+++ b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
@@ -275,12 +275,12 @@ void tst_QPointF::division()
{
{
QPointF p(1e-14, 1e-14);
- p = p / sqrt(dot(p, p));
+ p = p / std::sqrt(dot(p, p));
QCOMPARE(dot(p, p), qreal(1.0));
}
{
QPointF p(1e-14, 1e-14);
- p /= sqrt(dot(p, p));
+ p /= std::sqrt(dot(p, p));
QCOMPARE(dot(p, p), qreal(1.0));
}
}
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 8cd9610542..d2f7a6ee50 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -2033,6 +2033,8 @@ void tst_QString::simplified_data()
QTest::newRow("chars apart posttab") << "a \tb" << "a b";
QTest::newRow("chars apart pretab") << "a\t b" << "a b";
QTest::newRow("many words") << " just some random\ttext here" << "just some random text here";
+ QTest::newRow("newlines") << "a\nb\nc" << "a b c";
+ QTest::newRow("newlines-trailing") << "a\nb\nc\n" << "a b c";
}
void tst_QString::simplified()
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 8ce0e3942e..d361aa12a6 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -1464,7 +1464,7 @@ void tst_QWindow::initialSize()
QSize defaultSize(0,0);
{
Window w;
- w.show();
+ w.showNormal();
QTRY_VERIFY(w.width() > 0);
QTRY_VERIFY(w.height() > 0);
defaultSize = QSize(w.width(), w.height());
@@ -1472,7 +1472,7 @@ void tst_QWindow::initialSize()
{
Window w;
w.setWidth(m_testWindowSize.width());
- w.show();
+ w.showNormal();
#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
// so we only expect one resize event
QTRY_COMPARE(w.width(), qGuiApp->primaryScreen()->availableGeometry().width());
@@ -1485,7 +1485,7 @@ void tst_QWindow::initialSize()
Window w;
const QSize testSize(m_testWindowSize.width(), 42);
w.resize(testSize);
- w.show();
+ w.showNormal();
#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
// so we only expect one resize event
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 159bb6a041..f6167262a9 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -111,6 +111,7 @@ private slots:
void drawLine_task190634();
void drawLine_task229459();
void drawLine_task234891();
+ void drawLineEndPoints();
void drawRect_data() { fillData(); }
void drawRect();
@@ -1036,6 +1037,50 @@ void tst_QPainter::drawLine_task216948()
QCOMPARE(img.pixel(0, i), QColor(Qt::black).rgba());
}
+void tst_QPainter::drawLineEndPoints()
+{
+ QImage img(256, 256, QImage::Format_ARGB32_Premultiplied);
+ img.fill(0x0);
+
+ QPainter p;
+ for (int x = 0; x < img.width(); ++x) {
+ QRgb color = qRgb(x, 0, 0);
+ p.begin(&img);
+ p.setPen(QPen(color));
+ p.drawLine(x, 0, 255 - x, 255);
+ p.end();
+ QCOMPARE(img.pixel(x, 0), color);
+ QCOMPARE(img.pixel(255 - x, 255), color);
+ }
+ for (int y = 0; y < img.height(); ++y) {
+ QRgb color = qRgb(0, y, 0);
+ p.begin(&img);
+ p.setPen(QPen(color));
+ p.drawLine(0, y, 255, 255 - y);
+ p.end();
+ QCOMPARE(img.pixel(0, y), color);
+ QCOMPARE(img.pixel(255, 255 - y), color);
+ }
+ for (int x = 0; x < img.width(); ++x) {
+ QRgb color = qRgb(x, 0, x);
+ p.begin(&img);
+ p.setPen(QPen(color));
+ p.drawLine(x, 255, 255 - x, 0);
+ p.end();
+ QCOMPARE(img.pixel(x, 255), color);
+ QCOMPARE(img.pixel(255 - x, 0), color);
+ }
+ for (int y = 0; y < img.height(); ++y) {
+ QRgb color = qRgb(0, y, y);
+ p.begin(&img);
+ p.setPen(QPen(color));
+ p.drawLine(255, y, 0, 255 - y);
+ p.end();
+ QCOMPARE(img.pixel(255, y), color);
+ QCOMPARE(img.pixel(0, 255 - y), color);
+ }
+}
+
void tst_QPainter::drawRect()
{
QFETCH(QRect, rect);
diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
index 4252561001..0a073f5c84 100644
--- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
@@ -895,12 +895,6 @@ void tst_QPainterPath::operators()
QCOMPARE(test, expected);
}
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-#define ANGLE(t) ((t) * 2 * M_PI / 360.0)
-
-
static inline bool pathFuzzyCompare(double p1, double p2)
{
return qAbs(p1 - p2) < 0.001;
@@ -931,7 +925,7 @@ void tst_QPainterPath::testArcMoveTo()
qreal y_radius = rect.height() / 2.0;
QPointF shouldBe = rect.center()
- + QPointF(x_radius * cos(ANGLE(angle)), -y_radius * sin(ANGLE(angle)));
+ + QPointF(x_radius * qCos(qDegreesToRadians(angle)), -y_radius * qSin(qDegreesToRadians(angle)));
qreal iw = 1 / rect.width();
qreal ih = 1 / rect.height();
diff --git a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp
index a1017eea3b..c4c4789b7a 100644
--- a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp
+++ b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp
@@ -152,125 +152,125 @@ void tst_QWMatrix::mapping_data()
// rotations
float deg = 0.;
- QTest::newRow( "rot 0 a" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot 0 a" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
+ std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 )
<< QPolygon ( QRect( 0, 0, 30, 40 ) );
deg = 0.00001f;
- QTest::newRow( "rot 0 b" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot 0 b" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
+ std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 )
<< QPolygon ( QRect( 0, 0, 30, 40 ) );
deg = 0.;
- QTest::newRow( "rot 0 c" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot 0 c" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
+ std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon ( QRect( 10, 20, 30, 40 ) );
deg = 0.00001f;
- QTest::newRow( "rot 0 d" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot 0 d" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
+ std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon ( QRect( 10, 20, 30, 40 ) );
#if 0
// rotations
deg = 90.;
- QTest::newRow( "rotscale 90 a" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 90 a" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( 0, -299, 400, 300 ) );
deg = 90.00001;
- QTest::newRow( "rotscale 90 b" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 90 b" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( 0, -299, 400, 300 ) );
deg = 90.;
- QTest::newRow( "rotscale 90 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 90 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( 200, -399, 400, 300 ) );
deg = 90.00001;
- QTest::newRow( "rotscale 90 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 90 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( 200, -399, 400, 300 ) );
deg = 180.;
- QTest::newRow( "rotscale 180 a" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 180 a" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( -299, -399, 300, 400 ) );
deg = 180.000001;
- QTest::newRow( "rotscale 180 b" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 180 b" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( -299, -399, 300, 400 ) );
deg = 180.;
- QTest::newRow( "rotscale 180 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 180 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -399, -599, 300, 400 ) );
deg = 180.000001;
- QTest::newRow( "rotscale 180 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 180 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -399, -599, 300, 400 ) );
deg = 270.;
- QTest::newRow( "rotscale 270 a" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 270 a" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( -399, 00, 400, 300 ) );
deg = 270.0000001;
- QTest::newRow( "rotscale 270 b" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 270 b" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( -399, 00, 400, 300 ) );
deg = 270.;
- QTest::newRow( "rotscale 270 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 270 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -599, 100, 400, 300 ) );
deg = 270.000001;
- QTest::newRow( "rotscale 270 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rotscale 270 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -599, 100, 400, 300 ) );
// rotations that are not multiples of 90 degrees. mapRect returns the bounding rect here.
deg = 45;
- QTest::newRow( "rot 45 a" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot 45 a" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
+ std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 10, 10 )
<< QPolygon( QRect( 0, -7, 14, 14 ) );
- QTest::newRow( "rot 45 b" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot 45 b" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
+ std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( 21, -14, 49, 49 ) );
- QTest::newRow( "rot 45 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot 45 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 10, 10 )
<< QPolygon( QRect( 0, -70, 141, 141 ) );
- QTest::newRow( "rot 45 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot 45 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( 212, -141, 495, 495 ) );
deg = -45;
- QTest::newRow( "rot -45 a" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot -45 a" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
+ std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 10, 10 )
<< QPolygon( QRect( -7, 0, 14, 14 ) );
- QTest::newRow( "rot -45 b" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot -45 b" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
+ std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -35, 21, 49, 49 ) );
- QTest::newRow( "rot -45 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot -45 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 10, 10 )
<< QPolygon( QRect( -70, 0, 141, 141 ) );
- QTest::newRow( "rot -45 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ QTest::newRow( "rot -45 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
+ 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -353, 212, 495, 495 ) );
#endif
diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
index 6f1a73b054..804f86b479 100644
--- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
@@ -864,11 +864,12 @@ void tst_QTcpServer::serverAddress_data()
QTest::newRow("AnyIPv4") << QHostAddress(QHostAddress::AnyIPv4) << QHostAddress(QHostAddress::AnyIPv4);
if (QtNetworkSettings::hasIPv6())
QTest::newRow("AnyIPv6") << QHostAddress(QHostAddress::AnyIPv6) << QHostAddress(QHostAddress::AnyIPv6);
- foreach (const QHostAddress& addr, QNetworkInterface::allAddresses()) {
- if (addr.isInSubnet(QHostAddress::parseSubnet("fe80::/10"))
- || addr.isInSubnet(QHostAddress::parseSubnet("169.254/16")))
- continue; //cannot bind on link local addresses
- QTest::newRow(qPrintable(addr.toString())) << addr << addr;
+ foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) {
+ if ((iface.flags() & QNetworkInterface::IsUp) == 0)
+ continue;
+ foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) {
+ QTest::newRow(qPrintable(entry.ip().toString())) << entry.ip() << entry.ip();
+ }
}
}
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
index 4bd330b04f..6e04cd9d0e 100644
--- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -1233,6 +1233,8 @@ void tst_QUdpSocket::setMulticastInterface_data()
QTest::addColumn<QHostAddress>("address");
QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
foreach (const QNetworkInterface &iface, interfaces) {
+ if ((iface.flags() & QNetworkInterface::IsUp) == 0)
+ continue;
foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) {
QTest::newRow(QString("%1:%2").arg(iface.name()).arg(entry.ip().toString()).toLatin1())
<< iface
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index 1833af7af5..4fd8b99acf 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -76,11 +76,7 @@ private slots:
void sizeHint_data();
void sizeHint();
void taskQTBUG_20191_shortcutWithKeypadModifer();
-/*
- void state();
- void group();
- void stateChanged();
-*/
+ void emitReleasedAfterChange();
protected slots:
void resetCounters();
@@ -419,19 +415,6 @@ void tst_QPushButton::clicked()
QCOMPARE( release_count, (uint)10 );
}
-/*
-void tst_QPushButton::group()
-{
-}
-
-void tst_QPushButton::state()
-{
-}
-
-void tst_QPushButton::stateChanged()
-{
-}
-*/
QPushButton *pb = 0;
void tst_QPushButton::helperSlotDelete()
{
@@ -681,5 +664,36 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
QCOMPARE(spy2.count(), 1);
}
+void tst_QPushButton::emitReleasedAfterChange()
+{
+ QPushButton *button1 = new QPushButton("A");
+ QPushButton *button2 = new QPushButton("B");
+ QVBoxLayout *layout = new QVBoxLayout();
+ layout->addWidget(button1);
+ layout->addWidget(button2);
+ QDialog dialog;
+ dialog.setLayout(layout);
+ dialog.show();
+ QTest::qWaitForWindowExposed(&dialog);
+ QApplication::setActiveWindow(&dialog);
+ button1->setFocus();
+
+ QSignalSpy spy(button1, SIGNAL(released()));
+ QTest::mousePress(button1, Qt::LeftButton);
+ QVERIFY(button1->isDown());
+ QTest::keyClick(&dialog, Qt::Key_Tab);
+ QVERIFY(!button1->isDown());
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ QCOMPARE(spy.count(), 0);
+ button1->setFocus();
+ QTest::mousePress(button1, Qt::LeftButton);
+ QVERIFY(button1->isDown());
+ button1->setEnabled(false);
+ QVERIFY(!button1->isDown());
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QPushButton)
#include "tst_qpushbutton.moc"
diff --git a/tests/benchmarks/corelib/tools/qregexp/main.cpp b/tests/benchmarks/corelib/tools/qregexp/main.cpp
index 88d3b3fa96..aa31b037fe 100644
--- a/tests/benchmarks/corelib/tools/qregexp/main.cpp
+++ b/tests/benchmarks/corelib/tools/qregexp/main.cpp
@@ -75,17 +75,13 @@ private slots:
void rangeReplace2();
void matchReplace2();
-#ifdef HAVE_JSC
void simpleFindJSC();
void rangeReplaceJSC();
void matchReplaceJSC();
-#endif
-#ifdef HAVE_BOOST
void simpleFindBoost();
void rangeReplaceBoost();
void matchReplaceBoost();
-#endif
/* those apply an (incorrect) regexp on entire source
(this main.cpp). JSC appears to handle this
@@ -95,14 +91,10 @@ private slots:
void horribleReplace1();
void horribleReplace2();
void horribleWrongReplace2();
-#ifdef HAVE_JSC
void horribleWrongReplaceJSC();
void horribleReplaceJSC();
-#endif
-#ifdef HAVE_BOOST
void horribleWrongReplaceBoost();
void horribleReplaceBoost();
-#endif
private:
QString str1;
QString str2;
@@ -451,9 +443,9 @@ void tst_qregexp::horribleReplace2()
}
QCOMPARE(r, QString("1.2.3"));
}
-#ifdef HAVE_JSC
void tst_qregexp::simpleFindJSC()
{
+#ifdef HAVE_JSC
int numr;
const char * errmsg=" ";
QString rxs("happy");
@@ -467,10 +459,14 @@ void tst_qregexp::simpleFindJSC()
jsRegExpFree(rx);
QCOMPARE(numr, 1);
QCOMPARE(offsetVector[0], 11);
+#else
+ QSKIP("JSC is not enabled for this platform");
+#endif
}
void tst_qregexp::rangeReplaceJSC()
{
+#ifdef HAVE_JSC
QScriptValue r;
QScriptEngine engine;
engine.globalObject().setProperty("s", str1);
@@ -480,10 +476,14 @@ void tst_qregexp::rangeReplaceJSC()
r = replaceFunc.call(QScriptValue());
}
QCOMPARE(r.toString(), QString("W- -r- -ll h-ppy monk-ys"));
+#else
+ QSKIP("JSC is not enabled for this platform");
+#endif
}
void tst_qregexp::matchReplaceJSC()
{
+#ifdef HAVE_JSC
QScriptValue r;
QScriptEngine engine;
engine.globalObject().setProperty("s", str1);
@@ -493,10 +493,14 @@ void tst_qregexp::matchReplaceJSC()
r = replaceFunc.call(QScriptValue());
}
QCOMPARE(r.toString(), QString("eaeaae"));
+#else
+ QSKIP("JSC is not enabled for this platform");
+#endif
}
void tst_qregexp::horribleWrongReplaceJSC()
{
+#ifdef HAVE_JSC
QScriptValue r;
QScriptEngine engine;
engine.globalObject().setProperty("s", str2);
@@ -506,10 +510,14 @@ void tst_qregexp::horribleWrongReplaceJSC()
r = replaceFunc.call(QScriptValue());
}
QCOMPARE(r.toString(), str2);
+#else
+ QSKIP("JSC is not enabled for this platform");
+#endif
}
void tst_qregexp::horribleReplaceJSC()
{
+#ifdef HAVE_JSC
QScriptValue r;
QScriptEngine engine;
// the m flag doesn't actually work here; dunno
@@ -520,11 +528,14 @@ void tst_qregexp::horribleReplaceJSC()
r = replaceFunc.call(QScriptValue());
}
QCOMPARE(r.toString(), QString("1.2.3"));
-}
+#else
+ QSKIP("JSC is not enabled for this platform");
#endif
+}
+void tst_qregexp::simpleFindBoost()
+{
#ifdef HAVE_BOOST
-void tst_qregexp::simpleFindBoost(){
int roff;
boost::regex rx ("happy", boost::regex_constants::perl);
std::string s = str1.toStdString();
@@ -538,10 +549,15 @@ void tst_qregexp::simpleFindBoost(){
roff = (what[0].first)-start;
}
QCOMPARE(roff, 11);
+#else
+ QSKIP("Boost is not enabled for this platform");
+#endif
+
}
void tst_qregexp::rangeReplaceBoost()
{
+#ifdef HAVE_BOOST
boost::regex pattern ("[a-f]", boost::regex_constants::perl);
std::string s = str1.toStdString();
std::string r;
@@ -549,10 +565,14 @@ void tst_qregexp::rangeReplaceBoost()
r = boost::regex_replace (s, pattern, "-");
}
QCOMPARE(r, std::string("W- -r- -ll h-ppy monk-ys"));
+#else
+ QSKIP("Boost is not enabled for this platform");
+#endif
}
void tst_qregexp::matchReplaceBoost()
{
+#ifdef HAVE_BOOST
boost::regex pattern ("[^a-f]*([a-f]+)[^a-f]*",boost::regex_constants::perl);
std::string s = str1.toStdString();
std::string r;
@@ -560,10 +580,14 @@ void tst_qregexp::matchReplaceBoost()
r = boost::regex_replace (s, pattern, "$1");
}
QCOMPARE(r, std::string("eaeaae"));
+#else
+ QSKIP("Boost is not enabled for this platform");
+#endif
}
void tst_qregexp::horribleWrongReplaceBoost()
{
+#ifdef HAVE_BOOST
boost::regex pattern (".*#""define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+)\".*", boost::regex_constants::perl);
std::string s = str2.toStdString();
std::string r;
@@ -571,10 +595,14 @@ void tst_qregexp::horribleWrongReplaceBoost()
r = boost::regex_replace (s, pattern, "$1.$2.$3");
}
QCOMPARE(r, s);
+#else
+ QSKIP("Boost is not enabled for this platform");
+#endif
}
void tst_qregexp::horribleReplaceBoost()
{
+#ifdef HAVE_BOOST
boost::regex pattern (".*#""define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+).*", boost::regex_constants::perl);
std::string s = str2.toStdString();
std::string r;
@@ -582,8 +610,10 @@ void tst_qregexp::horribleReplaceBoost()
r = boost::regex_replace (s, pattern, "$1.$2.$3");
}
QCOMPARE(r, std::string("1.2.3"));
+#else
+ QSKIP("Boost is not enabled for this platform");
+#endif
}
-#endif //HAVE_BOOST
QTEST_MAIN(tst_qregexp)
diff --git a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro
index d194d2b698..8b35ecffed 100644
--- a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro
+++ b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro
@@ -11,9 +11,11 @@ qtHaveModule(script):!pcre {
QT += script
}
-exists($$[QT_SYSROOT]/usr/include/boost/regex.hpp) {
-DEFINES+=HAVE_BOOST
-LIBS+=-lboost_regex
+!qnx {
+ exists($$[QT_SYSROOT]/usr/include/boost/regex.hpp) {
+ DEFINES += HAVE_BOOST
+ LIBS += -lboost_regex
+ }
}
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/manual/cocoa/popups/main.cpp b/tests/manual/cocoa/popups/main.cpp
new file mode 100644
index 0000000000..46249d6772
--- /dev/null
+++ b/tests/manual/cocoa/popups/main.cpp
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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.
+**
+** 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.
+**
+** 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window();
+
+public slots:
+ void triggered(QAction*);
+ void clean();
+ void showPoppWindow();
+
+private:
+ QLabel *explanation;
+ QToolButton *toolButton;
+ QMenu *menu;
+ QLineEdit *echo;
+ QComboBox *comboBox;
+ QPushButton *pushButton;
+};
+
+Window::Window()
+{
+ QGroupBox* group = new QGroupBox(tr("test the popup"));
+
+ explanation = new QLabel(
+ "This test is used to verify that popup windows will be closed "
+ "as expected. This includes when clicking outside the popup or moving the "
+ "parent window. Tested popups include context menus, combo box popups, tooltips "
+ "and QWindow with Qt::Popup set."
+ );
+ explanation->setWordWrap(true);
+ explanation->setToolTip("I'm a tool tip!");
+
+ menu = new QMenu(group);
+ menu->addAction(tr("line one"));
+ menu->addAction(tr("line two"));
+ menu->addAction(tr("line three"));
+ menu->addAction(tr("line four"));
+ menu->addAction(tr("line five"));
+
+ QMenu *subMenu1 = new QMenu();
+ subMenu1->addAction("1");
+ subMenu1->addAction("2");
+ subMenu1->addAction("3");
+ menu->addMenu(subMenu1);
+
+ QMenu *subMenu2 = new QMenu();
+ subMenu2->addAction("2 1");
+ subMenu2->addAction("2 2");
+ subMenu2->addAction("2 3");
+ menu->addMenu(subMenu2);
+
+ toolButton = new QToolButton(group);
+ toolButton->setMenu(menu);
+ toolButton->setPopupMode( QToolButton::MenuButtonPopup );
+ toolButton->setText("select me");
+
+ echo = new QLineEdit(group);
+ echo->setPlaceholderText("not triggered");
+
+ connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(triggered(QAction*)));
+ connect(menu, SIGNAL(aboutToShow()), this, SLOT(clean()));
+
+ comboBox = new QComboBox();
+ comboBox->addItem("Item 1");
+ comboBox->addItem("Item 2");
+ comboBox->addItem("Item 3");
+
+ pushButton = new QPushButton("Show popup window");
+ connect(pushButton, SIGNAL(clicked()), this, SLOT(showPoppWindow()));
+
+ QVBoxLayout* layout = new QVBoxLayout;
+ layout->addWidget(explanation);
+ layout->addWidget(toolButton);
+ layout->addWidget(echo);
+ layout->addWidget(comboBox);
+ layout->addWidget(pushButton);
+
+ group ->setLayout(layout);
+ setLayout(layout);
+ setWindowTitle(tr("Popup Window Testing"));
+}
+
+void Window::clean()
+{
+ echo->setText("");
+}
+
+void Window::showPoppWindow()
+{
+ QWindow *window = new QWindow();
+ window->setTransientParent(this->windowHandle());
+ window->setPosition(this->pos());
+ window->setWidth(100);
+ window->setHeight(100);
+ window->setFlags(Qt::Window | Qt::Popup);
+ window->show();
+}
+
+void Window::triggered(QAction* act)
+{
+ if (!act)
+ return;
+ echo->setText(act->text());
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Window window;
+ window.show();
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/cocoa/popups/popups.pro b/tests/manual/cocoa/popups/popups.pro
new file mode 100644
index 0000000000..d0a3d44171
--- /dev/null
+++ b/tests/manual/cocoa/popups/popups.pro
@@ -0,0 +1,4 @@
+QT += widgets
+
+SOURCES = main.cpp
+CONFIG -= app_bundle