summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp13
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp50
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp20
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp1
-rw-r--r--tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp14
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp6
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp12
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp15
8 files changed, 107 insertions, 24 deletions
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 8d62a38e6b..485b24dc62 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -765,6 +765,19 @@ void tst_QFileInfo::canonicalFilePath()
QDir::current().rmdir(linkTarget);
}
#endif
+
+#ifdef Q_OS_DARWIN
+ {
+ // Check if canonicalFilePath's result is in Composed normalization form.
+ QString path = QString::fromLatin1("caf\xe9");
+ QDir dir(QDir::tempPath());
+ dir.mkdir(path);
+ QString canonical = QFileInfo(dir.filePath(path)).canonicalFilePath();
+ QString roundtrip = QFile::decodeName(QFile::encodeName(canonical));
+ QCOMPARE(canonical, roundtrip);
+ dir.rmdir(path);
+ }
+#endif
}
void tst_QFileInfo::fileName_data()
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 87a801c9dd..ed298bfafa 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -158,6 +158,8 @@ private slots:
void testByteArray();
void iniCodec();
void bom();
+ void embeddedZeroByte_data();
+ void embeddedZeroByte();
private:
void cleanupTestFiles();
@@ -627,7 +629,6 @@ void tst_QSettings::testByteArray_data()
#ifndef QT_NO_COMPRESS
QTest::newRow("compressed") << qCompress(bytes);
#endif
- QTest::newRow("with \\0") << bytes + '\0' + bytes;
}
void tst_QSettings::testByteArray()
@@ -678,6 +679,53 @@ void tst_QSettings::bom()
QVERIFY(allkeys.contains("section2/foo2"));
}
+void tst_QSettings::embeddedZeroByte_data()
+{
+ QTest::addColumn<QVariant>("value");
+
+ QByteArray bytes("hello\0world", 11);
+
+ QTest::newRow("bytearray\\0") << QVariant(bytes);
+ QTest::newRow("string\\0") << QVariant(QString::fromLatin1(bytes.data(), bytes.size()));
+
+ bytes = QByteArray("@String(");
+
+ QTest::newRow("@bytearray") << QVariant(bytes);
+ QTest::newRow("@string") << QVariant(QString(bytes));
+
+ bytes = QByteArray("@String(\0test", 13);
+
+ QTest::newRow("@bytearray\\0") << QVariant(bytes);
+ QTest::newRow("@string\\0") << QVariant(QString::fromLatin1(bytes.data(), bytes.size()));
+}
+
+void tst_QSettings::embeddedZeroByte()
+{
+ QFETCH(QVariant, value);
+ {
+ QSettings settings("QtProject", "tst_qsettings");
+ settings.setValue(QTest::currentDataTag(), value);
+ }
+ {
+ QSettings settings("QtProject", "tst_qsettings");
+ QVariant outValue = settings.value(QTest::currentDataTag());
+
+ switch (value.type()) {
+ case QVariant::ByteArray:
+ QCOMPARE(outValue.toByteArray(), value.toByteArray());
+ break;
+ case QVariant::String:
+ QCOMPARE(outValue.toString(), value.toString());
+ break;
+ default:
+ Q_UNREACHABLE();
+ }
+
+ if (value.toByteArray().contains(QChar::Null))
+ QVERIFY(outValue.toByteArray().contains(QChar::Null));
+ }
+}
+
void tst_QSettings::testErrorHandling_data()
{
QTest::addColumn<int>("filePerms"); // -1 means file should not exist
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 70446e803a..e0010fb8be 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -782,6 +782,24 @@ void tst_QWindow::isActive()
// child has focus
QVERIFY(window.isActive());
+ // test focus back to parent and then back to child (QTBUG-39362)
+ // also verify the cumulative FocusOut and FocusIn counts
+ // activate parent
+ window.requestActivate();
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
+ QVERIFY(window.isActive());
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(child.received(QEvent::FocusOut), 1);
+ QTRY_COMPARE(window.received(QEvent::FocusIn), 2);
+
+ // activate child again
+ child.requestActivate();
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &child);
+ QVERIFY(child.isActive());
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.received(QEvent::FocusOut), 2);
+ QTRY_COMPARE(child.received(QEvent::FocusIn), 2);
+
Window dialog;
dialog.setTransientParent(&window);
dialog.setGeometry(QRect(m_availableTopLeft + QPoint(110, 100), m_testWindowSize));
@@ -806,7 +824,7 @@ void tst_QWindow::isActive()
QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QCoreApplication::processEvents();
QTRY_COMPARE(dialog.received(QEvent::FocusOut), 1);
- QTRY_COMPARE(window.received(QEvent::FocusIn), 2);
+ QTRY_COMPARE(window.received(QEvent::FocusIn), 3);
QVERIFY(window.isActive());
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index 847d6e2e2f..244df5b899 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -842,6 +842,7 @@ void tst_QCssParser::colorValue_data()
QTest::newRow("hsla") << "color: hsva(10, 20, 30, 40)" << QColor::fromHsv(10, 20, 30, 40);
QTest::newRow("invalid1") << "color: rgb(why, does, it, always, rain, on, me)" << QColor();
QTest::newRow("invalid2") << "color: rgba(i, meant, norway)" << QColor();
+ QTest::newRow("invalid3") << "color: rgb(21)" << QColor();
QTest::newRow("role") << "color: palette(base)" << qApp->palette().color(QPalette::Base);
QTest::newRow("role2") << "color: palette( window-text ) " << qApp->palette().color(QPalette::WindowText);
QTest::newRow("transparent") << "color: transparent" << QColor(Qt::transparent);
diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index 8a1a5b8369..849e2d8662 100644
--- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -188,16 +188,16 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
result += cookie;
QTest::newRow("effective-tld1-accepted") << preset << cookie << "http://something.co.uk" << result << true;
- // 2. anything .mz is an effective TLD ('*.mz'), but 'teledata.mz' is an exception
+ // 2. anything .ck is an effective TLD ('*.ck'), but 'www.ck' is an exception
result.clear();
preset.clear();
- cookie.setDomain(".farmacia.mz");
- QTest::newRow("effective-tld2-denied") << preset << cookie << "http://farmacia.mz" << result << false;
- QTest::newRow("effective-tld2-denied2") << preset << cookie << "http://www.farmacia.mz" << result << false;
- QTest::newRow("effective-tld2-denied3") << preset << cookie << "http://www.anything.farmacia.mz" << result << false;
- cookie.setDomain(".teledata.mz");
+ cookie.setDomain(".foo.ck");
+ QTest::newRow("effective-tld2-denied") << preset << cookie << "http://foo.ck" << result << false;
+ QTest::newRow("effective-tld2-denied2") << preset << cookie << "http://www.foo.ck" << result << false;
+ QTest::newRow("effective-tld2-denied3") << preset << cookie << "http://www.anything.foo.ck" << result << false;
+ cookie.setDomain(".www.ck");
result += cookie;
- QTest::newRow("effective-tld2-accepted") << preset << cookie << "http://www.teledata.mz" << result << true;
+ QTest::newRow("effective-tld2-accepted") << preset << cookie << "http://www.www.ck" << result << true;
result.clear();
preset.clear();
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 205067d89c..e6a615d4f5 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -324,7 +324,7 @@ void tst_QAction::enabledVisibleInteraction()
void tst_QAction::task200823_tooltip()
{
- QAction *action = new QAction("foo", 0);
+ const QScopedPointer<QAction> action(new QAction("foo", Q_NULLPTR));
QString shortcut("ctrl+o");
action->setShortcut(shortcut);
@@ -338,8 +338,8 @@ void tst_QAction::task200823_tooltip()
void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
{
// test without a group
- QAction *actionWithoutGroup = new QAction("Test", qApp);
- QSignalSpy spyWithoutGroup(actionWithoutGroup, SIGNAL(triggered(bool)));
+ const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", Q_NULLPTR));
+ QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), SIGNAL(triggered(bool)));
QCOMPARE(spyWithoutGroup.count(), 0);
actionWithoutGroup->trigger();
// signal should be emitted
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index ab9729342c..779773eff0 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -2197,8 +2197,8 @@ void tst_QApplication::noQuitOnHide()
{
int argc = 0;
QApplication app(argc, 0);
- QWidget *window1 = new NoQuitOnHideWidget;
- window1->show();
+ NoQuitOnHideWidget window1;
+ window1.show();
QCOMPARE(app.exec(), 1);
}
@@ -2232,12 +2232,12 @@ void tst_QApplication::abortQuitOnShow()
{
int argc = 0;
QApplication app(argc, 0);
- QWidget *window1 = new ShowCloseShowWidget(false);
- window1->show();
+ ShowCloseShowWidget window1(false);
+ window1.show();
QCOMPARE(app.exec(), 0);
- QWidget *window2 = new ShowCloseShowWidget(true);
- window2->show();
+ ShowCloseShowWidget window2(true);
+ window2.show();
QCOMPARE(app.exec(), 1);
}
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index a19f4aea56..6c7197b85e 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -390,7 +390,8 @@ void tst_QFormLayout::setFormStyle()
QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
#endif
- widget.setStyle(QStyleFactory::create("windows"));
+ const QScopedPointer<QStyle> windowsStyle(QStyleFactory::create("windows"));
+ widget.setStyle(windowsStyle.data());
QCOMPARE(layout.labelAlignment(), Qt::AlignLeft);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
@@ -401,14 +402,16 @@ void tst_QFormLayout::setFormStyle()
this test is cross platform.. so create dummy styles that
return all the right stylehints.
*/
- widget.setStyle(new DummyMacStyle());
+ DummyMacStyle macStyle;
+ widget.setStyle(&macStyle);
QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignHCenter | Qt::AlignTop));
QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::FieldsStayAtSizeHint);
QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
- widget.setStyle(new DummyQtopiaStyle());
+ DummyQtopiaStyle qtopiaStyle;
+ widget.setStyle(&qtopiaStyle);
QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
@@ -886,7 +889,7 @@ void tst_QFormLayout::takeAt()
QCOMPARE(layout->count(), 7);
for (int i = 6; i >= 0; --i) {
- layout->takeAt(0);
+ delete layout->takeAt(0);
QCOMPARE(layout->count(), i);
}
}
@@ -978,7 +981,7 @@ void tst_QFormLayout::replaceWidget()
QFormLayout::ItemRole role;
// replace editor
- layout->replaceWidget(edit1, edit3);
+ delete layout->replaceWidget(edit1, edit3);
edit1->hide(); // Not strictly needed for the test, but for normal usage it is.
QCOMPARE(layout->indexOf(edit1), -1);
QCOMPARE(layout->indexOf(edit3), editIndex);
@@ -989,7 +992,7 @@ void tst_QFormLayout::replaceWidget()
QCOMPARE(rownum, 0);
QCOMPARE(role, QFormLayout::FieldRole);
- layout->replaceWidget(label1, label2);
+ delete layout->replaceWidget(label1, label2);
label1->hide();
QCOMPARE(layout->indexOf(label1), -1);
QCOMPARE(layout->indexOf(label2), labelIndex);