1 | #include <QtTest/QTest> |
---|---|
2 | |
3 | #include <poppler-qt6.h> |
4 | |
5 | #include <memory> |
6 | |
7 | class TestOutline : public QObject |
8 | { |
9 | Q_OBJECT |
10 | public: |
11 | explicit TestOutline(QObject *parent = nullptr) : QObject(parent) { } |
12 | private slots: |
13 | void checkOutline_xr02(); |
14 | }; |
15 | |
16 | void TestOutline::checkOutline_xr02() |
17 | { |
18 | std::unique_ptr<Poppler::Document> document { Poppler::Document::load(TESTDATADIR "/unittestcases/xr02.pdf") }; |
19 | QVERIFY(document.get()); |
20 | |
21 | const auto outline = document->outline(); |
22 | QCOMPARE(outline.size(), 2); |
23 | |
24 | const auto &foo = outline[0]; |
25 | QVERIFY(!foo.isNull()); |
26 | QCOMPARE(foo.name(), QStringLiteral("foo")); |
27 | QCOMPARE(foo.isOpen(), false); |
28 | const auto fooDest = foo.destination(); |
29 | QVERIFY(!fooDest.isNull()); |
30 | QCOMPARE(fooDest->pageNumber(), 1); |
31 | QVERIFY(foo.externalFileName().isEmpty()); |
32 | QVERIFY(foo.uri().isEmpty()); |
33 | QVERIFY(!foo.hasChildren()); |
34 | QVERIFY(foo.children().isEmpty()); |
35 | |
36 | const auto &bar = outline[1]; |
37 | QVERIFY(!bar.isNull()); |
38 | QCOMPARE(bar.name(), QStringLiteral("bar")); |
39 | QCOMPARE(bar.isOpen(), false); |
40 | const auto barDest = bar.destination(); |
41 | QVERIFY(!barDest.isNull()); |
42 | QCOMPARE(barDest->pageNumber(), 2); |
43 | QVERIFY(bar.externalFileName().isEmpty()); |
44 | QVERIFY(bar.uri().isEmpty()); |
45 | QVERIFY(!bar.hasChildren()); |
46 | QVERIFY(bar.children().isEmpty()); |
47 | } |
48 | |
49 | QTEST_GUILESS_MAIN(TestOutline) |
50 | #include "check_outline.moc" |
51 |