[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/plugins/textshape/tests
From:       Casper Boemann <cbr () boemann ! dk>
Date:       2010-02-22 12:43:23
Message-ID: 1266842603.172577.28821.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1094289 by boemann:

Add test that shows what was fixed in commit 1092990



 M  +1 -0      TestDocumentLayout.h  
 M  +65 -0     TestLists.cpp  


--- trunk/koffice/plugins/textshape/tests/TestDocumentLayout.h #1094288:1094289
@@ -62,6 +62,7 @@
     void testNumberedList();
     void testInterruptedLists(); // consecutiveNumbering
     void testNestedLists();
+    void testNestedPrefixedLists();
     void testAutoRestartList();
     void testListParagraphIndent();
     void testRomanNumbering();
--- trunk/koffice/plugins/textshape/tests/TestLists.cpp #1094288:1094289
@@ -334,6 +334,71 @@
     }
 }
 
+void TestDocumentLayout::testNestedPrefixedLists()
+{
+    /* A list with different prefix for each level should show only the prefix of that level
+     * Specifically we should not concatenate the prefixes of the higher levels
+     * Specifically we should not concatenate the suffixes of the higher levels
+     * That is only the prefix and the suffix of the current level should be applied
+     */
+    initForNewTest("MMMM\nSSSS\n");
+
+    KoParagraphStyle h1;
+    m_styleManager->add(&h1);
+    KoParagraphStyle h2;
+    m_styleManager->add(&h2);
+
+    KoListStyle listStyle;
+    KoListLevelProperties llp1;
+    llp1.setStartValue(1);
+    llp1.setStyle(KoListStyle::DecimalItem);
+    llp1.setListItemPrefix("Main");
+    llp1.setListItemSuffix(":");
+
+    listStyle.setLevelProperties(llp1);
+
+    KoListLevelProperties llp2;
+    llp2.setStartValue(1);
+    llp2.setStyle(KoListStyle::DecimalItem);
+    llp2.setLevel(2);
+    llp2.setListItemPrefix("Sub");
+    llp2.setListItemSuffix("*");
+    llp2.setDisplayLevel(2);
+    listStyle.setLevelProperties(llp2);
+
+    h1.setListStyle(&listStyle);
+    h2.setListLevel(2);
+    h2.setListStyle(&listStyle);
+    
+    QVERIFY(listStyle.hasLevelProperties(1));
+    QVERIFY(listStyle.hasLevelProperties(2));
+    QVERIFY(!listStyle.hasLevelProperties(3));
+
+    QTextBlock block = m_doc->begin().next();
+    h1.applyStyle(block);
+    block = block.next();
+    QVERIFY(block.isValid());
+    h2.applyStyle(block);
+
+    m_layout->layout();
+
+    block = m_doc->begin();
+    QVERIFY(block.userData() == 0);
+    block = block.next();
+    static const char* texts[] = { "Main1:", "Sub1.1*"};
+    int i = 0;
+    qreal indent = 0.0;
+    while (block.isValid()) {
+        KoTextBlockData *data = dynamic_cast<KoTextBlockData*>(block.userData());
+        //qDebug() << "text: " << block.text();
+        //qDebug() << "expected: " << texts[i];
+        QVERIFY(data);
+        //qDebug() << data->counterText();
+        QCOMPARE(data->counterText(), QString(texts[i++]));
+        block = block.next();
+    }
+}
+
 void TestDocumentLayout::testAutoRestartList()
 {
     initForNewTest("Humans\nGandhi\nEinstein\nInventions\nCar\nToilet\nLaboratory\n");
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic