Changeset View
Changeset View
Standalone View
Standalone View
libs/textlayout/tests/TestDocumentLayout.cpp
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 83 | while (1) { | |||
---|---|---|---|---|---|
96 | } | 96 | } | ||
97 | txtLayout->endLayout(); | 97 | txtLayout->endLayout(); | ||
98 | block = block.next(); | 98 | block = block.next(); | ||
99 | } | 99 | } | ||
100 | 100 | | |||
101 | m_layout->layout(); | 101 | m_layout->layout(); | ||
102 | 102 | | |||
103 | MockRootAreaProvider *p = dynamic_cast<MockRootAreaProvider*>(m_layout->provider()); | 103 | MockRootAreaProvider *p = dynamic_cast<MockRootAreaProvider*>(m_layout->provider()); | ||
104 | QVERIFY(p->m_area); | 104 | QVERIFY(p->area()); | ||
105 | 105 | | |||
106 | QCOMPARE(lines, 8); | 106 | QCOMPARE(lines, 8); | ||
107 | 107 | | |||
108 | /* Following is device-/font-dependent and therefore can be different on other computers | 108 | /* Following is device-/font-dependent and therefore can be different on other computers | ||
109 | // outside text | 109 | // outside text | ||
110 | QCOMPARE(p->m_area->hitTest(QPointF(0, 0), Qt::FuzzyHit).position, 0); | 110 | QCOMPARE(p->area()->hitTest(QPointF(0, 0), Qt::FuzzyHit).position, 0); | ||
111 | QCOMPARE(p->m_area->hitTest(QPointF(0, 0), Qt::ExactHit).position, -1); | 111 | QCOMPARE(p->area()->hitTest(QPointF(0, 0), Qt::ExactHit).position, -1); | ||
112 | QCOMPARE(p->m_area->hitTest(QPointF(19, 49), Qt::ExactHit).position, 51); | 112 | QCOMPARE(p->area()->hitTest(QPointF(19, 49), Qt::ExactHit).position, 51); | ||
113 | QCOMPARE(p->m_area->hitTest(QPointF(71, 0), Qt::ExactHit).position, -1); | 113 | QCOMPARE(p->area()->hitTest(QPointF(71, 0), Qt::ExactHit).position, -1); | ||
114 | QCOMPARE(p->m_area->hitTest(QPointF(71, 51), Qt::ExactHit).position, 62); | 114 | QCOMPARE(p->area()->hitTest(QPointF(71, 51), Qt::ExactHit).position, 62); | ||
115 | 115 | | |||
116 | // first char | 116 | // first char | ||
117 | QCOMPARE(p->m_area->hitTest(QPointF(20, 51), Qt::ExactHit).position, 52); | 117 | QCOMPARE(p->area()->hitTest(QPointF(20, 51), Qt::ExactHit).position, 52); | ||
118 | QCOMPARE(p->m_area->hitTest(QPointF(20, 50), Qt::ExactHit).position, 52); | 118 | QCOMPARE(p->area()->hitTest(QPointF(20, 50), Qt::ExactHit).position, 52); | ||
119 | 119 | | |||
120 | // below line 1 | 120 | // below line 1 | ||
121 | //QCOMPARE(p->m_area->hitTest(QPointF(20, 51 + lineHeight), Qt::ExactHit).position, -1); | 121 | //QCOMPARE(p->area()->hitTest(QPointF(20, 51 + lineHeight), Qt::ExactHit).position, -1); | ||
122 | //QVERIFY(p->m_area->hitTest(QPointF(20, 51 + lineHeight), Qt::FuzzyHit).position > 0); // line 2 | 122 | //QVERIFY(p->area()->hitTest(QPointF(20, 51 + lineHeight), Qt::FuzzyHit).position > 0); // line 2 | ||
123 | 123 | | |||
124 | // parag2 | 124 | // parag2 | ||
125 | QCOMPARE(p->m_area->hitTest(QPointF(20, paragOffets[1]), Qt::ExactHit).position, 139); | 125 | QCOMPARE(p->area()->hitTest(QPointF(20, paragOffets[1]), Qt::ExactHit).position, 139); | ||
126 | QCOMPARE(p->m_area->hitTest(QPointF(20, paragOffets[1]), Qt::FuzzyHit).position, 139); | 126 | QCOMPARE(p->area()->hitTest(QPointF(20, paragOffets[1]), Qt::FuzzyHit).position, 139); | ||
127 | QVERIFY(p->m_area->hitTest(QPointF(20, paragOffets[1] + 20), Qt::FuzzyHit).position >= 139); | 127 | QVERIFY(p->area()->hitTest(QPointF(20, paragOffets[1] + 20), Qt::FuzzyHit).position >= 139); | ||
128 | */ | 128 | */ | ||
129 | Q_UNUSED(lineHeight); // used in the above commented piece of code | 129 | Q_UNUSED(lineHeight); // used in the above commented piece of code | ||
130 | Q_UNUSED(paragOffets); // used in the above commented piece of code | 130 | Q_UNUSED(paragOffets); // used in the above commented piece of code | ||
131 | } | 131 | } | ||
132 | 132 | | |||
133 | void TestDocumentLayout::testRootAreaZeroWidth() | 133 | void TestDocumentLayout::testRootAreaZeroWidth() | ||
134 | { | 134 | { | ||
135 | setupTest("a"); | 135 | setupTest("a"); | ||
136 | 136 | | |||
137 | MockRootAreaProvider *provider = dynamic_cast<MockRootAreaProvider*>(m_layout->provider()); | 137 | MockRootAreaProvider *provider = dynamic_cast<MockRootAreaProvider*>(m_layout->provider()); | ||
138 | provider->setSuggestedRect(QRectF(10., 10., 0., 200.)); | 138 | provider->setSuggestedRect(QRectF(10., 10., 0., 200.)); | ||
139 | 139 | | |||
140 | m_layout->layout(); | 140 | m_layout->layout(); | ||
141 | 141 | | |||
142 | QVERIFY(!provider->m_askedForMoreThenOneArea); | 142 | QVERIFY(!provider->m_askedForMoreThenOneArea); | ||
143 | QVERIFY(provider->m_area); | 143 | QVERIFY(provider->area()); | ||
144 | QVERIFY(!provider->m_area->isDirty()); | 144 | QVERIFY(!provider->area()->isDirty()); | ||
145 | QVERIFY(!provider->m_area->virginPage()); | 145 | QVERIFY(!provider->area()->virginPage()); | ||
146 | QVERIFY(provider->m_area->nextStartOfArea()); | 146 | QVERIFY(provider->area()->nextStartOfArea()); | ||
147 | QVERIFY(!provider->m_area->isStartingAt(provider->m_area->nextStartOfArea())); | 147 | QVERIFY(!provider->area()->isStartingAt(provider->area()->nextStartOfArea())); | ||
148 | QCOMPARE(provider->m_area->boundingRect().topLeft(), QPointF(10.,10.)); | 148 | QCOMPARE(provider->area()->boundingRect().topLeft(), QPointF(10.,10.)); | ||
149 | //QCOMPARE(provider->m_area->boundingRect().height(), qreal(14.4)); | 149 | //QCOMPARE(provider->area()->boundingRect().height(), qreal(14.4)); | ||
150 | QCOMPARE(provider->m_area->referenceRect().topLeft(), QPointF(10.,10.)); | 150 | QCOMPARE(provider->area()->referenceRect().topLeft(), QPointF(10.,10.)); | ||
151 | //QCOMPARE(provider->m_area->referenceRect().bottomLeft(), QPointF(0.,14.4)); | 151 | //QCOMPARE(provider->area()->referenceRect().bottomLeft(), QPointF(0.,14.4)); | ||
152 | } | 152 | } | ||
153 | 153 | | |||
154 | void TestDocumentLayout::testRootAreaZeroHeight() | 154 | void TestDocumentLayout::testRootAreaZeroHeight() | ||
155 | { | 155 | { | ||
156 | setupTest("a"); | 156 | setupTest("a"); | ||
157 | 157 | | |||
158 | MockRootAreaProvider *provider = dynamic_cast<MockRootAreaProvider*>(m_layout->provider()); | 158 | MockRootAreaProvider *provider = dynamic_cast<MockRootAreaProvider*>(m_layout->provider()); | ||
159 | provider->setSuggestedRect(QRectF(10., 10., 200.,0.)); | 159 | provider->setSuggestedRect(QRectF(10., 10., 200.,0.)); | ||
160 | 160 | | |||
161 | m_layout->layout(); | 161 | m_layout->layout(); | ||
162 | 162 | | |||
163 | QVERIFY(!provider->m_askedForMoreThenOneArea); // we add the text anyways even if it does not match in height | 163 | QVERIFY(!provider->m_askedForMoreThenOneArea); // we add the text anyways even if it does not match in height | ||
164 | QVERIFY(provider->m_area); | 164 | QVERIFY(provider->area()); | ||
165 | QVERIFY(!provider->m_area->isDirty()); | 165 | QVERIFY(!provider->area()->isDirty()); | ||
166 | QVERIFY(!provider->m_area->virginPage()); // should not be virigin any longer cause we added text | 166 | QVERIFY(!provider->area()->virginPage()); // should not be virigin any longer cause we added text | ||
167 | QVERIFY(provider->m_area->nextStartOfArea()); | 167 | QVERIFY(provider->area()->nextStartOfArea()); | ||
168 | QVERIFY(!provider->m_area->isStartingAt(provider->m_area->nextStartOfArea())); // start- and end-iterator should not be equal cause we added text | 168 | QVERIFY(!provider->area()->isStartingAt(provider->area()->nextStartOfArea())); // start- and end-iterator should not be equal cause we added text | ||
169 | QCOMPARE(provider->m_area->boundingRect(), QRectF(10.,10.,200.,0.)); | 169 | QCOMPARE(provider->area()->boundingRect(), QRectF(10.,10.,200.,0.)); | ||
170 | QCOMPARE(provider->m_area->referenceRect(), QRectF(10.,10.,200.,0.)); | 170 | QCOMPARE(provider->area()->referenceRect(), QRectF(10.,10.,200.,0.)); | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | void TestDocumentLayout::testRootAreaZeroWidthAndHeight() | 173 | void TestDocumentLayout::testRootAreaZeroWidthAndHeight() | ||
174 | { | 174 | { | ||
175 | setupTest("a"); | 175 | setupTest("a"); | ||
176 | 176 | | |||
177 | MockRootAreaProvider *provider = dynamic_cast<MockRootAreaProvider*>(m_layout->provider()); | 177 | MockRootAreaProvider *provider = dynamic_cast<MockRootAreaProvider*>(m_layout->provider()); | ||
178 | provider->setSuggestedRect(QRectF(10., 10., 0., 0.)); | 178 | provider->setSuggestedRect(QRectF(10., 10., 0., 0.)); | ||
179 | 179 | | |||
180 | m_layout->layout(); | 180 | m_layout->layout(); | ||
181 | 181 | | |||
182 | QVERIFY(!provider->m_askedForMoreThenOneArea); | 182 | QVERIFY(!provider->m_askedForMoreThenOneArea); | ||
183 | QVERIFY(provider->m_area); | 183 | QVERIFY(provider->area()); | ||
184 | QVERIFY(!provider->m_area->isDirty()); | 184 | QVERIFY(!provider->area()->isDirty()); | ||
185 | QVERIFY(!provider->m_area->virginPage()); | 185 | QVERIFY(!provider->area()->virginPage()); | ||
186 | QVERIFY(provider->m_area->nextStartOfArea()); | 186 | QVERIFY(provider->area()->nextStartOfArea()); | ||
187 | QVERIFY(!provider->m_area->isStartingAt(provider->m_area->nextStartOfArea())); | 187 | QVERIFY(!provider->area()->isStartingAt(provider->area()->nextStartOfArea())); | ||
188 | QCOMPARE(provider->m_area->boundingRect().topLeft(), QPointF(10.,10.)); | 188 | QCOMPARE(provider->area()->boundingRect().topLeft(), QPointF(10.,10.)); | ||
189 | QCOMPARE(provider->m_area->boundingRect().height(), qreal(0.)); | 189 | QCOMPARE(provider->area()->boundingRect().height(), qreal(0.)); | ||
190 | //QCOMPARE(provider->m_area->boundingRect().width(), qreal(6.67188)); | 190 | //QCOMPARE(provider->area()->boundingRect().width(), qreal(6.67188)); | ||
191 | QCOMPARE(provider->m_area->referenceRect(), QRectF(10.,10.,0.,0.)); | 191 | QCOMPARE(provider->area()->referenceRect(), QRectF(10.,10.,0.,0.)); | ||
192 | } | 192 | } | ||
193 | 193 | | |||
194 | QTEST_MAIN(TestDocumentLayout) | 194 | QTEST_MAIN(TestDocumentLayout) |