summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp')
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp49
1 files changed, 13 insertions, 36 deletions
diff --git a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
index 31cb036515..4b9a23ffcf 100644
--- a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
+++ b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QTemporaryDir>
#include <QTest>
@@ -79,7 +54,7 @@ void tst_qfileopenevent::cleanupTestCase()
void tst_qfileopenevent::createFile(const QString &filename, const QByteArray &content)
{
QFile file(filename);
- file.open(QFile::WriteOnly);
+ QVERIFY(file.open(QFile::WriteOnly));
file.write(content);
file.close();
}
@@ -103,8 +78,9 @@ void tst_qfileopenevent::constructor()
QByteArray tst_qfileopenevent::readFileContent(QFileOpenEvent& event)
{
- QFile file;
- event.openFile(file, QFile::ReadOnly);
+ QFile file(event.file());
+ if (!file.open(QFile::ReadOnly))
+ qFatal("Cannot open file %s", qPrintable(event.file()));
file.seek(0);
QByteArray data = file.readAll();
return data;
@@ -112,8 +88,8 @@ QByteArray tst_qfileopenevent::readFileContent(QFileOpenEvent& event)
bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QByteArray& writeContent)
{
- QFile file;
- bool ok = event.openFile(file, QFile::Append | QFile::Unbuffered);
+ QFile file(event.file());
+ bool ok = file.open(QFile::Append | QFile::Unbuffered);
if (ok)
ok = file.write(writeContent) == writeContent.size();
return ok;
@@ -152,8 +128,8 @@ void tst_qfileopenevent::handleLifetime()
QScopedPointer<QFileOpenEvent> event(createFileAndEvent(QLatin1String("testHandleLifetime"), QByteArray("test content")));
// open a QFile after the original RFile is closed
- QFile qFile;
- QCOMPARE(event->openFile(qFile, QFile::Append | QFile::Unbuffered), true);
+ QFile qFile(event->file());
+ QVERIFY(qFile.open(QFile::Append | QFile::Unbuffered));
event.reset(0);
// write to the QFile after the event is closed
@@ -163,7 +139,7 @@ void tst_qfileopenevent::handleLifetime()
// check the content
QFile checkContent("testHandleLifetime");
- checkContent.open(QFile::ReadOnly);
+ QVERIFY(checkContent.open(QFile::ReadOnly));
QString content(checkContent.readAll());
QCOMPARE(content, QLatin1String("test content+closed original handles"));
checkContent.close();
@@ -177,7 +153,8 @@ void tst_qfileopenevent::multiOpen()
QFile files[5];
for (int i=0; i<5; i++) {
- QCOMPARE(event->openFile(files[i], QFile::ReadOnly), true);
+ files[i].setFileName(event->file());
+ QVERIFY(files[i].open(QFile::ReadOnly));
}
for (int i=0; i<5; i++)
files[i].seek(i);