예제 #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());
}