Changeset View
Changeset View
Standalone View
Standalone View
autotests/annotationstest.cpp
Show All 24 Lines | 24 | private slots: | |||
---|---|---|---|---|---|
25 | void initTestCase(); | 25 | void initTestCase(); | ||
26 | void testDistance(); | 26 | void testDistance(); | ||
27 | void testDistance_data(); | 27 | void testDistance_data(); | ||
28 | // void testLine(); | 28 | // void testLine(); | ||
29 | // void testPoly(); | 29 | // void testPoly(); | ||
30 | // void testInk(); | 30 | // void testInk(); | ||
31 | // void testHighlight(); | 31 | // void testHighlight(); | ||
32 | // void testGeom(); | 32 | // void testGeom(); | ||
33 | void testTypewriter(); | ||||
33 | void cleanupTestCase(); | 34 | void cleanupTestCase(); | ||
34 | 35 | | |||
35 | private: | 36 | private: | ||
36 | Okular::Document *m_document; | 37 | Okular::Document *m_document; | ||
37 | }; | 38 | }; | ||
38 | 39 | | |||
39 | void AnnotationTest::initTestCase() | 40 | void AnnotationTest::initTestCase() | ||
40 | { | 41 | { | ||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | 71 | { | |||
135 | QTest::newRow("Highlight: Point 1") << (Okular::Annotation*) highlight << 0.1 << 0.1 << 0; | 136 | QTest::newRow("Highlight: Point 1") << (Okular::Annotation*) highlight << 0.1 << 0.1 << 0; | ||
136 | QTest::newRow("Highlight: Point 2") << (Okular::Annotation*) highlight << 0.2 << 0.1 << 0; | 137 | QTest::newRow("Highlight: Point 2") << (Okular::Annotation*) highlight << 0.2 << 0.1 << 0; | ||
137 | QTest::newRow("Highlight: Point 3") << (Okular::Annotation*) highlight << 0.8 << 0.9 << 0; | 138 | QTest::newRow("Highlight: Point 3") << (Okular::Annotation*) highlight << 0.8 << 0.9 << 0; | ||
138 | QTest::newRow("Highlight: Point 4") << (Okular::Annotation*) highlight << 0.9 << 0.9 << 0; | 139 | QTest::newRow("Highlight: Point 4") << (Okular::Annotation*) highlight << 0.9 << 0.9 << 0; | ||
139 | QTest::newRow("Highlight: Inside") << (Okular::Annotation*) highlight << 0.5 << 0.5 << 0; | 140 | QTest::newRow("Highlight: Inside") << (Okular::Annotation*) highlight << 0.5 << 0.5 << 0; | ||
140 | QTest::newRow("Highlight: Outside") << (Okular::Annotation*) highlight << 1.0 << 0.9 << qRound( pow( documentX * 0.1, 2 ) ); | 141 | QTest::newRow("Highlight: Outside") << (Okular::Annotation*) highlight << 1.0 << 0.9 << qRound( pow( documentX * 0.1, 2 ) ); | ||
141 | } | 142 | } | ||
142 | 143 | | |||
144 | void AnnotationTest::testTypewriter() | ||||
145 | { | ||||
146 | Okular::Annotation * annot = nullptr; | ||||
147 | Okular::TextAnnotation * ta = new Okular::TextAnnotation(); | ||||
148 | annot = ta; | ||||
149 | ta->setFlags( ta->flags() | Okular::Annotation::FixedRotation ); | ||||
150 | ta->setTextType( Okular::TextAnnotation::InPlace ); | ||||
151 | ta->setInplaceIntent( Okular::TextAnnotation::TypeWriter ); | ||||
152 | ta->style().setWidth( 0.0 ); | ||||
153 | ta->style().setColor( QColor(255,255,255,0) ); | ||||
154 | | ||||
155 | annot->setBoundingRectangle( Okular::NormalizedRect( 0.8, 0.1, 0.85, 0.15 ) ); | ||||
156 | annot->setContents( QStringLiteral("annot contents") ); | ||||
157 | | ||||
158 | m_document->addPageAnnotation( 0, annot ); | ||||
159 | | ||||
160 | QDomNode annotNode = annot->getAnnotationPropertiesDomNode(); | ||||
161 | QDomNodeList annotNodeList = annotNode.toElement().elementsByTagName("base"); | ||||
162 | QDomElement annotEl = annotNodeList.item(0).toElement(); | ||||
163 | QCOMPARE( annotEl.attribute( QStringLiteral("color") ), QStringLiteral("#00ffffff") ); | ||||
164 | QCOMPARE( annotEl.attribute( QStringLiteral("flags") ), QStringLiteral("4") ); | ||||
165 | QCOMPARE( annotEl.attribute( QStringLiteral("contents") ), QStringLiteral("annot contents") ); | ||||
166 | } | ||||
143 | 167 | | |||
144 | QTEST_MAIN( AnnotationTest ) | 168 | QTEST_MAIN( AnnotationTest ) | ||
145 | #include "annotationstest.moc" | 169 | #include "annotationstest.moc" |