fix page counter
This commit is contained in:
13 files changed
+310
-122
No files matched your search
@@ -312,6 +312,34 @@ private slots:
|
||||
QVERIFY(imgTrue.pixelColor(testX, testY).alpha() > 0);
|
||||
}
|
||||
|
||||
void contentChunkFontSizeScaling()
|
||||
{
|
||||
const QString html = QStringLiteral("<p>Testing dynamic font scaling directly on structured ContentChunk without re-parsing XML.</p>");
|
||||
auto chunks = HtmlBlockParser::parseChunks(html, QStringLiteral("section.xhtml"));
|
||||
QCOMPARE(chunks.size(), 1);
|
||||
const auto &chunk = chunks.first();
|
||||
|
||||
QVERIFY(chunk.charCount > 20);
|
||||
|
||||
LayoutParams p16;
|
||||
p16.contentWidth = 400;
|
||||
p16.fontSize = 16;
|
||||
p16.lineSpacing = 1.0;
|
||||
auto prep16 = ChunkLayoutEngine::prepareChunk(chunk, 16);
|
||||
auto l16 = ChunkLayoutEngine::layoutPreparedChunk(prep16, p16);
|
||||
|
||||
LayoutParams p24;
|
||||
p24.contentWidth = 400;
|
||||
p24.fontSize = 24;
|
||||
p24.lineSpacing = 1.0;
|
||||
auto prep24 = ChunkLayoutEngine::prepareChunk(chunk, 24);
|
||||
auto l24 = ChunkLayoutEngine::layoutPreparedChunk(prep24, p24);
|
||||
|
||||
QVERIFY(l24.totalHeight > l16.totalHeight);
|
||||
QVERIFY(!l24.lines.isEmpty());
|
||||
QVERIFY(l24.lines[0].runs[0].font.pixelSize() > l16.lines[0].runs[0].font.pixelSize());
|
||||
}
|
||||
|
||||
void clipRectCullingSkipsOffscreenImage()
|
||||
{
|
||||
class TrackingResolver : public IBookImageResolver {
|
||||
@@ -370,35 +398,6 @@ private slots:
|
||||
KnuthPlassItem::setImageResolver(nullptr);
|
||||
}
|
||||
|
||||
void contentChunkFontSizeScaling()
|
||||
{
|
||||
const QString html = QStringLiteral("<p>Testing dynamic font scaling directly on structured ContentChunk without re-parsing XML.</p>");
|
||||
auto chunks = HtmlBlockParser::parseChunks(html, QStringLiteral("section.xhtml"));
|
||||
QCOMPARE(chunks.size(), 1);
|
||||
const auto &chunk = chunks.first();
|
||||
|
||||
QVERIFY(chunk.wordCount > 5);
|
||||
QVERIFY(chunk.charCount > 20);
|
||||
|
||||
LayoutParams p16;
|
||||
p16.contentWidth = 400;
|
||||
p16.fontSize = 16;
|
||||
p16.lineSpacing = 1.0;
|
||||
auto prep16 = ChunkLayoutEngine::prepareChunk(chunk, 16);
|
||||
auto l16 = ChunkLayoutEngine::layoutPreparedChunk(prep16, p16);
|
||||
|
||||
LayoutParams p24;
|
||||
p24.contentWidth = 400;
|
||||
p24.fontSize = 24;
|
||||
p24.lineSpacing = 1.0;
|
||||
auto prep24 = ChunkLayoutEngine::prepareChunk(chunk, 24);
|
||||
auto l24 = ChunkLayoutEngine::layoutPreparedChunk(prep24, p24);
|
||||
|
||||
QVERIFY(l24.totalHeight > l16.totalHeight);
|
||||
QVERIFY(!l24.lines.isEmpty());
|
||||
QVERIFY(l24.lines[0].runs[0].font.pixelSize() > l16.lines[0].runs[0].font.pixelSize());
|
||||
}
|
||||
|
||||
void contentChunkPartitionAndUnnestedContainers()
|
||||
{
|
||||
const QString html = QStringLiteral(
|
||||
@@ -412,12 +411,10 @@ private slots:
|
||||
|
||||
QCOMPARE(chunks[0].sectionHref, QStringLiteral("section1.xhtml"));
|
||||
QCOMPARE(chunks[0].unnestedContainers, 0);
|
||||
QVERIFY(chunks[0].wordCount > 0);
|
||||
QVERIFY(chunks[0].charCount > 0);
|
||||
|
||||
QCOMPARE(chunks[1].sectionHref, QStringLiteral("section1.xhtml"));
|
||||
QCOMPARE(chunks[1].unnestedContainers, 1); // Carries the open blockquote container
|
||||
QVERIFY(chunks[1].wordCount > 0);
|
||||
QVERIFY(chunks[1].charCount > 0);
|
||||
|
||||
// Layout both chunks and verify decorations
|
||||
|
||||
@@ -218,6 +218,9 @@ public:
|
||||
QStringLiteral("<p>Content paragraph for chunk index %1 with sufficient words for layout.</p>").arg(i),
|
||||
QStringLiteral("text/section_%1.xhtml").arg(i)
|
||||
);
|
||||
if (!parsed.isEmpty()) {
|
||||
parsed[0].charCount = kNormalizedCharsPerPage;
|
||||
}
|
||||
list.append(parsed);
|
||||
}
|
||||
return list;
|
||||
@@ -746,7 +749,6 @@ private slots:
|
||||
const auto &chunk = chunks.first();
|
||||
|
||||
QCOMPARE(chunk.sectionHref, QStringLiteral("section.xhtml"));
|
||||
QVERIFY(chunk.wordCount > 0);
|
||||
QVERIFY(chunk.charCount > 0);
|
||||
QCOMPARE(chunk.unnestedContainers, 0);
|
||||
}
|
||||
@@ -929,7 +931,7 @@ private slots:
|
||||
model.setScrollPosition(3, 45.0, 0.35);
|
||||
|
||||
QCOMPARE(posSpy.count(), 1);
|
||||
QCOMPARE(model.currentPage(), 4);
|
||||
QCOMPARE(model.currentChunk(), 3);
|
||||
QCOMPARE(model.progress(), 0.35);
|
||||
|
||||
BookPosition loaded = ctx.store->load(reader.contentHash());
|
||||
@@ -1157,8 +1159,7 @@ private slots:
|
||||
model.setReader(&reader);
|
||||
|
||||
model.setScrollPosition(5, 0.0, 0.5);
|
||||
const int page = model.currentPage();
|
||||
const int anchorChunk = page - 1;
|
||||
const int anchorChunk = model.currentChunk();
|
||||
QVERIFY(anchorChunk >= 0);
|
||||
QVERIFY(anchorChunk < model.rowCount());
|
||||
}
|
||||
@@ -1240,7 +1241,7 @@ private slots:
|
||||
// 2. progress
|
||||
QCOMPARE(model.progress(), 0.0);
|
||||
// 3. anchor_chunk
|
||||
QCOMPARE(model.currentPage() - 1, 0);
|
||||
QCOMPARE(model.currentChunk(), 0);
|
||||
// 4. use_book_colours
|
||||
QCOMPARE(model.useBookColours(), false);
|
||||
// 5. status
|
||||
|
||||
@@ -46,8 +46,7 @@ public:
|
||||
for (int i = 0; i < m_count; ++i) {
|
||||
ContentChunk chunk;
|
||||
chunk.sectionHref = QStringLiteral("text/ch_%1.xhtml").arg(i);
|
||||
chunk.wordCount = 10;
|
||||
chunk.charCount = 60;
|
||||
chunk.charCount = kNormalizedCharsPerPage;
|
||||
chunk.unnestedContainers = 0;
|
||||
|
||||
BlockItem p;
|
||||
@@ -411,7 +410,6 @@ private slots:
|
||||
{
|
||||
ContentChunk chunk;
|
||||
chunk.sectionHref = QStringLiteral("sec1.xhtml");
|
||||
chunk.wordCount = 100;
|
||||
chunk.charCount = 500;
|
||||
chunk.unnestedContainers = 1;
|
||||
QVERIFY(chunk.isEmpty());
|
||||
|
||||
Reference in new issue
Block a user