summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-07-13 15:07:42 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-07-13 15:19:50 (GMT)
commit9db4b800a2c8da5916a6d5da9e37a17d185cdc5e (patch)
tree42adeb7d7a8d658cb26453349e7b5a1a8897fbfe /tests
parente15d415acbd426e58fb1e967eb331fe41488dfff (diff)
downloadQt-9db4b800a2c8da5916a6d5da9e37a17d185cdc5e.zip
Qt-9db4b800a2c8da5916a6d5da9e37a17d185cdc5e.tar.gz
Qt-9db4b800a2c8da5916a6d5da9e37a17d185cdc5e.tar.bz2
More tests for list numbering
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp10
-rw-r--r--tests/auto/qtextlist/tst_qtextlist.cpp40
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index 56f5e7a..4559daa 100644
--- a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -2758,6 +2758,16 @@ void tst_QTextDocumentFragment::css_listStyleType()
QVERIFY(cursor.currentList());
QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListUpperAlpha);
+ doc->setHtml("<ul style=\"list-style-type: upper-roman\"><li>Blah</li></ul>");
+ cursor.movePosition(QTextCursor::End);
+ QVERIFY(cursor.currentList());
+ QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListUpperRoman);
+
+ doc->setHtml("<ul style=\"list-style-type: lower-roman\"><li>Blah</li></ul>");
+ cursor.movePosition(QTextCursor::End);
+ QVERIFY(cursor.currentList());
+ QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListLowerRoman);
+
// ignore the unsupported list-style-position inside the list-style shorthand property
doc->setHtml("<ul style=\"list-style: outside decimal\"><li>Blah</li></ul>");
cursor.movePosition(QTextCursor::End);
diff --git a/tests/auto/qtextlist/tst_qtextlist.cpp b/tests/auto/qtextlist/tst_qtextlist.cpp
index e41d3be..4ab6f5a 100644
--- a/tests/auto/qtextlist/tst_qtextlist.cpp
+++ b/tests/auto/qtextlist/tst_qtextlist.cpp
@@ -77,6 +77,8 @@ private slots:
void add();
void defaultIndent();
void blockUpdate();
+ void numbering_data();
+ void numbering();
private:
QTextDocument *doc;
@@ -336,5 +338,43 @@ void tst_QTextList::blockUpdate()
QVERIFY(!layout->error);
}
+void tst_QTextList::numbering_data()
+{
+ QTest::addColumn<int>("format");
+ QTest::addColumn<int>("number");
+ QTest::addColumn<QString>("result");
+
+ QTest::newRow("E.") << int(QTextListFormat::ListUpperAlpha) << 5 << "E.";
+ QTest::newRow("abc.") << int(QTextListFormat::ListLowerAlpha) << (26 + 2) * 26 + 3 << "abc.";
+ QTest::newRow("12.") << int(QTextListFormat::ListDecimal) << 12 << "12.";
+ QTest::newRow("XXIV.") << int(QTextListFormat::ListUpperRoman) << 24 << "XXIV.";
+ QTest::newRow("VIII.") << int(QTextListFormat::ListUpperRoman) << 8 << "VIII.";
+ QTest::newRow("xxx.") << int(QTextListFormat::ListLowerRoman) << 30 << "xxx.";
+ QTest::newRow("xxix.") << int(QTextListFormat::ListLowerRoman) << 29 << "xxix.";
+// QTest::newRow("xxx. alpha") << int(QTextListFormat::ListLowerAlpha) << (24 * 26 + 24) * 26 + 24 << "xxx."; //Too slow
+}
+
+void tst_QTextList::numbering()
+{
+ QFETCH(int, format);
+ QFETCH(int, number);
+ QFETCH(QString, result);
+
+
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::Style(format));
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ for (int i = 1; i < number; ++i)
+ cursor.insertBlock();
+
+ QCOMPARE(list->count(), number);
+
+ QVERIFY(cursor.currentList());
+ QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), number - 1);
+ QCOMPARE(cursor.currentList()->itemText(cursor.block()), result);
+}
+
QTEST_MAIN(tst_QTextList)
#include "tst_qtextlist.moc"