diff options
Diffstat (limited to 'tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp')
-rw-r--r-- | tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp b/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp index 9eb1e2401..743e4c625 100644 --- a/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp +++ b/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp @@ -81,8 +81,7 @@ private slots: QVERIFY(!op.performOperation()); QCOMPARE(UpdateOperation::Error(op.error()), UpdateOperation::InvalidArguments); - QCOMPARE(op.errorString(), QString("Invalid arguments in AppendFile: " - "0 arguments given, exactly 2 arguments expected.")); + QCOMPARE(op.errorString(), QString("Invalid arguments in AppendFile: 0 arguments given, 2 to 4 arguments expected in the form: <filename> <text to apply> [UNDOOPERATION, \"\"].")); op.setArguments(QStringList() << "" << ""); QTest::ignoreMessage(QtWarningMsg, "QFSFileEngine::open: No file name specified"); @@ -98,10 +97,14 @@ private slots: QTest::addColumn<QString>("source"); QTest::addColumn<QString>("append"); QTest::addColumn<QString>("expected"); + QTest::addColumn<bool>("overrideUndo"); QTest::newRow("newline") << "Line1\nLine2\nLine3\n" << "AppendedText" - << "Line1\nLine2\nLine3\nAppendedText"; + << "Line1\nLine2\nLine3\nAppendedText" << false; QTest::newRow("no newline") << "Lorem ipsum " << "dolore sit amet" - << "Lorem ipsum dolore sit amet"; + << "Lorem ipsum dolore sit amet" << false; + + QTest::newRow("no undo") << "Lorem ipsum " << "dolore sit amet" + << "Lorem ipsum dolore sit amet" << true; } void testAppendText() @@ -109,6 +112,7 @@ private slots: QFETCH(QString, source); QFETCH(QString, append); QFETCH(QString, expected); + QFETCH(bool, overrideUndo); QFile file(m_testFilePath); QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); @@ -117,20 +121,29 @@ private slots: stream << source << Qt::flush; file.close(); - AppendFileOperation op; - op.setArguments(QStringList() << m_testFilePath << append); + AppendFileOperation *op = new AppendFileOperation(); + op->setArguments(QStringList() << m_testFilePath << append); + if (overrideUndo) + op->setArguments(op->arguments() << QLatin1String("UNDOOPERATION")); - op.backup(); - QVERIFY(QFileInfo(op.value("backupOfFile").toString()).exists()); + op->backup(); + QVERIFY(QFileInfo(op->value("backupOfFile").toString()).exists()); - QVERIFY2(op.performOperation(), op.errorString().toLatin1()); + QVERIFY2(op->performOperation(), op->errorString().toLatin1()); QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); QCOMPARE(stream.readAll(), expected); file.close(); - QVERIFY2(op.undoOperation(), op.errorString().toLatin1()); + QVERIFY2(op->undoOperation(), op->errorString().toLatin1()); QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); - QCOMPARE(stream.readAll(), source); + if (overrideUndo) + QCOMPARE(stream.readAll(), expected); + else + QCOMPARE(stream.readAll(), source); + QString backupFileName = op->value("backupOfFile").toString(); + delete op; + QVERIFY(!QFileInfo::exists(backupFileName)); + file.close(); QVERIFY(file.remove()); |