summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/util/qundogroup/tst_qundogroup.cpp')
-rw-r--r--tests/auto/gui/util/qundogroup/tst_qundogroup.cpp81
1 files changed, 31 insertions, 50 deletions
diff --git a/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
index 617e0239e1..36f72b2ca0 100644
--- a/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
+++ b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
@@ -1,34 +1,15 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+#include <QTest>
#include <QUndoGroup>
#include <QUndoStack>
#include <QAction>
+#include <QSignalSpy>
+#if QT_CONFIG(process)
+#include <QProcess>
+#endif
+#include <QLibraryInfo>
+#include <QTranslator>
/******************************************************************************
** Commands
@@ -38,10 +19,10 @@ class InsertCommand : public QUndoCommand
{
public:
InsertCommand(QString *str, int idx, const QString &text,
- QUndoCommand *parent = 0);
+ QUndoCommand *parent = nullptr);
- virtual void undo();
- virtual void redo();
+ virtual void undo() override;
+ virtual void redo() override;
private:
QString *m_str;
@@ -52,10 +33,10 @@ private:
class RemoveCommand : public QUndoCommand
{
public:
- RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent = 0);
+ RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent = nullptr);
- virtual void undo();
- virtual void redo();
+ virtual void undo() override;
+ virtual void redo() override;
private:
QString *m_str;
@@ -66,12 +47,12 @@ private:
class AppendCommand : public QUndoCommand
{
public:
- AppendCommand(QString *str, const QString &text, QUndoCommand *parent = 0);
+ AppendCommand(QString *str, const QString &text, QUndoCommand *parent = nullptr);
- virtual void undo();
- virtual void redo();
- virtual int id() const;
- virtual bool mergeWith(const QUndoCommand *other);
+ virtual void undo() override;
+ virtual void redo() override;
+ virtual int id() const override;
+ virtual bool mergeWith(const QUndoCommand *other) override;
bool merged;
@@ -84,7 +65,7 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text,
QUndoCommand *parent)
: QUndoCommand(parent)
{
- QVERIFY(str->length() >= idx);
+ QVERIFY(str->size() >= idx);
setText("insert");
@@ -95,22 +76,22 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text,
void InsertCommand::redo()
{
- QVERIFY(m_str->length() >= m_idx);
+ QVERIFY(m_str->size() >= m_idx);
m_str->insert(m_idx, m_text);
}
void InsertCommand::undo()
{
- QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text);
+ QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text);
- m_str->remove(m_idx, m_text.length());
+ m_str->remove(m_idx, m_text.size());
}
RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent)
: QUndoCommand(parent)
{
- QVERIFY(str->length() >= idx + len);
+ QVERIFY(str->size() >= idx + len);
setText("remove");
@@ -121,14 +102,14 @@ RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *paren
void RemoveCommand::redo()
{
- QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text);
+ QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text);
- m_str->remove(m_idx, m_text.length());
+ m_str->remove(m_idx, m_text.size());
}
void RemoveCommand::undo()
{
- QVERIFY(m_str->length() >= m_idx);
+ QVERIFY(m_str->size() >= m_idx);
m_str->insert(m_idx, m_text);
}
@@ -150,9 +131,9 @@ void AppendCommand::redo()
void AppendCommand::undo()
{
- QCOMPARE(m_str->mid(m_str->length() - m_text.length()), m_text);
+ QCOMPARE(m_str->mid(m_str->size() - m_text.size()), m_text);
- m_str->truncate(m_str->length() - m_text.length());
+ m_str->truncate(m_str->size() - m_text.size());
}
int AppendCommand::id() const
@@ -592,7 +573,7 @@ void tst_QUndoGroup::commandTextFormat()
#if !QT_CONFIG(process)
QSKIP("No QProcess available");
#else
- QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath);
+ QString binDir = QLibraryInfo::path(QLibraryInfo::BinariesPath);
if (QProcess::execute(binDir + "/lrelease -version") != 0)
QSKIP("lrelease is missing or broken");