From a08546507fe0ce356e4183e557d9408295c80610 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 21 Feb 2012 13:31:19 +1000 Subject: Reduce QQuickTextEdit memory usage. Remove unnecessary members from QQuickTextEditPrivate and QQuickTextControlPrivate and re-order and pack to reduce padding for alignment. Change-Id: I14f5e3fc01646d02745f095c2a4b168cd675745d Reviewed-by: Yann Bodson --- tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp index 41c8546688..62b85b8d24 100644 --- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp @@ -903,10 +903,7 @@ void tst_qquicktextedit::color() QVERIFY(textEditObject); QVERIFY(textEditPrivate); QVERIFY(textEditPrivate->control); - - QPalette pal = textEditPrivate->control->palette(); QCOMPARE(textEditPrivate->color, QColor("black")); - QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text)); } //test normal for (int i = 0; i < colorStrings.size(); i++) -- cgit v1.2.3 From 12f0663dbda6ae56d3307493ca34212f601dd3aa Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 21 Feb 2012 14:11:04 +1000 Subject: Fix font size calculation in headings in StyledText. Calculate the font size correctly even when the size is specified in pixels and update this size when the font changes. Also make sure that the text layout's font is set before parsing. Task-number: QTBUG-24458 Change-Id: Ida7723f6e4f4b9fd3a6878076f4beaf5bda8f7f7 Reviewed-by: Andrew den Exter --- .../tst_qdeclarativestyledtext.cpp | 130 +++++++++++---------- .../qtquick2/qquicktext/data/pixelFontSizes.qml | 21 ++++ .../qtquick2/qquicktext/data/pointFontSizes.qml | 21 ++++ tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 72 ++++++++++++ 4 files changed, 181 insertions(+), 63 deletions(-) create mode 100644 tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml create mode 100644 tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp b/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp index fd0d1abd29..ca3855c32a 100644 --- a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp +++ b/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp @@ -88,68 +88,69 @@ void tst_qdeclarativestyledtext::textOutput_data() QTest::addColumn("input"); QTest::addColumn("output"); QTest::addColumn("formats"); - - QTest::newRow("bold") << "bold" << "bold" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("italic") << "italic" << "italic" << (FormatList() << Format(Format::Italic, 0, 6)); - QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)); - QTest::newRow("strong") << "strong" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)); - QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)); - QTest::newRow("missing >") << "text") << "text") << "text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("missing ") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("nested") << "text italic bold" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5)); - QTest::newRow("bad nest") << "text italic" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6)); - QTest::newRow("font color") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)); - QTest::newRow("font color: single quote") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)); - QTest::newRow("font size") << "text" << "text" << (FormatList() << Format(0, 0, 4)); - QTest::newRow("font empty") << "text" << "text" << FormatList(); - QTest::newRow("font bad 1") << "text" << "text" << FormatList(); - QTest::newRow("font bad 2") << "text" << "" << FormatList(); - QTest::newRow("extra close") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("extra space") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("entities") << "<b>this & that</b>" << "this & that" << FormatList(); - QTest::newRow("newline") << "text
more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("paragraph") << "text

more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("paragraph closed") << "text

more text

more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("paragraph closed bold") << "text

more text

more text
" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24)); - QTest::newRow("self-closing newline") << "text
more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("empty") << "" << "" << FormatList(); - QTest::newRow("unknown tag") << "underline not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9)); - QTest::newRow("ordered list") << "
  1. one
  2. two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList(); - QTest::newRow("ordered list closed") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list alpha") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list upper alpha") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list roman") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list upper roman") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list bad") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list") << "
    • one
    • two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList(); - QTest::newRow("unordered list closed") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list disc") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list square") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list bad") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("header close") << "

      head

      more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h0") << "head" << "head" << FormatList(); - QTest::newRow("h1") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h2") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h3") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h4") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h5") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h6") << "
      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h7") << "head" << "head" << FormatList(); - QTest::newRow("pre") << "normal
      pre text
      normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9)); - QTest::newRow("pre lb") << "normal
      pre\n text
      normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10)); - QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList(); - QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList(); - QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList(); - QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList(); - QTest::newRow("space after newline") << "text
      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("space after paragraph") << "text

      more text

      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("space in header") << "

      head

      " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("space before bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4)); - QTest::newRow("space leading bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5)); - QTest::newRow("space trailing bold") << "this is bold " << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)); - QTest::newRow("img") << "ab" << "a b" << FormatList(); + QTest::addColumn("modifiesFontSize"); + + QTest::newRow("bold") << "bold" << "bold" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("italic") << "italic" << "italic" << (FormatList() << Format(Format::Italic, 0, 6)) << false; + QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false; + QTest::newRow("strong") << "strong" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)) << false; + QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false; + QTest::newRow("missing >") << "text") << "text") << "text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("missing ") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("nested") << "text italic bold" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5)) << false; + QTest::newRow("bad nest") << "text italic" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6)) << false; + QTest::newRow("font color") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)) << false; + QTest::newRow("font color: single quote") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)) << false; + QTest::newRow("font size") << "text" << "text" << (FormatList() << Format(0, 0, 4)) << true; + QTest::newRow("font empty") << "text" << "text" << FormatList() << false; + QTest::newRow("font bad 1") << "text" << "text" << FormatList() << false; + QTest::newRow("font bad 2") << "text" << "" << FormatList() << false; + QTest::newRow("extra close") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("extra space") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("entities") << "<b>this & that</b>" << "this & that" << FormatList() << false; + QTest::newRow("newline") << "text
      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("paragraph") << "text

      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("paragraph closed") << "text

      more text

      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("paragraph closed bold") << "text

      more text

      more text
      " << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24)) << false; + QTest::newRow("self-closing newline") << "text
      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("empty") << "" << "" << FormatList() << false; + QTest::newRow("unknown tag") << "underline not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9)) << false; + QTest::newRow("ordered list") << "
      1. one
      2. two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false; + QTest::newRow("ordered list closed") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list alpha") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list upper alpha") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list roman") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list upper roman") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list bad") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("unordered list") << "
        • one
        • two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false; + QTest::newRow("unordered list closed") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("unordered list disc") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("unordered list square") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("unordered list bad") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("header close") << "

          head

          more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h0") << "head" << "head" << FormatList() << false; + QTest::newRow("h1") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h2") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h3") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h4") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h5") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h6") << "
          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h7") << "head" << "head" << FormatList() << false; + QTest::newRow("pre") << "normal
          pre text
          normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9)) << false; + QTest::newRow("pre lb") << "normal
          pre\n text
          normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10)) << false; + QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList() << false; + QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList() << false; + QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList() << false; + QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList() << false; + QTest::newRow("space after newline") << "text
          more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("space after paragraph") << "text

          more text

          more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("space in header") << "

          head

          " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("space before bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4)) << false; + QTest::newRow("space leading bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5)) << false; + QTest::newRow("space trailing bold") << "this is bold " << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)) << false; + QTest::newRow("img") << "ab" << "a b" << FormatList() << false; } void tst_qdeclarativestyledtext::textOutput() @@ -157,10 +158,12 @@ void tst_qdeclarativestyledtext::textOutput() QFETCH(QString, input); QFETCH(QString, output); QFETCH(FormatList, formats); + QFETCH(bool, modifiesFontSize); QTextLayout layout; QList imgTags; - QDeclarativeStyledText::parse(input, layout, imgTags, QUrl(), 0, false); + bool fontSizeModified = false; + QDeclarativeStyledText::parse(input, layout, imgTags, QUrl(), 0, false, &fontSizeModified); QCOMPARE(layout.text(), output); @@ -177,6 +180,7 @@ void tst_qdeclarativestyledtext::textOutput() QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic)); QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline)); } + QCOMPARE(fontSizeModified, modifiesFontSize); } diff --git a/tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml b/tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml new file mode 100644 index 0000000000..e3d81b682e --- /dev/null +++ b/tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 200 + + property variant pixelSize: 6 + + Text { + objectName: "text" + font.pixelSize: parent.pixelSize + text: "This is
          a font
          size test." + } + + Text { + x: 200 + objectName: "textWithTag" + font.pixelSize: parent.pixelSize + text: "This is

          a font

          size test." + } +} diff --git a/tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml b/tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml new file mode 100644 index 0000000000..6feb8fecf8 --- /dev/null +++ b/tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 200 + + property variant pointSize: 6 + + Text { + objectName: "text" + font.pointSize: parent.pointSize + text: "This is
          a font
          size test." + } + + Text { + x: 200 + objectName: "textWithTag" + font.pointSize: parent.pointSize + text: "This is

          a font

          size test." + } +} diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index d1c0f765d0..86d502f07e 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -122,6 +122,8 @@ private slots: void fontSizeModeMultiline(); void multilengthStrings_data(); void multilengthStrings(); + void fontFormatSizes_data(); + void fontFormatSizes(); private: QStringList standard; @@ -2427,6 +2429,76 @@ void tst_qquicktext::multilengthStrings() QCOMPARE(myText->truncated(), true); } +void tst_qquicktext::fontFormatSizes_data() +{ + QTest::addColumn("text"); + QTest::addColumn("textWithTag"); + QTest::addColumn("fontIsBigger"); + + QTest::newRow("fs1") << "Hello world!" << "Hello world!" << false; + QTest::newRow("fs2") << "Hello world!" << "Hello world!" << false; + QTest::newRow("fs3") << "Hello world!" << "Hello world!" << false; + QTest::newRow("fs4") << "Hello world!" << "Hello world!" << true; + QTest::newRow("fs5") << "Hello world!" << "Hello world!" << true; + QTest::newRow("fs6") << "Hello world!" << "Hello world!" << true; + QTest::newRow("fs7") << "Hello world!" << "Hello world!" << true; + QTest::newRow("h1") << "This is
          a font
          size test." << "This is

          a font

          size test." << true; + QTest::newRow("h2") << "This is
          a font
          size test." << "This is

          a font

          size test." << true; + QTest::newRow("h3") << "This is
          a font
          size test." << "This is

          a font

          size test." << true; + QTest::newRow("h4") << "This is
          a font
          size test." << "This is

          a font

          size test." << true; + QTest::newRow("h5") << "This is
          a font
          size test." << "This is
          a font
          size test." << false; + QTest::newRow("h6") << "This is
          a font
          size test." << "This is
          a font
          size test." << false; +} + +void tst_qquicktext::fontFormatSizes() +{ + QFETCH(QString, text); + QFETCH(QString, textWithTag); + QFETCH(bool, fontIsBigger); + + QQuickView *view = new QQuickView; + { + view->setSource(testFileUrl("pointFontSizes.qml")); + view->show(); + + QQuickText *qtext = view->rootObject()->findChild("text"); + QQuickText *qtextWithTag = view->rootObject()->findChild("textWithTag"); + QVERIFY(qtext != 0); + QVERIFY(qtextWithTag != 0); + + qtext->setText(text); + qtextWithTag->setText(textWithTag); + + for (int size = 6; size < 100; size += 4) { + view->rootObject()->setProperty("pointSize", size); + if (fontIsBigger) + QVERIFY(qtext->height() <= qtextWithTag->height()); + else + QVERIFY(qtext->height() >= qtextWithTag->height()); + } + } + + { + view->setSource(testFileUrl("pixelFontSizes.qml")); + QQuickText *qtext = view->rootObject()->findChild("text"); + QQuickText *qtextWithTag = view->rootObject()->findChild("textWithTag"); + QVERIFY(qtext != 0); + QVERIFY(qtextWithTag != 0); + + qtext->setText(text); + qtextWithTag->setText(textWithTag); + + for (int size = 6; size < 100; size += 4) { + view->rootObject()->setProperty("pixelSize", size); + if (fontIsBigger) + QVERIFY(qtext->height() <= qtextWithTag->height()); + else + QVERIFY(qtext->height() >= qtextWithTag->height()); + } + } + delete view; +} + QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" -- cgit v1.2.3 From c5f65d859720c9345f995136301f6809bbb82867 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 23 Feb 2012 11:58:23 +1000 Subject: QML locale.firstDayOfWeek returns 7 for Sunday To match JS Date object, Sunday should be 0. Change-Id: I662c0b1fcbf921fa1c4bb58f900366dd088b343b Reviewed-by: Glenn Watson --- .../qdeclarativelocale/tst_qdeclarativelocale.cpp | 38 +++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp index bf5c8c7af4..7d86ad9148 100644 --- a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp +++ b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp @@ -68,6 +68,8 @@ private slots: void dayName(); void standaloneDayName_data(); void standaloneDayName(); + void firstDayOfWeek_data(); + void firstDayOfWeek(); void weekDays_data(); void weekDays(); void uiLanguages_data(); @@ -154,7 +156,6 @@ void tst_qdeclarativelocale::addPropertyData(const QString &l) LOCALE_PROP(QString,negativeSign), LOCALE_PROP(QString,positiveSign), LOCALE_PROP(QString,exponential), - LOCALE_PROP(int,firstDayOfWeek), LOCALE_PROP(int,measurementSystem), LOCALE_PROP(int,textDirection), { 0, QVariant() } @@ -426,6 +427,41 @@ void tst_qdeclarativelocale::standaloneDayName() delete obj; } +void tst_qdeclarativelocale::firstDayOfWeek_data() +{ + QTest::addColumn("locale"); + + QTest::newRow("en_US") << "en_US"; + QTest::newRow("de_DE") << "de_DE"; + QTest::newRow("ar_SA") << "ar_SA"; + QTest::newRow("hi_IN") << "hi_IN"; + QTest::newRow("zh_CN") << "zh_CN"; + QTest::newRow("th_TH") << "th_TH"; +} + +void tst_qdeclarativelocale::firstDayOfWeek() +{ + QFETCH(QString, locale); + + QDeclarativeComponent c(&engine, testFileUrl("properties.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QVariant val = obj->property("firstDayOfWeek"); + QVERIFY(val.type() == QVariant::Int); + + int day = int(QLocale(locale).firstDayOfWeek()); + if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) + day = 0; + QCOMPARE(day, val.toInt()); + + delete obj; +} + void tst_qdeclarativelocale::weekDays_data() { QTest::addColumn("locale"); -- cgit v1.2.3 From 924a9620d528da85dc19df7573d33ba4132e5a3a Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 17 Feb 2012 12:26:21 +1000 Subject: Fix Text eliding with implicit height and maximumLineCount. Ignore the height of the text if the element height is invalid. Task-number: QTBUG-24293 Change-Id: I1646c3f64583da40e6166aeea24c2c4af42cb279 Reviewed-by: Yann Bodson --- tests/auto/qtquick2/qquicktext/data/multilineelide.qml | 2 +- tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml b/tests/auto/qtquick2/qquicktext/data/multilineelide.qml index f3bb65775b..ffca0d638a 100644 --- a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml +++ b/tests/auto/qtquick2/qquicktext/data/multilineelide.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 Text { - width: 200; height: 200 + width: 200 wrapMode: Text.WordWrap elide: Text.ElideRight maximumLineCount: 3 diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index 86d502f07e..c28de8b53c 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -471,6 +471,12 @@ void tst_qquicktext::multilineElide() qreal lineHeight = myText->contentHeight() / 3.; + // Set a valid height greater than the truncated content height and ensure the line count is + // unchanged. + myText->setHeight(200); + QCOMPARE(myText->lineCount(), 3); + QCOMPARE(myText->truncated(), true); + // reduce size and ensure fewer lines are drawn myText->setHeight(lineHeight * 2); QCOMPARE(myText->lineCount(), 2); -- cgit v1.2.3 From dc3165178851b9bda71dd238c8a5faca4dfa7a45 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Thu, 23 Feb 2012 14:55:16 +1000 Subject: Remove warning produced by 'parent' reference. When Qt.createQmlObject is invoked from QML, any contained references to parent produce a warning from V8. To prevent this, move the assignment of the parent object to before the initial execution of the bindings. Task-number: QTBUG-24464 Change-Id: Ib330822f1ca46ec5a6af648a56197da09669c3f2 Reviewed-by: Martin Jones --- .../data/createParentReference.qml | 12 ++++++++ .../tst_qdeclarativecomponent.cpp | 32 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml b/tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml new file mode 100644 index 0000000000..daa5d3c167 --- /dev/null +++ b/tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + id: root + width: 100 + height: 100 + + function createChild() { + Qt.createQmlObject("import QtQuick 2.0;" + + "Item { width: parent.width; }", root); + } +} diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp index c529649fc0..993c706092 100644 --- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp +++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -71,6 +71,7 @@ private slots: void qmlCreateObject(); void qmlCreateObjectWithProperties(); void qmlIncubateObject(); + void qmlCreateParentReference(); private: QDeclarativeEngine engine; @@ -181,6 +182,37 @@ void tst_qdeclarativecomponent::qmlCreateObjectWithProperties() delete testBindingThisObj; } +static QStringList warnings; +static void msgHandler(QtMsgType, const char *warning) +{ + warnings << QString::fromUtf8(warning); +} + +void tst_qdeclarativecomponent::qmlCreateParentReference() +{ + QDeclarativeEngine engine; + + QCOMPARE(engine.outputWarningsToStandardError(), true); + + warnings.clear(); + QtMsgHandler old = qInstallMsgHandler(msgHandler); + + QDeclarativeComponent component(&engine, testFileUrl("createParentReference.qml")); + QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(QMetaObject::invokeMethod(object, "createChild")); + delete object; + + qInstallMsgHandler(old); + + engine.setOutputWarningsToStandardError(false); + QCOMPARE(engine.outputWarningsToStandardError(), false); + + QCOMPARE(warnings.count(), 0); +} + QTEST_MAIN(tst_qdeclarativecomponent) #include "tst_qdeclarativecomponent.moc" -- cgit v1.2.3 From fb3889a423365b1736cae8850cdb2b3ac77b14a8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Feb 2012 10:55:34 +0100 Subject: Use new plugin system in QtDeclarative. - Use prefix "org.qt-project" for interfaces. - Use new macros, add json files. Change-Id: I53df83f95153c5c9c462098584606284470a5ae0 Reviewed-by: Martin Jones --- tests/auto/declarative/qdeclarativelanguage/testtypes.h | 3 ++- tests/auto/declarative/qdeclarativemoduleplugin/empty.json | 1 + tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp | 4 ++-- tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp | 4 ++-- tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp | 4 ++-- .../auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp | 4 ++-- .../declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp | 4 ++-- .../declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp | 4 ++-- .../declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp | 4 ++-- 9 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/empty.json (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index 4a37139056..ec0c185123 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -67,7 +67,8 @@ public: }; QT_BEGIN_NAMESPACE -Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface"); +#define MyInterface_iid "org.qt-project.Qt.Test.MyInterface" +Q_DECLARE_INTERFACE(MyInterface, MyInterface_iid); QT_END_NAMESPACE QML_DECLARE_INTERFACE(MyInterface); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/empty.json b/tests/auto/declarative/qdeclarativemoduleplugin/empty.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/empty.json @@ -0,0 +1 @@ +{} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp index 27e0beb4be..a8a0f69a3a 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp @@ -66,6 +66,8 @@ private: class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -80,5 +82,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp index 904664ee0e..c67b5b1b63 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp @@ -66,6 +66,8 @@ private: class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -80,5 +82,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp index 267535dd74..869630bd63 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp @@ -65,6 +65,8 @@ private: class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -79,5 +81,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp index 0052c6ee53..51e48781f6 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp @@ -56,6 +56,8 @@ public: class MyMixedPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyMixedPlugin() { @@ -69,5 +71,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp index 6fc6eee1c7..ab8b3d479e 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp @@ -56,6 +56,8 @@ public: class MyMixedPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyMixedPlugin() { @@ -69,5 +71,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp index 7cb0365abe..88b807e14d 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp @@ -46,6 +46,8 @@ class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: void registerTypes(const char *uri) { @@ -54,5 +56,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp index 2446c93bf9..fe110a28d4 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp @@ -65,6 +65,8 @@ private: class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -79,5 +81,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); -- cgit v1.2.3 From 7e76d66f526de98804f01771ca0fea1ade7b6677 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 23 Feb 2012 08:51:36 +0000 Subject: Fix crash in instruction dump Change-Id: I2cfa9da120a602b52f401dd304b44cd17c47b220 Reviewed-by: Alan Alpert Reviewed-by: Roberto Raggi --- .../qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index 072718a95c..769d385efc 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -499,9 +499,9 @@ void tst_qdeclarativeinstruction::dump() << "24\t\tSTORE_OBJECT\t\t21" << "25\t\tSTORE_VARIANT_OBJECT\t22" << "26\t\tSTORE_INTERFACE\t\t23" - << "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\"" + << "27\t\tSTORE_SIGNAL\t\t2\t3" << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4" - << "29\t\tASSIGN_SIGNAL_OBJECT\t4\t\t\t\"mySignal\"" + << "29\t\tASSIGN_SIGNAL_OBJECT\t4" << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9" << "31\t\tSTORE_BINDING\t26\t3\t2" << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4" -- cgit v1.2.3 From 212204b4fff05aed43a931e71855948ec9910b59 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 20 Feb 2012 14:46:26 +0100 Subject: Fix rewrite of multiline string literals. This commits ensures that we don't rewrite `\'-terminated multiline string literals. Also, it fixes the processing of \r characters inside the string literals. Change-Id: If3d7c1b83c7306b9ccb1be31412b6f8e76434c41 Reviewed-by: Oswald Buddenhagen Reviewed-by: Aaron Kennedy --- .../data/rewriteMultiLineStrings_crlf.1.qml | 13 ++++++++++++ .../tst_qdeclarativeecmascript.cpp | 23 ++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml new file mode 100644 index 0000000000..f84ba8c722 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Rectangle { + id: root + + Component.onCompleted: { + var o = Qt.createQmlObject("import QtQuick 2.0; \ + \ + Item { \ + property bool b: true; \ + }", root, "Instance") + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index d30766f982..cc94e6fb4a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1570,8 +1570,6 @@ void tst_qdeclarativeecmascript::compileInvalidBinding() { // QTBUG-23387: ensure that invalid bindings don't cause a crash. QDeclarativeComponent component(&engine, testFileUrl("v8bindingException.qml")); - QString warning = component.url().toString() + ":16: SyntaxError: Unexpected token ILLEGAL"; - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); QObject *object = component.create(); QVERIFY(object != 0); delete object; @@ -5287,12 +5285,21 @@ void tst_qdeclarativeecmascript::qtbug_21864() void tst_qdeclarativeecmascript::rewriteMultiLineStrings() { - // QTBUG-23387 - QDeclarativeComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - QTRY_COMPARE(o->property("test").toBool(), true); - delete o; + { + // QTBUG-23387 + QDeclarativeComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QTRY_COMPARE(o->property("test").toBool(), true); + delete o; + } + + { + QDeclarativeComponent component(&engine, testFileUrl("rewriteMultiLineStrings_crlf.1.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + delete o; + } } void tst_qdeclarativeecmascript::qobjectConnectionListExceptionHandling() -- cgit v1.2.3 From 5fee1e79cc1c18acf58f9171a73a7525154a65cd Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 23 Feb 2012 14:11:48 +1000 Subject: Use floating point types for position offsets and cursorRectangle. Rounding to align painting to pixel boundaries is no longer necessary are largely removed. Correct the few instances remaining in TextEdit and TextInput. Change-Id: Ic6ec57092d74ec43b23d85cd8868e0190acc3e09 Reviewed-by: Yann Bodson --- .../qtquick2/qquicktextedit/tst_qquicktextedit.cpp | 38 +++++------ .../qquicktextinput/tst_qquicktextinput.cpp | 77 +++++++++++----------- 2 files changed, 56 insertions(+), 59 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp index 62b85b8d24..e2673c1f17 100644 --- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp @@ -461,10 +461,10 @@ void tst_qquicktextedit::width() layout.endLayout(); - qreal metricWidth = ceil(layout.boundingRect().width()); + qreal metricWidth = layout.boundingRect().width(); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(metricWidth)); + QCOMPARE(textEditObject->width(), metricWidth); } for (int i = 0; i < richText.size(); i++) @@ -475,7 +475,7 @@ void tst_qquicktextedit::width() if (requiresUnhintedMetrics) document.setUseDesignMetrics(true); - int documentWidth = ceil(document.idealWidth()); + qreal documentWidth = document.idealWidth(); QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); @@ -483,7 +483,7 @@ void tst_qquicktextedit::width() QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(documentWidth)); + QCOMPARE(textEditObject->width(), documentWidth); } } @@ -1843,8 +1843,8 @@ void tst_qquicktextedit::cursorDelegate() //Test Delegate gets moved for (int i=0; i<= textEditObject->text().length(); i++) { textEditObject->setCursorPosition(i); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); } // Clear preedit text; QInputMethodEvent event; @@ -1858,8 +1858,8 @@ void tst_qquicktextedit::cursorDelegate() QTest::mouseClick(&view, Qt::LeftButton, 0, point1); QTest::qWait(50); QTRY_VERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); // Test delegate gets moved on mouse drag textEditObject->setCursorPosition(0); @@ -1869,27 +1869,27 @@ void tst_qquicktextedit::cursorDelegate() QGuiApplication::sendEvent(&view, &mv); QTest::mouseRelease(&view, Qt::LeftButton, 0, point2); QTest::qWait(50); - QTRY_COMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QTRY_COMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); textEditObject->setReadOnly(true); textEditObject->setCursorPosition(0); QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint()); QTest::qWait(50); QTRY_VERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); textEditObject->setCursorPosition(0); QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint()); QTest::qWait(50); QTRY_VERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); textEditObject->setCursorPosition(0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); //Test Delegate gets deleted textEditObject->setCursorDelegate(0); QVERIFY(!textEditObject->findChild("cursorInstance")); @@ -2582,14 +2582,14 @@ void tst_qquicktextedit::cursorRectangleSize() qApp->sendEvent(qApp->focusObject(), &event); QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF(); - QRect cursorRectFromItem = textEdit->cursorRectangle(); + QRectF cursorRectFromItem = textEdit->cursorRectangle(); QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition()); // item and input query cursor rectangles match - QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect()); + QCOMPARE(cursorRectFromItem, cursorRectFromQuery); // item cursor rectangle and positionToRectangle calculations match - QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect()); + QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle); // item-canvas transform and input item transform match QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform()); diff --git a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp index c1768bd98a..236b12002e 100644 --- a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp @@ -2341,12 +2341,12 @@ void tst_qquicktextinput::cursorDelegate() //Test Delegate gets moved for (int i=0; i<= textInputObject->text().length(); i++) { textInputObject->setCursorPosition(i); - QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y()); } textInputObject->setCursorPosition(0); - QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y()); //Test Delegate gets deleted textInputObject->setCursorDelegate(0); QVERIFY(!textInputObject->findChild("cursorInstance")); @@ -2404,9 +2404,6 @@ void tst_qquicktextinput::cursorVisible() QCOMPARE(spy.count(), 7); } -static QRect round(const QRectF &r) { - return QRect(qRound(r.left()), qRound(r.top()), qCeil(r.width()), qCeil(r.height())); } - void tst_qquicktextinput::cursorRectangle() { @@ -2430,7 +2427,7 @@ void tst_qquicktextinput::cursorRectangle() input.setWidth(line.cursorToX(5, QTextLine::Leading)); input.setHeight(qCeil(line.height() * 3 / 2)); - QRect r; + QRectF r; // some tolerance for different fonts. #ifdef Q_OS_LINUX @@ -2445,28 +2442,28 @@ void tst_qquicktextinput::cursorRectangle() QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } // Check the cursor rectangle remains within the input bounding rect when auto scrolling. - QVERIFY(r.left() < input.width()); + QVERIFY(r.left() < input.width() + error); QVERIFY(r.right() >= input.width() - error); for (int i = 6; i < text.length(); ++i) { input.setCursorPosition(i); QCOMPARE(r, input.cursorRectangle()); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } for (int i = text.length() - 2; i >= 0; --i) { input.setCursorPosition(i); r = input.cursorRectangle(); - QCOMPARE(r.top(), 0); + QCOMPARE(r.top(), 0.); QVERIFY(r.right() >= 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } // Check position with word wrap. @@ -2478,24 +2475,24 @@ void tst_qquicktextinput::cursorRectangle() QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); - QCOMPARE(r.top(), 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(r.top(), 0.); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } input.setCursorPosition(6); r = input.cursorRectangle(); - QCOMPARE(r.left(), 0); + QCOMPARE(r.left(), 0.); QVERIFY(r.top() > line.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(6)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(6), r); for (int i = 7; i < text.length(); ++i) { input.setCursorPosition(i); r = input.cursorRectangle(); QVERIFY(r.top() > line.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } // Check vertical scrolling with word wrap. @@ -2506,40 +2503,40 @@ void tst_qquicktextinput::cursorRectangle() QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); - QCOMPARE(r.top(), 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(round(input.positionToRectangle(i))), r); + QCOMPARE(r.top(), 0.); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } input.setCursorPosition(6); r = input.cursorRectangle(); - QCOMPARE(r.left(), 0); + QCOMPARE(r.left(), 0.); QVERIFY(r.bottom() >= input.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(6)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(6), r); for (int i = 7; i < text.length(); ++i) { input.setCursorPosition(i); r = input.cursorRectangle(); QVERIFY(r.bottom() >= input.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } for (int i = text.length() - 2; i >= 6; --i) { input.setCursorPosition(i); r = input.cursorRectangle(); QVERIFY(r.bottom() >= input.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } for (int i = 5; i >= 0; --i) { input.setCursorPosition(i); r = input.cursorRectangle(); - QCOMPARE(r.top(), 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(r.top(), 0.); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } input.setText("Hi!"); @@ -3228,14 +3225,14 @@ void tst_qquicktextinput::cursorRectangleSize() qApp->sendEvent(qApp->focusObject(), &event); QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF(); - QRect cursorRectFromItem = textInput->cursorRectangle(); + QRectF cursorRectFromItem = textInput->cursorRectangle(); QRectF cursorRectFromPositionToRectangle = textInput->positionToRectangle(textInput->cursorPosition()); // item and input query cursor rectangles match - QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect()); + QCOMPARE(cursorRectFromItem, cursorRectFromQuery); // item cursor rectangle and positionToRectangle calculations match - QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect()); + QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle); // item-canvas transform and input item transform match QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform()); -- cgit v1.2.3 From 91d543f00904a6caa2fab850ff3eca12de2d65ac Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 24 Feb 2012 10:22:35 +1000 Subject: Add additional autotests for signal handlers. Change-Id: Ie94ce8b536347981310abeb077a88acedf44c7e6 Reviewed-by: Chris Adams --- .../data/signalAssignment.3.qml | 5 +++++ .../data/signalAssignment.4.qml | 6 ++++++ .../declarative/qdeclarativeecmascript/testtypes.h | 2 ++ .../tst_qdeclarativeecmascript.cpp | 21 +++++++++++++++++++++ .../qdeclarativelanguage/data/signal.5.errors.txt | 1 + .../qdeclarativelanguage/data/signal.5.qml | 6 ++++++ .../tst_qdeclarativelanguage.cpp | 1 + tests/auto/declarative/qmlmin/tst_qmlmin.cpp | 3 ++- 8 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml new file mode 100644 index 0000000000..690b7cf216 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + onUnnamedArgumentSignal: setString('pass ' + a + ' ' + c) +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml new file mode 100644 index 0000000000..0e1e728a86 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + + +MyQmlObject { + onSignalWithGlobalName: setString('pass ' + parseInt("5")) +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index a463d3f64a..ce8e80e81b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -180,6 +180,7 @@ public: signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e); + void unnamedArgumentSignal(int a, qreal, QString c); void stringChanged(); void urlChanged(); void objectChanged(); @@ -188,6 +189,7 @@ signals: void signalWithUnknownType(const MyQmlObject::MyType &arg); void signalWithVariant(const QVariant &arg); void signalWithQJSValue(const QJSValue &arg); + void signalWithGlobalName(int parseInt); void intChanged(); public slots: diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index cc94e6fb4a..7fc137e38d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -376,6 +376,27 @@ void tst_qdeclarativeecmascript::signalAssignment() QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2")); delete object; } + + { + QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.3.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->string(), QString()); + emit object->unnamedArgumentSignal(19, 10.25, "Hello world!"); + QEXPECT_FAIL("", "QTBUG-24481", Continue); + QCOMPARE(object->string(), QString("pass 19 Hello world!")); + delete object; + } + + { + QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.4.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->string(), QString()); + emit object->signalWithGlobalName(19); + QCOMPARE(object->string(), QString("pass 5")); + delete object; + } } void tst_qdeclarativeecmascript::methods() diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt new file mode 100644 index 0000000000..cf772e881e --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt @@ -0,0 +1 @@ +4:27:Expected token `identifier' diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml new file mode 100644 index 0000000000..63921cb2ca --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + signal mySignal(string) +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 480a898ff0..1f211ae963 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -354,6 +354,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false; QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false; QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false; + QTest::newRow("signal.5") << "signal.5.qml" << "signal.5.errors.txt" << false; QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false; diff --git a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp b/tests/auto/declarative/qmlmin/tst_qmlmin.cpp index c6b019071e..df4e2a01dc 100644 --- a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/declarative/qmlmin/tst_qmlmin.cpp @@ -96,10 +96,11 @@ void tst_qmlmin::initTestCase() // Add invalid files (i.e. files with syntax errors) invalidFiles << "tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml"; + invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml"; + invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/property.4.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/empty.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml"; -- cgit v1.2.3 From 9d2b618fa022daeabd45e57aa1596197db883037 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Feb 2012 10:34:44 +1000 Subject: Start of examples refactor This is the general reorg of the examples directory structure, plus additional guidelines. calculator, animations and accessibility have been updated to the new standards and tested, as an example. Task-number: QTBUG-24133 Change-Id: I76c3b86751d3195ba2a5474ff23afb875765e9a4 Reviewed-by: Alan Alpert --- tests/auto/qtquick2/examples/tst_examples.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/examples/tst_examples.cpp b/tests/auto/qtquick2/examples/tst_examples.cpp index 0e420f7277..ce8f214efd 100644 --- a/tests/auto/qtquick2/examples/tst_examples.cpp +++ b/tests/auto/qtquick2/examples/tst_examples.cpp @@ -89,32 +89,25 @@ tst_examples::tst_examples() excludedFiles << "doc/src/snippets/declarative/listmodel.qml"; //Just a ListModel, no root QQuickItem // Add directories you want excluded here - excludedDirs << "examples/declarative/text/fonts"; // QTBUG-21415 + excludedDirs << "examples/shared"; //Not an example + excludedDirs << "examples/qtquick/text/fonts"; // QTBUG-21415 excludedDirs << "doc/src/snippets/declarative/path"; //No root QQuickItem - // Not run in QQuickView - excludedDirs << "examples/declarative/qtquick1"; - // These snippets are not expected to run on their own. excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex"; excludedDirs << "doc/src/snippets/declarative/qtbinding"; excludedDirs << "doc/src/snippets/declarative/imports"; - excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; - excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; - excludedDirs << "doc/src/snippets/qtquick1/imports"; #ifdef QT_NO_WEBKIT - excludedDirs << "examples/declarative/modelviews/webview"; - excludedDirs << "examples/declarative/webbrowser"; + excludedDirs << "examples/qtquick/modelviews/webview"; + excludedDirs << "examples/demos/webbrowser"; excludedDirs << "doc/src/snippets/declarative/webview"; - excludedDirs << "doc/src/snippets/qtquick1/webview"; #endif #ifdef QT_NO_XMLPATTERNS - excludedDirs << "examples/declarative/xml/xmldata"; - excludedDirs << "examples/declarative/twitter"; - excludedDirs << "examples/declarative/flickr"; - excludedDirs << "examples/declarative/photoviewer"; + excludedDirs << "examples/demos/twitter"; + excludedDirs << "examples/demos/flickr"; + excludedDirs << "examples/demos/photoviewer"; #endif } @@ -230,12 +223,10 @@ void tst_examples::sgexamples_data() { QTest::addColumn("file"); - QString examples = QLatin1String(SRCDIR) + "/../../../../examples/declarative/"; - QString tutorials = QLatin1String(SRCDIR) + "/../../../../examples/tutorials/"; //Only declarative tutorials since modularization + QString examples = QLatin1String(SRCDIR) + "/../../../../examples/"; QStringList files; files << findQmlFiles(QDir(examples)); - files << findQmlFiles(QDir(tutorials)); foreach (const QString &file, files) QTest::newRow(qPrintable(file)) << file; -- cgit v1.2.3 From 6c08b232f31430896e332b9222f3ded2b3e73c7a Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 24 Feb 2012 18:05:35 +1000 Subject: Stabilise tests Change-Id: I2227fede52f5b0d59bd0dd9b10ab0151318d61dd Reviewed-by: Martin Jones --- .../qquicklistview/data/multipleTransitions.qml | 2 +- .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 26 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml index 50ffbc53c3..3e3248535b 100644 --- a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml +++ b/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml @@ -10,7 +10,7 @@ Rectangle { // interrupting transitions will still produce the correct result) property int timeBetweenActions: duration / 2 - property int duration: 100 + property int duration: 300 property int count: list.count diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index eb7efd6d33..959bb2b265 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -490,6 +490,7 @@ void tst_QQuickListView::inserted_more() canvas->setSource(testFileUrl("listviewtest.qml")); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -643,6 +644,7 @@ void tst_QQuickListView::insertBeforeVisible() canvas->setSource(testFileUrl("listviewtest.qml")); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -733,6 +735,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) canvas->setSource(source); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -922,6 +925,7 @@ void tst_QQuickListView::removed_more(const QUrl &source) canvas->setSource(source); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -1143,6 +1147,7 @@ void tst_QQuickListView::moved(const QUrl &source) canvas->setSource(source); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -1369,6 +1374,7 @@ void tst_QQuickListView::multipleChanges() canvas->setSource(testFileUrl("listviewtest.qml")); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -4813,6 +4819,7 @@ void tst_QQuickListView::populateTransitions() canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia); canvas->setSource(testFileUrl("populateTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview); @@ -4950,6 +4957,7 @@ void tst_QQuickListView::addTransitions() ctxt->setContextProperty("testObject", testObject); canvas->setSource(testFileUrl("addTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -5144,6 +5152,7 @@ void tst_QQuickListView::moveTransitions() ctxt->setContextProperty("testObject", testObject); canvas->setSource(testFileUrl("moveTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -5346,6 +5355,7 @@ void tst_QQuickListView::removeTransitions() ctxt->setContextProperty("testObject", testObject); canvas->setSource(testFileUrl("removeTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -5537,6 +5547,7 @@ void tst_QQuickListView::multipleTransitions() ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); canvas->setSource(testFileUrl("multipleTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -5603,20 +5614,9 @@ void tst_QQuickListView::multipleTransitions() } QCOMPARE(listview->count(), model.count()); - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - // verify all items moved to the correct final positions - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QList items = findItems(contentItem, "wrapper"); + for (int i=0; i < model.count() && i < items.count(); ++i) { QQuickItem *item = findItem(contentItem, "wrapper", i); QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); QTRY_COMPARE(item->x(), 0.0); -- cgit v1.2.3 From cd6cabc6ccd2499662ddb3b5748561557360843b Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 27 Feb 2012 11:08:15 +1000 Subject: Improve test coverage for anchors. Change-Id: I2705407b16ef678ed5b3cbfa7116ae6b18366688 Reviewed-by: Yann Bodson --- tests/auto/qtquick2/qquickanchors/data/stretch.qml | 39 ++++++++++++++++++++ .../qtquick2/qquickanchors/tst_qquickanchors.cpp | 41 ++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tests/auto/qtquick2/qquickanchors/data/stretch.qml (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquickanchors/data/stretch.qml b/tests/auto/qtquick2/qquickanchors/data/stretch.qml new file mode 100644 index 0000000000..64e23e30b5 --- /dev/null +++ b/tests/auto/qtquick2/qquickanchors/data/stretch.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + + Rectangle { + id: rect1 + x: 20; y: 20; + height: 360; width: 360; + + Rectangle { + id: rect2; objectName: "stretcher" + anchors.verticalCenter: rect1.verticalCenter + anchors.bottom: rect3.top + anchors.horizontalCenter: rect1.horizontalCenter + anchors.left: rect3.left + } + + Rectangle { + id: rect3 + x: 160; y: 230 + width: 10 + height: 10 + } + + Rectangle { + id: rect4; objectName: "stretcher2" + anchors.verticalCenter: rect1.verticalCenter + anchors.top: rect5.top + } + + Rectangle { + id: rect5 + x: 160; y: 130 + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp index 8d82abc53b..af43686e27 100644 --- a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp +++ b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp @@ -83,6 +83,7 @@ private slots: void fillRTL(); void margins(); void marginsRTL(); + void stretch(); }; void tst_qquickanchors::basicAnchors() @@ -472,6 +473,10 @@ void tst_qquickanchors::fill() qApp->processEvents(); QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rectPrivate->anchors()->leftMargin(), 10.0); + QCOMPARE(rectPrivate->anchors()->topMargin(), 30.0); + QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0); + QCOMPARE(rectPrivate->anchors()->bottomMargin(), 40.0); QCOMPARE(rect->x(), 0.0 + 10.0); QCOMPARE(rect->y(), 0.0 + 30.0); QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); @@ -481,6 +486,10 @@ void tst_qquickanchors::fill() rectPrivate->anchors()->setRightMargin(0.0); rectPrivate->anchors()->setBottomMargin(0.0); rectPrivate->anchors()->setTopMargin(10.0); + QCOMPARE(rectPrivate->anchors()->leftMargin(), 20.0); + QCOMPARE(rectPrivate->anchors()->topMargin(), 10.0); + QCOMPARE(rectPrivate->anchors()->rightMargin(), 0.0); + QCOMPARE(rectPrivate->anchors()->bottomMargin(), 0.0); QCOMPARE(rect->x(), 0.0 + 20.0); QCOMPARE(rect->y(), 0.0 + 10.0); QCOMPARE(rect->width(), 200.0 - 20.0); @@ -523,11 +532,15 @@ void tst_qquickanchors::centerIn() QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), 10.0); + QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), 30.0); QCOMPARE(rect->x(), 75.0 + 10); QCOMPARE(rect->y(), 75.0 + 30); //Alter Offsets (tests QTBUG-6631) rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); rectPrivate->anchors()->setVerticalCenterOffset(-10.0); + QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), -20.0); + QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), -10.0); QCOMPARE(rect->x(), 75.0 - 20.0); QCOMPARE(rect->y(), 75.0 - 10.0); @@ -623,6 +636,11 @@ void tst_qquickanchors::margins() qApp->processEvents(); QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rectPrivate->anchors()->margins(), 10.0); + QCOMPARE(rectPrivate->anchors()->topMargin(), 6.0); + QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0); + QCOMPARE(rectPrivate->anchors()->bottomMargin(), 10.0); + QCOMPARE(rectPrivate->anchors()->rightMargin(), 10.0); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 6.0); QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); @@ -631,6 +649,12 @@ void tst_qquickanchors::margins() rectPrivate->anchors()->setTopMargin(0.0); rectPrivate->anchors()->setMargins(20.0); + QCOMPARE(rectPrivate->anchors()->margins(), 20.0); + QEXPECT_FAIL("","QTBUG-24515", Continue); + QCOMPARE(rectPrivate->anchors()->topMargin(), 0.0); + QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0); + QCOMPARE(rectPrivate->anchors()->bottomMargin(), 20.0); + QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 20.0); QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0); @@ -663,6 +687,23 @@ void tst_qquickanchors::marginsRTL() delete view; } +void tst_qquickanchors::stretch() +{ + QQuickView *view = new QQuickView(testFileUrl("stretch.qml")); + + qApp->processEvents(); + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("stretcher")); + QCOMPARE(rect->x(), 160.0); + QCOMPARE(rect->y(), 130.0); + QCOMPARE(rect->width(), 40.0); + QCOMPARE(rect->height(), 100.0); + + QQuickRectangle* rect2 = findItem(view->rootObject(), QLatin1String("stretcher2")); + QCOMPARE(rect2->y(), 130.0); + QCOMPARE(rect2->height(), 100.0); + + delete view; +} QTEST_MAIN(tst_qquickanchors) -- cgit v1.2.3 From de02b0f6ba4c422ff617308617b32804b15d1f7e Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Fri, 24 Feb 2012 16:14:12 +1000 Subject: Ensure importing module API in js import works This commit adds a unit test to ensure that a property of a module api can be accessed in a JavaScript import. Change-Id: Iecba76a9db0400ece1777256f19803d4bad53438 Reviewed-by: Alan Alpert --- .../qdeclarativeecmascript/data/jsimport/importModuleApi.js | 5 +++++ .../data/jsimport/testImportModuleApi.qml | 10 ++++++++++ .../qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 7 +++++++ 3 files changed, 22 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js new file mode 100644 index 0000000000..7a4f434665 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js @@ -0,0 +1,5 @@ +.import Qt.test 1.0 as QObjectModuleApi + +function testFunc() { + return QObjectModuleApi.qobjectTestProperty +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml new file mode 100644 index 0000000000..b3e545dd7c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import "importModuleApi.js" as Script + +Item { + property variant testValue: 5 + + Component.onCompleted: { + testValue = Script.testFunc(); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 7fc137e38d..6905252107 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -3267,6 +3267,13 @@ void tst_qdeclarativeecmascript::importScripts_data() << QStringList() << (QStringList() << QLatin1String("testValue")) << (QVariantList() << QVariant(18)); + + QTest::newRow("import module api into js import") + << testFileUrl("jsimport/testImportModuleApi.qml") + << QString() + << QStringList() + << (QStringList() << QLatin1String("testValue")) + << (QVariantList() << QVariant(20)); } void tst_qdeclarativeecmascript::importScripts() -- cgit v1.2.3 From d2921ffc52fed380326f8abb86d6d659cc47f9d1 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Fri, 24 Feb 2012 14:40:11 +1000 Subject: Check engine equality condition inside null ptr check Previously, we asserted if the engine associated with the two external resources from the arguments to the object comparison callback were not equal, prior to checking that the external resources were non-null. Task-number: QTBUG-24489 Change-Id: I4b2bd2377fcf38163d1341e43e056b1405ab72ac Reviewed-by: Yunqiao Yin Reviewed-by: Michael Brasser --- .../qdeclarativevaluetypes/data/nonValueTypeComparison.qml | 10 ++++++++++ .../qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp | 13 +++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml new file mode 100644 index 0000000000..0ffa5eb666 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + property variant somepoint: Qt.point(1,2) + property variant randomjsobj: {"some": 1, "thing": 2} + property bool test1: somepoint != randomjsobj + + property variant similar: {"x":1, "y":2} + property bool test2: somepoint != similar +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 72ec7a5abf..e701efa2a4 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -93,6 +93,7 @@ private slots: void returnValues(); void varAssignment(); void bindingsSpliceCorrectly(); + void nonValueTypeComparison(); private: QDeclarativeEngine engine; @@ -1301,6 +1302,18 @@ void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly() } } +void tst_qdeclarativevaluetypes::nonValueTypeComparison() +{ + QDeclarativeComponent component(&engine, testFileUrl("nonValueTypeComparison.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + + delete object; +} + QTEST_MAIN(tst_qdeclarativevaluetypes) #include "tst_qdeclarativevaluetypes.moc" -- cgit v1.2.3 From 15dac112df4f44ba8b15047720e1570fd4096f26 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 23 Feb 2012 16:57:06 +1000 Subject: Don't create a separate section header for currentItem The currentItem FxViewItem contained it's own section item, which when created would cause the current item delegate to be repositioned. This change associates the section item with the delegate item, via the attached object. Change-Id: Ie675d545539b56d0f1cf5a9b4ea26668978a5e72 Reviewed-by: Bea Lam --- .../qquicklistview/data/sectionpropertychange.qml | 92 ++++++++++++++++++++++ .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 53 ++++++++++++- 2 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml b/tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml new file mode 100644 index 0000000000..f4679b5af0 --- /dev/null +++ b/tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml @@ -0,0 +1,92 @@ +import QtQuick 2.0 + +Rectangle { + width: 320; height: 480 + + Rectangle { + id: groupButtons + width: 300; height: 30 + color: "yellow" + border.width: 1 + Text { + anchors.centerIn: parent + text: "swap" + } + anchors { + top: parent.top + horizontalCenter: parent.horizontalCenter + } + MouseArea { + anchors.fill: parent + onClicked: switchGroups() + } + } + + function switchGroups() { + if ("title" === myListView.groupBy) + myListView.groupBy = "genre" + else + myListView.groupBy = "title" + } + + Component.onCompleted: { + myListView.model = generateModel(myListView) + } + + ListView { + id: myListView + objectName: "list" + + clip: true + property string groupBy: "title" + + anchors { + top: groupButtons.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + + delegate: Item { + objectName: "wrapper" + height: 50 + width: 320 + Text { id: t; text: model.title } + Text { text: model.author; font.pixelSize: 10; anchors.top: t.bottom } + Text { text: parent.y; anchors.right: parent.right } + } + + onGroupByChanged: { + model.move(0,1,1) + section.property = groupBy + } + + section { + criteria: ViewSection.FullString + delegate: Rectangle { width: 320; height: 25; color: "lightblue" + objectName: "sect" + Text {text: section } + Text { text: parent.y; anchors.right: parent.right } + } + property: "title" + } + } + + function generateModel(theParent) + { + var books = [ + { "author": "Billy Bob", "genre": "Anarchism", "title": "Frogs and Love" }, + { "author": "Lefty Smith", "genre": "Horror", "title": "Chainsaws for Noobs" } + ]; + + var model = Qt.createQmlObject("import QtQuick 2.0; ListModel {}", theParent); + + for (var i = 0; i < books.length; ++i) { + var book = books[i]; + model.append(book); + } + return model; + } + +} + diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index 959bb2b265..253df3295f 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -125,6 +125,7 @@ private slots: void qAbstractItemModel_sections(); void sectionsPositioning(); void sectionsDelegate(); + void sectionPropertyChange(); void cacheBuffer(); void positionViewAtIndex(); void resetModel(); @@ -2095,9 +2096,9 @@ void tst_QQuickListView::sectionsPositioning() QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); model.removeItem(5); QTRY_COMPARE(listview->count(), model.count()); - for (int i = 0; i < 3; ++i) { - QQuickItem *item = findItem(contentItem, - "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); + for (int i = 1; i < 3; ++i) { + QQuickItem *item = findVisibleChild(contentItem, + "sect_" + QString::number(i)); QVERIFY(item); QTRY_COMPARE(item->y(), qreal(i*20*6)); } @@ -2135,6 +2136,52 @@ void tst_QQuickListView::sectionsPositioning() delete canvas; } +void tst_QQuickListView::sectionPropertyChange() +{ + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("sectionpropertychange.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + for (int i = 0; i < 2; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), qreal(25. + i*75.)); + } + + QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups"); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + for (int i = 0; i < 2; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), qreal(25. + i*75.)); + } + + QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups"); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + for (int i = 0; i < 2; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), qreal(25. + i*75.)); + } + + delete canvas; +} + void tst_QQuickListView::currentIndex_delayedItemCreation() { QFETCH(bool, setCurrentToZero); -- cgit v1.2.3 From 8e3284135d2be23ca1be79569271f39092d6d6b4 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 27 Feb 2012 17:37:57 +1000 Subject: Skip test case for now Change-Id: I06128c544c1ee03d4528f6f86fc776e09be87316 Reviewed-by: Bea Lam --- tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp | 2 ++ tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index cc76b7b401..5765a67b77 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -1272,6 +1272,8 @@ void tst_QQuickGridView::moved_data() void tst_QQuickGridView::multipleChanges() { + QSKIP("QTBUG-24523"); + QFETCH(int, startCount); QFETCH(QList, changes); QFETCH(int, newCount); diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index 253df3295f..04da3f732f 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -5566,6 +5566,8 @@ void tst_QQuickListView::removeTransitions_data() void tst_QQuickListView::multipleTransitions() { + QSKIP("QTBUG-24523"); + // Tests that if you interrupt a transition in progress with another action that // cancels the previous transition, the resulting items are still placed correctly. -- cgit v1.2.3 From cfad9eb4df8b8e389143b138ca4536bca0d163eb Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Mon, 27 Feb 2012 13:01:03 +0100 Subject: QmlProfiler: send v8 profiling started signal Change-Id: Ie26bd47c9b79a7f524b9c5bc59146be1ea93761d Reviewed-by: Kai Koehne --- .../debugger/qv8profilerservice/tst_qv8profilerservice.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp index 92b893afc6..165783fed5 100644 --- a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp +++ b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp @@ -91,6 +91,7 @@ public: QList snapshotMessages; signals: + void started(); void complete(); void snapshot(); @@ -158,6 +159,9 @@ void QV8ProfilerClient::messageReceived(const QByteArray &message) case QV8ProfilerService::V8SnapshotComplete: emit snapshot(); break; + case QV8ProfilerService::V8Started: + emit started(); + break; default: QString failMessage = QString("Unknown message type: %1").arg(messageType); QFAIL(qPrintable(failMessage)); @@ -208,6 +212,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceEnabled() QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); m_client->startProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -225,6 +231,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceDisabled() QFAIL(qPrintable(failMsg)); } m_client->startProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -236,6 +244,8 @@ void tst_QV8ProfilerService::nonBlockingConnect() QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); m_client->startProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -257,6 +267,8 @@ void tst_QV8ProfilerService::profileOnExit() QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); m_client->startProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -270,6 +282,8 @@ void tst_QV8ProfilerService::console() m_client->stopProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); QVERIFY(!m_client->traceMessages.isEmpty()); -- cgit v1.2.3 From ccd859d2c47e926415c5b1307e84efd4197583c4 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 27 Feb 2012 10:19:01 +1000 Subject: Skip c++ examples in sgexamples test They should be tested separately, QTBUG-24516 has been raised to implement this. Change-Id: Ic90bc8327e6c07164ed34b3d02f2612561491ec0 Reviewed-by: Michael Brasser --- tests/auto/qtquick2/examples/tst_examples.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/examples/tst_examples.cpp b/tests/auto/qtquick2/examples/tst_examples.cpp index ce8f214efd..e80bfec0e2 100644 --- a/tests/auto/qtquick2/examples/tst_examples.cpp +++ b/tests/auto/qtquick2/examples/tst_examples.cpp @@ -88,10 +88,11 @@ tst_examples::tst_examples() // Add files to exclude here excludedFiles << "doc/src/snippets/declarative/listmodel.qml"; //Just a ListModel, no root QQuickItem - // Add directories you want excluded here - excludedDirs << "examples/shared"; //Not an example - excludedDirs << "examples/qtquick/text/fonts"; // QTBUG-21415 + // Add directories you want excluded here (don't add examples/, because they install to examples/qtdeclarative/) + excludedDirs << "shared"; //Not an example + excludedDirs << "qtquick/text/fonts"; // QTBUG-21415 excludedDirs << "doc/src/snippets/declarative/path"; //No root QQuickItem + excludedDirs << "tutorials/gettingStartedQml"; //C++ example, but no cpp files in root dir // These snippets are not expected to run on their own. excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex"; @@ -99,15 +100,15 @@ tst_examples::tst_examples() excludedDirs << "doc/src/snippets/declarative/imports"; #ifdef QT_NO_WEBKIT - excludedDirs << "examples/qtquick/modelviews/webview"; - excludedDirs << "examples/demos/webbrowser"; + excludedDirs << "qtquick/modelviews/webview"; + excludedDirs << "demos/webbrowser"; excludedDirs << "doc/src/snippets/declarative/webview"; #endif #ifdef QT_NO_XMLPATTERNS - excludedDirs << "examples/demos/twitter"; - excludedDirs << "examples/demos/flickr"; - excludedDirs << "examples/demos/photoviewer"; + excludedDirs << "demos/twitter"; + excludedDirs << "demos/flickr"; + excludedDirs << "demos/photoviewer"; #endif } -- cgit v1.2.3 From 0bf62c44ab5bc53162ef0d7efea38764e2df8318 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 28 Feb 2012 09:48:27 +1000 Subject: Correctly set duration and easing for AnchorAnimation. Task-number: QTBUG-24532 Change-Id: I3aad9cd8281b954896c2c1d44b2dcae68f913928 Reviewed-by: Yunqiao Yin --- .../qdeclarativeanimations/tst_qdeclarativeanimations.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index c7a0717dd3..348586cea8 100644 --- a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -105,6 +106,7 @@ private slots: void pauseBindingBug(); void pauseBug(); void loopingBug(); + void anchorBug(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -1314,6 +1316,19 @@ void tst_qdeclarativeanimations::loopingBug() delete obj; } +//QTBUG-24532 +void tst_qdeclarativeanimations::anchorBug() +{ + QQuickAnchorAnimation animation; + animation.setDuration(5000); + animation.setEasing(QEasingCurve(QEasingCurve::InOutBack)); + animation.start(); + animation.pause(); + + QCOMPARE(animation.qtAnimation()->duration(), 5000); + QCOMPARE(static_cast(animation.qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutBack)); +} + QTEST_MAIN(tst_qdeclarativeanimations) #include "tst_qdeclarativeanimations.moc" -- cgit v1.2.3 From f7dae3960b2ab6f5db3a79e3ea701f2531b909d7 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 14 Feb 2012 09:33:42 +1000 Subject: Add AnimatedSprite A simpler sprite image element for the simple usecase. Because sometimes an engine with stochastic capabilities is overkill. Change-Id: I2b76c5d417719e92a548f6266bffd563dc016983 Reviewed-by: Alan Alpert --- .../qtquick2/qquickanimatedsprite/data/basic.qml | 58 ++++++++++++++ .../qquickanimatedsprite/data/squarefacesprite.png | Bin 0 -> 496 bytes .../qquickanimatedsprite/qquickanimatedsprite.pro | 15 ++++ .../tst_qquickanimatedsprite.cpp | 83 +++++++++++++++++++++ tests/auto/qtquick2/qtquick2.pro | 1 + 5 files changed, 157 insertions(+) create mode 100644 tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml create mode 100644 tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png create mode 100644 tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro create mode 100644 tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml b/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml new file mode 100644 index 0000000000..f219e5fb81 --- /dev/null +++ b/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + AnimatedSprite { + objectName: "sprite" + loops: 3 + source: "squarefacesprite.png" + frames: 6 + frameDuration: 120 + width: 160 + height: 160 + } +} diff --git a/tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png b/tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png new file mode 100644 index 0000000000..f9a5d5fcce Binary files /dev/null and b/tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png differ diff --git a/tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro b/tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro new file mode 100644 index 0000000000..aad73d538d --- /dev/null +++ b/tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickanimatedsprite +SOURCES += tst_qquickanimatedsprite.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp new file mode 100644 index 0000000000..3cc8f129fd --- /dev/null +++ b/tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "../../shared/util.h" +#include +#include + +class tst_qquickanimatedsprite : public QDeclarativeDataTest +{ + Q_OBJECT +public: + tst_qquickanimatedsprite(){} + +private slots: + void test_properties(); +}; + +void tst_qquickanimatedsprite::test_properties() +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(testFileUrl("basic.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QVERIFY(canvas->rootObject()); + QQuickAnimatedSprite* sprite = canvas->rootObject()->findChild("sprite"); + QVERIFY(sprite); + + QVERIFY(sprite->running()); + QVERIFY(!sprite->paused()); + QVERIFY(sprite->interpolate()); + QCOMPARE(sprite->loops(), 3); + + sprite->setRunning(false); + QVERIFY(!sprite->running()); + sprite->setInterpolate(false); + QVERIFY(!sprite->interpolate()); + + delete canvas; +} + +QTEST_MAIN(tst_qquickanimatedsprite) + +#include "tst_qquickanimatedsprite.moc" diff --git a/tests/auto/qtquick2/qtquick2.pro b/tests/auto/qtquick2/qtquick2.pro index 7acd75f69e..60e302759e 100644 --- a/tests/auto/qtquick2/qtquick2.pro +++ b/tests/auto/qtquick2/qtquick2.pro @@ -31,6 +31,7 @@ QUICKTESTS = \ qquickaccessible \ qquickanchors \ qquickanimatedimage \ + qquickanimatedsprite \ qquickborderimage \ qquickcanvas \ qquickdrag \ -- cgit v1.2.3 From 75a0d33d250a97d5ee0314f5b7aad876d9ee2fa8 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 14 Feb 2012 18:16:21 +1000 Subject: Rename SpriteImage to SpriteSequence Also rename Sprite::frames->Sprite::frameCount Change-Id: I2e7a71adc37044fd696ffda2a5da4835725ba3a8 Reviewed-by: Alan Alpert --- .../qtquick2/qquickanimatedsprite/data/basic.qml | 2 +- .../qtquick2/qquickspriteimage/data/advance.qml | 66 -------------- .../auto/qtquick2/qquickspriteimage/data/basic.qml | 60 ------------- .../qquickspriteimage/data/squarefacesprite.png | Bin 496 -> 0 bytes .../qquickspriteimage/qquickspriteimage.pro | 15 ---- .../qquickspriteimage/tst_qquickspriteimage.cpp | 98 --------------------- .../qtquick2/qquickspritesequence/data/advance.qml | 66 ++++++++++++++ .../qtquick2/qquickspritesequence/data/basic.qml | 60 +++++++++++++ .../qquickspritesequence/data/squarefacesprite.png | Bin 0 -> 496 bytes .../qquickspritesequence/qquickspritesequence.pro | 15 ++++ .../tst_qquickspritesequence.cpp | 98 +++++++++++++++++++++ tests/auto/qtquick2/qtquick2.pro | 2 +- 12 files changed, 241 insertions(+), 241 deletions(-) delete mode 100644 tests/auto/qtquick2/qquickspriteimage/data/advance.qml delete mode 100644 tests/auto/qtquick2/qquickspriteimage/data/basic.qml delete mode 100644 tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png delete mode 100644 tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro delete mode 100644 tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp create mode 100644 tests/auto/qtquick2/qquickspritesequence/data/advance.qml create mode 100644 tests/auto/qtquick2/qquickspritesequence/data/basic.qml create mode 100644 tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png create mode 100644 tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro create mode 100644 tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml b/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml index f219e5fb81..2dd20630d9 100644 --- a/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml +++ b/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml @@ -50,7 +50,7 @@ Rectangle { objectName: "sprite" loops: 3 source: "squarefacesprite.png" - frames: 6 + frameCount: 6 frameDuration: 120 width: 160 height: 160 diff --git a/tests/auto/qtquick2/qquickspriteimage/data/advance.qml b/tests/auto/qtquick2/qquickspriteimage/data/advance.qml deleted file mode 100644 index 46a49ca673..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/data/advance.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "black" - width: 320 - height: 320 - - SpriteImage { - objectName: "sprite" - sprites: [Sprite { - name: "firstState" - source: "squarefacesprite.png" - frames: 3 - frameSync: true - to: {"secondState":1} - }, Sprite { - name: "secondState" - source: "squarefacesprite.png" - frames: 6 - frameSync: true - } ] - width: 160 - height: 160 - } -} diff --git a/tests/auto/qtquick2/qquickspriteimage/data/basic.qml b/tests/auto/qtquick2/qquickspriteimage/data/basic.qml deleted file mode 100644 index 2f2b1c96fa..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/data/basic.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "black" - width: 320 - height: 320 - - SpriteImage { - objectName: "sprite" - sprites: Sprite { - name: "happy" - source: "squarefacesprite.png" - frames: 6 - frameDuration: 120 - } - width: 160 - height: 160 - } -} diff --git a/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png b/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png deleted file mode 100644 index f9a5d5fcce..0000000000 Binary files a/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro b/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro deleted file mode 100644 index 0d63007c65..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickspriteimage -SOURCES += tst_qquickspriteimage.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp b/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp deleted file mode 100644 index 37453521fa..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include "../../shared/util.h" -#include -#include - -class tst_qquickspriteimage : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquickspriteimage(){} - -private slots: - void test_properties(); - void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine -}; - -void tst_qquickspriteimage::test_properties() -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(testFileUrl("basic.qml")); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QVERIFY(canvas->rootObject()); - QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); - QVERIFY(sprite); - - QVERIFY(sprite->running()); - QVERIFY(sprite->interpolate()); - - sprite->setRunning(false); - QVERIFY(!sprite->running()); - sprite->setInterpolate(false); - QVERIFY(!sprite->interpolate()); - - delete canvas; -} - -void tst_qquickspriteimage::test_framerateAdvance() -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(testFileUrl("advance.qml")); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QVERIFY(canvas->rootObject()); - QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); - QVERIFY(sprite); - - QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState")); - delete canvas; -} - -QTEST_MAIN(tst_qquickspriteimage) - -#include "tst_qquickspriteimage.moc" diff --git a/tests/auto/qtquick2/qquickspritesequence/data/advance.qml b/tests/auto/qtquick2/qquickspritesequence/data/advance.qml new file mode 100644 index 0000000000..5866dcbfac --- /dev/null +++ b/tests/auto/qtquick2/qquickspritesequence/data/advance.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + SpriteSequence { + objectName: "sprite" + sprites: [Sprite { + name: "firstState" + source: "squarefacesprite.png" + frameCount: 3 + frameSync: true + to: {"secondState":1} + }, Sprite { + name: "secondState" + source: "squarefacesprite.png" + frameCount: 6 + frameSync: true + } ] + width: 160 + height: 160 + } +} diff --git a/tests/auto/qtquick2/qquickspritesequence/data/basic.qml b/tests/auto/qtquick2/qquickspritesequence/data/basic.qml new file mode 100644 index 0000000000..5eb7475f11 --- /dev/null +++ b/tests/auto/qtquick2/qquickspritesequence/data/basic.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + SpriteSequence { + objectName: "sprite" + sprites: Sprite { + name: "happy" + source: "squarefacesprite.png" + frameCount: 6 + frameDuration: 120 + } + width: 160 + height: 160 + } +} diff --git a/tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png b/tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png new file mode 100644 index 0000000000..f9a5d5fcce Binary files /dev/null and b/tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png differ diff --git a/tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro b/tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro new file mode 100644 index 0000000000..16c20ef75b --- /dev/null +++ b/tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickspritesequence +SOURCES += tst_qquickspritesequence.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp b/tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp new file mode 100644 index 0000000000..848d6a343c --- /dev/null +++ b/tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "../../shared/util.h" +#include +#include + +class tst_qquickspritesequence : public QDeclarativeDataTest +{ + Q_OBJECT +public: + tst_qquickspritesequence(){} + +private slots: + void test_properties(); + void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine +}; + +void tst_qquickspritesequence::test_properties() +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(testFileUrl("basic.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QVERIFY(canvas->rootObject()); + QQuickSpriteSequence* sprite = canvas->rootObject()->findChild("sprite"); + QVERIFY(sprite); + + QVERIFY(sprite->running()); + QVERIFY(sprite->interpolate()); + + sprite->setRunning(false); + QVERIFY(!sprite->running()); + sprite->setInterpolate(false); + QVERIFY(!sprite->interpolate()); + + delete canvas; +} + +void tst_qquickspritesequence::test_framerateAdvance() +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(testFileUrl("advance.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QVERIFY(canvas->rootObject()); + QQuickSpriteSequence* sprite = canvas->rootObject()->findChild("sprite"); + QVERIFY(sprite); + + QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState")); + delete canvas; +} + +QTEST_MAIN(tst_qquickspritesequence) + +#include "tst_qquickspritesequence.moc" diff --git a/tests/auto/qtquick2/qtquick2.pro b/tests/auto/qtquick2/qtquick2.pro index 60e302759e..9034cb445a 100644 --- a/tests/auto/qtquick2/qtquick2.pro +++ b/tests/auto/qtquick2/qtquick2.pro @@ -53,7 +53,7 @@ QUICKTESTS = \ qquickpositioners \ qquickrepeater \ qquickshadereffect \ - qquickspriteimage \ + qquickspritesequence \ qquicktext \ qquicktextedit \ qquicktextinput \ -- cgit v1.2.3 From ba3ac328ca721712c56f28a1fc6ae8e64b6ad7f2 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 22 Feb 2012 17:23:47 +1000 Subject: Add generic "displaced" transition property This is the default displaced transition that will be applied if addDisplaced, removeDisplaced or moveDisplaced are not specified (or are disabled). Change-Id: I9356036dc93bd9cb26e64e0b1769228113b74273 Reviewed-by: Martin Jones --- .../qquickgridview/data/displacedTransitions.qml | 138 +++++++++++++ .../qtquick2/qquickgridview/tst_qquickgridview.cpp | 211 ++++++++++++++++++++ .../qquicklistview/data/displacedTransitions.qml | 128 +++++++++++++ .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 213 +++++++++++++++++++++ tests/auto/qtquick2/shared/viewtestutil.h | 1 + 5 files changed, 691 insertions(+) create mode 100644 tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml create mode 100644 tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml new file mode 100644 index 0000000000..d9353c0639 --- /dev/null +++ b/tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml @@ -0,0 +1,138 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 500 + height: 600 + + property int duration: 10 + property int count: grid.count + + Component { + id: myDelegate + Rectangle { + id: wrapper + + property string nameData: name + + objectName: "wrapper" + width: 80 + height: 60 + Text { + text: index + } + Text { + x: 40 + text: wrapper.x + ", " + wrapper.y + } + Text { + y: 20 + id: textName + objectName: "textName" + text: name + } + Text { + y: 40 + id: textNumber + objectName: "textNumber" + text: number + } + color: GridView.isCurrentItem ? "lightsteelblue" : "white" + + onXChanged: checkPos() + onYChanged: checkPos() + + function checkPos() { + if (Qt.point(x, y) == displaced_transitionVia) + model_displaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == addDisplaced_transitionVia) + model_addDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == moveDisplaced_transitionVia) + model_moveDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == removeDisplaced_transitionVia) + model_removeDisplaced_transitionVia.addItem(name, "") + } + } + } + + GridView { + id: grid + + property int targetTransitionsDone + property int displaceTransitionsDone + + objectName: "grid" + focus: true + anchors.centerIn: parent + width: 240 + height: 320 + cellWidth: 80 + cellHeight: 60 + model: testModel + delegate: myDelegate + + displaced: useDisplaced ? displaced : null + addDisplaced: useAddDisplaced ? addDisplaced : null + moveDisplaced: useMoveDisplaced ? moveDisplaced : null + removeDisplaced: useRemoveDisplaced ? removeDisplaced : null + + Transition { + id: displaced + enabled: displacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: displaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: displaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: addDisplaced + enabled: addDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: addDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: addDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: moveDisplaced + enabled: moveDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: moveDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: moveDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: removeDisplaced + enabled: removeDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true } + } + } + } + + Rectangle { + anchors.fill: grid + color: "lightsteelblue" + opacity: 0.2 + } +} + diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index 5765a67b77..6d755a64c7 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -138,6 +138,8 @@ private slots: void moveTransitions_data(); void removeTransitions(); void removeTransitions_data(); + void displacedTransitions(); + void displacedTransitions_data(); void multipleTransitions(); void multipleTransitions_data(); @@ -4557,6 +4559,215 @@ void tst_QQuickGridView::removeTransitions_data() << 18 << 3 << ListRange(); } +void tst_QQuickGridView::displacedTransitions() +{ + QFETCH(bool, useDisplaced); + QFETCH(bool, displacedEnabled); + QFETCH(bool, useAddDisplaced); + QFETCH(bool, addDisplacedEnabled); + QFETCH(bool, useMoveDisplaced); + QFETCH(bool, moveDisplacedEnabled); + QFETCH(bool, useRemoveDisplaced); + QFETCH(bool, removeDisplacedEnabled); + QFETCH(ListChange, change); + QFETCH(ListRange, expectedDisplacedIndexes); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_displaced_transitionVia; + QaimModel model_addDisplaced_transitionVia; + QaimModel model_moveDisplaced_transitionVia; + QaimModel model_removeDisplaced_transitionVia; + + QPointF displaced_transitionVia(-50, -100); + QPointF addDisplaced_transitionVia(-150, 100); + QPointF moveDisplaced_transitionVia(50, -100); + QPointF removeDisplaced_transitionVia(150, 100); + + QQuickView *canvas = createView(); + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia); + ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia); + ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia); + ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia); + ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia); + ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia); + ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia); + ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia); + ctxt->setContextProperty("useDisplaced", useDisplaced); + ctxt->setContextProperty("displacedEnabled", displacedEnabled); + ctxt->setContextProperty("useAddDisplaced", useAddDisplaced); + ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled); + ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced); + ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled); + ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced); + ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled); + canvas->setSource(testFileUrl("displacedTransitions.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + gridview->setProperty("displaceTransitionsDone", false); + + switch (change.type) { + case ListChange::Inserted: + { + QList > targetItemData; + for (int i=change.index; icount()); + break; + } + case ListChange::Removed: + model.removeItems(change.index, change.count); + QTRY_COMPARE(model.count(), gridview->count()); + break; + case ListChange::Moved: + model.moveItems(change.index, change.to, change.count); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + break; + case ListChange::SetCurrent: + case ListChange::SetContentY: + break; + } + if ((useDisplaced && displacedEnabled) + || (useAddDisplaced && addDisplacedEnabled) + || (useMoveDisplaced && moveDisplacedEnabled) + || (useRemoveDisplaced && removeDisplacedEnabled)) { + QTRY_VERIFY(gridview->property("displaceTransitionsDone").toBool()); + } + + if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled) + model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced"); + else + QCOMPARE(model_addDisplaced_transitionVia.count(), 0); + if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled) + model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced"); + else + QCOMPARE(model_moveDisplaced_transitionVia.count(), 0); + if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled) + model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced"); + else + QCOMPARE(model_removeDisplaced_transitionVia.count(), 0); + + if (useDisplaced && displacedEnabled + && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled)) + || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled)) + || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) { + model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced"); + } else { + QCOMPARE(model_displaced_transitionVia.count(), 0); + } + + // verify all items moved to the correct final positions + QList items = findItems(contentItem, "wrapper"); + for (int i=0; i < model.count() && i < items.count(); ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::displacedTransitions_data() +{ + QTest::addColumn("useDisplaced"); + QTest::addColumn("displacedEnabled"); + QTest::addColumn("useAddDisplaced"); + QTest::addColumn("addDisplacedEnabled"); + QTest::addColumn("useMoveDisplaced"); + QTest::addColumn("moveDisplacedEnabled"); + QTest::addColumn("useRemoveDisplaced"); + QTest::addColumn("removeDisplacedEnabled"); + QTest::addColumn("change"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("no displaced transitions at all") + << false << false + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("just displaced") + << true << true + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("just displaced (not enabled)") + << true << false + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("displaced + addDisplaced") + << true << true + << true << true + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("displaced + addDisplaced (not enabled)") + << true << true + << true << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("displaced + moveDisplaced") + << true << true + << false << false + << true << true + << false << false + << ListChange::move(0, 10, 1) << ListRange(1, 10); + + QTest::newRow("displaced + moveDisplaced (not enabled)") + << true << true + << false << false + << true << false + << false << false + << ListChange::move(0, 10, 1) << ListRange(1, 10); + + QTest::newRow("displaced + removeDisplaced") + << true << true + << false << false + << false << false + << true << true + << ListChange::remove(0, 1) << ListRange(1, 18); + + QTest::newRow("displaced + removeDisplaced (not enabled)") + << true << true + << false << false + << false << false + << true << false + << ListChange::remove(0, 1) << ListRange(1, 18); + + + QTest::newRow("displaced + add, should use generic displaced for a remove") + << true << true + << true << true + << false << false + << true << false + << ListChange::remove(0, 1) << ListRange(1, 18); +} + void tst_QQuickGridView::multipleTransitions() { // Tests that if you interrupt a transition in progress with another action that diff --git a/tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml new file mode 100644 index 0000000000..cc7892e930 --- /dev/null +++ b/tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml @@ -0,0 +1,128 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 500 + height: 600 + + property int duration: 10 + property int count: list.count + + Component { + id: myDelegate + Rectangle { + id: wrapper + + property string nameData: name + + objectName: "wrapper" + height: 20 + width: 240 + Text { text: index } + Text { + x: 30 + id: textName + objectName: "textName" + text: name + } + Text { + x: 200 + text: wrapper.y + } + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + + onXChanged: checkPos() + onYChanged: checkPos() + + function checkPos() { + if (Qt.point(x, y) == displaced_transitionVia) + model_displaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == addDisplaced_transitionVia) + model_addDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == moveDisplaced_transitionVia) + model_moveDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == removeDisplaced_transitionVia) + model_removeDisplaced_transitionVia.addItem(name, "") + } + } + } + + ListView { + id: list + + property int targetTransitionsDone + property int displaceTransitionsDone + + objectName: "list" + focus: true + anchors.centerIn: parent + width: 240 + height: 320 + model: testModel + delegate: myDelegate + + displaced: useDisplaced ? displaced : null + addDisplaced: useAddDisplaced ? addDisplaced : null + moveDisplaced: useMoveDisplaced ? moveDisplaced : null + removeDisplaced: useRemoveDisplaced ? removeDisplaced : null + + Transition { + id: displaced + enabled: displacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: displaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: displaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: addDisplaced + enabled: addDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: addDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: addDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: moveDisplaced + enabled: moveDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: moveDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: moveDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: removeDisplaced + enabled: removeDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + } + + Rectangle { + anchors.fill: list + color: "lightsteelblue" + opacity: 0.2 + } +} + diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index 04da3f732f..a834f1aa03 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -179,6 +179,8 @@ private slots: void moveTransitions_data(); void removeTransitions(); void removeTransitions_data(); + void displacedTransitions(); + void displacedTransitions_data(); void multipleTransitions(); void multipleTransitions_data(); @@ -5564,6 +5566,217 @@ void tst_QQuickListView::removeTransitions_data() << 17 << 3 << ListRange(); } +void tst_QQuickListView::displacedTransitions() +{ + QFETCH(bool, useDisplaced); + QFETCH(bool, displacedEnabled); + QFETCH(bool, useAddDisplaced); + QFETCH(bool, addDisplacedEnabled); + QFETCH(bool, useMoveDisplaced); + QFETCH(bool, moveDisplacedEnabled); + QFETCH(bool, useRemoveDisplaced); + QFETCH(bool, removeDisplacedEnabled); + QFETCH(ListChange, change); + QFETCH(ListRange, expectedDisplacedIndexes); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_displaced_transitionVia; + QaimModel model_addDisplaced_transitionVia; + QaimModel model_moveDisplaced_transitionVia; + QaimModel model_removeDisplaced_transitionVia; + + QPointF displaced_transitionVia(-50, -100); + QPointF addDisplaced_transitionVia(-150, 100); + QPointF moveDisplaced_transitionVia(50, -100); + QPointF removeDisplaced_transitionVia(150, 100); + + QQuickView *canvas = createView(); + QDeclarativeContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject(canvas); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testObject", testObject); + ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia); + ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia); + ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia); + ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia); + ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia); + ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia); + ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia); + ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia); + ctxt->setContextProperty("useDisplaced", useDisplaced); + ctxt->setContextProperty("displacedEnabled", displacedEnabled); + ctxt->setContextProperty("useAddDisplaced", useAddDisplaced); + ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled); + ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced); + ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled); + ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced); + ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled); + canvas->setSource(testFileUrl("displacedTransitions.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + listview->setProperty("displaceTransitionsDone", false); + + switch (change.type) { + case ListChange::Inserted: + { + QList > targetItemData; + for (int i=change.index; icount()); + break; + } + case ListChange::Removed: + model.removeItems(change.index, change.count); + QTRY_COMPARE(model.count(), listview->count()); + break; + case ListChange::Moved: + model.moveItems(change.index, change.to, change.count); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + break; + case ListChange::SetCurrent: + case ListChange::SetContentY: + break; + } + if ((useDisplaced && displacedEnabled) + || (useAddDisplaced && addDisplacedEnabled) + || (useMoveDisplaced && moveDisplacedEnabled) + || (useRemoveDisplaced && removeDisplacedEnabled)) { + QTRY_VERIFY(listview->property("displaceTransitionsDone").toBool()); + } + + if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled) + model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced"); + else + QCOMPARE(model_addDisplaced_transitionVia.count(), 0); + if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled) + model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced"); + else + QCOMPARE(model_moveDisplaced_transitionVia.count(), 0); + if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled) + model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced"); + else + QCOMPARE(model_removeDisplaced_transitionVia.count(), 0); + + if (useDisplaced && displacedEnabled + && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled)) + || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled)) + || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) { + model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced"); + } else { + QCOMPARE(model_displaced_transitionVia.count(), 0); + } + + // verify all items moved to the correct final positions + QList items = findItems(contentItem, "wrapper"); + for (int i=0; i < model.count() && i < items.count(); ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), 0.0); + QCOMPARE(item->y(), i * 20.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickListView::displacedTransitions_data() +{ + QTest::addColumn("useDisplaced"); + QTest::addColumn("displacedEnabled"); + QTest::addColumn("useAddDisplaced"); + QTest::addColumn("addDisplacedEnabled"); + QTest::addColumn("useMoveDisplaced"); + QTest::addColumn("moveDisplacedEnabled"); + QTest::addColumn("useRemoveDisplaced"); + QTest::addColumn("removeDisplacedEnabled"); + QTest::addColumn("change"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("no displaced transitions at all") + << false << false + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("just displaced") + << true << true + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("just displaced (not enabled)") + << true << false + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("displaced + addDisplaced") + << true << true + << true << true + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("displaced + addDisplaced (not enabled)") + << true << true + << true << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("displaced + moveDisplaced") + << true << true + << false << false + << true << true + << false << false + << ListChange::move(0, 10, 1) << ListRange(1, 10); + + QTest::newRow("displaced + moveDisplaced (not enabled)") + << true << true + << false << false + << true << false + << false << false + << ListChange::move(0, 10, 1) << ListRange(1, 10); + + QTest::newRow("displaced + removeDisplaced") + << true << true + << false << false + << false << false + << true << true + << ListChange::remove(0, 1) << ListRange(1, 16); + + QTest::newRow("displaced + removeDisplaced (not enabled)") + << true << true + << false << false + << false << false + << true << false + << ListChange::remove(0, 1) << ListRange(1, 16); + + + QTest::newRow("displaced + add, should use generic displaced for a remove") + << true << true + << true << true + << false << false + << true << false + << ListChange::remove(0, 1) << ListRange(1, 16); +} + void tst_QQuickListView::multipleTransitions() { QSKIP("QTBUG-24523"); diff --git a/tests/auto/qtquick2/shared/viewtestutil.h b/tests/auto/qtquick2/shared/viewtestutil.h index 71fd5065df..ebee1787d3 100644 --- a/tests/auto/qtquick2/shared/viewtestutil.h +++ b/tests/auto/qtquick2/shared/viewtestutil.h @@ -174,6 +174,7 @@ namespace QQuickViewTestUtil }; } +Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange) Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange) -- cgit v1.2.3 From 4e0e0e5cc59a0e5379dcc1964976288d3c3e1b82 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 23 Feb 2012 13:25:58 +1000 Subject: Don't round Text dimensions. Painting issues in QtQuick1 meant drawing had to be aligned to pixel boundaries, since this is no longer a problem we should use qreal everywhere. Change-Id: I58e88e10270fa603170f1cedf471bfb53bd89b73 Reviewed-by: Yann Bodson --- tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml | 2 +- tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml | 2 +- tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 8 ++------ 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml b/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml index d26576eacd..6b9dc71fbc 100644 --- a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml +++ b/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml @@ -7,7 +7,7 @@ Item { Text { id: myText objectName: "myText" - width: 100 + width: 60 font.pixelSize: 15 font.family: "Helvetica" } diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml b/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml index 0da9bc353a..21f1b20619 100644 --- a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml +++ b/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml @@ -7,7 +7,7 @@ Item { Text { id: myText objectName: "myText" - width: 100 + width: 60 height: 36 font.pixelSize: 15 font.family: "Helvetica" diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index c28de8b53c..5f13f6211d 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -295,11 +295,10 @@ void tst_qquicktext::width() layout.endLayout(); - metricWidth = qCeil(layout.boundingRect().width()); + metricWidth = layout.boundingRect().width(); } else { QFontMetricsF fm(f); - qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); - metricWidth = qCeil(metricWidth); + metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); } QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }"; @@ -2422,9 +2421,6 @@ void tst_qquicktext::multilengthStrings() QCOMPARE(myText->contentWidth(), mediumWidth); QCOMPARE(myText->contentHeight(), mediumHeight); -#ifdef Q_OS_MAC - QEXPECT_FAIL("Wrap", "QTBUG-24310", Continue); -#endif QCOMPARE(myText->truncated(), true); myText->setSize(QSizeF(shortWidth, shortHeight)); -- cgit v1.2.3 From 9593df26c4a87130947dbdacf5ddb2f7a3412cbc Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Mon, 20 Feb 2012 14:56:12 +0100 Subject: FolderListModel: remove widget and QDirModel use FolderListModel used the obsolete QDirModel internally. Because of this it needed widgets to work. I have made a threaded model instead that use QDir internally. Change-Id: Ibd1267a135ee3c6df7bcde420073866b7a76d0d1 Reviewed-by: Alan Alpert --- .../qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp index 07eb6e87e1..708f3c90bb 100644 --- a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp @@ -170,8 +170,8 @@ void tst_qdeclarativefolderlistmodel::refresh() flm->setProperty("sortReversed", true); - QCOMPARE(removeStart, 0); - QCOMPARE(removeEnd, count-1); + QTRY_COMPARE(removeStart, 0); + QTRY_COMPARE(removeEnd, count-1); // wait for refresh } QTEST_MAIN(tst_qdeclarativefolderlistmodel) -- cgit v1.2.3 From 648337d19abde0bc1d3f248f11ad4a40890f532f Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 7 Feb 2012 19:37:38 +0100 Subject: Add autotest for QML meta-objects This autotest checks that the QMetaObject generated from a QML type can be introspected from C++ (properties, class info, signals and slots). Change-Id: I9a50f138f911690f5c55cd28e5b49f0682450d07 Reviewed-by: Aaron Kennedy --- tests/auto/declarative/declarative.pro | 1 + .../qdeclarativemetaobject/data/method.1.qml | 5 + .../qdeclarativemetaobject/data/method.2.qml | 5 + .../qdeclarativemetaobject/data/method.3.qml | 5 + .../data/property.MyQmlObject.qml | 6 + .../data/property.QtObject.qml | 5 + .../data/property.alias.2.qml | 6 + .../data/property.alias.3.qml | 7 + .../qdeclarativemetaobject/data/property.alias.qml | 7 + .../qdeclarativemetaobject/data/property.bool.qml | 5 + .../qdeclarativemetaobject/data/property.color.qml | 5 + .../qdeclarativemetaobject/data/property.date.qml | 5 + .../qdeclarativemetaobject/data/property.int.qml | 5 + .../data/property.list.MyQmlObject.qml | 6 + .../data/property.list.QtObject.qml | 5 + .../qdeclarativemetaobject/data/property.real.qml | 5 + .../data/property.string.qml | 5 + .../qdeclarativemetaobject/data/property.url.qml | 5 + .../qdeclarativemetaobject/data/property.var.qml | 5 + .../data/property.variant.qml | 5 + .../qdeclarativemetaobject/data/signal.1.qml | 5 + .../qdeclarativemetaobject/data/signal.2.qml | 5 + .../qdeclarativemetaobject/data/signal.3.qml | 5 + .../qdeclarativemetaobject/data/signal.4.qml | 5 + .../qdeclarativemetaobject/data/signal.5.qml | 5 + .../qdeclarativemetaobject.pro | 14 + .../tst_qdeclarativemetaobject.cpp | 364 +++++++++++++++++++++ 27 files changed, 506 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro create mode 100644 tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp (limited to 'tests/auto') diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 7288da27ba..85de8618e2 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -15,6 +15,7 @@ PUBLICTESTS += \ qdeclarativeinfo \ qdeclarativelistreference \ qdeclarativelocale \ + qdeclarativemetaobject \ qdeclarativemoduleplugin \ qdeclarativeqt \ qdeclarativetranslation \ diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml b/tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml new file mode 100644 index 0000000000..a021881743 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function testFunction() { return 19; } +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml b/tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml new file mode 100644 index 0000000000..d514955f47 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function testFunction(foo) { return 19; } +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml b/tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml new file mode 100644 index 0000000000..d6d19758c9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function testFunction(foo, bar, baz) { return 19; } +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml new file mode 100644 index 0000000000..8903bbb3e9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +QtObject { + property MyQmlObject test: MyQmlObject {} +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml new file mode 100644 index 0000000000..20c42b5851 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property QtObject test: QtObject {} +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml new file mode 100644 index 0000000000..cae1ae6696 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + id: me + property alias test: me +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml new file mode 100644 index 0000000000..86422ae367 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Text { + id: me + font.family: "Arial" + property alias test: me.font.family +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml new file mode 100644 index 0000000000..33a4a1c5b0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + objectName: "Joe" + id: me + property alias test: me.objectName +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml new file mode 100644 index 0000000000..9459cb6394 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property bool test: true +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml new file mode 100644 index 0000000000..7451a27101 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property color test: "#ff0000" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml new file mode 100644 index 0000000000..05fcb2516c --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property date test: "2012-02-07" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml new file mode 100644 index 0000000000..ae419d08cb --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int test: 19 +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml new file mode 100644 index 0000000000..602762cba2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +QtObject { + property list test: [ MyQmlObject {} ] +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml new file mode 100644 index 0000000000..e774d70b42 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property list test: [ QtObject {} ] +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml new file mode 100644 index 0000000000..de2baf5be2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property real test: 21 +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml new file mode 100644 index 0000000000..2a625c4fe4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property string test: "dog" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml new file mode 100644 index 0000000000..c820c82515 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property url test: "http://foo.bar" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml new file mode 100644 index 0000000000..9ea9245317 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property var test: [5, true, "ciao"] +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml new file mode 100644 index 0000000000..edffa173c4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property variant test: "12,34" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml new file mode 100644 index 0000000000..113130f3cc --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml new file mode 100644 index 0000000000..db860cc7cd --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(string foo) +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml new file mode 100644 index 0000000000..4d04041f8f --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(int foo, bool bar, real baz) +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml new file mode 100644 index 0000000000..ad9b002176 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(variant foo, var bar) +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml new file mode 100644 index 0000000000..b848bb5cb5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(color foo, date bar, url baz) +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro b/tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro new file mode 100644 index 0000000000..206f510506 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qdeclarativemetaobject +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativemetaobject.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += declarative testlib diff --git a/tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp b/tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp new file mode 100644 index 0000000000..424de872b7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp @@ -0,0 +1,364 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "../../shared/util.h" + +Q_DECLARE_METATYPE(QMetaMethod::MethodType) + +class MyQmlObject : public QObject +{ + Q_OBJECT +}; +QML_DECLARE_TYPE(MyQmlObject) + +class tst_QDeclarativeMetaObject : public QDeclarativeDataTest +{ + Q_OBJECT +private slots: + void initTestCase(); + + void property_data(); + void property(); + void method_data(); + void method(); + +private: + MyQmlObject myQmlObject; +}; + +void tst_QDeclarativeMetaObject::initTestCase() +{ + QDeclarativeDataTest::initTestCase(); + + qmlRegisterType("Qt.test", 1,0, "MyQmlObject"); +} + +void tst_QDeclarativeMetaObject::property_data() +{ + QTest::addColumn("testFile"); + QTest::addColumn("cppTypeName"); + QTest::addColumn("cppType"); + QTest::addColumn("isDefault"); + QTest::addColumn("expectedValue"); + QTest::addColumn("isWritable"); + QTest::addColumn("newValue"); + + QTest::newRow("int") << "property.int.qml" + << QByteArray("int") << int(QMetaType::Int) + << false // default + << QVariant(19) << true << QVariant(42); + QTest::newRow("bool") << "property.bool.qml" + << QByteArray("bool") << int(QMetaType::Bool) + << true // default + << QVariant(true) << true << QVariant(false); + QTest::newRow("real") << "property.real.qml" + << QByteArray("double") << int(QMetaType::Double) + << false // default + << QVariant(double(21)) + << true // writable + << QVariant(double(37)); + QTest::newRow("string") << "property.string.qml" + << QByteArray("QString") << int(QMetaType::QString) + << true // default + << QVariant(QString::fromLatin1("dog")) + << true // writable + << QVariant(QString::fromLatin1("food")); + QTest::newRow("url") << "property.url.qml" + << QByteArray("QUrl") << int(QMetaType::QUrl) + << false // default + << QVariant(QUrl("http://foo.bar")) + << true //writable + << QVariant(QUrl("http://bar.baz")); + QTest::newRow("color") << "property.color.qml" + << QByteArray("QColor") << int(QMetaType::QColor) + << true // default + << QVariant(QColor("#ff0000")) + << true // writable + << QVariant(QColor("#00ff00")); + QTest::newRow("date") << "property.date.qml" + << QByteArray("QDateTime") << int(QMetaType::QDateTime) + << false // default + << QVariant(QDateTime(QDate(2012, 2, 7))) + << true // writable + << QVariant(QDateTime(QDate(2010, 7, 2))); + QTest::newRow("variant") << "property.variant.qml" + << QByteArray("QVariant") << int(QMetaType::QVariant) + << true // default + << QVariant(QPointF(12, 34)) + << true // writable + << QVariant(QSizeF(45, 67)); + QTest::newRow("var") << "property.var.qml" + << QByteArray("QVariant") << int(QMetaType::QVariant) + << false // default + << QVariant(QVariantList() << 5 << true << "ciao") + << true // writable + << QVariant(QVariantList() << 17.0); + QTest::newRow("QtObject") << "property.QtObject.qml" + << QByteArray("QObject*") << int(QMetaType::QObjectStar) + << false // default + << QVariant() + << true // writable + << QVariant::fromValue(static_cast(this)); + QTest::newRow("list") << "property.list.QtObject.qml" + << QByteArray("QDeclarativeListProperty") + << qMetaTypeId >() + << false // default + << QVariant() + << false // writable + << QVariant(); + QTest::newRow("MyQmlObject") << "property.MyQmlObject.qml" + << QByteArray("MyQmlObject*") << qMetaTypeId() + << false // default + << QVariant() + << true // writable + << QVariant::fromValue(&myQmlObject); + QTest::newRow("list") << "property.list.MyQmlObject.qml" + << QByteArray("QDeclarativeListProperty") + << qMetaTypeId >() + << false // default + << QVariant() + << false // writable + << QVariant(); + QTest::newRow("alias") << "property.alias.qml" + << QByteArray("QString") << int(QMetaType::QString) + << false // default + << QVariant(QString::fromLatin1("Joe")) + << true // writable + << QVariant(QString::fromLatin1("Bob")); + QTest::newRow("alias-2") << "property.alias.2.qml" + << QByteArray("QObject*") << int(QMetaType::QObjectStar) + << false // default + << QVariant() + << false // writable + << QVariant(); + QTest::newRow("alias-3") << "property.alias.3.qml" + << QByteArray("QString") << int(QMetaType::QString) + << false // default + << QVariant(QString::fromLatin1("Arial")) + << true // writable + << QVariant(QString::fromLatin1("Helvetica")); +} + +void tst_QDeclarativeMetaObject::property() +{ + QFETCH(QString, testFile); + QFETCH(QByteArray, cppTypeName); + QFETCH(int, cppType); + QFETCH(bool, isDefault); + QFETCH(QVariant, expectedValue); + QFETCH(bool, isWritable); + QFETCH(QVariant, newValue); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, testFileUrl(testFile)); + QObject *object = component.create(); + QVERIFY(object != 0); + + const QMetaObject *mo = object->metaObject(); + QVERIFY(mo->superClass() != 0); + QVERIFY(QByteArray(mo->className()).contains("_QML_")); + QCOMPARE(mo->propertyOffset(), mo->superClass()->propertyCount()); + QCOMPARE(mo->propertyCount(), mo->superClass()->propertyCount() + 1); + + QMetaProperty prop = mo->property(mo->propertyOffset()); + QCOMPARE(prop.name(), "test"); + + QCOMPARE(QByteArray(prop.typeName()), cppTypeName); + QEXPECT_FAIL("QtObject", "prop.type() returns UserType for QtObject properties", Continue); + QEXPECT_FAIL("alias-2", "prop.type() returns UserType for QtObject properties", Continue); + if (prop.userType() < QMetaType::User) + QCOMPARE(prop.type(), QVariant::Type(cppType)); + QCOMPARE(prop.userType(), cppType); + + QVERIFY(!prop.isConstant()); + QVERIFY(!prop.isDesignable()); + QVERIFY(!prop.isEnumType()); + QVERIFY(!prop.isFinal()); + QVERIFY(!prop.isFlagType()); + QVERIFY(prop.isReadable()); + QVERIFY(!prop.isResettable()); + QVERIFY(prop.isScriptable()); + QVERIFY(!prop.isStored()); + QVERIFY(!prop.isUser()); + QVERIFY(prop.isValid()); + QCOMPARE(prop.isWritable(), isWritable); + + QCOMPARE(mo->classInfoOffset(), mo->superClass()->classInfoCount()); + QCOMPARE(mo->classInfoCount(), mo->superClass()->classInfoCount() + (isDefault ? 1 : 0)); + if (isDefault) { + QMetaClassInfo info = mo->classInfo(mo->classInfoOffset()); + QCOMPARE(info.name(), "DefaultProperty"); + QCOMPARE(info.value(), "test"); + } + + QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount()); + QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); // the signal + + QVERIFY(prop.notifySignalIndex() != -1); + QMetaMethod signal = prop.notifySignal(); + QCOMPARE(signal.methodType(), QMetaMethod::Signal); + QCOMPARE(signal.signature(), "testChanged()"); + QCOMPARE(signal.access(), QMetaMethod::Protected); + QCOMPARE(signal.parameterTypes(), QList()); + QCOMPARE(signal.parameterNames(), QList()); + QCOMPARE(signal.tag(), ""); + QCOMPARE(signal.typeName(), ""); + + QSignalSpy changedSpy(object, SIGNAL(testChanged())); + QObject::connect(object, SIGNAL(testChanged()), object, SLOT(deleteLater())); + + if (expectedValue.isValid()) + QCOMPARE(prop.read(object), expectedValue); + else + QVERIFY(prop.read(object).isValid()); + QCOMPARE(changedSpy.count(), 0); + + if (isWritable) { + QVERIFY(prop.write(object, newValue)); + QCOMPARE(changedSpy.count(), 1); + QCOMPARE(prop.read(object), newValue); + } else { + QVERIFY(!prop.write(object, prop.read(object))); + QCOMPARE(changedSpy.count(), 0); + } + + delete object; +} + +void tst_QDeclarativeMetaObject::method_data() +{ + QTest::addColumn("testFile"); + QTest::addColumn("signature"); + QTest::addColumn("methodType"); + QTest::addColumn("returnTypeName"); + QTest::addColumn >("parameterTypeNames"); + QTest::addColumn >("parameterNames"); + + QTest::newRow("testFunction()") << "method.1.qml" + << "testFunction()" + << QMetaMethod::Slot + << "QVariant" + << QList() + << QList(); + QTest::newRow("testFunction(foo)") << "method.2.qml" + << "testFunction(QVariant)" + << QMetaMethod::Slot + << "QVariant" + << (QList() << "QVariant") + << (QList() << "foo"); + QTest::newRow("testFunction(foo, bar, baz)") << "method.3.qml" + << "testFunction(QVariant,QVariant,QVariant)" + << QMetaMethod::Slot + << "QVariant" + << (QList() << "QVariant" << "QVariant" << "QVariant") + << (QList() << "foo" << "bar" << "baz"); + QTest::newRow("testSignal") << "signal.1.qml" + << "testSignal()" + << QMetaMethod::Signal + << "" + << QList() + << QList(); + QTest::newRow("testSignal(string foo)") << "signal.2.qml" + << "testSignal(QString)" + << QMetaMethod::Signal + << "" + << (QList() << "QString") + << (QList() << "foo"); + QTest::newRow("testSignal(int foo, bool bar, real baz)") << "signal.3.qml" + << "testSignal(int,bool,qreal)" + << QMetaMethod::Signal + << "" + << (QList() << "int" << "bool" << "qreal") + << (QList() << "foo" << "bar" << "baz"); + QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml" + << "testSignal(QVariant,QVariant)" + << QMetaMethod::Signal + << "" + << (QList() << "QVariant" << "QVariant") + << (QList() << "foo" << "bar"); + QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml" + << "testSignal(QColor,QDateTime,QUrl)" + << QMetaMethod::Signal + << "" + << (QList() << "QColor" << "QDateTime" << "QUrl") + << (QList() << "foo" << "bar" << "baz"); +} + +void tst_QDeclarativeMetaObject::method() +{ + QFETCH(QString, testFile); + QFETCH(QString, signature); + QFETCH(QMetaMethod::MethodType, methodType); + QFETCH(QString, returnTypeName); + QFETCH(QList, parameterTypeNames); + QFETCH(QList, parameterNames); + + QCOMPARE(parameterTypeNames.size(), parameterNames.size()); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, testFileUrl(testFile)); + QObject *object = component.create(); + QVERIFY(object != 0); + + const QMetaObject *mo = object->metaObject(); + QVERIFY(mo->superClass() != 0); + QVERIFY(QByteArray(mo->className()).contains("_QML_")); + QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount()); + QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); + + QMetaMethod method = mo->method(mo->methodOffset()); + QCOMPARE(method.methodType(), methodType); + QCOMPARE(QString::fromUtf8(method.signature()), signature); + QCOMPARE(method.access(), QMetaMethod::Protected); + QCOMPARE(method.parameterTypes(), parameterTypeNames); + QCOMPARE(method.parameterNames(), parameterNames); + QCOMPARE(method.tag(), ""); + QCOMPARE(QString::fromUtf8(method.typeName()), returnTypeName); + + delete object; +} + +QTEST_MAIN(tst_QDeclarativeMetaObject) + +#include "tst_qdeclarativemetaobject.moc" -- cgit v1.2.3 From 1ebad3a320e69b82a7a135f618fd38f650791539 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 1 Mar 2012 10:10:07 +1000 Subject: Fix QQuickDropArea test compilation. Change-Id: I5feaabe235201af842ca6bc4f3496b1861b06fb9 Reviewed-by: Michael Brasser --- .../qtquick2/qquickdroparea/qquickdroparea.pro | 2 + .../qtquick2/qquickdroparea/tst_qquickdroparea.cpp | 75 +++++++++++----------- 2 files changed, 40 insertions(+), 37 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro b/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro index 46fe08c145..6c6de13d5f 100644 --- a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro +++ b/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro @@ -7,3 +7,5 @@ SOURCES += tst_qquickdroparea.cpp CONFIG += parallel_test QT += core-private gui-private declarative-private quick-private network testlib + +mac: CONFIG += insignificant_test # QTBUG-24588 diff --git a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp index 0cd3fa9416..88cf1ec009 100644 --- a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp +++ b/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp @@ -48,6 +48,7 @@ #include #include +#include template static T evaluate(QObject *scope, const QString &expression) { @@ -193,14 +194,14 @@ void tst_QQuickDropArea::containsDrag_external() QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "hasDrag"), false); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "hasDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(evaluate(dropArea, "exitEvents"), 0); evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "hasDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); @@ -208,13 +209,13 @@ void tst_QQuickDropArea::containsDrag_external() evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "hasDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); QCOMPARE(evaluate(dropArea, "exitEvents"), 0); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "hasDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); @@ -222,13 +223,13 @@ void tst_QQuickDropArea::containsDrag_external() evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "hasDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); QCOMPARE(evaluate(dropArea, "exitEvents"), 1); - QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50)); + QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50), Qt::CopyAction); } void tst_QQuickDropArea::keys_internal() @@ -363,80 +364,80 @@ void tst_QQuickDropArea::keys_external() QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = \"text/x-blue\""); QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue"); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = \"text/x-red\""); QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red"); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = \"text/x-green\""); QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green"); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]"); QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green"); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); data.removeFormat("text/x-red"); data.removeFormat("text/x-blue"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = []"); QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList()); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); data.setData("text/x-red", "red"); data.setData("text/x-blue", "blue"); QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50), Qt::CopyAction); } void tst_QQuickDropArea::source_internal() @@ -589,7 +590,7 @@ void tst_QQuickDropArea::position_external() QMimeData data; - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(evaluate(dropArea, "moveEvents"), 1); QCOMPARE(evaluate(dropArea, "drag.x"), qreal(50)); @@ -600,7 +601,7 @@ void tst_QQuickDropArea::position_external() QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); QCOMPARE(evaluate(dropArea, "moveEvents"), 1); QCOMPARE(evaluate(dropArea, "drag.x"), qreal(40)); @@ -611,7 +612,7 @@ void tst_QQuickDropArea::position_external() QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); QCOMPARE(evaluate(dropArea, "moveEvents"), 1); QCOMPARE(evaluate(dropArea, "drag.x"), qreal(75)); @@ -621,7 +622,7 @@ void tst_QQuickDropArea::position_external() QCOMPARE(evaluate(dropArea, "eventX"), qreal(75)); QCOMPARE(evaluate(dropArea, "eventY"), qreal(25)); - QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25)); + QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25), Qt::CopyAction); } void tst_QQuickDropArea::drop_internal() @@ -886,7 +887,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -894,7 +895,7 @@ void tst_QQuickDropArea::simultaneousDrags() QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -902,7 +903,7 @@ void tst_QQuickDropArea::simultaneousDrags() QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -920,7 +921,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), false); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -931,7 +932,7 @@ void tst_QQuickDropArea::simultaneousDrags() // external then internal. evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -965,7 +966,7 @@ void tst_QQuickDropArea::simultaneousDrags() QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), false); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); @@ -1061,7 +1062,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -1071,7 +1072,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -1081,7 +1082,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -1101,7 +1102,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), false); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -1109,7 +1110,7 @@ void tst_QQuickDropArea::simultaneousDrags() QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); - QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); } QTEST_MAIN(tst_QQuickDropArea) -- cgit v1.2.3 From e3a43b3ca3b1e2d6fd92945d6d7f42aed8203abc Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 24 Feb 2012 09:27:12 +1000 Subject: Reduce size of QQuickTextPrivate Move less used members to an extra struct lazily allocated Change-Id: I87e464af4b9d29303705dd7e766f734309ed7763 Reviewed-by: Andrew den Exter --- tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index 5f13f6211d..2be2dcd43d 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -326,8 +326,9 @@ void tst_qquicktext::width() QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); QVERIFY(textPrivate != 0); + QVERIFY(textPrivate->extra.isAllocated()); - QTextDocument *doc = textPrivate->textDocument(); + QTextDocument *doc = textPrivate->extra->doc; QVERIFY(doc != 0); QCOMPARE(int(textObject->width()), int(doc->idealWidth())); @@ -677,19 +678,20 @@ void tst_qquicktext::horizontalAlignment_RightToLeft() // implicitly aligned rich text should follow the reading direction of text QCOMPARE(text->hAlign(), QQuickText::AlignRight); QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); + QVERIFY(textPrivate->extra.isAllocated()); + QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft); // explicitly left aligned rich text text->setHAlign(QQuickText::AlignLeft); QCOMPARE(text->hAlign(), QQuickText::AlignLeft); QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight); + QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignRight); // explicitly right aligned rich text text->setHAlign(QQuickText::AlignRight); QCOMPARE(text->hAlign(), QQuickText::AlignRight); QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); + QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft); text->setText(textString); text->setTextFormat(QQuickText::PlainText); @@ -1623,8 +1625,7 @@ void tst_qquicktext::lineLaidOut() QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); QVERIFY(textPrivate != 0); - QTextDocument *doc = textPrivate->textDocument(); - QVERIFY(doc == 0); + QVERIFY(!textPrivate->extra.isAllocated()); #if defined(Q_OS_MAC) QVERIFY(myText->lineCount() == textPrivate->linesRects.count()); -- cgit v1.2.3 From ae4c3c14e2535fbbf439c2baeb4333bbc21c2a96 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Wed, 29 Feb 2012 11:37:42 +1000 Subject: Allow styled text to be elided. Task-number: QTBUG-24521 Change-Id: Idd451d0a8a238a60691386726e34054c0368b658 Reviewed-by: Yann Bodson --- .../auto/qtquick2/qquicktext/data/fontSizeMode.qml | 2 - tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 521 ++++++++++----------- 2 files changed, 249 insertions(+), 274 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml b/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml index 20f7535365..84f7ce8d50 100644 --- a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml +++ b/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml @@ -19,6 +19,4 @@ Item { font.pixelSize: 30 font.family: "Helvetica" } - - TextInput { focus: true; objectName: "input" } } diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index 2be2dcd43d..3fd05dbcb2 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -58,6 +58,8 @@ DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) +Q_DECLARE_METATYPE(QQuickText::TextFormat) + class tst_qquicktext : public QDeclarativeDataTest { Q_OBJECT @@ -69,6 +71,7 @@ private slots: void width(); void wrap(); void elide(); + void multilineElide_data(); void multilineElide(); void textFormat(); @@ -440,10 +443,12 @@ void tst_qquicktext::elide() QCOMPARE(textObject->elideMode(), m); QCOMPARE(textObject->width(), 100.); + if (m != QQuickText::ElideNone && !standard.at(i).contains('\n')) + QVERIFY(textObject->contentWidth() <= textObject->width()); + delete textObject; } - // richtext - does nothing for (int i = 0; i < richText.size(); i++) { QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }"; @@ -454,17 +459,29 @@ void tst_qquicktext::elide() QCOMPARE(textObject->elideMode(), m); QCOMPARE(textObject->width(), 100.); + if (m != QQuickText::ElideNone && standard.at(i).contains("
          ")) + QVERIFY(textObject->contentWidth() <= textObject->width()); + delete textObject; } } } +void tst_qquicktext::multilineElide_data() +{ + QTest::addColumn("format"); + QTest::newRow("plain") << QQuickText::PlainText; + QTest::newRow("styled") << QQuickText::StyledText; +} + void tst_qquicktext::multilineElide() { + QFETCH(QQuickText::TextFormat, format); QQuickView *canvas = createView(testFile("multilineelide.qml")); QQuickText *myText = qobject_cast(canvas->rootObject()); QVERIFY(myText != 0); + myText->setTextFormat(format); QCOMPARE(myText->lineCount(), 3); QCOMPARE(myText->truncated(), true); @@ -1843,17 +1860,15 @@ void tst_qquicktext::imgTagsError() void tst_qquicktext::fontSizeMode_data() { QTest::addColumn("text"); - QTest::addColumn("canElide"); - QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << true; - QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" << false; + QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog"; + QTest::newRow("styled") << "The quick red fox jumped over the lazy brown dog"; } void tst_qquicktext::fontSizeMode() { QFETCH(QString, text); - QFETCH(bool, canElide); - QQuickView *canvas = createView(testFile("fontSizeMode.qml")); + QScopedPointer canvas(createView(testFile("fontSizeMode.qml"))); canvas->show(); QQuickText *myText = canvas->rootObject()->findChild("myText"); @@ -1881,29 +1896,27 @@ void tst_qquicktext::fontSizeMode() QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding QVERIFY(horizontalFitHeight <= myText->height() + 2); - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -1913,29 +1926,27 @@ void tst_qquicktext::fontSizeMode() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight > originalHeight); - if (canElide) { - // Elide won't affect the height of a single line with VerticalFit but will crop the width. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide won't affect the height of a single line with VerticalFit but will crop the width. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -1943,29 +1954,27 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::FixedSize); myText->setWrapMode(QQuickText::Wrap); @@ -1985,17 +1994,15 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2006,17 +2013,15 @@ void tst_qquicktext::fontSizeMode() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight < originalHeight); - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2024,17 +2029,15 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::FixedSize); myText->setMaximumLineCount(2); @@ -2051,17 +2054,15 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2072,17 +2073,15 @@ void tst_qquicktext::fontSizeMode() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight < originalHeight); - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2090,33 +2089,29 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); } void tst_qquicktext::fontSizeModeMultiline_data() { QTest::addColumn("text"); - QTest::addColumn("canElide"); - QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog" << true; - QTest::newRow("richtext") << "The quick red fox jumped
          over the lazy brown dog
          " << false; + QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog"; + QTest::newRow("styledtext") << "The quick red fox jumped
          over the lazy brown dog
          "; } void tst_qquicktext::fontSizeModeMultiline() { QFETCH(QString, text); - QFETCH(bool, canElide); - QQuickView *canvas = createView(testFile("fontSizeMode.qml")); + QScopedPointer canvas(createView(testFile("fontSizeMode.qml"))); canvas->show(); QQuickText *myText = canvas->rootObject()->findChild("myText"); @@ -2146,31 +2141,29 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding QVERIFY(horizontalFitHeight > myText->height()); - if (canElide) { - // Right eliding will remove the last line - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QCOMPARE(myText->lineCount(), 1); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(myText->contentHeight() <= myText->height() + 2); - - // Left or middle eliding wont have any effect. - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Right eliding will remove the last line + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QCOMPARE(myText->lineCount(), 1); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(myText->contentHeight() <= myText->height() + 2); + + // Left or middle eliding wont have any effect. + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2180,30 +2173,28 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(verticalFitWidth <= myText->width() + 2); QVERIFY(verticalFitHeight <= myText->height() + 2); - if (canElide) { - // Elide will have no effect. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide will have no effect. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2211,29 +2202,27 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::FixedSize); myText->setWrapMode(QQuickText::Wrap); @@ -2253,17 +2242,15 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Text will be elided vertically with HorizontalFit - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(myText->contentHeight() <= myText->height() + 2); + // Text will be elided vertically with HorizontalFit + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(myText->contentHeight() <= myText->height() + 2); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2274,17 +2261,15 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight < originalHeight); - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2292,17 +2277,15 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::FixedSize); myText->setMaximumLineCount(2); @@ -2319,17 +2302,15 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(myText->contentHeight() <= myText->height() + 2); + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(myText->contentHeight() <= myText->height() + 2); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2340,17 +2321,15 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight < originalHeight); - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2358,17 +2337,15 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); } void tst_qquicktext::multilengthStrings_data() -- cgit v1.2.3 From 61ab01252d928576bf9ef1d8c6cc421e1a825dde Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 29 Feb 2012 13:54:16 +1000 Subject: Reenable value type binding auto removal tests. Change-Id: I349017bf24f9f2f18024d1257eeaebb348cc8503 Reviewed-by: Chris Adams --- .../declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index e701efa2a4..15001f70c8 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -951,7 +951,6 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() delete object; } - /* { QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -976,6 +975,8 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() { QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml")); + QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QRect"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -993,7 +994,6 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() delete object; } -*/ } // Test that property value sources assign to value types -- cgit v1.2.3 From 79608d6f72ea5963aed2fa161b9ef6781adbc41e Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 27 Feb 2012 13:16:11 +1000 Subject: Improved transitions for Row, Column, Grid, Flow The view transitions functionality for ListView and GridView has been integrated into the positioner elements. Not all of this functionality is available for positioners, though, since they don't have models (and thus cannot identify certain model operations) and they don't manage the lifetime of their children. Task-number: QTBUG-24336 Change-Id: I71588de289555d2ef5a763af11358bc0af7b31a7 Reviewed-by: Alan Alpert --- .../qquickpositioners/data/transitions.qml | 196 +++++++++ .../qquickpositioners/qquickpositioners.pro | 1 + .../qquickpositioners/tst_qquickpositioners.cpp | 455 +++++++++++++++++++++ tests/auto/qtquick2/shared/viewtestutil.h | 1 + 4 files changed, 653 insertions(+) create mode 100644 tests/auto/qtquick2/qquickpositioners/data/transitions.qml (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquickpositioners/data/transitions.qml b/tests/auto/qtquick2/qquickpositioners/data/transitions.qml new file mode 100644 index 0000000000..982e64141c --- /dev/null +++ b/tests/auto/qtquick2/qquickpositioners/data/transitions.qml @@ -0,0 +1,196 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 500 + height: 500 + + property int duration: 50 + + property int targetTransitionsDone + property int displaceTransitionsDone + + property var targetTrans_items: new Object() + property var targetTrans_targetIndexes: new Array() + property var targetTrans_targetItems: new Array() + + property var displacedTrans_items: new Object() + property var displacedTrans_targetIndexes: new Array() + property var displacedTrans_targetItems: new Array() + + // for QDeclarativeListProperty types + function copyList(propList) { + var temp = new Array() + for (var i=0; i #include #include +#include "../shared/viewtestutil.h" +#include "../shared/visualtestutil.h" #include "../../shared/util.h" +using namespace QQuickViewTestUtil; +using namespace QQuickVisualTestUtil; + class tst_qquickpositioners : public QDeclarativeDataTest { Q_OBJECT @@ -88,11 +93,145 @@ private slots: void test_attachedproperties(); void test_attachedproperties_data(); void test_attachedproperties_dynamic(); + void addTransitions_row(); + void addTransitions_row_data(); + void addTransitions_column(); + void addTransitions_column_data(); + void addTransitions_grid(); + void addTransitions_grid_data(); + void addTransitions_flow(); + void addTransitions_flow_data(); + void moveTransitions_row(); + void moveTransitions_row_data(); + void moveTransitions_column(); + void moveTransitions_column_data(); + void moveTransitions_grid(); + void moveTransitions_grid_data(); + void moveTransitions_flow(); + void moveTransitions_flow_data(); private: QQuickView *createView(const QString &filename, bool wait=true); + + void addTransitions(const QString &positionerObjectName); + void addTransitions_data(); + void moveTransitions(const QString &positionerObjectName); + void moveTransitions_data(); + void matchIndexLists(const QVariantList &indexLists, const QList &expectedIndexes); + void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes); + void matchItemLists(const QVariantList &itemLists, const QList &expectedItems); + void checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize); }; +void tst_qquickpositioners::addTransitions_row() +{ + addTransitions("row"); +} + +void tst_qquickpositioners::addTransitions_row_data() +{ + addTransitions_data(); +} + +void tst_qquickpositioners::addTransitions_column() +{ + addTransitions("column"); +} + +void tst_qquickpositioners::addTransitions_column_data() +{ + addTransitions_data(); +} + +void tst_qquickpositioners::addTransitions_grid() +{ + addTransitions("grid"); +} + +void tst_qquickpositioners::addTransitions_grid_data() +{ + // don't use addTransitions_data() because grid displaces items differently + // (adding items further down the grid can cause displace transitions at + // previous indexes, since grid is auto-resized to tightly fit all of its items) + + QTest::addColumn("initialItemCount"); + QTest::addColumn("insertionIndex"); + QTest::addColumn("insertionCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9); + QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9); + QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7); + + QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9); + QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9); + QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9); +} + +void tst_qquickpositioners::addTransitions_flow() +{ + addTransitions("flow"); +} + +void tst_qquickpositioners::addTransitions_flow_data() +{ + addTransitions_data(); +} + +void tst_qquickpositioners::moveTransitions_row() +{ + moveTransitions("row"); +} + +void tst_qquickpositioners::moveTransitions_row_data() +{ + moveTransitions_data(); +} + +void tst_qquickpositioners::moveTransitions_column() +{ + moveTransitions("column"); +} + +void tst_qquickpositioners::moveTransitions_column_data() +{ + moveTransitions_data(); +} + +void tst_qquickpositioners::moveTransitions_grid() +{ + moveTransitions("grid"); +} + +void tst_qquickpositioners::moveTransitions_grid_data() +{ + // don't use moveTransitions_data() because grid displaces items differently + // (removing items further down the grid can cause displace transitions at + // previous indexes, since grid is auto-resized to tightly fit all of its items) + + QTest::addColumn("initialItemCount"); + QTest::addColumn("change"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9); + QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(2, 3) + ListRange(5, 9); + QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange(2, 3) + ListRange(6, 7); + + QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9); + QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(1, 3) + ListRange(7, 9); + QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange(1, 3) + ListRange(5, 6); +} + +void tst_qquickpositioners::moveTransitions_flow() +{ + moveTransitions("flow"); +} + +void tst_qquickpositioners::moveTransitions_flow_data() +{ + moveTransitions_data(); +} + tst_qquickpositioners::tst_qquickpositioners() { } @@ -370,6 +509,285 @@ void tst_qquickpositioners::test_horizontal_animated_disabled() delete canvas; } +void tst_qquickpositioners::addTransitions(const QString &positionerObjectName) +{ + QFETCH(int, initialItemCount); + QFETCH(int, insertionIndex); + QFETCH(int, insertionCount); + QFETCH(ListRange, expectedDisplacedIndexes); + + QPointF targetItems_transitionFrom(-50, -50); + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_targetItems_transitionFrom; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = QQuickViewTestUtil::createView(); + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("enableAddTransition", true); + ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + canvas->setSource(testFile("transitions.qml")); + canvas->show(); + qApp->processEvents(); + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + QQuickItem *positioner = canvas->rootObject()->findChild(positionerObjectName); + QVERIFY(positioner); + positioner->findChild("repeater")->setProperty("model", QVariant::fromValue(&model)); + + QList > targetData; + QList targetIndexes; + for (int i=0; i targetItems = findItems(positioner, "wrapper", targetIndexes); + + // check initial add transition + // (positioners run the add transition on all items that are initially created for the view) + QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), initialItemCount); + QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), 0); + model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); + matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes); + matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems); + + model_targetItems_transitionFrom.clear(); + canvas->rootObject()->setProperty("targetTransitionsDone", 0); + canvas->rootObject()->setProperty("targetTrans_items", QVariantMap()); + canvas->rootObject()->setProperty("targetTrans_targetIndexes", QVariantList()); + canvas->rootObject()->setProperty("targetTrans_targetItems", QVariantList()); + + // do insertion + targetData.clear(); + targetIndexes.clear(); + for (int i=insertionIndex; iproperty("count").toInt()); + + targetItems = findItems(positioner, "wrapper", targetIndexes); + + QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), targetData.count()); + QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count()); + + // check the target and displaced items were animated + model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes); + matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount); + matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes); + matchIndexLists(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(canvas->rootObject()->property("displacedTrans_targetItems").toList(), targetItems); + } + + checkItemPositions(positioner, &model, 5.0); // XXX fetch from qml? + + delete canvas; +} + +void tst_qquickpositioners::addTransitions_data() +{ + // If this data changes, update addTransitions_grid_data() also + + QTest::addColumn("initialItemCount"); + QTest::addColumn("insertionIndex"); + QTest::addColumn("insertionCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9); + QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(5, 9); + QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange(); + + QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9); + QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(5, 9); + QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange(); +} + +void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) +{ + QFETCH(int, initialItemCount); + QFETCH(ListChange, change); + QFETCH(ListRange, expectedDisplacedIndexes); + + QPointF targetItems_transitionFrom(-50, -50); + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Item" + QString::number(i), ""); + QaimModel model_targetItems_transitionFrom; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = QQuickViewTestUtil::createView(); + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("enableAddTransition", false); + ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + canvas->setSource(testFile("transitions.qml")); + canvas->show(); + qApp->processEvents(); + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + QQuickItem *positioner = canvas->rootObject()->findChild(positionerObjectName); + QVERIFY(positioner); + positioner->findChild("repeater")->setProperty("model", QVariant::fromValue(&model)); + QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false); + + switch (change.type) { + case ListChange::Removed: + model.removeItems(change.index, change.count); + QTRY_COMPARE(model.count(), positioner->property("count").toInt()); + break; + case ListChange::Moved: + model.moveItems(change.index, change.to, change.count); + QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false); + break; + case ListChange::Inserted: + case ListChange::SetCurrent: + case ListChange::SetContentY: + QVERIFY(false); + break; + } + + QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count()); + QCOMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), 0); + + // check the target and displaced items were animated + QCOMPARE(model_targetItems_transitionFrom.count(), 0); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + QCOMPARE(canvas->rootObject()->property("targetTrans_items").toMap().count(), 0); + QCOMPARE(canvas->rootObject()->property("targetTrans_targetIndexes").toList().count(), 0); + QCOMPARE(canvas->rootObject()->property("targetTrans_targetItems").toList().count(), 0); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes; + if (change.type == ListChange::Inserted) + displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count); + else if (change.type == ListChange::Moved) + displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, change.index, change.to, change.count); + else if (change.type == ListChange::Removed) + displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count); + else + QVERIFY(false); + matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes); + + QVariantList listOfEmptyIntLists; + for (int i=0; i()); + QCOMPARE(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), listOfEmptyIntLists); + QVariantList listOfEmptyObjectLists; + for (int i=0; irootObject()->property("displacedTrans_targetItems").toList(), listOfEmptyObjectLists); + } + + checkItemPositions(positioner, &model, 5.0); + + delete canvas; +} + +void tst_qquickpositioners::moveTransitions_data() +{ + // If this data changes, update moveTransitions_grid_data() also + + QTest::addColumn("initialItemCount"); + QTest::addColumn("change"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9); + QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(5, 9); + QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange(); + + QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9); + QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(7, 9); + QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange(); +} + + +void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize) +{ + QVERIFY(model->count() > 0); + qreal padding = 0; + qreal currentSize = 30; + qreal rowX = 0; + qreal rowY = 0; + + for (int i=0; icount(); ++i) { + QQuickItem *item = findItem(positioner, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + + QCOMPARE(item->width(), currentSize); + QCOMPARE(item->height(), currentSize); + + if (qobject_cast(positioner)) { + QCOMPARE(item->x(), (i * 30.0) + padding); + QCOMPARE(item->y(), 0.0); + } else if (qobject_cast(positioner)) { + QCOMPARE(item->x(), 0.0); + QCOMPARE(item->y(), (i * 30.0) + padding); + } else if (qobject_cast(positioner)) { + int columns = 4; + int rows = qCeil(model->count() / qreal(columns)); + int lastMatchingRowIndex = (rows * columns) - (columns - i%columns); + if (lastMatchingRowIndex >= model->count()) + lastMatchingRowIndex -= columns; + if (i % columns > 0) { + QQuickItem *finalAlignedRowItem = findItem(positioner, "wrapper", lastMatchingRowIndex); + QVERIFY(finalAlignedRowItem); + QCOMPARE(item->x(), finalAlignedRowItem->x()); + } else { + QCOMPARE(item->x(), 0.0); + } + if (i / columns > 0) { + QQuickItem *prevRowLastItem = findItem(positioner, "wrapper", (i/columns * columns) - 1); + QVERIFY(prevRowLastItem); + QCOMPARE(item->y(), prevRowLastItem->y() + prevRowLastItem->height()); + } else { + QCOMPARE(item->y(), 0.0); + } + } else if (qobject_cast(positioner)) { + if (rowX + item->width() > positioner->width()) { + QQuickItem *prevItem = findItem(positioner, "wrapper", i-1); + QVERIFY(prevItem); + rowX = 0; + rowY = prevItem->y() + prevItem->height(); + } + QCOMPARE(item->x(), rowX); + QCOMPARE(item->y(), rowY); + rowX += item->width(); + } else { + QVERIFY2(false, "Unknown positioner type"); + } + QQuickText *name = findItem(positioner, "name", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model->name(i)); + + padding += i * incrementalSize; + currentSize += incrementalSize; + } +} + void tst_qquickpositioners::test_vertical() { QQuickView *canvas = createView(testFile("vertical.qml")); @@ -1466,6 +1884,43 @@ QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait return canvas; } +void tst_qquickpositioners::matchIndexLists(const QVariantList &indexLists, const QList &expectedIndexes) +{ + for (int i=0; i current = indexLists[i].value >().toSet(); + if (current != expectedIndexes.toSet()) + qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes; + QCOMPARE(current, expectedIndexes.toSet()); + } +} + +void tst_qquickpositioners::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes) +{ + for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) { + QVERIFY(it.value().type() == QVariant::Int); + QString name = it.key(); + int itemIndex = it.value().toInt(); + QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex))); + if (model.name(itemIndex) != name) + qDebug() << itemIndex; + QCOMPARE(model.name(itemIndex), name); + } + QCOMPARE(items.count(), expectedIndexes.count()); +} + +void tst_qquickpositioners::matchItemLists(const QVariantList &itemLists, const QList &expectedItems) +{ + for (int i=0; i(current[j].value()); + QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j))); + QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j))); + } + QCOMPARE(current.count(), expectedItems.count()); + } +} QTEST_MAIN(tst_qquickpositioners) diff --git a/tests/auto/qtquick2/shared/viewtestutil.h b/tests/auto/qtquick2/shared/viewtestutil.h index ebee1787d3..9833fcd5cc 100644 --- a/tests/auto/qtquick2/shared/viewtestutil.h +++ b/tests/auto/qtquick2/shared/viewtestutil.h @@ -174,6 +174,7 @@ namespace QQuickViewTestUtil }; } +Q_DECLARE_METATYPE(QQuickViewTestUtil::QaimModel*) Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange) Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange) -- cgit v1.2.3 From 4dde313139960d706a747d0c3260c774c3966c3d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 28 Feb 2012 16:32:45 +1000 Subject: Add QColor support to v4. Change-Id: I033e92007f894d45695ea48d7f954d534a2fadee Reviewed-by: Chris Adams Reviewed-by: Matthew Vogt Reviewed-by: Martin Jones Reviewed-by: Roberto Raggi --- tests/auto/declarative/v4/data/colorType.qml | 18 ++++++++++++++++++ tests/auto/declarative/v4/tst_v4.cpp | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/auto/declarative/v4/data/colorType.qml (limited to 'tests/auto') diff --git a/tests/auto/declarative/v4/data/colorType.qml b/tests/auto/declarative/v4/data/colorType.qml new file mode 100644 index 0000000000..f6a98a4a3e --- /dev/null +++ b/tests/auto/declarative/v4/data/colorType.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +QtObject { + property bool useMyColor: true + property color myColor: "red" + property color myOtherColor: "green" + + property color test1: useMyColor ? myColor : myOtherColor + property color test2: useMyColor ? "red" : "green" + property color test3: useMyColor ? myColor : "green" + + property bool test4: !myColor ? false : true + + property bool test5: myColor != "red" + property bool test6: myColor == "#ff0000" + property bool test7: myColor != "#00ff00" +} + diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp index 927dc0f082..99e3f3255f 100644 --- a/tests/auto/declarative/v4/tst_v4.cpp +++ b/tests/auto/declarative/v4/tst_v4.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -73,6 +74,7 @@ private slots: void stringComparison(); void unaryMinus(); void unaryPlus(); + void colorType(); private: QDeclarativeEngine engine; @@ -348,6 +350,22 @@ void tst_v4::unaryPlus() delete o; } +void tst_v4::colorType() +{ + QDeclarativeComponent component(&engine, testFileUrl("colorType.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").value(), QColor("red")); + QCOMPARE(o->property("test2").value(), QColor("red")); + QCOMPARE(o->property("test3").value(), QColor("red")); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + QCOMPARE(o->property("test6").toBool(), true); + QCOMPARE(o->property("test7").toBool(), true); + delete o; +} + QTEST_MAIN(tst_v4) #include "tst_v4.moc" -- cgit v1.2.3 From d290cb3a499a0c3a71ab1f63cbd2fc45b0f5835f Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 27 Feb 2012 16:26:05 +1000 Subject: Fix when animating items that are already moving The view must transition displaced/moved items that are currently transitioning to another position; check against the current transition-to position, not just the current item position. Task-number: QTBUG-24522 Change-Id: Icf1c290f76ceb8c93716f1562ae0bc5a75445b78 Reviewed-by: Martin Jones --- .../qquickgridview/data/multipleTransitions.qml | 28 ++++++++++++++++++- .../qtquick2/qquickgridview/tst_qquickgridview.cpp | 32 ++++++++++++++++++---- .../qquicklistview/data/multipleTransitions.qml | 27 ++++++++++++++++++ .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 28 ++++++++++++++++--- 4 files changed, 105 insertions(+), 10 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml index 45b86e22cf..909ec3a0b7 100644 --- a/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml +++ b/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml @@ -10,7 +10,7 @@ Rectangle { // interrupting transitions will still produce the correct result) property int timeBetweenActions: duration / 2 - property int duration: 100 + property int duration: 300 property int count: grid.count @@ -46,6 +46,8 @@ Rectangle { property bool runningAddDisplaced: false property bool runningMoveTargets: false property bool runningMoveDisplaced: false + property bool runningRemoveTargets: false + property bool runningRemoveDisplaced: false objectName: "grid" width: 240 @@ -103,6 +105,30 @@ Rectangle { ScriptAction { script: grid.runningMoveDisplaced = false } } } + + remove: Transition { + id: removeTargets + SequentialAnimation { + ScriptAction { script: grid.runningRemoveTargets = true } + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeTargets_transitionTo.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeTargets_transitionTo.y; duration: root.duration } + } + ScriptAction { script: grid.runningRemoveTargets = false } + } + } + + removeDisplaced: Transition { + id: removeDisplaced + SequentialAnimation { + ScriptAction { script: grid.runningRemoveDisplaced = true } + ParallelAnimation { + NumberAnimation { properties: "x"; from: removeDisplaced_transitionFrom.x; duration: root.duration } + NumberAnimation { properties: "y"; from: removeDisplaced_transitionFrom.y; duration: root.duration } + } + ScriptAction { script: grid.runningRemoveDisplaced = false } + } + } } Rectangle { diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index 6d755a64c7..077cd2b26a 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -4776,12 +4776,15 @@ void tst_QQuickGridView::multipleTransitions() QFETCH(int, initialCount); QFETCH(qreal, contentY); QFETCH(QList, changes); + QFETCH(bool, rippleAddDisplaced); // add transitions on the left, moves on the right QPointF addTargets_transitionFrom(-50, -50); QPointF addDisplaced_transitionFrom(-50, 50); QPointF moveTargets_transitionFrom(50, -50); QPointF moveDisplaced_transitionFrom(50, 50); + QPointF removeTargets_transitionTo(-100, 300); + QPointF removeDisplaced_transitionFrom(100, 300); QmlListModel model; for (int i = 0; i < initialCount; i++) @@ -4794,8 +4797,12 @@ void tst_QQuickGridView::multipleTransitions() ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom); ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom); ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); + ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo); + ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom); + ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced); canvas->setSource(testFileUrl("multipleTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); @@ -4803,6 +4810,11 @@ void tst_QQuickGridView::multipleTransitions() QVERIFY(contentItem != 0); QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + if (contentY != 0) { + gridview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + } + int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt(); QList > targetItems; @@ -4894,18 +4906,21 @@ void tst_QQuickGridView::multipleTransitions_data() QTest::addColumn("initialCount"); QTest::addColumn("contentY"); QTest::addColumn >("changes"); + QTest::addColumn("rippleAddDisplaced"); // the added item and displaced items should move to final dest correctly QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList() - << ListChange::insert(0, 1) - << ListChange::move(0, 3, 1) - ); + << ListChange::insert(0, 1) + << ListChange::move(0, 3, 1) + ) + << false; // items affected by the add should change from move to add transition QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList() << ListChange::move(1, 10, 3) << ListChange::insert(0, 1) - ); + ) + << false; // items should be placed correctly if you trigger a transition then refill for that index QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList() @@ -4913,7 +4928,14 @@ void tst_QQuickGridView::multipleTransitions_data() << ListChange::setContentY(160.0) << ListChange::setContentY(0.0) << ListChange::insert(0, 1) - ); + ) + << false; + + QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList() + << ListChange::insert(1, 1) + << ListChange::remove(1, 1) + ) + << true; } void tst_QQuickGridView::cacheBuffer() diff --git a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml index 3e3248535b..8264b42b64 100644 --- a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml +++ b/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml @@ -45,6 +45,8 @@ Rectangle { property bool runningAddDisplaced: false property bool runningMoveTargets: false property bool runningMoveDisplaced: false + property bool runningRemoveTargets: false + property bool runningRemoveDisplaced: false objectName: "list" focus: true @@ -70,6 +72,7 @@ Rectangle { id: addDisplaced SequentialAnimation { ScriptAction { script: list.runningAddDisplaced = true } + PauseAnimation { duration: rippleAddDisplaced ? addDisplaced.ViewTransition.index * root.duration/10 : 0 } ParallelAnimation { NumberAnimation { properties: "x"; from: addDisplaced_transitionFrom.x; duration: root.duration } NumberAnimation { properties: "y"; from: addDisplaced_transitionFrom.y; duration: root.duration } @@ -101,6 +104,30 @@ Rectangle { ScriptAction { script: list.runningMoveDisplaced = false } } } + + remove: Transition { + id: removeTargets + SequentialAnimation { + ScriptAction { script: list.runningRemoveTargets = true } + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeTargets_transitionTo.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeTargets_transitionTo.y; duration: root.duration } + } + ScriptAction { script: list.runningRemoveTargets = false } + } + } + + removeDisplaced: Transition { + id: removeDisplaced + SequentialAnimation { + ScriptAction { script: list.runningRemoveDisplaced = true } + ParallelAnimation { + NumberAnimation { properties: "x"; from: removeDisplaced_transitionFrom.x; duration: root.duration } + NumberAnimation { properties: "y"; from: removeDisplaced_transitionFrom.y; duration: root.duration } + } + ScriptAction { script: list.runningRemoveDisplaced = false } + } + } } Rectangle { diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index a834f1aa03..8f1527fa36 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -5787,12 +5787,14 @@ void tst_QQuickListView::multipleTransitions() QFETCH(int, initialCount); QFETCH(qreal, contentY); QFETCH(QList, changes); + QFETCH(bool, rippleAddDisplaced); - // add transitions on the left, moves on the right QPointF addTargets_transitionFrom(-50, -50); QPointF addDisplaced_transitionFrom(-50, 50); QPointF moveTargets_transitionFrom(50, -50); QPointF moveDisplaced_transitionFrom(50, 50); + QPointF removeTargets_transitionTo(-100, 300); + QPointF removeDisplaced_transitionFrom(100, 300); QmlListModel model; for (int i = 0; i < initialCount; i++) @@ -5807,6 +5809,9 @@ void tst_QQuickListView::multipleTransitions() ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom); ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom); ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); + ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo); + ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom); + ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced); canvas->setSource(testFileUrl("multipleTransitions.qml")); canvas->show(); QTest::qWaitForWindowShown(canvas); @@ -5817,6 +5822,11 @@ void tst_QQuickListView::multipleTransitions() QVERIFY(contentItem != 0); QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + if (contentY != 0) { + listview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + } + int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt(); QList > targetItems; @@ -5897,18 +5907,21 @@ void tst_QQuickListView::multipleTransitions_data() QTest::addColumn("initialCount"); QTest::addColumn("contentY"); QTest::addColumn >("changes"); + QTest::addColumn("rippleAddDisplaced"); // the added item and displaced items should move to final dest correctly QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList() << ListChange::insert(0, 1) << ListChange::move(0, 3, 1) - ); + ) + << false; // items affected by the add should change from move to add transition QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList() << ListChange::move(1, 10, 3) << ListChange::insert(0, 1) - ); + ) + << false; // items should be placed correctly if you trigger a transition then refill for that index QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList() @@ -5916,7 +5929,14 @@ void tst_QQuickListView::multipleTransitions_data() << ListChange::setContentY(80.0) << ListChange::setContentY(0.0) << ListChange::insert(0, 1) - ); + ) + << false; + + QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList() + << ListChange::insert(1, 1) + << ListChange::remove(1, 1) + ) + << true; } QList tst_QQuickListView::toIntList(const QVariantList &list) -- cgit v1.2.3 From 181545935323c74c2ec9c5a89ff51606008e30c0 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 29 Feb 2012 14:59:49 +0100 Subject: Profiler: Use RAII helper structs for ranges Exclusively use RAII helper structs for ranges. Change-Id: Ief9ab25a9e49e1b2c3c091e5d9de6479e36eaa50 Reviewed-by: Christiaan Janssen --- .../qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro index 564945faf7..52139bf569 100644 --- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro +++ b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro @@ -12,4 +12,4 @@ include (../../../shared/util.pri) CONFIG += parallel_test declarative_debug -QT += declarative-private testlib +QT += core-private v8-private declarative-private testlib -- cgit v1.2.3