mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 00:35:27 +08:00
qt 6.6.0 clean
This commit is contained in:
@ -26,7 +26,6 @@ endif()
|
||||
if(QT_FEATURE_private_tests)
|
||||
add_subdirectory(qfontcache)
|
||||
add_subdirectory(qtextlayout)
|
||||
add_subdirectory(qzip)
|
||||
add_subdirectory(qtextodfwriter)
|
||||
endif()
|
||||
if(TARGET Qt::Xml)
|
||||
|
@ -1543,20 +1543,26 @@ void tst_QCssParser::gradient()
|
||||
QList<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
|
||||
QList<QCss::Declaration> decls = rules.at(0).declarations;
|
||||
QCss::ValueExtractor ve(decls);
|
||||
QBrush fg, sfg, pfg;
|
||||
QBrush sbg, abg;
|
||||
QVERIFY(ve.extractPalette(&fg, &sfg, &sbg, &abg, &pfg));
|
||||
QBrush foreground;
|
||||
QBrush selectedForeground;
|
||||
QBrush selectedBackground;
|
||||
QBrush alternateBackground;
|
||||
QBrush placeHolderTextForeground;
|
||||
QBrush accent;
|
||||
QVERIFY(ve.extractPalette(&foreground, &selectedForeground, &selectedBackground,
|
||||
&alternateBackground, &placeHolderTextForeground, &accent));
|
||||
|
||||
if (type == "linear") {
|
||||
QCOMPARE(sbg.style(), Qt::LinearGradientPattern);
|
||||
const QLinearGradient *lg = static_cast<const QLinearGradient *>(sbg.gradient());
|
||||
QCOMPARE(selectedBackground.style(), Qt::LinearGradientPattern);
|
||||
const auto *lg = static_cast<const QLinearGradient *>(selectedBackground.gradient());
|
||||
QCOMPARE(lg->start(), start);
|
||||
QCOMPARE(lg->finalStop(), finalStop);
|
||||
} else if (type == "conical") {
|
||||
QCOMPARE(sbg.style(), Qt::ConicalGradientPattern);
|
||||
const QConicalGradient *cg = static_cast<const QConicalGradient *>(sbg.gradient());
|
||||
QCOMPARE(selectedBackground.style(), Qt::ConicalGradientPattern);
|
||||
const auto *cg = static_cast<const QConicalGradient *>(selectedBackground.gradient());
|
||||
QCOMPARE(cg->center(), start);
|
||||
}
|
||||
const QGradient *g = sbg.gradient();
|
||||
const QGradient *g = selectedBackground.gradient();
|
||||
QCOMPARE(g->spread(), QGradient::Spread(spread));
|
||||
QCOMPARE(g->stops().at(0).first, stop0);
|
||||
QCOMPARE(g->stops().at(0).second, color0);
|
||||
|
@ -54,6 +54,7 @@ private slots:
|
||||
void setFamilies();
|
||||
void setFamiliesAndFamily_data();
|
||||
void setFamiliesAndFamily();
|
||||
void featureAccessors();
|
||||
};
|
||||
|
||||
// Testing get/set functions
|
||||
@ -150,7 +151,7 @@ void tst_QFont::italicOblique()
|
||||
continue;
|
||||
}
|
||||
QFont f = QFontDatabase::font(family, style, 12);
|
||||
QVERIFY(f.italic());
|
||||
QVERIFY2(f.italic(), qPrintable(QString::asprintf("Failed for font \"%ls\"", qUtf16Printable(f.family()))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -841,5 +842,37 @@ void tst_QFont::setFamiliesAndFamily()
|
||||
QFontDatabase::removeApplicationFont(weirdFontId);
|
||||
}
|
||||
|
||||
void tst_QFont::featureAccessors()
|
||||
{
|
||||
QFont font;
|
||||
QVERIFY(font.featureTags().isEmpty());
|
||||
font.setFeature("abcd", 0xc0ffee);
|
||||
|
||||
quint32 abcdTag = QFont::stringToTag("abcd");
|
||||
quint32 bcdeTag = QFont::stringToTag("bcde");
|
||||
QVERIFY(font.isFeatureSet(abcdTag));
|
||||
QVERIFY(!font.isFeatureSet(bcdeTag));
|
||||
QCOMPARE(font.featureTags().size(), 1);
|
||||
QCOMPARE(font.featureTags().first(), abcdTag);
|
||||
QCOMPARE(QFont::tagToString(font.featureTags().first()), QByteArray("abcd"));
|
||||
QCOMPARE(font.featureValue(abcdTag), 0xc0ffeeU);
|
||||
QCOMPARE(font.featureValue(bcdeTag), 0U);
|
||||
font.setFeature(abcdTag, 0xf00d);
|
||||
QCOMPARE(font.featureTags().size(), 1);
|
||||
QCOMPARE(font.featureValue(abcdTag), 0xf00dU);
|
||||
font.setFeature("abcde", 0xcaca0);
|
||||
QVERIFY(!font.isFeatureSet(QFont::stringToTag("abcde")));
|
||||
QCOMPARE(font.featureTags().size(), 1);
|
||||
QFont font2 = font;
|
||||
|
||||
font.unsetFeature("abcd");
|
||||
QVERIFY(!font.isFeatureSet(QFont::stringToTag("abcd")));
|
||||
QVERIFY(font.featureTags().isEmpty());
|
||||
|
||||
QVERIFY(font2.isFeatureSet(QFont::stringToTag("abcd")));
|
||||
font2.clearFeatures();
|
||||
QVERIFY(font.featureTags().isEmpty());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QFont)
|
||||
#include "tst_qfont.moc"
|
||||
|
@ -967,7 +967,7 @@ void tst_QGlyphRun::objectReplacementCharacter()
|
||||
QList<QGlyphRun> glyphRuns = layout.glyphRuns();
|
||||
QCOMPARE(glyphRuns.size(), 1);
|
||||
QCOMPARE(glyphRuns.first().glyphIndexes().size(), 1);
|
||||
QCOMPARE(glyphRuns.first().glyphIndexes().first(), 5);
|
||||
QCOMPARE(glyphRuns.first().glyphIndexes().first(), uint(5));
|
||||
}
|
||||
|
||||
#endif // QT_NO_RAWFONT
|
||||
|
@ -1545,15 +1545,20 @@ void tst_QTextCursor::insertMarkdown_data()
|
||||
<< 6 << QString("0) eggs\n1) maple syrup\n")
|
||||
<< QString("bread\u2029eggs\u2029maple syrup\u2029milk")
|
||||
<< QString("bread\neggs\nmaple syrup\nmilk")
|
||||
<< QString("1) bread\n2) eggs\n1) maple syrup\n2) milk\n");
|
||||
// renumbering would happen if we re-read the whole document
|
||||
<< QString("1) bread\n2) eggs\n0) maple syrup\n1) milk\n");
|
||||
// Renumbering would happen if we re-read the whole document.
|
||||
// Currently insertion only uses the new list format after a paragraph separator.
|
||||
// For that reason "bread" and "eggs" use the original list format, while "maple syrup" and
|
||||
// "milk" use the format from the just inserted list.
|
||||
|
||||
QTest::newRow("list after a list")
|
||||
<< "1) bread\n2) milk\n\n" << 2
|
||||
<< 13 << QString("\n0) eggs\n1) maple syrup\n")
|
||||
<< QString("bread\u2029milk\u2029eggs\u2029maple syrup")
|
||||
<< QString("bread\nmilk\neggs\nmaple syrup")
|
||||
<< QString("1) bread\n2) milk\n3) eggs\n1) maple syrup\n");
|
||||
<< QString("1) bread\n2) milk\n3) eggs\n0) maple syrup\n");
|
||||
// Same behavior as above. "eggs" uses the original list format, but "maple syrup" uses the
|
||||
// format of the inserted list, which means "maple syrup" now has a start of 0.
|
||||
|
||||
const QString markdownHeadingString("# Hello\nWorld\n");
|
||||
|
||||
|
@ -1780,6 +1780,22 @@ void tst_QTextDocument::toHtml_data()
|
||||
"<li class=\"unchecked\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">unchecked item</li>\n"
|
||||
"<li class=\"checked\" style=\" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">checked item</li></ul>");
|
||||
}
|
||||
|
||||
{
|
||||
CREATE_DOC_AND_CURSOR();
|
||||
|
||||
QTextListFormat fmt;
|
||||
fmt.setStyle(QTextListFormat::ListDecimal);
|
||||
fmt.setStart(4);
|
||||
cursor.insertList(fmt);
|
||||
cursor.insertText("Blah");
|
||||
cursor.insertBlock();
|
||||
cursor.insertText("Bleh");
|
||||
|
||||
QTest::newRow("ordered list with start") << QTextDocumentFragment(&doc)
|
||||
<< QString("EMPTYBLOCK") +
|
||||
QString("<ol start=\"4\" style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;\">\n<li style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</li>\n<li style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Bleh</li></ol>");
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QTextDocument::toHtml()
|
||||
|
@ -96,6 +96,7 @@ private slots:
|
||||
void html_thCentered();
|
||||
void orderedListNumbering();
|
||||
void html_blockAfterList();
|
||||
void html_listStartAttribute();
|
||||
void html_subAndSuperScript();
|
||||
void html_cssColors();
|
||||
void obeyFragmentMarkersInImport();
|
||||
@ -1471,6 +1472,22 @@ void tst_QTextDocumentFragment::html_blockAfterList()
|
||||
QCOMPARE(cursor.blockFormat().indent(), 0);
|
||||
}
|
||||
|
||||
void tst_QTextDocumentFragment::html_listStartAttribute()
|
||||
{
|
||||
const char html[] = "<ol start=-1><li>Foo</ol><ol><li>Bar</ol>";
|
||||
cursor.insertFragment(QTextDocumentFragment::fromHtml(html));
|
||||
|
||||
cursor.movePosition(QTextCursor::Start);
|
||||
|
||||
QVERIFY(cursor.currentList());
|
||||
QCOMPARE(cursor.currentList()->format().start(), -1);
|
||||
|
||||
QVERIFY(cursor.movePosition(QTextCursor::NextBlock));
|
||||
|
||||
QVERIFY(cursor.currentList());
|
||||
QCOMPARE(cursor.currentList()->format().start(), 1);
|
||||
}
|
||||
|
||||
void tst_QTextDocumentFragment::html_subAndSuperScript()
|
||||
{
|
||||
const char subHtml[] = "<sub>Subby</sub>";
|
||||
|
@ -36,6 +36,8 @@ private slots:
|
||||
void blockUpdate();
|
||||
void numbering_data();
|
||||
void numbering();
|
||||
void start_data();
|
||||
void start();
|
||||
|
||||
private:
|
||||
QTextDocument *doc;
|
||||
@ -400,5 +402,61 @@ void tst_QTextList::numbering()
|
||||
QCOMPARE(cursor.currentList()->itemText(cursor.block()), result);
|
||||
}
|
||||
|
||||
void tst_QTextList::start_data()
|
||||
{
|
||||
QTest::addColumn<int>("format");
|
||||
QTest::addColumn<int>("start");
|
||||
QTest::addColumn<QStringList>("expectedItemTexts");
|
||||
|
||||
QTest::newRow("-1.") << int(QTextListFormat::ListDecimal) << -1
|
||||
<< QStringList{ "-1.", "0.", "1." };
|
||||
QTest::newRow("0.") << int(QTextListFormat::ListDecimal) << 0
|
||||
<< QStringList{ "0.", "1.", "2." };
|
||||
QTest::newRow("1.") << int(QTextListFormat::ListDecimal) << 1
|
||||
<< QStringList{ "1.", "2.", "3." };
|
||||
|
||||
QTest::newRow("A. -1") << int(QTextListFormat::ListUpperAlpha) << -1
|
||||
<< QStringList{ "-1.", "0.", "A." };
|
||||
QTest::newRow("A. 0.") << int(QTextListFormat::ListUpperAlpha) << 0
|
||||
<< QStringList{ "0.", "A.", "B." };
|
||||
QTest::newRow("a. -1") << int(QTextListFormat::ListLowerAlpha) << -1
|
||||
<< QStringList{ "-1.", "0.", "a." };
|
||||
QTest::newRow("a. 0.") << int(QTextListFormat::ListLowerAlpha) << 0
|
||||
<< QStringList{ "0.", "a.", "b." };
|
||||
QTest::newRow("d. 4.") << int(QTextListFormat::ListLowerAlpha) << 4
|
||||
<< QStringList{ "d.", "e.", "f." };
|
||||
|
||||
QTest::newRow("I. -1") << int(QTextListFormat::ListUpperRoman) << -1
|
||||
<< QStringList{ "-1.", "0.", "I." };
|
||||
QTest::newRow("I. 0.") << int(QTextListFormat::ListUpperRoman) << 0
|
||||
<< QStringList{ "0.", "I.", "II." };
|
||||
QTest::newRow("i. -1") << int(QTextListFormat::ListLowerRoman) << -1
|
||||
<< QStringList{ "-1.", "0.", "i." };
|
||||
QTest::newRow("i. 0.") << int(QTextListFormat::ListLowerRoman) << 0
|
||||
<< QStringList{ "0.", "i.", "ii." };
|
||||
}
|
||||
|
||||
void tst_QTextList::start()
|
||||
{
|
||||
QFETCH(int, format);
|
||||
QFETCH(int, start);
|
||||
QFETCH(QStringList, expectedItemTexts);
|
||||
|
||||
QTextListFormat fmt;
|
||||
fmt.setStyle(QTextListFormat::Style(format));
|
||||
fmt.setStart(start);
|
||||
QTextList *list = cursor.createList(fmt);
|
||||
QVERIFY(list);
|
||||
|
||||
while (list->count() < int(expectedItemTexts.size()))
|
||||
cursor.insertBlock();
|
||||
|
||||
QCOMPARE(list->count(), expectedItemTexts.size());
|
||||
|
||||
for (int i = 0; i < list->count(); ++i)
|
||||
QCOMPARE(cursor.currentList()->itemText(cursor.currentList()->item(i)),
|
||||
expectedItemTexts[i]);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QTextList)
|
||||
#include "tst_qtextlist.moc"
|
||||
|
@ -182,36 +182,58 @@ void tst_QTextMarkdownImporter::thematicBreaks()
|
||||
void tst_QTextMarkdownImporter::lists_data()
|
||||
{
|
||||
QTest::addColumn<QString>("input");
|
||||
QTest::addColumn<int>("skipToCheckStart");
|
||||
QTest::addColumn<int>("expectedListStart");
|
||||
QTest::addColumn<int>("expectedItemCount");
|
||||
QTest::addColumn<bool>("expectedEmptyItems");
|
||||
QTest::addColumn<QString>("rewrite");
|
||||
|
||||
// Some of these cases show odd behavior, which is subject to change
|
||||
// as the importer and the writer are tweaked to fix bugs over time.
|
||||
QTest::newRow("dot newline") << ".\n" << 0 << true << ".\n\n";
|
||||
QTest::newRow("number dot newline") << "1.\n" << 1 << true << "1. \n";
|
||||
QTest::newRow("star newline") << "*\n" << 1 << true << "* \n";
|
||||
QTest::newRow("hyphen newline") << "-\n" << 1 << true << "- \n";
|
||||
QTest::newRow("hyphen space newline") << "- \n" << 1 << true << "- \n";
|
||||
QTest::newRow("hyphen space letter newline") << "- a\n" << 1 << false << "- a\n";
|
||||
QTest::newRow("dot newline") << ".\n" << 0 << 1 << 0 << true << ".\n\n";
|
||||
QTest::newRow("number dot newline") << "1.\n" << 0 << 1 << 1 << true << "1. \n";
|
||||
QTest::newRow("number offset start") << "2. text\n" << 0 << 2 << 1 << false << "2. text\n";
|
||||
QTest::newRow("second list offset start")
|
||||
<< "1. text\n\nintervening paragraph\n\n4. second list item"
|
||||
<< 2 << 4 << 2 << false
|
||||
<< "1. text\n\nintervening paragraph\n\n4. second list item\n";
|
||||
QTest::newRow("list continuation offset start")
|
||||
<< "3. text\n\n next paragraph in item 1\n10. second list item"
|
||||
<< 2 << 3 << 2 << false
|
||||
<< "3. text\n\n next paragraph in item 1\n\n4. second list item\n";
|
||||
QTest::newRow("nested list offset start")
|
||||
<< "1. text\n\n 0. indented list item\n\n4. second item in first list"
|
||||
<< 1 << 0 << 3 << false
|
||||
<< "1. text\n 0. indented list item\n2. second item in first list\n";
|
||||
QTest::newRow("offset start after nested list")
|
||||
<< "1. text\n\n 0. indented list item\n\n4. second item in first list"
|
||||
<< 2 << 1 << 3 << false
|
||||
<< "1. text\n 0. indented list item\n2. second item in first list\n";
|
||||
QTest::newRow("star newline") << "*\n" << 0 << 1 << 1 << true << "* \n";
|
||||
QTest::newRow("hyphen newline") << "-\n" << 0 << 1 << 1 << true << "- \n";
|
||||
QTest::newRow("hyphen space newline") << "- \n" << 0 << 1 << 1 << true << "- \n";
|
||||
QTest::newRow("hyphen space letter newline") << "- a\n" << 0 << 1 << 1 << false << "- a\n";
|
||||
QTest::newRow("hyphen nbsp newline") <<
|
||||
QString::fromUtf8("-\u00A0\n") << 0 << true << "-\u00A0\n\n";
|
||||
QTest::newRow("nested empty lists") << "*\n *\n *\n" << 1 << true << " * \n";
|
||||
QTest::newRow("list nested in empty list") << "-\n * a\n" << 2 << false << "- \n * a\n";
|
||||
QString::fromUtf8("-\u00A0\n") << 0 << 1 << 0 << true << "-\u00A0\n\n";
|
||||
QTest::newRow("nested empty lists") << "*\n *\n *\n" << 0 << 1 << 1 << true << " * \n";
|
||||
QTest::newRow("list nested in empty list") << "-\n * a\n" << 0 << 1 << 2 << false << "- \n * a\n";
|
||||
QTest::newRow("lists nested in empty lists")
|
||||
<< "-\n * a\n * b\n- c\n *\n + d\n" << 5 << false
|
||||
<< "-\n * a\n * b\n- c\n *\n + d\n" << 0 << 1 << 5 << false
|
||||
<< "- \n * a\n * b\n- c *\n + d\n";
|
||||
QTest::newRow("numeric lists nested in empty lists")
|
||||
<< "- \n 1. a\n 2. b\n- c\n 1.\n + d\n" << 4 << false
|
||||
<< "- \n 1. a\n 2. b\n- c\n 1.\n + d\n" << 0 << 1 << 4 << false
|
||||
<< "- \n 1. a\n 2. b\n- c 1. + d\n";
|
||||
QTest::newRow("styled spans in list items")
|
||||
<< "1. normal text\n2. **bold** text\n3. `code` in the item\n4. *italic* text\n5. _underlined_ text\n" << 5 << false
|
||||
<< "1. normal text\n2. **bold** text\n3. `code` in the item\n4. *italic* text\n5. _underlined_ text\n"
|
||||
<< 0 << 1 << 5 << false
|
||||
<< "1. normal text\n2. **bold** text\n3. `code` in the item\n4. *italic* text\n5. _underlined_ text\n";
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownImporter::lists()
|
||||
{
|
||||
QFETCH(QString, input);
|
||||
QFETCH(int, skipToCheckStart);
|
||||
QFETCH(int, expectedListStart);
|
||||
QFETCH(int, expectedItemCount);
|
||||
QFETCH(bool, expectedEmptyItems);
|
||||
QFETCH(QString, rewrite);
|
||||
@ -227,6 +249,8 @@ void tst_QTextMarkdownImporter::lists()
|
||||
out.close();
|
||||
}
|
||||
#endif
|
||||
qCDebug(lcTests) << " original:" << input;
|
||||
qCDebug(lcTests) << "rewritten:" << doc.toMarkdown();
|
||||
|
||||
QTextFrame::iterator iterator = doc.rootFrame()->begin();
|
||||
QTextFrame *currentFrame = iterator.currentFrame();
|
||||
@ -239,10 +263,12 @@ void tst_QTextMarkdownImporter::lists()
|
||||
QCOMPARE(iterator.currentFrame(), currentFrame);
|
||||
// Check whether the block is text or a horizontal rule
|
||||
QTextBlock block = iterator.currentBlock();
|
||||
QTextListFormat listFmt;
|
||||
if (block.textList()) {
|
||||
++itemCount;
|
||||
if (!block.text().isEmpty())
|
||||
emptyItems = false;
|
||||
listFmt = block.textList()->format();
|
||||
}
|
||||
qCDebug(lcTests, "%d %s%s", i,
|
||||
(block.textList() ? "<li>" : "<p>"), qPrintable(block.text()));
|
||||
@ -261,6 +287,11 @@ void tst_QTextMarkdownImporter::lists()
|
||||
QCOMPARE(listItemFmt.fontItalic(), false);
|
||||
QCOMPARE(listItemFmt.fontUnderline(), false);
|
||||
QCOMPARE(listItemFmt.fontFixedPitch(), false);
|
||||
if (i == skipToCheckStart) {
|
||||
qCDebug(lcTests) << "skipped to list item" << i << block.text()
|
||||
<< "start" << listFmt.start() << "expected" << expectedListStart;
|
||||
QCOMPARE(listFmt.start(), expectedListStart);
|
||||
}
|
||||
++iterator;
|
||||
++i;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ private slots:
|
||||
void testWriteNestedBulletLists_data();
|
||||
void testWriteNestedBulletLists();
|
||||
void testWriteNestedNumericLists();
|
||||
void testWriteNumericListWithStart();
|
||||
void testWriteTable();
|
||||
void rewriteDocument_data();
|
||||
void rewriteDocument();
|
||||
@ -284,6 +285,7 @@ void tst_QTextMarkdownWriter::testWriteNestedNumericLists()
|
||||
list1->add(cursor.block());
|
||||
|
||||
QTextListFormat fmt2;
|
||||
// Alpha "numbering" is not supported in markdown, so we'll actually get decimal.
|
||||
fmt2.setStyle(QTextListFormat::ListLowerAlpha);
|
||||
fmt2.setNumberSuffix(QLatin1String(")"));
|
||||
fmt2.setIndent(2);
|
||||
@ -305,7 +307,24 @@ void tst_QTextMarkdownWriter::testWriteNestedNumericLists()
|
||||
list2->add(cursor.block());
|
||||
|
||||
const QString output = documentToUnixMarkdown();
|
||||
// There's no QTextList API to set the starting number so we hard-coded all lists to start at 1 (QTBUG-65384)
|
||||
|
||||
#ifdef DEBUG_WRITE_OUTPUT
|
||||
{
|
||||
QFile out(QDir::temp().filePath(QLatin1String(QTest::currentTestFunction()) + ".md"));
|
||||
out.open(QFile::WriteOnly);
|
||||
out.write(output.toUtf8());
|
||||
out.close();
|
||||
}
|
||||
{
|
||||
QFile out(QDir::temp().filePath(QLatin1String(QTest::currentTestFunction()) + ".html"));
|
||||
out.open(QFile::WriteOnly);
|
||||
out.write(document->toHtml().toUtf8());
|
||||
out.close();
|
||||
}
|
||||
#endif
|
||||
|
||||
// While we can set the start index for a block, if list items intersect each other, they will
|
||||
// still use the list numbering.
|
||||
const QString expected = QString::fromLatin1(
|
||||
"1. ListItem 1\n 1) ListItem 2\n 1. ListItem 3\n2. ListItem 4\n 2) ListItem 5\n");
|
||||
if (output != expected && isMainFontFixed())
|
||||
@ -313,6 +332,92 @@ void tst_QTextMarkdownWriter::testWriteNestedNumericLists()
|
||||
QCOMPARE(output, expected);
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::testWriteNumericListWithStart()
|
||||
{
|
||||
QTextCursor cursor(document);
|
||||
|
||||
// The first list will start at 2.
|
||||
QTextListFormat fmt1;
|
||||
fmt1.setStyle(QTextListFormat::ListDecimal);
|
||||
fmt1.setStart(2);
|
||||
QTextList *list1 = cursor.createList(fmt1);
|
||||
cursor.insertText("ListItem 1");
|
||||
list1->add(cursor.block());
|
||||
|
||||
// This list uses the default start (1) again.
|
||||
QTextListFormat fmt2;
|
||||
// Alpha "numbering" is not supported in markdown, so we'll actually get decimal.
|
||||
fmt2.setStyle(QTextListFormat::ListLowerAlpha);
|
||||
fmt2.setNumberSuffix(QLatin1String(")"));
|
||||
fmt2.setIndent(2);
|
||||
QTextList *list2 = cursor.insertList(fmt2);
|
||||
cursor.insertText("ListItem 2");
|
||||
|
||||
// Negative list numbers are disallowed by most Markdown implementations. This list will start
|
||||
// at 1 for that reason.
|
||||
QTextListFormat fmt3;
|
||||
fmt3.setStyle(QTextListFormat::ListDecimal);
|
||||
fmt3.setIndent(3);
|
||||
fmt3.setStart(-1);
|
||||
cursor.insertList(fmt3);
|
||||
cursor.insertText("ListItem 3");
|
||||
|
||||
// Continuing list1, so the second item will have the number 3.
|
||||
cursor.insertBlock();
|
||||
cursor.insertText("ListItem 4");
|
||||
list1->add(cursor.block());
|
||||
|
||||
// This will look out of place: it's in a different position than its list would suggest.
|
||||
// Generates invalid markdown numbering (OK for humans, but md4c will parse it differently than we "meant").
|
||||
// TODO QTBUG-111707: the writer needs to add newlines, otherwise ListItem 5 becomes part of the text for ListItem 4.
|
||||
cursor.insertBlock();
|
||||
cursor.insertText("ListItem 5");
|
||||
list2->add(cursor.block());
|
||||
|
||||
// 0 indexed lists are fine.
|
||||
QTextListFormat fmt4;
|
||||
fmt4.setStyle(QTextListFormat::ListDecimal);
|
||||
fmt4.setStart(0);
|
||||
QTextList *list4 = cursor.insertList(fmt4);
|
||||
cursor.insertText("SecondList Item 0");
|
||||
list4->add(cursor.block());
|
||||
|
||||
// Ensure list numbers are incremented properly.
|
||||
cursor.insertBlock();
|
||||
cursor.insertText("SecondList Item 1");
|
||||
list4->add(cursor.block());
|
||||
|
||||
const QString output = documentToUnixMarkdown();
|
||||
const QString expected = QString::fromLatin1(
|
||||
R"(2. ListItem 1
|
||||
1) ListItem 2
|
||||
1. ListItem 3
|
||||
3. ListItem 4
|
||||
2) ListItem 5
|
||||
0. SecondList Item 0
|
||||
1. SecondList Item 1
|
||||
)");
|
||||
|
||||
#ifdef DEBUG_WRITE_OUTPUT
|
||||
{
|
||||
QFile out(QDir::temp().filePath(QLatin1String(QTest::currentTestFunction()) + ".md"));
|
||||
out.open(QFile::WriteOnly);
|
||||
out.write(output.toUtf8());
|
||||
out.close();
|
||||
}
|
||||
{
|
||||
QFile out(QDir::temp().filePath(QLatin1String(QTest::currentTestFunction()) + ".html"));
|
||||
out.open(QFile::WriteOnly);
|
||||
out.write(document->toHtml().toUtf8());
|
||||
out.close();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (output != expected && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(output, expected);
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::testWriteTable()
|
||||
{
|
||||
QTextCursor cursor(document);
|
||||
|
@ -1,21 +0,0 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## tst_qzip Test:
|
||||
#####################################################################
|
||||
|
||||
# Collect test data
|
||||
file(GLOB_RECURSE test_data
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
testdata/*
|
||||
)
|
||||
|
||||
qt_internal_add_test(tst_qzip
|
||||
SOURCES
|
||||
tst_qzip.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::GuiPrivate
|
||||
TESTDATA ${test_data}
|
||||
)
|
BIN
tests/auto/gui/text/qzip/testdata/symlink.zip
vendored
BIN
tests/auto/gui/text/qzip/testdata/symlink.zip
vendored
Binary file not shown.
BIN
tests/auto/gui/text/qzip/testdata/test.zip
vendored
BIN
tests/auto/gui/text/qzip/testdata/test.zip
vendored
Binary file not shown.
@ -1,116 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
#include <QBuffer>
|
||||
|
||||
#include <private/qzipwriter_p.h>
|
||||
#include <private/qzipreader_p.h>
|
||||
|
||||
class tst_QZip : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void basicUnpack();
|
||||
void symlinks();
|
||||
void readTest();
|
||||
void createArchive();
|
||||
};
|
||||
|
||||
void tst_QZip::basicUnpack()
|
||||
{
|
||||
QZipReader zip(QFINDTESTDATA("/testdata/test.zip"), QIODevice::ReadOnly);
|
||||
QList<QZipReader::FileInfo> files = zip.fileInfoList();
|
||||
QCOMPARE(files.size(), 2);
|
||||
|
||||
QZipReader::FileInfo fi = files.at(0);
|
||||
QVERIFY(fi.isValid());
|
||||
QCOMPARE(fi.filePath, QString("test"));
|
||||
QCOMPARE(uint(fi.isDir), (uint) 1);
|
||||
QCOMPARE(uint(fi.isFile), (uint) 0);
|
||||
QCOMPARE(uint(fi.isSymLink), (uint) 0);
|
||||
|
||||
QCOMPARE(fi.permissions,QFile::Permissions( QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner
|
||||
| QFile::ReadUser | QFile::WriteUser | QFile::ExeUser ));
|
||||
|
||||
QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss"));
|
||||
|
||||
fi = files.at(1);
|
||||
QVERIFY(fi.isValid());
|
||||
QCOMPARE(fi.filePath, QString("test/test.txt"));
|
||||
QCOMPARE(uint(fi.isDir), (uint) 0);
|
||||
QCOMPARE(uint(fi.isFile), (uint) 1);
|
||||
QCOMPARE(uint(fi.isSymLink), (uint) 0);
|
||||
|
||||
QVERIFY(fi.permissions == QFile::Permissions( QFile::ReadOwner | QFile::WriteOwner
|
||||
| QFile::ReadUser | QFile::WriteUser ));
|
||||
|
||||
QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss"));
|
||||
|
||||
QCOMPARE(zip.fileData("test/test.txt"), QByteArray("content\n"));
|
||||
|
||||
fi = zip.entryInfoAt(-1);
|
||||
QVERIFY(!fi.isValid());
|
||||
}
|
||||
|
||||
void tst_QZip::symlinks()
|
||||
{
|
||||
QZipReader zip(QFINDTESTDATA("/testdata/symlink.zip"), QIODevice::ReadOnly);
|
||||
QList<QZipReader::FileInfo> files = zip.fileInfoList();
|
||||
QCOMPARE(files.size(), 2);
|
||||
|
||||
QZipReader::FileInfo fi = files.at(0);
|
||||
QVERIFY(fi.isValid());
|
||||
QCOMPARE(fi.filePath, QString("symlink"));
|
||||
QVERIFY(!fi.isDir);
|
||||
QVERIFY(!fi.isFile);
|
||||
QVERIFY(fi.isSymLink);
|
||||
|
||||
QCOMPARE(zip.fileData("symlink"), QByteArray("destination"));
|
||||
|
||||
fi = files.at(1);
|
||||
QVERIFY(fi.isValid());
|
||||
QCOMPARE(fi.filePath, QString("destination"));
|
||||
QVERIFY(!fi.isDir);
|
||||
QVERIFY(fi.isFile);
|
||||
QVERIFY(!fi.isSymLink);
|
||||
}
|
||||
|
||||
void tst_QZip::readTest()
|
||||
{
|
||||
QZipReader zip("foobar.zip", QIODevice::ReadOnly); // non existing file.
|
||||
QList<QZipReader::FileInfo> files = zip.fileInfoList();
|
||||
QCOMPARE(files.size(), 0);
|
||||
QByteArray b = zip.fileData("foobar");
|
||||
QCOMPARE(b.size(), 0);
|
||||
}
|
||||
|
||||
void tst_QZip::createArchive()
|
||||
{
|
||||
QBuffer buffer;
|
||||
QZipWriter zip(&buffer);
|
||||
QByteArray fileContents("simple file contents\nline2\n");
|
||||
zip.addFile("My Filename", fileContents);
|
||||
zip.close();
|
||||
QByteArray zipFile = buffer.buffer();
|
||||
|
||||
// QFile f("createArchiveTest.zip"); f.open(QIODevice::WriteOnly); f.write(zipFile); f.close();
|
||||
|
||||
QBuffer buffer2(&zipFile);
|
||||
QZipReader zip2(&buffer2);
|
||||
QList<QZipReader::FileInfo> files = zip2.fileInfoList();
|
||||
QCOMPARE(files.size(), 1);
|
||||
QZipReader::FileInfo file = files.at(0);
|
||||
QCOMPARE(file.filePath, QString("My Filename"));
|
||||
QCOMPARE(uint(file.isDir), (uint) 0);
|
||||
QCOMPARE(uint(file.isFile), (uint) 1);
|
||||
QCOMPARE(uint(file.isSymLink), (uint) 0);
|
||||
QCOMPARE(file.permissions, QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::WriteUser) );
|
||||
QCOMPARE(file.size, (long long) 27);
|
||||
QCOMPARE(zip2.fileData("My Filename"), fileContents);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QZip)
|
||||
#include "tst_qzip.moc"
|
Reference in New Issue
Block a user