diff options
Diffstat (limited to 'tests/auto/qundogroup')
-rw-r--r-- | tests/auto/qundogroup/testdata/qundogroup.ts | 25 | ||||
-rw-r--r-- | tests/auto/qundogroup/tst_qundogroup.cpp | 37 |
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/qundogroup/testdata/qundogroup.ts b/tests/auto/qundogroup/testdata/qundogroup.ts new file mode 100644 index 0000000..a059bcb --- /dev/null +++ b/tests/auto/qundogroup/testdata/qundogroup.ts @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0" language="en"> +<context> + <name>QUndoGroup</name> + <message> + <source>Undo %1</source> + <translation>undo-prefix %1 undo-suffix</translation> + </message> + <message> + <source>Undo</source> + <comment>Default text for undo action</comment> + <translation>Undo-default-text</translation> + </message> + <message> + <source>Redo %1</source> + <translation>redo-prefix %1 redo-suffix</translation> + </message> + <message> + <source>Redo</source> + <comment>Default text for redo action</comment> + <translation>Redo-default-text</translation> + </message> +</context> +</TS> diff --git a/tests/auto/qundogroup/tst_qundogroup.cpp b/tests/auto/qundogroup/tst_qundogroup.cpp index 8927f85..d2909b7 100644 --- a/tests/auto/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/qundogroup/tst_qundogroup.cpp @@ -201,6 +201,7 @@ private slots: void deleteStack(); void checkSignals(); void addStackAndDie(); + void commandTextFormat(); }; tst_QUndoGroup::tst_QUndoGroup() @@ -604,6 +605,42 @@ void tst_QUndoGroup::addStackAndDie() delete stack; } +void tst_QUndoGroup::commandTextFormat() +{ + QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); + QVERIFY(!QProcess::execute(binDir + "/lrelease testdata/qundogroup.ts")); + + QTranslator translator; + QVERIFY(translator.load("testdata/qundogroup.qm")); + qApp->installTranslator(&translator); + + QUndoGroup group; + QAction *undo_action = group.createUndoAction(0); + QAction *redo_action = group.createRedoAction(0); + + QCOMPARE(undo_action->text(), QString("Undo-default-text")); + QCOMPARE(redo_action->text(), QString("Redo-default-text")); + + QUndoStack stack(&group); + stack.setActive(); + QString str; + + stack.push(new AppendCommand(&str, "foo")); + QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix")); + QCOMPARE(redo_action->text(), QString("Redo-default-text")); + + stack.push(new InsertCommand(&str, 0, "bar")); + stack.undo(); + QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix")); + QCOMPARE(redo_action->text(), QString("redo-prefix insert redo-suffix")); + + stack.undo(); + QCOMPARE(undo_action->text(), QString("Undo-default-text")); + QCOMPARE(redo_action->text(), QString("redo-prefix append redo-suffix")); + + qApp->removeTranslator(&translator); +} + #else class tst_QUndoGroup : public QObject { |