diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-04-10 01:30:44 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-04-10 01:30:44 (GMT) |
commit | 082b9125d627df11692f2a03b80c9e962e82eda5 (patch) | |
tree | fee60bb2f217c1a22db68329beffc3d29a2498c9 /tests | |
parent | cb188229132e36ef1fe1af4c8e2db0df6047be76 (diff) | |
parent | 22c35fb59aee3ae2cb70be891b4f0e376f4ff5c5 (diff) | |
download | Qt-082b9125d627df11692f2a03b80c9e962e82eda5.zip Qt-082b9125d627df11692f2a03b80c9e962e82eda5.tar.gz Qt-082b9125d627df11692f2a03b80c9e962e82eda5.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging:
Lancelot: bail out if rendering consistently fails
Minor optimization to lance/elot
Make it possible to test the new font hinting in lance[elot]
Fixes: The "test: too many arguments" error after every make
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arthur/common/paintcommands.cpp | 34 | ||||
-rw-r--r-- | tests/arthur/common/paintcommands.h | 1 | ||||
-rw-r--r-- | tests/auto/lancelot/scripts/hinting.qps | 26 | ||||
-rw-r--r-- | tests/auto/lancelot/tst_lancelot.cpp | 11 |
4 files changed, 64 insertions, 8 deletions
diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index b00ce81..7a018e3 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -96,6 +96,13 @@ const char *PaintCommands::fontWeightTable[] = { "Black" }; +const char *PaintCommands::fontHintingTable[] = { + "Default", + "None", + "Vertical", + "Full" +}; + const char *PaintCommands::clipOperationTable[] = { "NoClip", "ReplaceClip", @@ -177,8 +184,9 @@ const char *PaintCommands::imageFormatTable[] = { int PaintCommands::translateEnum(const char *table[], const QString &pattern, int limit) { + QByteArray p = pattern.toLatin1().toLower(); for (int i=0; i<limit; ++i) - if (pattern.toLower() == QString(QLatin1String(table[i])).toLower()) + if (p == QByteArray::fromRawData(table[i], qstrlen(table[i])).toLower()) return i; return -1; } @@ -287,9 +295,9 @@ void PaintCommands::staticInit() "setCompositionMode <composition mode enum>", "setCompositionMode SourceOver"); DECL_PAINTCOMMAND("setFont", command_setFont, - "^setFont\\s+\"([\\w\\s]*)\"\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$", - "setFont <fontFace> [size] [font weight|font weight enum] [italic]\n - font weight is an integer between 0 and 99", - "setFont \"times\" normal"); + "^setFont\\s+\"([\\w\\s]*)\"\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$", + "setFont <fontFace> [size] [font weight|font weight enum] [italic] [hinting enum]\n - font weight is an integer between 0 and 99", + "setFont \"times\" 12"); DECL_PAINTCOMMAND("setPen", command_setPen, "^setPen\\s+#?(\\w*)$", "setPen <color>\nsetPen <pen style enum>\nsetPen brush", @@ -641,6 +649,7 @@ void PaintCommands::staticInit() ADD_ENUMLIST("brush styles", brushStyleTable); ADD_ENUMLIST("pen styles", penStyleTable); ADD_ENUMLIST("font weights", fontWeightTable); + ADD_ENUMLIST("font hintings", fontHintingTable); ADD_ENUMLIST("clip operations", clipOperationTable); ADD_ENUMLIST("spread methods", spreadMethodTable); ADD_ENUMLIST("composition modes", compositionModeTable); @@ -2061,11 +2070,22 @@ void PaintCommands::command_setFont(QRegExp re) bool italic = caps.at(4).toLower() == "true" || caps.at(4).toLower() == "italic"; + QFont font(family, size, weight, italic); + +#if QT_VERSION >= 0x040800 + int hinting = translateEnum(fontHintingTable, caps.at(5), 4); + if (hinting == -1) + hinting = 0; + else + font.setHintingPreference(QFont::HintingPreference(hinting)); +#else + int hinting = 1; +#endif if (m_verboseMode) - printf(" -(lance) setFont(family=%s, size=%d, weight=%d, italic=%d\n", - qPrintable(family), size, weight, italic); + printf(" -(lance) setFont(family=%s, size=%d, weight=%d, italic=%d hinting=%s\n", + qPrintable(family), size, weight, italic, fontHintingTable[hinting]); - m_painter->setFont(QFont(family, size, weight, italic)); + m_painter->setFont(font); } /***************************************************************************************************/ diff --git a/tests/arthur/common/paintcommands.h b/tests/arthur/common/paintcommands.h index b2516e1..2740412 100644 --- a/tests/arthur/common/paintcommands.h +++ b/tests/arthur/common/paintcommands.h @@ -290,6 +290,7 @@ private: static const char *brushStyleTable[]; static const char *penStyleTable[]; static const char *fontWeightTable[]; + static const char *fontHintingTable[]; static const char *clipOperationTable[]; static const char *spreadMethodTable[]; static const char *coordinateMethodTable[]; diff --git a/tests/auto/lancelot/scripts/hinting.qps b/tests/auto/lancelot/scripts/hinting.qps new file mode 100644 index 0000000..7ce21b2 --- /dev/null +++ b/tests/auto/lancelot/scripts/hinting.qps @@ -0,0 +1,26 @@ +translate 10 50 +setFont "sansserif" 10 +drawText 0 0 "Default hinting:" +setFont "times" 12 normal normal default +drawText 0 20 "The quick brown fox jumps over the lazy dog" + +translate 0 50 +setFont "sansserif" 10 +drawText 0 0 "No hinting:" +setFont "times" 12 normal normal none +drawText 0 20 "The quick brown fox jumps over the lazy dog" + +translate 0 50 +setFont "sansserif" 10 +drawText 0 0 "Vertical hinting:" +setFont "times" 12 normal normal vertical +drawText 0 20 "The quick brown fox jumps over the lazy dog" + +translate 0 50 +setFont "sansserif" 10 +drawText 0 0 "Full hinting:" +setFont "times" 12 normal normal full +drawText 0 20 "The quick brown fox jumps over the lazy dog" + + +# Note: there is also the textlayout_draw command which might be interesting here. diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index e515c48..9721665 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -239,11 +239,20 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format) QSKIP("Blacklisted by baseline server.", SkipSingle); ImageItem rendered = render(baseline, engine, format); + static int consecutiveErrs = 0; if (rendered.image.isNull()) { // Assume an error in the test environment, not Qt QWARN("Error: Failed to render image."); - QSKIP("Aborted due to errors.", SkipSingle); + if (++consecutiveErrs < 3) { + QSKIP("Aborted due to errors.", SkipSingle); + } else { + consecutiveErrs = 0; + QSKIP("Too many errors, skipping rest of testfunction.", SkipAll); + } + } else { + consecutiveErrs = 0; } + if (baseline.status == ImageItem::BaselineNotFound) { proto.submitNewBaseline(rendered, 0); QSKIP("Baseline not found; new baseline created.", SkipSingle); |