summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp41
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp48
-rw-r--r--tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp186
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp103
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp17
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp19
-rw-r--r--tests/auto/gui/qopenglconfig/buglist.json8
-rw-r--r--tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp38
-rw-r--r--tests/auto/other/headersclean/headersclean.pro3
-rw-r--r--tests/auto/other/macnativeevents/BLACKLIST11
-rw-r--r--tests/auto/other/macnativeevents/macnativeevents.pro1
-rw-r--r--tests/auto/other/other.pro5
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp7
-rw-r--r--tests/benchmarks/gui/image/image.pro1
-rw-r--r--tests/benchmarks/gui/image/qimagescale/qimagescale.pro4
-rw-r--r--tests/benchmarks/gui/image/qimagescale/tst_qimagescale.cpp140
-rw-r--r--tests/manual/cocoa/appicon/README3
-rw-r--r--tests/manual/cocoa/appicon/appicon.pro4
-rw-r--r--tests/manual/cocoa/appicon/main.cpp68
19 files changed, 608 insertions, 99 deletions
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index caa22db144..e8a7105f6e 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -90,6 +90,8 @@ private slots:
void entryList_data();
void entryList();
+ void entryListTimedSort();
+
void entryListSimple_data();
void entryListSimple();
@@ -831,6 +833,45 @@ void tst_QDir::entryList()
QFile::remove(entrylistPath + "brokenlink");
}
+void tst_QDir::entryListTimedSort()
+{
+#ifndef QT_NO_PROCESS
+ const QString touchBinary = "/bin/touch";
+ if (!QFile::exists(touchBinary))
+ QSKIP("/bin/touch not found");
+
+ const QString entrylistPath = m_dataPath + "/entrylist/";
+ QTemporaryFile aFile(entrylistPath + "A-XXXXXX.qws");
+ QTemporaryFile bFile(entrylistPath + "B-XXXXXX.qws");
+
+ QVERIFY(aFile.open());
+ QVERIFY(bFile.open());
+ {
+ QProcess p;
+ p.start(touchBinary, QStringList() << "-t" << "201306021513" << aFile.fileName());
+ QVERIFY(p.waitForFinished(1000));
+ }
+ {
+ QProcess p;
+ p.start(touchBinary, QStringList() << "-t" << "201504131513" << bFile.fileName());
+ QVERIFY(p.waitForFinished(1000));
+ }
+
+ QStringList actual = QDir(entrylistPath).entryList(QStringList() << "*.qws", QDir::NoFilter,
+ QDir::Time);
+
+ QFileInfo aFileInfo(aFile);
+ QFileInfo bFileInfo(bFile);
+ QVERIFY(bFileInfo.lastModified().msecsTo(aFileInfo.lastModified()) < 0);
+
+ QCOMPARE(actual.size(), 2);
+ QCOMPARE(actual.first(), bFileInfo.fileName());
+ QCOMPARE(actual.last(), aFileInfo.fileName());
+#else
+ QSKIP("This test requires QProcess support.");
+#endif // QT_NO_PROCESS
+}
+
void tst_QDir::entryListSimple_data()
{
QTest::addColumn<QString>("dirName");
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 88b1bebb29..b3333c6d68 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -1254,6 +1254,54 @@ void tst_QMetaType::registerType()
QCOMPARE(qRegisterMetaType<MyFoo>("MyFoo"), fooId);
QCOMPARE(QMetaType::type("MyFoo"), fooId);
+
+ // cannot unregister built-in types
+ QVERIFY(!QMetaType::unregisterType(QMetaType::QString));
+ QCOMPARE(QMetaType::type("QString"), int(QMetaType::QString));
+ QCOMPARE(QMetaType::type("MyString"), int(QMetaType::QString));
+
+ // cannot unregister declared types
+ QVERIFY(!QMetaType::unregisterType(fooId));
+ QCOMPARE(QMetaType::type("TestSpace::Foo"), fooId);
+ QCOMPARE(QMetaType::type("MyFoo"), fooId);
+
+ // test unregistration of dynamic types (used by Qml)
+ int unregId = QMetaType::registerType("UnregisterMe",
+ 0,
+ 0,
+ QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Destruct,
+ QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Construct,
+ 0, QMetaType::TypeFlags(), 0);
+ QCOMPARE(QMetaType::registerTypedef("UnregisterMeTypedef", unregId), unregId);
+ int unregId2 = QMetaType::registerType("UnregisterMe2",
+ 0,
+ 0,
+ QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Destruct,
+ QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Construct,
+ 0, QMetaType::TypeFlags(), 0);
+ QVERIFY(unregId >= int(QMetaType::User));
+ QCOMPARE(unregId2, unregId + 2);
+
+ QVERIFY(QMetaType::unregisterType(unregId));
+ QCOMPARE(QMetaType::type("UnregisterMe"), 0);
+ QCOMPARE(QMetaType::type("UnregisterMeTypedef"), 0);
+ QCOMPARE(QMetaType::type("UnregisterMe2"), unregId2);
+ QVERIFY(QMetaType::unregisterType(unregId2));
+ QCOMPARE(QMetaType::type("UnregisterMe2"), 0);
+
+ // re-registering should always return the lowest free index
+ QCOMPARE(QMetaType::registerType("UnregisterMe2",
+ 0,
+ 0,
+ QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Destruct,
+ QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Construct,
+ 0, QMetaType::TypeFlags(), 0), unregId);
+ QCOMPARE(QMetaType::registerType("UnregisterMe",
+ 0,
+ 0,
+ QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Destruct,
+ QtMetaTypePrivate::QMetaTypeFunctionHelper<void>::Construct,
+ 0, QMetaType::TypeFlags(), 0), unregId + 1);
}
class IsRegisteredDummyType { };
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
index 6e51f8f0ed..96d0a62f6b 100644
--- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
@@ -244,6 +244,9 @@ private slots:
void signalTransitionSenderInDifferentThread2();
void signalTransitionRegistrationThreadSafety();
void childModeConstructor();
+
+ void qtbug_44963();
+ void qtbug_44783();
};
class TestState : public QState
@@ -908,8 +911,11 @@ void tst_QStateMachine::historyStateHasNowhereToGo()
QStateMachine machine;
QState *initialState = new QState(&machine);
+ initialState->setObjectName("initialState");
machine.setInitialState(initialState);
- machine.setErrorState(new QState(&machine)); // avoid warnings
+ QState *errorState = new QState(&machine);
+ errorState->setObjectName("errorState");
+ machine.setErrorState(errorState); // avoid warnings
QState *brokenState = new QState(&machine);
brokenState->setObjectName("brokenState");
@@ -917,7 +923,9 @@ void tst_QStateMachine::historyStateHasNowhereToGo()
QHistoryState *historyState = new QHistoryState(brokenState);
historyState->setObjectName("historyState");
- initialState->addTransition(new EventTransition(QEvent::User, historyState));
+ EventTransition *t = new EventTransition(QEvent::User, historyState);
+ t->setObjectName("initialState->historyState");
+ initialState->addTransition(t);
machine.start();
QCoreApplication::processEvents();
@@ -4272,6 +4280,11 @@ void tst_QStateMachine::transitionsFromParallelStateWithNoChildren()
void tst_QStateMachine::parallelStateTransition()
{
+ // This test checks if the parallel state is exited and re-entered if one compound state
+ // is exited and subsequently re-entered. When the parallel state is exited, the other compound
+ // state in the parallel state has to be exited too. When the parallel state is re-entered, the
+ // other state also needs to be re-entered.
+
QStateMachine machine;
QState *parallelState = new QState(QState::ParallelStates, &machine);
@@ -4300,12 +4313,16 @@ void tst_QStateMachine::parallelStateTransition()
s1OtherChild->setObjectName("s1OtherChild");
DEFINE_ACTIVE_SPY(s1OtherChild);
+ // The following transition will exit s1 (which means that parallelState is also exited), and
+ // subsequently re-entered (which means that parallelState is also re-entered).
EventTransition *et = new EventTransition(QEvent::User, s1OtherChild);
et->setObjectName("s1->s1OtherChild");
s1->addTransition(et);
machine.start();
QCoreApplication::processEvents();
+
+ // Initial entrance of the parallel state and its sub-states:
TEST_ACTIVE_CHANGED(parallelState, 1);
TEST_ACTIVE_CHANGED(s1, 1);
TEST_ACTIVE_CHANGED(s1InitialChild, 1);
@@ -4323,22 +4340,22 @@ void tst_QStateMachine::parallelStateTransition()
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
- TEST_ACTIVE_CHANGED(parallelState, 1);
- TEST_ACTIVE_CHANGED(s1, 3);
- TEST_ACTIVE_CHANGED(s1InitialChild, 2);
- TEST_ACTIVE_CHANGED(s2, 3);
- TEST_ACTIVE_CHANGED(s2InitialChild, 3);
- TEST_ACTIVE_CHANGED(s1OtherChild, 1);
+ TEST_ACTIVE_CHANGED(parallelState, 3); // initial + exit + entry
+ TEST_ACTIVE_CHANGED(s1, 3); // initial + exit + entry
+ TEST_ACTIVE_CHANGED(s1InitialChild, 2); // initial + exit
+ TEST_ACTIVE_CHANGED(s2, 3); // initial + exit due to parent exit + entry due to parent re-entry
+ TEST_ACTIVE_CHANGED(s2InitialChild, 3); // initial + exit due to parent exit + re-entry due to parent re-entry
+ TEST_ACTIVE_CHANGED(s1OtherChild, 1); // entry due to transition
QVERIFY(machine.isRunning());
+ // Check that s1InitialChild is not in the configuration, because although s1 is re-entered,
+ // another child state (s1OtherChild) is active, so the initial child should not be activated.
QVERIFY(machine.configuration().contains(parallelState));
-
QVERIFY(machine.configuration().contains(s1));
QVERIFY(machine.configuration().contains(s2));
QVERIFY(machine.configuration().contains(s1OtherChild));
QVERIFY(machine.configuration().contains(s2InitialChild));
QCOMPARE(machine.configuration().size(), 5);
-
}
void tst_QStateMachine::nestedRestoreProperties()
@@ -6169,5 +6186,154 @@ void tst_QStateMachine::childModeConstructor()
}
}
+void tst_QStateMachine::qtbug_44963()
+{
+ SignalEmitter emitter;
+
+ QStateMachine machine;
+ QState a(QState::ParallelStates, &machine);
+ QHistoryState ha(QHistoryState::DeepHistory, &a);
+ QState b(QState::ParallelStates, &a);
+ QState c(QState::ParallelStates, &b);
+ QState d(QState::ParallelStates, &c);
+ QState e(QState::ParallelStates, &d);
+ QState i(&e);
+ QState i1(&i);
+ QState i2(&i);
+ QState j(&e);
+ QState h(&d);
+ QState g(&c);
+ QState k(&a);
+ QState l(&machine);
+
+ machine.setInitialState(&a);
+ ha.setDefaultState(&b);
+ i.setInitialState(&i1);
+ i1.addTransition(&emitter, SIGNAL(signalWithIntArg(int)), &i2)->setObjectName("i1->i2");
+ i2.addTransition(&emitter, SIGNAL(signalWithDefaultArg(int)), &l)->setObjectName("i2->l");
+ l.addTransition(&emitter, SIGNAL(signalWithNoArg()), &ha)->setObjectName("l->ha");
+
+ a.setObjectName("a");
+ ha.setObjectName("ha");
+ b.setObjectName("b");
+ c.setObjectName("c");
+ d.setObjectName("d");
+ e.setObjectName("e");
+ i.setObjectName("i");
+ i1.setObjectName("i1");
+ i2.setObjectName("i2");
+ j.setObjectName("j");
+ h.setObjectName("h");
+ g.setObjectName("g");
+ k.setObjectName("k");
+ l.setObjectName("l");
+
+ machine.start();
+
+ QTRY_COMPARE(machine.configuration().contains(&i1), true);
+ QTRY_COMPARE(machine.configuration().contains(&i2), false);
+ QTRY_COMPARE(machine.configuration().contains(&j), true);
+ QTRY_COMPARE(machine.configuration().contains(&h), true);
+ QTRY_COMPARE(machine.configuration().contains(&g), true);
+ QTRY_COMPARE(machine.configuration().contains(&k), true);
+ QTRY_COMPARE(machine.configuration().contains(&l), false);
+
+ emitter.emitSignalWithIntArg(0);
+
+ QTRY_COMPARE(machine.configuration().contains(&i1), false);
+ QTRY_COMPARE(machine.configuration().contains(&i2), true);
+ QTRY_COMPARE(machine.configuration().contains(&j), true);
+ QTRY_COMPARE(machine.configuration().contains(&h), true);
+ QTRY_COMPARE(machine.configuration().contains(&g), true);
+ QTRY_COMPARE(machine.configuration().contains(&k), true);
+ QTRY_COMPARE(machine.configuration().contains(&l), false);
+
+ emitter.emitSignalWithDefaultArg();
+
+ QTRY_COMPARE(machine.configuration().contains(&i1), false);
+ QTRY_COMPARE(machine.configuration().contains(&i2), false);
+ QTRY_COMPARE(machine.configuration().contains(&j), false);
+ QTRY_COMPARE(machine.configuration().contains(&h), false);
+ QTRY_COMPARE(machine.configuration().contains(&g), false);
+ QTRY_COMPARE(machine.configuration().contains(&k), false);
+ QTRY_COMPARE(machine.configuration().contains(&l), true);
+
+ emitter.emitSignalWithNoArg();
+
+ QTRY_COMPARE(machine.configuration().contains(&i1), false);
+ QTRY_COMPARE(machine.configuration().contains(&i2), true);
+ QTRY_COMPARE(machine.configuration().contains(&j), true);
+ QTRY_COMPARE(machine.configuration().contains(&h), true);
+ QTRY_COMPARE(machine.configuration().contains(&g), true);
+ QTRY_COMPARE(machine.configuration().contains(&k), true);
+ QTRY_COMPARE(machine.configuration().contains(&l), false);
+
+ QVERIFY(machine.isRunning());
+}
+
+void tst_QStateMachine::qtbug_44783()
+{
+ SignalEmitter emitter;
+
+ QStateMachine machine;
+ QState s(&machine);
+ QState p(QState::ParallelStates, &s);
+ QState p1(&p);
+ QState p1_1(&p1);
+ QState p1_2(&p1);
+ QState p2(&p);
+ QState s1(&machine);
+
+ machine.setInitialState(&s);
+ s.setInitialState(&p);
+ p1.setInitialState(&p1_1);
+ p1_1.addTransition(&emitter, SIGNAL(signalWithNoArg()), &p1_2)->setObjectName("p1_1->p1_2");
+ p2.addTransition(&emitter, SIGNAL(signalWithNoArg()), &s1)->setObjectName("p2->s1");
+
+ s.setObjectName("s");
+ p.setObjectName("p");
+ p1.setObjectName("p1");
+ p1_1.setObjectName("p1_1");
+ p1_2.setObjectName("p1_2");
+ p2.setObjectName("p2");
+ s1.setObjectName("s1");
+
+ machine.start();
+
+ QTRY_COMPARE(machine.configuration().contains(&s), true);
+ QTRY_COMPARE(machine.configuration().contains(&p), true);
+ QTRY_COMPARE(machine.configuration().contains(&p1), true);
+ QTRY_COMPARE(machine.configuration().contains(&p1_1), true);
+ QTRY_COMPARE(machine.configuration().contains(&p1_2), false);
+ QTRY_COMPARE(machine.configuration().contains(&p2), true);
+ QTRY_COMPARE(machine.configuration().contains(&s1), false);
+
+ emitter.emitSignalWithNoArg();
+
+ // Only one of the following two can be true, because the two possible transitions conflict.
+ if (machine.configuration().contains(&s1)) {
+ // the transition p2 -> s1 was taken, not p1_1 -> p1_2, so:
+ // the parallel state exited, so none of the states inside it are active
+ QTRY_COMPARE(machine.configuration().contains(&s), false);
+ QTRY_COMPARE(machine.configuration().contains(&p), false);
+ QTRY_COMPARE(machine.configuration().contains(&p1), false);
+ QTRY_COMPARE(machine.configuration().contains(&p1_1), false);
+ QTRY_COMPARE(machine.configuration().contains(&p1_2), false);
+ QTRY_COMPARE(machine.configuration().contains(&p2), false);
+ } else {
+ // the transition p1_1 -> p1_2 was taken, not p2 -> s1, so:
+ // the parallel state was not exited and the state is the same as the start state with one
+ // difference: p1_1 inactive and p1_2 active:
+ QTRY_COMPARE(machine.configuration().contains(&s), true);
+ QTRY_COMPARE(machine.configuration().contains(&p), true);
+ QTRY_COMPARE(machine.configuration().contains(&p1), true);
+ QTRY_COMPARE(machine.configuration().contains(&p1_1), false);
+ QTRY_COMPARE(machine.configuration().contains(&p1_2), true);
+ QTRY_COMPARE(machine.configuration().contains(&p2), true);
+ }
+
+ QVERIFY(machine.isRunning());
+}
+
QTEST_MAIN(tst_QStateMachine)
#include "tst_qstatemachine.moc"
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 660809fb16..525d5b33a0 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -108,6 +108,7 @@ private slots:
void cacheKey();
void smoothScale();
+ void smoothScale2_data();
void smoothScale2();
void smoothScale3();
@@ -1539,58 +1540,68 @@ void tst_QImage::smoothScale()
}
// test area sampling
-void tst_QImage::smoothScale2()
+void tst_QImage::smoothScale2_data()
{
- int sizes[] = { 2, 4, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128, 0 };
- QImage::Format formats[] = { QImage::Format_ARGB32, QImage::Format_RGB32, QImage::Format_Invalid };
- for (int i = 0; sizes[i] != 0; ++i) {
- for (int j = 0; formats[j] != QImage::Format_Invalid; ++j) {
- int size = sizes[i];
-
- QRgb expected = formats[j] == QImage::Format_ARGB32 ? qRgba(63, 127, 255, 255) : qRgb(63, 127, 255);
-
- QImage img(size, size, formats[j]);
- img.fill(expected);
+ QTest::addColumn<int>("format");
+ QTest::addColumn<int>("size");
+
+ int sizes[] = { 2, 3, 4, 6, 7, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128, 0 };
+ QImage::Format formats[] = { QImage::Format_RGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_Invalid };
+ for (int j = 0; formats[j] != QImage::Format_Invalid; ++j) {
+ QString formatstr = formats[j] == QImage::Format_RGB32 ? QStringLiteral("rgb32") : QStringLiteral("argb32pm");
+ for (int i = 0; sizes[i] != 0; ++i) {
+ QTest::newRow(QString("%1 %2x%2").arg(formatstr).arg(sizes[i]).toUtf8()) << (int)formats[j] << sizes[i];
+ }
+ }
+}
- // scale x down, y down
- QImage scaled = img.scaled(QSize(1, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- QRgb pixel = scaled.pixel(0, 0);
+void tst_QImage::smoothScale2()
+{
+ QFETCH(int, format);
+ QFETCH(int, size);
+
+ QRgb expected = format == QImage::Format_RGB32 ? qRgb(63, 127, 255) : qRgba(31, 63, 127, 127);
+
+ QImage img(size, size, (QImage::Format)format);
+ img.fill(expected);
+
+ // scale x down, y down
+ QImage scaled = img.scaled(QSize(1, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ QRgb pixel = scaled.pixel(0, 0);
+ QCOMPARE(qAlpha(pixel), qAlpha(expected));
+ QCOMPARE(qRed(pixel), qRed(expected));
+ QCOMPARE(qGreen(pixel), qGreen(expected));
+ QCOMPARE(qBlue(pixel), qBlue(expected));
+
+ // scale x down, y up
+ scaled = img.scaled(QSize(1, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ pixel = scaled.pixel(0, y);
+ QCOMPARE(qAlpha(pixel), qAlpha(expected));
+ QCOMPARE(qRed(pixel), qRed(expected));
+ QCOMPARE(qGreen(pixel), qGreen(expected));
+ QCOMPARE(qBlue(pixel), qBlue(expected));
+ }
+
+ // scale x up, y down
+ scaled = img.scaled(QSize(size * 2, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = scaled.pixel(x, 0);
+ QCOMPARE(qAlpha(pixel), qAlpha(expected));
+ QCOMPARE(qRed(pixel), qRed(expected));
+ QCOMPARE(qGreen(pixel), qGreen(expected));
+ QCOMPARE(qBlue(pixel), qBlue(expected));
+ }
+
+ // scale x up, y up
+ scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = scaled.pixel(x, y);
QCOMPARE(qAlpha(pixel), qAlpha(expected));
QCOMPARE(qRed(pixel), qRed(expected));
QCOMPARE(qGreen(pixel), qGreen(expected));
QCOMPARE(qBlue(pixel), qBlue(expected));
-
- // scale x down, y up
- scaled = img.scaled(QSize(1, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- for (int y = 0; y < scaled.height(); ++y) {
- pixel = scaled.pixel(0, y);
- QCOMPARE(qAlpha(pixel), qAlpha(expected));
- QCOMPARE(qRed(pixel), qRed(expected));
- QCOMPARE(qGreen(pixel), qGreen(expected));
- QCOMPARE(qBlue(pixel), qBlue(expected));
- }
-
- // scale x up, y down
- scaled = img.scaled(QSize(size * 2, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- for (int x = 0; x < scaled.width(); ++x) {
- pixel = scaled.pixel(x, 0);
- QCOMPARE(qAlpha(pixel), qAlpha(expected));
- QCOMPARE(qRed(pixel), qRed(expected));
- QCOMPARE(qGreen(pixel), qGreen(expected));
- QCOMPARE(qBlue(pixel), qBlue(expected));
- }
-
- // scale x up, y up
- scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- for (int y = 0; y < scaled.height(); ++y) {
- for (int x = 0; x < scaled.width(); ++x) {
- pixel = scaled.pixel(x, y);
- QCOMPARE(qAlpha(pixel), qAlpha(expected));
- QCOMPARE(qRed(pixel), qRed(expected));
- QCOMPARE(qGreen(pixel), qGreen(expected));
- QCOMPARE(qBlue(pixel), qBlue(expected));
- }
- }
}
}
}
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index b921e1519f..19365bffdd 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -76,6 +76,7 @@ private slots:
void genericPluginsAndWindowSystemEvents();
void layoutDirection();
void globalShareContext();
+ void testSetPaletteAttribute();
void staticFunctions();
@@ -968,6 +969,22 @@ void tst_QGuiApplication::globalShareContext()
#endif
}
+void tst_QGuiApplication::testSetPaletteAttribute()
+{
+ QCoreApplication::setAttribute(Qt::AA_SetPalette, false);
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication") };
+
+ QGuiApplication app(argc, argv);
+
+ QVERIFY(!QCoreApplication::testAttribute(Qt::AA_SetPalette));
+ QPalette palette;
+ palette.setColor(QPalette::Foreground, Qt::red);
+ QGuiApplication::setPalette(palette);
+
+ QVERIFY(QCoreApplication::testAttribute(Qt::AA_SetPalette));
+}
+
// Test that static functions do not crash if there is no application instance.
void tst_QGuiApplication::staticFunctions()
{
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 7d17794c0b..ca9f6cb9f4 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -39,7 +39,6 @@
#include <qcolor.h>
#include <qdebug.h>
#include <qrgba64.h>
-#include <private/qdrawingprimitive_sse2_p.h>
class tst_QColor : public QObject
{
@@ -105,7 +104,6 @@ private slots:
void achromaticHslHue();
void premultiply();
- void unpremultiply_sse4();
void qrgba64();
void qrgba64Premultiply();
void qrgba64Equivalence();
@@ -1451,23 +1449,6 @@ void tst_QColor::premultiply()
}
}
-void tst_QColor::unpremultiply_sse4()
-{
- // Tests that qUnpremultiply_sse4 returns the same as qUnpremultiply.
-#if QT_COMPILER_SUPPORTS_HERE(SSE4_1)
- if (qCpuHasFeature(SSE4_1)) {
- for (uint a = 0; a < 256; a++) {
- for (uint c = 0; c <= a; c++) {
- QRgb p = qRgba(c, a-c, c, a);
- QCOMPARE(qUnpremultiply_sse4(p), qUnpremultiply(p));
- }
- }
- return;
- }
-#endif
- QSKIP("SSE4 not supported on this CPU.");
-}
-
void tst_QColor::qrgba64()
{
QRgba64 rgb64 = QRgba64::fromRgba(0x22, 0x33, 0x44, 0xff);
diff --git a/tests/auto/gui/qopenglconfig/buglist.json b/tests/auto/gui/qopenglconfig/buglist.json
index d2d06645aa..c7b8e61bc8 100644
--- a/tests/auto/gui/qopenglconfig/buglist.json
+++ b/tests/auto/gui/qopenglconfig/buglist.json
@@ -101,6 +101,14 @@
"features": [
"feature1"
]
+ },
+ {
+ "id": 128,
+ "description": "check for matching GL_VENDOR",
+ "gl_vendor": "The Qt Company",
+ "features": [
+ "cool_feature"
+ ]
}
]
}
diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
index bfb2623508..f88cbdc758 100644
--- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
+++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
@@ -217,6 +217,11 @@ void tst_QOpenGlConfig::testGlConfiguration()
context.doneCurrent();
qDebug().noquote() << '\n' << result;
+
+ // fromContext either uses the current context or creates a temporary dummy one.
+ QOpenGLConfig::Gpu gpu = QOpenGLConfig::Gpu::fromContext();
+ qDebug().noquote() << '\n' << "GL_VENDOR queried by QOpenGLConfig::Gpu:" << gpu.glVendor;
+ QVERIFY(!gpu.glVendor.isEmpty());
}
static inline QByteArray msgSetMismatch(const QSet<QString> &expected,
@@ -235,21 +240,28 @@ void tst_QOpenGlConfig::testBugList()
const QString fileName = QFINDTESTDATA("buglist.json");
QVERIFY(!fileName.isEmpty());
- QSet<QString> expectedFeatures;
- expectedFeatures << "feature1";
+ QSet<QString> expectedFeatures;
+ expectedFeatures << "feature1";
- QOpenGLConfig::Gpu gpu;
- gpu.vendorId = 0x10DE;
- gpu.deviceId = 0x0DE9;
+ QVersionNumber driverVersion(QVector<int>() << 9 << 18 << 13 << 4460);
+ QOpenGLConfig::Gpu gpu = QOpenGLConfig::Gpu::fromDevice(0x10DE, 0x0DE9, driverVersion);
-#ifdef Q_COMPILER_INITIALIZER_LISTS
- gpu.driverVersion = QVersionNumber({9, 18, 13, 4460});
-#else
- gpu.driverVersion = QVersionNumber(QVector<int>() << 9 << 18 << 13 << 4460);
-#endif
- const QSet<QString> actualFeatures =
- QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"),
- QVersionNumber(6, 3), fileName);
+ QSet<QString> actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"),
+ QVersionNumber(6, 3), fileName);
+ QVERIFY2(expectedFeatures == actualFeatures,
+ msgSetMismatch(expectedFeatures, actualFeatures));
+
+ gpu = QOpenGLConfig::Gpu::fromGLVendor(QByteArrayLiteral("Somebody Else"));
+ expectedFeatures.clear();
+ actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("linux"),
+ QVersionNumber(1, 0), fileName);
+ QVERIFY2(expectedFeatures == actualFeatures,
+ msgSetMismatch(expectedFeatures, actualFeatures));
+
+ gpu = QOpenGLConfig::Gpu::fromGLVendor(QByteArrayLiteral("The Qt Company"));
+ expectedFeatures = QSet<QString>() << "cool_feature";
+ actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("linux"),
+ QVersionNumber(1, 0), fileName);
QVERIFY2(expectedFeatures == actualFeatures,
msgSetMismatch(expectedFeatures, actualFeatures));
}
diff --git a/tests/auto/other/headersclean/headersclean.pro b/tests/auto/other/headersclean/headersclean.pro
deleted file mode 100644
index 73e0c5dd56..0000000000
--- a/tests/auto/other/headersclean/headersclean.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-QT = core concurrent network dbus xml sql testlib gui opengl widgets printsupport platformsupport-private
-load(qt_headersclean)
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/other/macnativeevents/BLACKLIST b/tests/auto/other/macnativeevents/BLACKLIST
new file mode 100644
index 0000000000..2820457075
--- /dev/null
+++ b/tests/auto/other/macnativeevents/BLACKLIST
@@ -0,0 +1,11 @@
+# QTBUG-22775
+[testDragWindow]
+osx
+[testMouseEnter]
+osx-10.9
+[testChildDialogInFrontOfModalParent]
+osx
+[testChildWindowInFrontOfStaysOnTopParentWindow]
+osx
+[testModifierCtrlWithDontSwapCtrlAndMeta]
+osx
diff --git a/tests/auto/other/macnativeevents/macnativeevents.pro b/tests/auto/other/macnativeevents/macnativeevents.pro
index e958f414e0..48ad04bbff 100644
--- a/tests/auto/other/macnativeevents/macnativeevents.pro
+++ b/tests/auto/other/macnativeevents/macnativeevents.pro
@@ -8,5 +8,4 @@ SOURCES += expectedeventlist.cpp nativeeventlist.cpp
SOURCES += tst_macnativeevents.cpp
requires(mac)
-CONFIG += insignificant_test # QTBUG-22775
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index 6e8f1e3c9c..a5ed4c5f31 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -4,7 +4,6 @@ SUBDIRS=\
baselineexample \
compiler \
gestures \
- headersclean \
lancelot \
languagechange \
macgui \
@@ -29,7 +28,6 @@ SUBDIRS=\
!qtHaveModule(widgets): SUBDIRS -= \
baselineexample \
gestures \
- headersclean \
lancelot \
languagechange \
modeltest \
@@ -44,14 +42,11 @@ SUBDIRS=\
!qtHaveModule(network): SUBDIRS -= \
baselineexample \
- headersclean \
lancelot \
networkselftest \
qnetworkaccessmanager_and_qprogressdialog \
qobjectperformance
-testcocoon: SUBDIRS -= headersclean
-
cross_compile: SUBDIRS -= \
atwrapper \
compiler
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index abcd06c628..e677891ce5 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -235,13 +235,16 @@ void tst_QFiledialog::directoryEnteredSignal()
{
QNonNativeFileDialog fd(0, "", QDir::root().path());
fd.setOptions(QFileDialog::DontUseNativeDialog);
+ QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
+ QVERIFY(sidebar);
+ if (sidebar->model()->rowCount() < 2)
+ QSKIP("This test requires at least 2 side bar entries.");
+
fd.show();
QTRY_COMPARE(fd.isVisible(), true);
QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString)));
// sidebar
- QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
- QVERIFY(sidebar->model()->rowCount() >= 2);
QModelIndex secondItem = sidebar->model()->index(1, 0);
QVERIFY(secondItem.isValid());
sidebar->setCurrentIndex(secondItem);
diff --git a/tests/benchmarks/gui/image/image.pro b/tests/benchmarks/gui/image/image.pro
index 71228f4499..89008290fc 100644
--- a/tests/benchmarks/gui/image/image.pro
+++ b/tests/benchmarks/gui/image/image.pro
@@ -3,6 +3,7 @@ SUBDIRS = \
blendbench \
qimageconversion \
qimagereader \
+ qimagescale \
qpixmap \
qpixmapcache
diff --git a/tests/benchmarks/gui/image/qimagescale/qimagescale.pro b/tests/benchmarks/gui/image/qimagescale/qimagescale.pro
new file mode 100644
index 0000000000..a576e2c9aa
--- /dev/null
+++ b/tests/benchmarks/gui/image/qimagescale/qimagescale.pro
@@ -0,0 +1,4 @@
+TEMPLATE = app
+TARGET = tst_bench_imageScale
+QT += testlib
+SOURCES += tst_qimagescale.cpp
diff --git a/tests/benchmarks/gui/image/qimagescale/tst_qimagescale.cpp b/tests/benchmarks/gui/image/qimagescale/tst_qimagescale.cpp
new file mode 100644
index 0000000000..58abfdf4da
--- /dev/null
+++ b/tests/benchmarks/gui/image/qimagescale/tst_qimagescale.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** 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 <qtest.h>
+#include <QImage>
+
+class tst_QImageScale : public QObject
+{
+ Q_OBJECT
+private slots:
+ void scaleRgb32_data();
+ void scaleRgb32();
+
+ void scaleArgb32pm_data();
+ void scaleArgb32pm();
+
+private:
+ QImage generateImageRgb32(int width, int height);
+ QImage generateImageArgb32(int width, int height);
+};
+
+void tst_QImageScale::scaleRgb32_data()
+{
+ QTest::addColumn<QImage>("inputImage");
+ QTest::addColumn<QSize>("outputSize");
+
+ QImage image = generateImageRgb32(1000, 1000);
+ QTest::newRow("1000x1000 -> 2000x2000") << image << QSize(2000, 2000);
+ QTest::newRow("1000x1000 -> 2000x1000") << image << QSize(2000, 1000);
+ QTest::newRow("1000x1000 -> 1000x2000") << image << QSize(1000, 2000);
+ QTest::newRow("1000x1000 -> 2000x500") << image << QSize(2000, 500);
+ QTest::newRow("1000x1000 -> 500x2000") << image << QSize(500, 2000);
+ QTest::newRow("1000x1000 -> 500x500") << image << QSize(500, 500);
+ QTest::newRow("1000x1000 -> 200x200") << image << QSize(200, 200);
+}
+
+void tst_QImageScale::scaleRgb32()
+{
+ QFETCH(QImage, inputImage);
+ QFETCH(QSize, outputSize);
+
+ QBENCHMARK {
+ volatile QImage output = inputImage.scaled(outputSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ // we need the volatile and the following to make sure the compiler does not do
+ // anything stupid :)
+ (void)output;
+ }
+}
+
+void tst_QImageScale::scaleArgb32pm_data()
+{
+ QTest::addColumn<QImage>("inputImage");
+ QTest::addColumn<QSize>("outputSize");
+
+ QImage image = generateImageArgb32(1000, 1000).convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ QTest::newRow("1000x1000 -> 2000x2000") << image << QSize(2000, 2000);
+ QTest::newRow("1000x1000 -> 2000x1000") << image << QSize(2000, 1000);
+ QTest::newRow("1000x1000 -> 1000x2000") << image << QSize(1000, 2000);
+ QTest::newRow("1000x1000 -> 2000x500") << image << QSize(2000, 500);
+ QTest::newRow("1000x1000 -> 500x2000") << image << QSize(500, 2000);
+ QTest::newRow("1000x1000 -> 500x500") << image << QSize(500, 500);
+ QTest::newRow("1000x1000 -> 200x200") << image << QSize(200, 200);
+}
+
+void tst_QImageScale::scaleArgb32pm()
+{
+ QFETCH(QImage, inputImage);
+ QFETCH(QSize, outputSize);
+
+ QBENCHMARK {
+ volatile QImage output = inputImage.scaled(outputSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ // we need the volatile and the following to make sure the compiler does not do
+ // anything stupid :)
+ (void)output;
+ }
+}
+
+/*
+ Fill a RGB32 image with "random" pixel values.
+ */
+QImage tst_QImageScale::generateImageRgb32(int width, int height)
+{
+ QImage image(width, height, QImage::Format_RGB32);
+
+ for (int y = 0; y < image.height(); ++y) {
+ QRgb *scanline = (QRgb*)image.scanLine(y);
+ for (int x = 0; x < width; ++x)
+ scanline[x] = qRgb(x, y, x ^ y);
+ }
+ return image;
+}
+
+/*
+ Fill a ARGB32 image with "random" pixel values.
+ */
+QImage tst_QImageScale::generateImageArgb32(int width, int height)
+{
+ QImage image(width, height, QImage::Format_ARGB32);
+ const int byteWidth = width * 4;
+
+ for (int y = 0; y < image.height(); ++y) {
+ uchar *scanline = image.scanLine(y);
+ for (int x = 0; x < byteWidth; ++x)
+ scanline[x] = x ^ y;
+ }
+ return image;
+}
+
+QTEST_MAIN(tst_QImageScale)
+#include "tst_qimagescale.moc"
diff --git a/tests/manual/cocoa/appicon/README b/tests/manual/cocoa/appicon/README
new file mode 100644
index 0000000000..ecef1286ff
--- /dev/null
+++ b/tests/manual/cocoa/appicon/README
@@ -0,0 +1,3 @@
+Test for checking that the dock icon is changed when
+QGuiApplication::setWindowIcon() is called. Clicking the
+buttong should change the entry in the dock to a red icon.
diff --git a/tests/manual/cocoa/appicon/appicon.pro b/tests/manual/cocoa/appicon/appicon.pro
new file mode 100644
index 0000000000..87df7b872c
--- /dev/null
+++ b/tests/manual/cocoa/appicon/appicon.pro
@@ -0,0 +1,4 @@
+QT += widgets
+TEMPLATE = app
+TARGET = appicon
+SOURCES += main.cpp
diff --git a/tests/manual/cocoa/appicon/main.cpp b/tests/manual/cocoa/appicon/main.cpp
new file mode 100644
index 0000000000..9e00e4e64c
--- /dev/null
+++ b/tests/manual/cocoa/appicon/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+ **
+ ** 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 <QApplication>
+#include <QPushButton>
+#include <QVBoxLayout>
+
+class TopWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ TopWidget(QWidget *parent = 0) : QWidget(parent)
+ {
+ QVBoxLayout *layout = new QVBoxLayout;
+ QPushButton *button = new QPushButton("Change app icon");
+ connect(button, SIGNAL(clicked()), this, SLOT(changeIcon()));
+ layout->addWidget(button);
+ setLayout(layout);
+ }
+public slots:
+ void changeIcon()
+ {
+ QPixmap pix(32, 32);
+ pix.fill(Qt::red);
+ QIcon i(pix);
+ qApp->setWindowIcon(i);
+ }
+};
+
+#include "main.moc"
+
+int main(int argc, char **argv)
+{
+ QApplication a(argc, argv);
+ TopWidget w;
+ w.show();
+ return a.exec();
+}