[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/plugins/textshape/tests
From: Ganesh Paramasivam <ganesh () crystalfab ! com>
Date: 2010-05-03 9:22:41
Message-ID: 20100503092241.EA7CDAC8AB () svn ! kde ! org
[Download RAW message or body]
SVN commit 1122194 by ganeshp:
Adding unit tests to check the merging of a prefix and a suffix delete
M +57 -3 TestChangeTrackedDelete.cpp
M +2 -0 TestChangeTrackedDelete.h
--- trunk/koffice/plugins/textshape/tests/TestChangeTrackedDelete.cpp \
#1122193:1122194 @@ -58,7 +58,7 @@
{
TextTool *textTool = new TextTool(new MockCanvas);
QTextDocument *document = textTool->m_textEditor->document();
- KoTextDocument(document).changeTracker()->setDisplayChanges(true);
+ KoTextDocumentLayout *layout = \
qobject_cast<KoTextDocumentLayout*>(document->documentLayout()); QTextCursor *cursor \
= textTool->m_textEditor->cursor(); cursor->insertText("Hello World");
cursor->setPosition(2);
@@ -66,13 +66,67 @@
ChangeTrackedDeleteCommand *delCommand = new \
ChangeTrackedDeleteCommand(ChangeTrackedDeleteCommand::NextChar, textTool); \
textTool->m_textEditor->addCommand(delCommand);
QCOMPARE(document->characterAt(2).unicode(), \
(ushort)(QChar::ObjectReplacementCharacter)); + // This is wierd. Without this \
loop present the succeeding call to inlineTextObject returs NULL. Why ?????? + for \
(int i=0; i<document->characterCount(); i++) { + cursor->setPosition(i);
+ }
cursor->setPosition(3);
- int changeId = cursor->charFormat().intProperty(KoCharacterStyle::ChangeTrackerId);
- QTextDocumentFragment deleteData = \
KoTextDocument(document).changeTracker()->elementById(changeId)->getDeleteData(); + \
KoDeleteChangeMarker *testMarker = \
dynamic_cast<KoDeleteChangeMarker*>(layout->inlineTextObjectManager()->inlineTextObject(*cursor));
+ QTextDocumentFragment deleteData = \
KoTextDocument(document).changeTracker()->elementById(testMarker->changeId())->getDeleteData();
QCOMPARE(deleteData.toPlainText(), QString("llo Wo"));
delete textTool;
}
+void TestChangeTrackedDelete::testPrefixMerge()
+{
+ TextTool *textTool = new TextTool(new MockCanvas);
+ QTextDocument *document = textTool->m_textEditor->document();
+ KoTextDocumentLayout *layout = \
qobject_cast<KoTextDocumentLayout*>(document->documentLayout()); + QTextCursor \
*cursor = textTool->m_textEditor->cursor(); + cursor->insertText("Hello World");
+ cursor->setPosition(3);
+ ChangeTrackedDeleteCommand *delCommand = new \
ChangeTrackedDeleteCommand(ChangeTrackedDeleteCommand::NextChar, textTool); + \
textTool->m_textEditor->addCommand(delCommand); + \
QCOMPARE(document->characterAt(3).unicode(), \
(ushort)(QChar::ObjectReplacementCharacter)); + cursor->setPosition(4);
+ delCommand = new \
ChangeTrackedDeleteCommand(ChangeTrackedDeleteCommand::NextChar, textTool); + \
textTool->m_textEditor->addCommand(delCommand); + // This is wierd. Without this \
loop present the succeeding call to inlineTextObject returs NULL. Why ?????? + for \
(int i=0; i<document->characterCount(); i++) { + cursor->setPosition(i);
+ }
+ cursor->setPosition(4);
+ KoDeleteChangeMarker *testMarker = \
dynamic_cast<KoDeleteChangeMarker*>(layout->inlineTextObjectManager()->inlineTextObject(*cursor));
+ QTextDocumentFragment deleteData = \
KoTextDocument(document).changeTracker()->elementById(testMarker->changeId())->getDeleteData();
+ QCOMPARE(deleteData.toPlainText(), QString("lo"));
+ delete textTool;
+}
+
+void TestChangeTrackedDelete::testSuffixMerge()
+{
+ TextTool *textTool = new TextTool(new MockCanvas);
+ QTextDocument *document = textTool->m_textEditor->document();
+ KoTextDocumentLayout *layout = \
qobject_cast<KoTextDocumentLayout*>(document->documentLayout()); + QTextCursor \
*cursor = textTool->m_textEditor->cursor(); + cursor->insertText("Hello World");
+ cursor->setPosition(3);
+ ChangeTrackedDeleteCommand *delCommand = new \
ChangeTrackedDeleteCommand(ChangeTrackedDeleteCommand::NextChar, textTool); + \
textTool->m_textEditor->addCommand(delCommand); + \
QCOMPARE(document->characterAt(3).unicode(), \
(ushort)(QChar::ObjectReplacementCharacter)); + cursor->setPosition(2);
+ delCommand = new \
ChangeTrackedDeleteCommand(ChangeTrackedDeleteCommand::NextChar, textTool); + \
textTool->m_textEditor->addCommand(delCommand); + // This is wierd. Without this \
loop present the succeeding call to inlineTextObject returs NULL. Why ?????? + for \
(int i=0; i<document->characterCount(); i++) { + cursor->setPosition(i);
+ }
+ cursor->setPosition(3);
+ KoDeleteChangeMarker *testMarker = \
dynamic_cast<KoDeleteChangeMarker*>(layout->inlineTextObjectManager()->inlineTextObject(*cursor));
+ QTextDocumentFragment deleteData = \
KoTextDocument(document).changeTracker()->elementById(testMarker->changeId())->getDeleteData();
+ QCOMPARE(deleteData.toPlainText(), QString("ll"));
+ delete textTool;
+}
+
QTEST_MAIN(TestChangeTrackedDelete)
#include <TestChangeTrackedDelete.moc>
--- trunk/koffice/plugins/textshape/tests/TestChangeTrackedDelete.h #1122193:1122194
@@ -19,6 +19,8 @@
void testDeletePreviousChar();
void testDeleteNextChar();
void testDeleteSelection();
+ void testPrefixMerge();
+ void testSuffixMerge();
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic