summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/util/qundostack/tst_qundostack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/util/qundostack/tst_qundostack.cpp')
-rw-r--r--tests/auto/gui/util/qundostack/tst_qundostack.cpp129
1 files changed, 55 insertions, 74 deletions
diff --git a/tests/auto/gui/util/qundostack/tst_qundostack.cpp b/tests/auto/gui/util/qundostack/tst_qundostack.cpp
index a24798cba7..3567bc6097 100644
--- a/tests/auto/gui/util/qundostack/tst_qundostack.cpp
+++ b/tests/auto/gui/util/qundostack/tst_qundostack.cpp
@@ -1,35 +1,16 @@
-/****************************************************************************
-**
-** 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 <QAction>
#include <QUndoStack>
+#include <QSignalSpy>
+#if QT_CONFIG(process)
+#include <QProcess>
+#endif
+#include <QTranslator>
+#include <QLibraryInfo>
/******************************************************************************
** Commands
@@ -39,10 +20,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;
@@ -53,10 +34,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;
@@ -68,13 +49,13 @@ class AppendCommand : public QUndoCommand
{
public:
AppendCommand(QString *str, const QString &text, bool _fail_merge = false,
- QUndoCommand *parent = 0);
+ QUndoCommand *parent = nullptr);
~AppendCommand();
- 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;
bool fail_merge;
@@ -88,23 +69,23 @@ private:
class IdleCommand : public QUndoCommand
{
public:
- IdleCommand(QUndoCommand *parent = 0);
+ IdleCommand(QUndoCommand *parent = nullptr);
~IdleCommand();
- virtual void undo();
- virtual void redo();
+ virtual void undo() override;
+ virtual void redo() override;
};
class MoveMouseCommand : public QUndoCommand
{
public:
- MoveMouseCommand(QPoint *mouse, QPoint oldPoint, QPoint newPoint, QUndoCommand *parent = 0);
+ MoveMouseCommand(QPoint *mouse, QPoint oldPoint, QPoint newPoint, QUndoCommand *parent = nullptr);
~MoveMouseCommand();
- 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;
private:
QPoint *m_mouse;
@@ -116,7 +97,7 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text,
QUndoCommand *parent)
: QUndoCommand(parent)
{
- QVERIFY(str->length() >= idx);
+ QVERIFY(str->size() >= idx);
setText("insert");
@@ -127,22 +108,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");
@@ -153,14 +134,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);
}
@@ -191,9 +172,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
@@ -343,44 +324,44 @@ static void checkState(QSignalSpy &redoTextChangedSpy,
QCOMPARE(stack.canRedo(), _canRedo);
QCOMPARE(stack.redoText(), QString(_redoText));
if (_indexChanged) {
- QCOMPARE(indexChangedSpy.count(), 1);
+ QCOMPARE(indexChangedSpy.size(), 1);
QCOMPARE(indexChangedSpy.at(0).at(0).toInt(), _index);
indexChangedSpy.clear();
} else {
- QCOMPARE(indexChangedSpy.count(), 0);
+ QCOMPARE(indexChangedSpy.size(), 0);
}
if (_cleanChanged) {
- QCOMPARE(cleanChangedSpy.count(), 1);
+ QCOMPARE(cleanChangedSpy.size(), 1);
QCOMPARE(cleanChangedSpy.at(0).at(0).toBool(), _clean);
cleanChangedSpy.clear();
} else {
- QCOMPARE(cleanChangedSpy.count(), 0);
+ QCOMPARE(cleanChangedSpy.size(), 0);
}
if (_undoChanged) {
- QCOMPARE(canUndoChangedSpy.count(), 1);
+ QCOMPARE(canUndoChangedSpy.size(), 1);
QCOMPARE(canUndoChangedSpy.at(0).at(0).toBool(), _canUndo);
QCOMPARE(undoAction->isEnabled(), _canUndo);
- QCOMPARE(undoTextChangedSpy.count(), 1);
+ QCOMPARE(undoTextChangedSpy.size(), 1);
QCOMPARE(undoTextChangedSpy.at(0).at(0).toString(), QString(_undoText));
QCOMPARE(undoAction->text(), glue("foo", _undoText));
canUndoChangedSpy.clear();
undoTextChangedSpy.clear();
} else {
- QCOMPARE(canUndoChangedSpy.count(), 0);
- QCOMPARE(undoTextChangedSpy.count(), 0);
+ QCOMPARE(canUndoChangedSpy.size(), 0);
+ QCOMPARE(undoTextChangedSpy.size(), 0);
}
if (_redoChanged) {
- QCOMPARE(canRedoChangedSpy.count(), 1);
+ QCOMPARE(canRedoChangedSpy.size(), 1);
QCOMPARE(canRedoChangedSpy.at(0).at(0).toBool(), _canRedo);
QCOMPARE(redoAction->isEnabled(), _canRedo);
- QCOMPARE(redoTextChangedSpy.count(), 1);
+ QCOMPARE(redoTextChangedSpy.size(), 1);
QCOMPARE(redoTextChangedSpy.at(0).at(0).toString(), QString(_redoText));
QCOMPARE(redoAction->text(), glue("bar", _redoText));
canRedoChangedSpy.clear();
redoTextChangedSpy.clear();
} else {
- QCOMPARE(canRedoChangedSpy.count(), 0);
- QCOMPARE(redoTextChangedSpy.count(), 0);
+ QCOMPARE(canRedoChangedSpy.size(), 0);
+ QCOMPARE(redoTextChangedSpy.size(), 0);
}
}
@@ -2636,8 +2617,8 @@ void tst_QUndoStack::obsolete()
QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged);
QPoint mouse(0, 0);
QString str;
- MoveMouseCommand *cmd1 = 0;
- MoveMouseCommand *cmd2 = 0;
+ MoveMouseCommand *cmd1 = nullptr;
+ MoveMouseCommand *cmd2 = nullptr;
stack.resetClean();
checkState(redoTextChangedSpy,
@@ -3856,7 +3837,7 @@ void tst_QUndoStack::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");