diff options
Diffstat (limited to 'tests/auto/other/lancelot')
-rw-r--r-- | tests/auto/other/lancelot/CMakeLists.txt | 84 | ||||
-rw-r--r-- | tests/auto/other/lancelot/lancelot.pro | 1 | ||||
-rw-r--r-- | tests/auto/other/lancelot/paintcommands.cpp | 64 | ||||
-rw-r--r-- | tests/auto/other/lancelot/paintcommands.h | 4 | ||||
-rw-r--r-- | tests/auto/other/lancelot/scripts/fillrect.qps | 121 | ||||
-rw-r--r-- | tests/auto/other/lancelot/scripts/fillrect_aa.qps | 121 | ||||
-rw-r--r-- | tests/auto/other/lancelot/scripts/filltest.qps | 26 | ||||
-rw-r--r-- | tests/auto/other/lancelot/scripts/perspectives2.qps | 14 |
8 files changed, 412 insertions, 23 deletions
diff --git a/tests/auto/other/lancelot/CMakeLists.txt b/tests/auto/other/lancelot/CMakeLists.txt new file mode 100644 index 0000000000..6f15ff7990 --- /dev/null +++ b/tests/auto/other/lancelot/CMakeLists.txt @@ -0,0 +1,84 @@ +# Generated from lancelot.pro. + +##################################################################### +## tst_lancelot Test: +##################################################################### + +# Collect test data +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + scripts/*) +list(APPEND test_data ${test_data_glob}) + +add_qt_test(tst_lancelot + SOURCES + ../../../baselineserver/shared/baselineprotocol.cpp ../../../baselineserver/shared/baselineprotocol.h + ../../../baselineserver/shared/lookup3.cpp + ../../../baselineserver/shared/qbaselinetest.cpp ../../../baselineserver/shared/qbaselinetest.h + paintcommands.cpp paintcommands.h + tst_lancelot.cpp + DEFINES + QMAKESPEC=\\\"\\\" + INCLUDE_DIRECTORIES + ../../../baselineserver/shared + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::Network + TESTDATA ${test_data} +) + +# Resources: +set(images_resource_files + "images/alpha.png" + "images/alpha2x2.png" + "images/bitmap.png" + "images/border.png" + "images/borderimage.png" + "images/dome_argb32.png" + "images/dome_indexed.png" + "images/dome_indexed_mask.png" + "images/dome_mono.png" + "images/dome_mono_128.png" + "images/dome_mono_palette.png" + "images/dome_rgb32.png" + "images/dot.png" + "images/face.png" + "images/gam030.png" + "images/gam045.png" + "images/gam056.png" + "images/gam100.png" + "images/gam200.png" + "images/image.png" + "images/mask.png" + "images/mask_100.png" + "images/masked.png" + "images/sign.png" + "images/solid.png" + "images/solid2x2.png" + "images/struct-image-01.jpg" + "images/struct-image-01.png" + "images/zebra.png" +) + +add_qt_resource(tst_lancelot "images" + PREFIX + "/" + FILES + ${images_resource_files} +) + + +## Scopes: +##################################################################### + +extend_target(tst_lancelot CONDITION QT_FEATURE_opengl + PUBLIC_LIBRARIES + Qt::OpenGL +) + +#### Keys ignored in scope 4:.:../../../baselineserver/shared:../../../baselineserver/shared/qbaselinetest.pri:WIN32: +# MKSPEC = "$$replace(QMAKESPEC, \\\\, /)" + +#### Keys ignored in scope 5:.:../../../baselineserver/shared:../../../baselineserver/shared/qbaselinetest.pri:else: +# MKSPEC = "$$QMAKESPEC" diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro index 6ece7315ed..5b9117983a 100644 --- a/tests/auto/other/lancelot/lancelot.pro +++ b/tests/auto/other/lancelot/lancelot.pro @@ -1,6 +1,7 @@ CONFIG += testcase TARGET = tst_lancelot QT += testlib gui-private +qtConfig(opengl): QT += opengl SOURCES += tst_lancelot.cpp \ paintcommands.cpp diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index fbf906b55d..7430c93a8e 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -230,9 +230,9 @@ void PaintCommands::staticInit() "begin_block <blockName>", "begin_block blockName"); DECL_PAINTCOMMAND("end_block", command_end_block, - "^end_block$", - "end_block", - "end_block"); + "^end_block\\s*(\\w*)$", + "end_block [blockName]", + "end_block blockName"); DECL_PAINTCOMMAND("repeat_block", command_repeat_block, "^repeat_block\\s+(\\w*)$", "repeat_block <blockName>", @@ -365,6 +365,7 @@ void PaintCommands::staticInit() "^gradient_setCoordinateMode\\s+(\\w*)$", "gradient_setCoordinateMode <coordinate method enum>", "gradient_setCoordinateMode ObjectBoundingMode"); + DECL_PAINTCOMMANDSECTION("drawing ops"); DECL_PAINTCOMMAND("drawPoint", command_drawPoint, "^drawPoint\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$", @@ -454,6 +455,14 @@ void PaintCommands::staticInit() "\n - where t means tile" "\n - and s is an offset in the tile", "drawTiledPixmap :/images/alpha.png "); + DECL_PAINTCOMMAND("fillRect", command_fillRect, + "^fillRect\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s*(\\w*)?$", + "fillRect <x> <y> <w> <h> [color]\n - Uses current brush if no color given", + "fillRect 10 10 20 20 blue"); + DECL_PAINTCOMMAND("fillRectF", command_fillRectF, + "^fillRectF\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s*(\\w*)?$", + "fillRectF <x> <y> <w> <h> [color]\n - Uses current brush if no color given", + "fillRectF 10.5 10.5 20.2 20.2 blue"); DECL_PAINTCOMMANDSECTION("painterPaths"); DECL_PAINTCOMMAND("path_moveTo", command_path_moveTo, @@ -735,6 +744,13 @@ void PaintCommands::runCommands() if (height <= 0) height = 800; + m_pathMap.clear(); + m_imageMap.clear(); + m_pixmapMap.clear(); + m_regionMap.clear(); + m_gradientStops.clear(); + m_blockMap.clear(); + // paint background if (m_checkers_background) { QPixmap pm(20, 20); @@ -892,6 +908,8 @@ void PaintCommands::command_begin_block(QRegularExpressionMatch re) const QString &blockName = re.captured(1); if (m_verboseMode) printf(" -(lance) begin_block (%s)\n", qPrintable(blockName)); + if (m_blockMap.contains(blockName)) + qFatal("Two blocks named (%s)", qPrintable(blockName)); m_commands[m_currentCommandIndex] = QLatin1String("# begin block (") + blockName + QLatin1Char(')'); QStringList newBlock; @@ -1331,6 +1349,46 @@ void PaintCommands::command_drawTextDocument(QRegularExpressionMatch re) m_painter->restore(); } +/***************************************************************************************************/ +void PaintCommands::command_fillRect(QRegularExpressionMatch re) +{ + QStringList caps = re.capturedTexts(); + int x = convertToInt(caps.at(1)); + int y = convertToInt(caps.at(2)); + int w = convertToInt(caps.at(3)); + int h = convertToInt(caps.at(4)); + + if (!caps.at(5).isEmpty()) { + QColor color = convertToColor(caps.at(5)); + if (m_verboseMode) + printf(" -(lance) fillRect(%d, %d, %d, %d, %s)\n", x, y, w, h, qPrintable(color.name())); + m_painter->fillRect(x, y, w, h, color); + } else { + if (m_verboseMode) + printf(" -(lance) fillRect(%d, %d, %d, %d)\n", x, y, w, h); + m_painter->fillRect(x, y, w, h, m_painter->brush()); + } +} + +void PaintCommands::command_fillRectF(QRegularExpressionMatch re) +{ + QStringList caps = re.capturedTexts(); + double x = convertToDouble(caps.at(1)); + double y = convertToDouble(caps.at(2)); + double w = convertToDouble(caps.at(3)); + double h = convertToDouble(caps.at(4)); + + if (!caps.at(5).isEmpty()) { + QColor color = convertToColor(caps.at(5)); + if (m_verboseMode) + printf(" -(lance) fillRectF(%.2f, %.2f, %.2f, %.2f, %s)\n", x, y, w, h, qPrintable(color.name())); + m_painter->fillRect(QRectF(x, y, w, h), color); + } else { + if (m_verboseMode) + printf(" -(lance) fillRectF(%.2f, %.2f, %.2f, %.2f)\n", x, y, w, h); + m_painter->fillRect(QRectF(x, y, w, h), m_painter->brush()); + } +} /***************************************************************************************************/ void PaintCommands::command_noop(QRegularExpressionMatch) diff --git a/tests/auto/other/lancelot/paintcommands.h b/tests/auto/other/lancelot/paintcommands.h index 79bdab634a..816ecd6fa2 100644 --- a/tests/auto/other/lancelot/paintcommands.h +++ b/tests/auto/other/lancelot/paintcommands.h @@ -200,6 +200,10 @@ private: void command_drawStaticText(QRegularExpressionMatch re); void command_drawTextDocument(QRegularExpressionMatch re); void command_drawTiledPixmap(QRegularExpressionMatch re); + void command_fillRect(QRegularExpressionMatch re); + void command_fillRectF(QRegularExpressionMatch re); + + // paths void command_path_addEllipse(QRegularExpressionMatch re); void command_path_addPolygon(QRegularExpressionMatch re); void command_path_addRect(QRegularExpressionMatch re); diff --git a/tests/auto/other/lancelot/scripts/fillrect.qps b/tests/auto/other/lancelot/scripts/fillrect.qps new file mode 100644 index 0000000000..103ef2646a --- /dev/null +++ b/tests/auto/other/lancelot/scripts/fillrect.qps @@ -0,0 +1,121 @@ +setRenderHint Antialiasing false + +# offscreen +translate 0 -200 + +begin_block rects +# int API +fillRect 10 10 20 20 green +fillRect 40 10 20 20 +drawRect 70 10 20 20 + +# float API, int values +fillRectF 10.0 40.0 20.0 20.0 green +fillRectF 40.0 40.0 20.0 20.0 +drawRect 70.0 40.0 20.0 20.0 + +# float API, float values +fillRectF 10.0 70.0 20.5 20.5 green +fillRectF 40.0 70.0 20.5 20.5 +drawRect 70.0 70.0 20.5 20.5 + +# alignment, int api, color +fillRect 10 100 10 10 green +fillRect 20 100 10 10 green +fillRect 10 110 10 10 green +fillRect 20 110 10 10 green + +# alignment, int api, brush +fillRect 40 100 10 10 +fillRect 50 100 10 10 +fillRect 40 110 10 10 +fillRect 50 110 10 10 + +# alignment comparison +drawRect 70 100 10 10 +drawRect 80 100 10 10 +drawRect 70 110 10 10 +drawRect 80 110 10 10 + +# alignment, float api, color +fillRectF 10.0 130.0 10.0 10.0 green +fillRectF 20.0 130.0 10.0 10.0 green +fillRectF 10.0 140.0 10.0 10.0 green +fillRectF 20.0 140.0 10.0 10.0 green + +# alignment, float api, brush +fillRectF 40.0 130.0 10.0 10.0 +fillRectF 50.0 130.0 10.0 10.0 +fillRectF 40.0 140.0 10.0 10.0 +fillRectF 50.0 140.0 10.0 10.0 + +# alignment comparison +drawRect 70.0 130.0 10.0 10.0 +drawRect 80.0 130.0 10.0 10.0 +drawRect 70.0 140.0 10.0 10.0 +drawRect 80.0 140.0 10.0 10.0 + +end_block + +begin_block row + +repeat_block rects + +save +translate 100.2 0.2 +repeat_block rects +restore + +save +translate 200.5 0.5 +repeat_block rects +restore + +save +translate 300.7 0.7 +repeat_block rects +restore + +end_block + +# end of block defs + +resetMatrix + +setPen NoPen +setBrush green +repeat_block row + +save +translate 500 50 +scale 0.42 0.42 +repeat_block row +restore + +save +translate 0 160 +scale 1.8 0.8 +repeat_block row +restore + +save +translate 650 320 +rotate 80 +repeat_block row +restore + +save +setBrush green Dense2Pattern +translate 0 400 +repeat_block row +restore + +save +gradient_clearStops +gradient_appendStop 0 green +gradient_appendStop 1 blue +gradient_setCoordinateMode ObjectBoundingMode +gradient_setLinear 0.0 0.0 1.0 1.0 +translate 0 600 +repeat_block row +restore diff --git a/tests/auto/other/lancelot/scripts/fillrect_aa.qps b/tests/auto/other/lancelot/scripts/fillrect_aa.qps new file mode 100644 index 0000000000..3232899661 --- /dev/null +++ b/tests/auto/other/lancelot/scripts/fillrect_aa.qps @@ -0,0 +1,121 @@ +setRenderHint Antialiasing true + +# offscreen +translate 0 -200 + +begin_block rects +# int API +fillRect 10 10 20 20 green +fillRect 40 10 20 20 +drawRect 70 10 20 20 + +# float API, int values +fillRectF 10.0 40.0 20.0 20.0 green +fillRectF 40.0 40.0 20.0 20.0 +drawRect 70.0 40.0 20.0 20.0 + +# float API, float values +fillRectF 10.0 70.0 20.5 20.5 green +fillRectF 40.0 70.0 20.5 20.5 +drawRect 70.0 70.0 20.5 20.5 + +# alignment, int api, color +fillRect 10 100 10 10 green +fillRect 20 100 10 10 green +fillRect 10 110 10 10 green +fillRect 20 110 10 10 green + +# alignment, int api, brush +fillRect 40 100 10 10 +fillRect 50 100 10 10 +fillRect 40 110 10 10 +fillRect 50 110 10 10 + +# alignment comparison +drawRect 70 100 10 10 +drawRect 80 100 10 10 +drawRect 70 110 10 10 +drawRect 80 110 10 10 + +# alignment, float api, color +fillRectF 10.0 130.0 10.0 10.0 green +fillRectF 20.0 130.0 10.0 10.0 green +fillRectF 10.0 140.0 10.0 10.0 green +fillRectF 20.0 140.0 10.0 10.0 green + +# alignment, float api, brush +fillRectF 40.0 130.0 10.0 10.0 +fillRectF 50.0 130.0 10.0 10.0 +fillRectF 40.0 140.0 10.0 10.0 +fillRectF 50.0 140.0 10.0 10.0 + +# alignment comparison +drawRect 70.0 130.0 10.0 10.0 +drawRect 80.0 130.0 10.0 10.0 +drawRect 70.0 140.0 10.0 10.0 +drawRect 80.0 140.0 10.0 10.0 + +end_block + +begin_block row + +repeat_block rects + +save +translate 100.2 0.2 +repeat_block rects +restore + +save +translate 200.5 0.5 +repeat_block rects +restore + +save +translate 300.7 0.7 +repeat_block rects +restore + +end_block + +# end of block defs + +resetMatrix + +setPen NoPen +setBrush green +repeat_block row + +save +translate 500 50 +scale 0.42 0.42 +repeat_block row +restore + +save +translate 0 160 +scale 1.8 0.8 +repeat_block row +restore + +save +translate 650 320 +rotate 80 +repeat_block row +restore + +save +setBrush green Dense2Pattern +translate 0 400 +repeat_block row +restore + +save +gradient_clearStops +gradient_appendStop 0 green +gradient_appendStop 1 blue +gradient_setCoordinateMode ObjectBoundingMode +gradient_setLinear 0.0 0.0 1.0 1.0 +translate 0 600 +repeat_block row +restore diff --git a/tests/auto/other/lancelot/scripts/filltest.qps b/tests/auto/other/lancelot/scripts/filltest.qps index 2eeba2ecf6..112ffc85be 100644 --- a/tests/auto/other/lancelot/scripts/filltest.qps +++ b/tests/auto/other/lancelot/scripts/filltest.qps @@ -133,7 +133,7 @@ setPen nopen translate 50 0 -begin_block rects +begin_block rects2 drawPath rect drawRect 0 20 10 10 drawImage img 0 40 @@ -154,59 +154,59 @@ translate 10 20 rotate 90 drawRect 0 0 10 10 restore -end_block rects +end_block rects2 setPen red drawText -5 -10 "0.0" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.1" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.2" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.3" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.4" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.5" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.6" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.7" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.8" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.9" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "1.0" setPen nopen @@ -410,4 +410,4 @@ drawText 0 0 "outline/fill consistency" setPen red setBrush green translate 80 -30 -drawPolygon [13.6965 -99.1837 -71.4767 13.823 32.4596 -33.1847]
\ No newline at end of file +drawPolygon [13.6965 -99.1837 -71.4767 13.823 32.4596 -33.1847] diff --git a/tests/auto/other/lancelot/scripts/perspectives2.qps b/tests/auto/other/lancelot/scripts/perspectives2.qps index 2f6d1d653c..6762e21af4 100644 --- a/tests/auto/other/lancelot/scripts/perspectives2.qps +++ b/tests/auto/other/lancelot/scripts/perspectives2.qps @@ -8,7 +8,7 @@ image_convertToFormat zebra_png zebra ARGB32_Premultiplied translate 75 100 # standard draw -begin_block row +begin_block row1 drawImage zebra -50 -50 translate 90 0 @@ -136,12 +136,12 @@ save rotate_y 180 drawImage zebra -50 -50 restore -end_block +end_block row1 resetMatrix translate 75 280 setRenderHint SmoothPixmapTransform -repeat_block row +repeat_block row1 resetMatrix setPen black @@ -162,7 +162,7 @@ setRenderHint SmoothPixmapTransform false translate 75 100 # standard draw -begin_block row +begin_block row2 drawImage dome -50 -50 translate 90 0 @@ -290,13 +290,13 @@ save rotate_y 180 drawImage dome -50 -50 restore -end_block +end_block row2 resetMatrix translate 0 400 translate 75 280 setRenderHint SmoothPixmapTransform -repeat_block row +repeat_block row2 resetMatrix setPen black @@ -306,4 +306,4 @@ drawText 0 0 "Fast Pixmap Transform" resetMatrix translate 0 400 translate 300 210 -drawText 0 0 "Smooth Pixmap Transform"
\ No newline at end of file +drawText 0 0 "Smooth Pixmap Transform" |