Changeset View
Changeset View
Standalone View
Standalone View
autotests/src/katetextbuffertest.cpp
Context not available. | |||||
466 | QVERIFY(f.remove()); | 466 | QVERIFY(f.remove()); | ||
---|---|---|---|---|---|
467 | QVERIFY(dir.remove()); | 467 | QVERIFY(dir.remove()); | ||
468 | } | 468 | } | ||
469 | | ||||
470 | void KateTextBufferTest::saveFileWithElevatedPrivileges() | ||||
471 | { | ||||
472 | // create temp dir and get file name inside | ||||
473 | QTemporaryDir dir; | ||||
474 | QVERIFY(dir.isValid()); | ||||
475 | const QString file_path = dir.path() + QLatin1String("/foo"); | ||||
476 | | ||||
477 | QFile f(file_path); | ||||
478 | QVERIFY(f.open(QIODevice::WriteOnly | QIODevice::Truncate)); | ||||
479 | f.write("1234567890"); | ||||
480 | QVERIFY(f.flush()); | ||||
481 | f.close(); | ||||
482 | | ||||
483 | Kate::TextBuffer buffer(nullptr, 1, true); | ||||
484 | buffer.setTextCodec(QTextCodec::codecForName("UTF-8")); | ||||
485 | buffer.setFallbackTextCodec(QTextCodec::codecForName("UTF-8")); | ||||
486 | bool a, b; | ||||
487 | int c; | ||||
488 | buffer.load(file_path, a, b, c, true); | ||||
489 | buffer.clear(); | ||||
490 | buffer.startEditing(); | ||||
491 | buffer.insertText(KTextEditor::Cursor(0, 0), QLatin1String("ABC")); | ||||
492 | buffer.finishEditing(); | ||||
493 | qDebug() << buffer.text(); | ||||
494 | buffer.save(file_path); | ||||
495 | | ||||
496 | f.open(QIODevice::ReadOnly); | ||||
497 | QCOMPARE(f.readAll(), QByteArray("ABC")); | ||||
498 | f.close(); | ||||
499 | | ||||
500 | QVERIFY(f.remove()); | ||||
501 | QVERIFY(dir.remove()); | ||||
502 | } | ||||
Context not available. |