Пример #1
0
void BlackMilordTests::check_PlainTextEditor_setTextgetText()
{
    PlainTextEditor *editor = Gui::plainTextEditor();
    QString testString = "test";
    editor->setPlainText(testString);
    QVERIFY(editor->toPlainText() == testString);
    testString = "test\ntest";
    editor->setPlainText(testString);
    QVERIFY(editor->toPlainText() == testString);
}
Пример #2
0
void BlackMilordTests::check_PlainTextEditor_blockCount()
{
    PlainTextEditor *editor = Gui::plainTextEditor();
    QString testString = "test\ntest";
    editor->setPlainText(testString);
    QVERIFY(editor->blockCount() == 2);
}
Пример #3
0
void BlackMilordTests::check_PlainTextEditor_visibleBlocks()
{
    PlainTextEditor *editor = Gui::plainTextEditor();
    QString testString = "test\ntest";
    editor->setPlainText(testString);
    QVERIFY(editor->firstVisibleBlock() == 0);
    QVERIFY(editor->lastVisibleBlock() == 1);
}
Пример #4
0
void BlackMilordTests::check_PlainTextEditor_setCursorPosition()
{
    PlainTextEditor *editor = Gui::plainTextEditor();
    QString testString = "testtest";
    editor->setPlainText(testString);
    QVERIFY(editor->getCursorPosition() == 8);
    editor->setCursorPosition(4);
    QVERIFY(editor->getCursorPosition() == 4);
    editor->setCursorPosition(0);
    QVERIFY(editor->getCursorPosition() == 0);
    editor->setCursorPositionToEnd();
    QVERIFY(editor->getCursorPosition() == 8);
    editor->setCursorPositionToStart();
    QVERIFY(editor->getCursorPosition() == 0);
}
Пример #5
0
void BlackMilordTests::check_PlainTextEditor_selection()
{
    PlainTextEditor *editor = Gui::plainTextEditor();
    QString testString = "testtest";
    editor->setPlainText(testString);
    QVERIFY(editor->hasSelection() == false);
    QVERIFY(editor->getSelectionStart() == editor->getSelectionEnd());
    QVERIFY(editor->getSelectionStart() == editor->getCursorPosition());
    editor->setSelection(0, 4);
    QVERIFY(editor->hasSelection() == true);
    QVERIFY(editor->getSelectionStart() == 0);
    QVERIFY(editor->getSelectionEnd() == 4);
    QVERIFY(editor->getSelectedText() == "test");
    editor->clearSelection();
    QVERIFY(editor->hasSelection() == false);
    QVERIFY(editor->getSelectionStart() == editor->getSelectionEnd());
    QVERIFY(editor->getSelectionStart() == editor->getCursorPosition());
}