Skip to content

Commit

Permalink
Fix for qsgtext autotests
Browse files Browse the repository at this point in the history
Change-Id: If02d4cb69b4f729b85b47222c17a0b1642e649fb
Reviewed-on: http://codereview.qt-project.org/6111
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
  • Loading branch information
Yann Bodson authored and Qt by Nokia committed Oct 6, 2011
1 parent 8c51219 commit b801f90
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/declarative/items/qsgtext.cpp
Expand Up @@ -1386,9 +1386,12 @@ void QSGText::setTextFormat(TextFormat format)
if (!wasRich && d->richText && isComponentComplete()) {
d->ensureDoc();
d->doc->setText(d->text);
d->rightToLeftText = d->doc->toPlainText().isRightToLeft();
d->richTextAsImage = enableImageCache();
} else {
d->rightToLeftText = d->text.isRightToLeft();
}

d->determineHorizontalAlignment();
d->updateLayout();

emit textFormatChanged(d->format);
Expand Down
16 changes: 8 additions & 8 deletions tests/auto/declarative/qsgtext/tst_qsgtext.cpp
Expand Up @@ -309,19 +309,19 @@ void tst_qsgtext::width()
{
QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test

QTextDocument document;
document.setHtml(richText.at(i));
document.setDocumentMargin(0);

int documentWidth = document.idealWidth();

QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\"; textFormat: Text.RichText }";
QDeclarativeComponent textComponent(&engine);
textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QSGText *textObject = qobject_cast<QSGText*>(textComponent.create());

QVERIFY(textObject != 0);
QCOMPARE(textObject->width(), qreal(documentWidth));

QSGTextPrivate *textPrivate = QSGTextPrivate::get(textObject);
QVERIFY(textPrivate != 0);

QTextDocument *doc = textPrivate->textDocument();
QVERIFY(doc != 0);

QCOMPARE(int(textObject->width()), int(doc->idealWidth()));
QVERIFY(textObject->textFormat() == QSGText::RichText);

delete textObject;
Expand Down

0 comments on commit b801f90

Please sign in to comment.