Example #1
0
void BlackMilordTests::check_PlainTextEditor_redoUndoAvailability()
{
    PlainTextEditor *editor = Gui::plainTextEditor();
    QVERIFY(!editor->canRedo());
    QVERIFY(!editor->canUndo());
    QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
    QVERIFY(!editor->canRedo());
    QVERIFY(editor->canUndo());
    QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_Enter);
    QVERIFY(!editor->canRedo());
    QVERIFY(editor->canUndo());
    QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
    QVERIFY(!editor->canRedo());
    QVERIFY(editor->canUndo());

    editor->undo();
    QVERIFY(editor->canRedo());
    QVERIFY(editor->canUndo());

    editor->undo();
    QVERIFY(editor->canRedo());
    QVERIFY(!editor->canUndo());

    editor->redo();
    QVERIFY(editor->canRedo());
    QVERIFY(editor->canUndo());

    editor->redo();
    QVERIFY(!editor->canRedo());
    QVERIFY(editor->canUndo());
}
Example #2
0
void BlackMilordTests::check_PlainTextEditor_typing()
{
    PlainTextEditor *editor = Gui::plainTextEditor();
    QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
    QVERIFY(editor->toPlainText() == "a");
    QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_B);
    QVERIFY(editor->toPlainText() == "ab");
}
Example #3
0
void BlackMilordTests::check_PlainTextEditor_getCursorPosition()
{
    PlainTextEditor *editor = Gui::plainTextEditor();
    QVERIFY(editor->getCursorPosition() == 0);
    QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
    QVERIFY(editor->getCursorPosition() == 1);
    QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_B);
    QVERIFY(editor->getCursorPosition() == 2);
    QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_Enter);
    QVERIFY(editor->getCursorPosition() == 3);
    QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
    QVERIFY(editor->getCursorPosition() == 4);
}