equal
deleted
inserted
replaced
108 void capitalization_smallCaps(); |
108 void capitalization_smallCaps(); |
109 void capitalization_capitalize(); |
109 void capitalization_capitalize(); |
110 void longText(); |
110 void longText(); |
111 void widthOfTabs(); |
111 void widthOfTabs(); |
112 void columnWrapWithTabs(); |
112 void columnWrapWithTabs(); |
|
113 void boundingRectForUnsetLineWidth(); |
|
114 void boundingRectForSetLineWidth(); |
|
115 void glyphLessItems(); |
113 |
116 |
114 // QTextLine stuff |
117 // QTextLine stuff |
115 void setNumColumnsWrapAtWordBoundaryOrAnywhere(); |
118 void setNumColumnsWrapAtWordBoundaryOrAnywhere(); |
116 void setNumColumnsWordWrap(); |
119 void setNumColumnsWordWrap(); |
117 void smallTextLengthNoWrap(); |
120 void smallTextLengthNoWrap(); |
976 { |
979 { |
977 QTextLayout layout("Foo\tBar", testFont); |
980 QTextLayout layout("Foo\tBar", testFont); |
978 // test if centering the tab works. We expect the center of 'Bar.' to be at the tab point. |
981 // test if centering the tab works. We expect the center of 'Bar.' to be at the tab point. |
979 QTextOption option = layout.textOption(); |
982 QTextOption option = layout.textOption(); |
980 QList<QTextOption::Tab> tabs; |
983 QList<QTextOption::Tab> tabs; |
981 QTextOption::Tab tab; |
984 QTextOption::Tab tab(150, QTextOption::CenterTab); |
982 tab.type = QTextOption::CenterTab; |
|
983 tab.position = 150; |
|
984 tabs.append(tab); |
985 tabs.append(tab); |
985 option.setTabs(tabs); |
986 option.setTabs(tabs); |
986 layout.setTextOption(option); |
987 layout.setTextOption(option); |
987 |
988 |
988 layout.beginLayout(); |
989 layout.beginLayout(); |
998 { |
999 { |
999 QTextLayout layout("Foo\tBar. Barrabas", testFont); |
1000 QTextLayout layout("Foo\tBar. Barrabas", testFont); |
1000 // try the different delimiter characters to see if the alignment works there. |
1001 // try the different delimiter characters to see if the alignment works there. |
1001 QTextOption option = layout.textOption(); |
1002 QTextOption option = layout.textOption(); |
1002 QList<QTextOption::Tab> tabs; |
1003 QList<QTextOption::Tab> tabs; |
1003 QTextOption::Tab tab; |
1004 QTextOption::Tab tab(100, QTextOption::DelimiterTab, QChar('.')); |
1004 tab.type = QTextOption::DelimiterTab; |
|
1005 tab.delimiter = QChar('.'); |
|
1006 tab.position = 100; |
|
1007 tabs.append(tab); |
1005 tabs.append(tab); |
1008 option.setTabs(tabs); |
1006 option.setTabs(tabs); |
1009 layout.setTextOption(option); |
1007 layout.setTextOption(option); |
1010 |
1008 |
1011 layout.beginLayout(); |
1009 layout.beginLayout(); |
1305 textLayout.endLayout(); |
1303 textLayout.endLayout(); |
1306 } |
1304 } |
1307 |
1305 |
1308 } |
1306 } |
1309 |
1307 |
|
1308 void tst_QTextLayout::boundingRectForUnsetLineWidth() |
|
1309 { |
|
1310 QTextLayout layout("FOOBAR"); |
|
1311 |
|
1312 layout.beginLayout(); |
|
1313 QTextLine line = layout.createLine(); |
|
1314 layout.endLayout(); |
|
1315 |
|
1316 QCOMPARE(layout.boundingRect().width(), line.naturalTextWidth()); |
|
1317 } |
|
1318 |
|
1319 void tst_QTextLayout::boundingRectForSetLineWidth() |
|
1320 { |
|
1321 QTextLayout layout("FOOBAR"); |
|
1322 |
|
1323 layout.beginLayout(); |
|
1324 QTextLine line = layout.createLine(); |
|
1325 line.setLineWidth(QFIXED_MAX - 1); |
|
1326 layout.endLayout(); |
|
1327 |
|
1328 QCOMPARE(layout.boundingRect().width(), qreal(QFIXED_MAX - 1)); |
|
1329 } |
|
1330 |
1310 void tst_QTextLayout::lineWidthFromBOM() |
1331 void tst_QTextLayout::lineWidthFromBOM() |
1311 { |
1332 { |
1312 const QString string(QChar(0xfeff)); // BYTE ORDER MARK |
1333 const QString string(QChar(0xfeff)); // BYTE ORDER MARK |
1313 QTextLayout layout(string); |
1334 QTextLayout layout(string); |
1314 layout.beginLayout(); |
1335 layout.beginLayout(); |
1317 layout.endLayout(); |
1338 layout.endLayout(); |
1318 |
1339 |
1319 // Don't spin into an infinite loop |
1340 // Don't spin into an infinite loop |
1320 } |
1341 } |
1321 |
1342 |
|
1343 void tst_QTextLayout::glyphLessItems() |
|
1344 { |
|
1345 { |
|
1346 QTextLayout layout; |
|
1347 layout.setText("\t\t"); |
|
1348 layout.beginLayout(); |
|
1349 layout.createLine(); |
|
1350 layout.endLayout(); |
|
1351 } |
|
1352 |
|
1353 { |
|
1354 QTextLayout layout; |
|
1355 layout.setText(QString::fromLatin1("AA") + QChar(QChar::LineSeparator)); |
|
1356 layout.beginLayout(); |
|
1357 layout.createLine(); |
|
1358 layout.endLayout(); |
|
1359 } |
|
1360 } |
1322 |
1361 |
1323 QTEST_MAIN(tst_QTextLayout) |
1362 QTEST_MAIN(tst_QTextLayout) |
1324 #include "tst_qtextlayout.moc" |
1363 #include "tst_qtextlayout.moc" |