From fdc87143eb9eff98938b6a086c3e81432be08e4d Mon Sep 17 00:00:00 2001 From: Charles Yin <charles.yin@nokia.com> Date: Tue, 4 Oct 2011 17:12:12 +1000 Subject: [PATCH] Add more unit tests for qsgcanvasitem and fix unstable tests Change-Id:I5fc11a5874d55ad423dc1fb9c3e1b75a38003465 Reviewed-on: http://codereview.qt-project.org/5962 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Charles Yin <charles.yin@nokia.com> --- .../items/context2d/qsgcanvasitem.cpp | 33 +- .../items/context2d/qsgcontext2d.cpp | 556 ++++--- .../items/context2d/qsgcontext2d_p.h | 1 - .../context2d/qsgcontext2dcommandbuffer.cpp | 20 +- .../items/context2d/qsgcontext2dtexture.cpp | 7 +- .../qsgcanvasitem/data/qt-logo.png | Bin 0 -> 23519 bytes .../qsgcanvasitem/data/tst_arc.qml | 487 ++++++ .../qsgcanvasitem/data/tst_arcto.qml | 410 +++++ .../qsgcanvasitem/data/tst_canvas.qml | 271 ++++ .../qsgcanvasitem/data/tst_colors.qml | 19 - .../qsgcanvasitem/data/tst_composite.qml | 380 +++++ .../qsgcanvasitem/data/tst_drawimage.qml | 42 + .../qsgcanvasitem/data/tst_fillStyle.qml | 12 +- .../qsgcanvasitem/data/tst_fillrect.qml | 4 +- .../qsgcanvasitem/data/tst_gradient.qml | 981 +++++++++++ .../qsgcanvasitem/data/tst_line.qml | 831 ++++++++++ .../qsgcanvasitem/data/tst_path.qml | 1443 +++++++++++++++++ .../qsgcanvasitem/data/tst_pattern.qml | 34 + .../qsgcanvasitem/data/tst_pixel.qml | 30 + .../qsgcanvasitem/data/tst_shadow.qml | 59 + .../qsgcanvasitem/data/tst_state.qml | 389 +++++ .../qsgcanvasitem/data/tst_strokeStyle.qml | 2 +- .../qsgcanvasitem/data/tst_text.qml | 34 + .../qsgcanvasitem/data/tst_transform.qml | 487 ++++++ .../qsgcanvasitem/qsgcanvasitem.pro | 23 + 25 files changed, 6304 insertions(+), 251 deletions(-) create mode 100644 tests/auto/declarative/qsgcanvasitem/data/qt-logo.png create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_arc.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_arcto.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_canvas.qml delete mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_colors.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_composite.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_drawimage.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_gradient.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_line.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_path.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_pattern.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_pixel.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_shadow.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_state.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_text.qml create mode 100644 tests/auto/declarative/qsgcanvasitem/data/tst_transform.qml diff --git a/src/declarative/items/context2d/qsgcanvasitem.cpp b/src/declarative/items/context2d/qsgcanvasitem.cpp index 50cbc7e2f1..6b0b438ddb 100644 --- a/src/declarative/items/context2d/qsgcanvasitem.cpp +++ b/src/declarative/items/context2d/qsgcanvasitem.cpp @@ -85,7 +85,7 @@ QSGCanvasItemPrivate::QSGCanvasItemPrivate() , hasTileSize(false) , hasCanvasWindow(false) , componentCompleted(false) - , renderTarget(QSGCanvasItem::Image) + , renderTarget(QSGCanvasItem::FramebufferObject) { } @@ -512,7 +512,9 @@ void QSGCanvasItem::createContext() QDeclarativeV8Handle QSGCanvasItem::getContext(const QString &contextId) { Q_D(QSGCanvasItem); - Q_UNUSED(contextId); + + if (contextId.toLower() != QLatin1String("2d")) + return QDeclarativeV8Handle::fromHandle(v8::Undefined()); if (!d->context) createContext(); @@ -552,7 +554,9 @@ void QSGCanvasItem::markDirty(const QRectF& region) */ bool QSGCanvasItem::save(const QString &filename) const { - return toImage().save(filename); + Q_D(const QSGCanvasItem); + QUrl url = d->baseUrl.resolved(QUrl::fromLocalFile(filename)); + return toImage().save(url.toLocalFile()); } QImage QSGCanvasItem::loadedImage(const QUrl& url) @@ -683,24 +687,25 @@ QString QSGCanvasItem::toDataURL(const QString& mimeType) const QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly); - QString mime = mimeType; + QString mime = mimeType.toLower(); QString type; - if (mimeType == QLatin1Literal("image/bmp")) + if (mime == QLatin1Literal("image/png")) { + type = QLatin1Literal("PNG"); + } else if (mime == QLatin1Literal("image/bmp")) type = QLatin1Literal("BMP"); - else if (mimeType == QLatin1Literal("image/jpeg")) + else if (mime == QLatin1Literal("image/jpeg")) type = QLatin1Literal("JPEG"); - else if (mimeType == QLatin1Literal("image/x-portable-pixmap")) + else if (mime == QLatin1Literal("image/x-portable-pixmap")) type = QLatin1Literal("PPM"); - else if (mimeType == QLatin1Literal("image/tiff")) + else if (mime == QLatin1Literal("image/tiff")) type = QLatin1Literal("TIFF"); - else if (mimeType == QLatin1Literal("image/xbm")) + else if (mime == QLatin1Literal("image/xbm")) type = QLatin1Literal("XBM"); - else if (mimeType == QLatin1Literal("image/xpm")) + else if (mime == QLatin1Literal("image/xpm")) type = QLatin1Literal("XPM"); - else { - type = QLatin1Literal("PNG"); - mime = QLatin1Literal("image/png"); - } + else + return QLatin1Literal("data:,"); + image.save(&buffer, type.toAscii()); buffer.close(); QString dataUrl = QLatin1Literal("data:%1;base64,%2"); diff --git a/src/declarative/items/context2d/qsgcontext2d.cpp b/src/declarative/items/context2d/qsgcontext2d.cpp index cfcfb063dd..ef69eefea9 100644 --- a/src/declarative/items/context2d/qsgcontext2d.cpp +++ b/src/declarative/items/context2d/qsgcontext2d.cpp @@ -59,6 +59,9 @@ #include "qv8engine_p.h" #include "qdeclarativeengine.h" +#include "qv8domerrors_p.h" +#include <QtCore/qnumeric.h> + QT_BEGIN_NAMESPACE /*! \qmlclass Context2D QSGContext2D @@ -102,78 +105,69 @@ static const double Q_PI = 3.14159265358979323846; // pi #define CHECK_CONTEXT_SETTER(r) if (!r || !r->context || !r->context->buffer()) \ V8THROW_ERROR_SETTER("Not a Context2D object"); #define qClamp(val, min, max) qMin(qMax(val, min), max) - -QColor qt_color_from_string(const QString& name) +#define CHECK_RGBA(c) (c == '-' || c == '.' || (c >=0 && c <= 9)) +QColor qt_color_from_string(v8::Local<v8::Value> name) { + v8::String::AsciiValue str(name); + + char *p = *str; + int len = str.length(); //rgb/hsl color string has at least 7 characters - if (name.isEmpty() || name.size() > 255 || name.size() <= 7) - return QColor(name); + if (!p || len > 255 || len <= 7) + return QColor(p); else { - const char* data = name.toLatin1().constData(); - bool isRgb = false, isHsl = false, hasAlpha = false; + bool isRgb(false), isHsl(false), hasAlpha(false); - int pos = 0; - while (isspace(data[pos])) pos++; - - if (strncmp(&(data[pos]), "rgb", 3) == 0) + while (isspace(*p)) p++; + if (strncmp(p, "rgb", 3) == 0) isRgb = true; - else if (strncmp(&(data[pos]), "hsl", 3) == 0) + else if (strncmp(p, "hsl", 3) == 0) isHsl = true; else - return QColor(name); - pos+=3; - if (data[pos] == 'a') - hasAlpha = true; + return QColor(p); - int rh, gs, bl, alpha = 255; + p+=3; //skip "rgb" or "hsl" + hasAlpha = (*p == 'a') ? true : false; + + ++p; //skip "(" - const int len = name.size(); - while (pos < len && (data[pos] != '(' || isspace(data[pos]))) pos++; - if (pos >= len) return QColor(); + if (hasAlpha) ++p; //skip "a" + + int rh, gs, bl, alpha = 255; //red - while (pos < len && !isdigit(data[pos])) pos++; - if (pos >= len) return QColor(); - rh = atoi(&(data[pos])); - while (pos < len && ((data[pos] != ',' && data[pos] != '%') || isspace(data[pos]))) pos++; - if (data[pos] == '%') { + while (isspace(*p)) p++; + rh = strtol(p, &p, 10); + if (*p == '%') { rh = qRound(rh/100.0 * 255); - pos++; + ++p; } + if (*p++ != ',') return QColor(); + //green - while (pos < len && !isdigit(data[pos])) pos++; - if (pos >= len) return QColor(); - gs = atoi(&(data[pos])); - while (pos < len && ((data[pos] != ',' && data[pos] != '%') || isspace(data[pos]))) pos++; - if (data[pos] == '%') { + while (isspace(*p)) p++; + gs = strtol(p, &p, 10); + if (*p == '%') { gs = qRound(gs/100.0 * 255); - pos++; + ++p; } + if (*p++ != ',') return QColor(); //blue - while (pos < len && !isdigit(data[pos])) pos++; - if (pos >= len) - return QColor(); - bl = atoi(&(data[pos])); - while (pos < len && ((data[pos] != ',' && data[pos] != '%') || isspace(data[pos]))) pos++; - if (data[pos] == '%') { + while (isspace(*p)) p++; + bl = strtol(p, &p, 10); + if (*p == '%') { bl = qRound(bl/100.0 * 255); - pos++; + ++p; } if (hasAlpha) { - while (pos < len && !isdigit(data[pos])) pos++; - if (pos >= len) - return QColor(); -#ifndef Q_CC_MSVC - const float alphaF = strtof(data + pos, 0); -#else - // MSVC does not have strtof - const double alphaF = strtod(data + pos, 0); -#endif - alpha = qRound(alphaF * 255); + if (*p++!= ',') return QColor(); + while (isspace(*p)) p++; + alpha = qRound(strtod(p, &p) * 255); } + if (*p != ')') return QColor(); if (isRgb) return QColor::fromRgba(qRgba(qClamp(rh, 0, 255), qClamp(gs, 0, 255), qClamp(bl, 0, 255), qClamp(alpha, 0, 255))); else @@ -475,6 +469,9 @@ static v8::Handle<v8::Value> ctx2d_reset(const v8::Arguments &args) CHECK_CONTEXT(r) r->context->reset(); + r->context->m_path = QPainterPath(); + r->context->m_path.setFillRule(Qt::WindingFill); + return args.This(); } @@ -539,9 +536,11 @@ static v8::Handle<v8::Value> ctx2d_rotate(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - if (args.Length() == 1) { qreal angle = args[0]->NumberValue(); + if (!qIsFinite(angle)) + return args.This(); + r->context->state.matrix.rotate(DEGREES(angle)); r->context->buffer()->updateMatrix(r->context->state.matrix); } @@ -573,6 +572,9 @@ static v8::Handle<v8::Value> ctx2d_scale(const v8::Arguments &args) qreal x, y; x = args[0]->NumberValue(); y = args[1]->NumberValue(); + if (!qIsFinite(x) || !qIsFinite(y)) + return args.This(); + r->context->state.matrix.scale(x, y); r->context->buffer()->updateMatrix(r->context->state.matrix); } @@ -620,12 +622,22 @@ static v8::Handle<v8::Value> ctx2d_setTransform(const v8::Arguments &args) if (args.Length() == 6) { - r->context->state.matrix = QTransform(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue(), - args[4]->NumberValue(), - args[5]->NumberValue()); + qreal a = args[0]->NumberValue(); + qreal b = args[1]->NumberValue(); + qreal c = args[2]->NumberValue(); + qreal d = args[3]->NumberValue(); + qreal e = args[4]->NumberValue(); + qreal f = args[5]->NumberValue(); + + if (!qIsFinite(a) + || !qIsFinite(b) + || !qIsFinite(c) + || !qIsFinite(d) + || !qIsFinite(e) + || !qIsFinite(f)) + return args.This(); + + r->context->state.matrix = QTransform(a, b, c, d, e, f); r->context->buffer()->updateMatrix(r->context->state.matrix); } @@ -649,12 +661,22 @@ static v8::Handle<v8::Value> ctx2d_transform(const v8::Arguments &args) if (args.Length() == 6) { - r->context->state.matrix *= QTransform(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue(), - args[4]->NumberValue(), - args[5]->NumberValue()); + qreal a = args[0]->NumberValue(); + qreal b = args[1]->NumberValue(); + qreal c = args[2]->NumberValue(); + qreal d = args[3]->NumberValue(); + qreal e = args[4]->NumberValue(); + qreal f = args[5]->NumberValue(); + + if (!qIsFinite(a) + || !qIsFinite(b) + || !qIsFinite(c) + || !qIsFinite(d) + || !qIsFinite(e) + || !qIsFinite(f)) + return args.This(); + + r->context->state.matrix *= QTransform(a, b, c, d, e, f); r->context->buffer()->updateMatrix(r->context->state.matrix); } @@ -677,8 +699,13 @@ static v8::Handle<v8::Value> ctx2d_translate(const v8::Arguments &args) if (args.Length() == 2) { - r->context->state.matrix.translate(args[0]->NumberValue(), - args[1]->NumberValue()); + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + + if (!qIsFinite(x) || !qIsFinite(y)) + return args.This(); + + r->context->state.matrix.translate(x, y); r->context->buffer()->updateMatrix(r->context->state.matrix); } @@ -713,10 +740,16 @@ static v8::Handle<v8::Value> ctx2d_shear(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - r->context->state.matrix.shear(args[0]->NumberValue(), - args[1]->NumberValue()); - r->context->buffer()->updateMatrix(r->context->state.matrix); + if (args.Length() == 2) { + qreal sh = args[0]->NumberValue(); + qreal sv = args[1]->NumberValue(); + if (!qIsFinite(sh) || !qIsFinite(sv)) + return args.This(); + + r->context->state.matrix.shear(sh, sv); + r->context->buffer()->updateMatrix(r->context->state.matrix); + } return args.This(); } // compositing @@ -742,6 +775,9 @@ static void ctx2d_globalAlpha_set(v8::Local<v8::String>, v8::Local<v8::Value> va qreal globalAlpha = value->NumberValue(); + if (!qIsFinite(globalAlpha)) + return; + if (globalAlpha >= 0.0 && globalAlpha <= 1.0 && r->context->state.globalAlpha != globalAlpha) { r->context->state.globalAlpha = globalAlpha; r->context->buffer()->setGlobalAlpha(r->context->state.globalAlpha); @@ -793,7 +829,11 @@ static void ctx2d_globalCompositeOperation_set(v8::Local<v8::String>, v8::Local< QV8Engine *engine = V8ENGINE_ACCESSOR(); - QPainter::CompositionMode cm = qt_composite_mode_from_string(engine->toString(value)); + QString mode = engine->toString(value); + QPainter::CompositionMode cm = qt_composite_mode_from_string(mode); + if (cm == QPainter::CompositionMode_SourceOver && mode != QStringLiteral("source-over")) + return; + if (cm != r->context->state.globalCompositeOperation) { r->context->state.globalCompositeOperation = cm; r->context->buffer()->setGlobalCompositeOperation(cm); @@ -868,7 +908,7 @@ static void ctx2d_fillStyle_set(v8::Local<v8::String>, v8::Local<v8::Value> valu } } } else if (value->IsString()) { - QColor color = qt_color_from_string(engine->toString(value)); + QColor color = qt_color_from_string(value); if (color.isValid() && r->context->state.fillStyle != QBrush(color)) { r->context->state.fillStyle = QBrush(color); r->context->buffer()->setFillStyle(r->context->state.fillStyle); @@ -974,7 +1014,7 @@ static void ctx2d_strokeStyle_set(v8::Local<v8::String>, v8::Local<v8::Value> va } } } else if (value->IsString()) { - QColor color = qt_color_from_string(engine->toString(value)); + QColor color = qt_color_from_string(value); if (color.isValid() && r->context->state.strokeStyle != QBrush(color)) { r->context->state.strokeStyle = QBrush(color); r->context->buffer()->setStrokeStyle(r->context->state.strokeStyle); @@ -1009,14 +1049,21 @@ static v8::Handle<v8::Value> ctx2d_createLinearGradient(const v8::Arguments &arg QV8Engine *engine = V8ENGINE(); if (args.Length() == 4) { - //TODO:infinite or NaN, the method must raise a NOT_SUPPORTED_ERR QSGContext2DEngineData *ed = engineData(engine); v8::Local<v8::Object> gradient = ed->constructorGradient->NewInstance(); QV8Context2DStyleResource *r = new QV8Context2DStyleResource(engine); - r->brush = QLinearGradient(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue()); + qreal x0 = args[0]->NumberValue(); + qreal y0 = args[1]->NumberValue(); + qreal x1 = args[2]->NumberValue(); + qreal y1 = args[3]->NumberValue(); + + if (!qIsFinite(x0) + || !qIsFinite(y0) + || !qIsFinite(x1) + || !qIsFinite(y1)) + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createLinearGradient(): Incorrect arguments") + + r->brush = QLinearGradient(x0, y0, x1, y1); gradient->SetExternalResource(r); return gradient; } @@ -1056,8 +1103,19 @@ static v8::Handle<v8::Value> ctx2d_createRadialGradient(const v8::Arguments &arg qreal x1 = args[3]->NumberValue(); qreal y1 = args[4]->NumberValue(); qreal r1 = args[5]->NumberValue(); - //TODO:infinite or NaN, a NOT_SUPPORTED_ERR exception must be raised. - //If either of r0 or r1 are negative, an INDEX_SIZE_ERR exception must be raised. + + if (!qIsFinite(x0) + || !qIsFinite(y0) + || !qIsFinite(x1) + || !qIsFinite(r0) + || !qIsFinite(r1) + || !qIsFinite(y1)) + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createRadialGradient(): Incorrect arguments") + + if (r0 < 0 || r1 < 0) + V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createRadialGradient(): Incorrect arguments") + + r->brush = QRadialGradient(QPointF(x1, y1), r0+r1, QPointF(x0, y0)); gradient->SetExternalResource(r); return gradient; @@ -1095,8 +1153,12 @@ static v8::Handle<v8::Value> ctx2d_createConicalGradient(const v8::Arguments &ar qreal x = args[0]->NumberValue(); qreal y = args[1]->NumberValue(); qreal angle = DEGREES(args[2]->NumberValue()); - //TODO:infinite or NaN, a NOT_SUPPORTED_ERR exception must be raised. - //If either of r0 or r1 are negative, an INDEX_SIZE_ERR exception must be raised. + if (!qIsFinite(x) || !qIsFinite(y)) + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createConicalGradient(): Incorrect arguments"); + + if (!qIsFinite(angle)) + V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createConicalGradient(): Incorrect arguments"); + r->brush = QConicalGradient(x, y, angle); gradient->SetExternalResource(r); return gradient; @@ -1255,6 +1317,8 @@ static void ctx2d_lineCap_set(v8::Local<v8::String>, v8::Local<v8::Value> value, cap = Qt::FlatCap; else if (lineCap == QLatin1String("square")) cap = Qt::SquareCap; + else + return; if (cap != r->context->state.lineCap) { r->context->state.lineCap = cap; @@ -1311,6 +1375,8 @@ static void ctx2d_lineJoin_set(v8::Local<v8::String>, v8::Local<v8::Value> value join = Qt::BevelJoin; else if (lineJoin == QLatin1String("miter")) join = Qt::MiterJoin; + else + return; if (join != r->context->state.lineJoin) { r->context->state.lineJoin = join; @@ -1338,7 +1404,7 @@ static void ctx2d_lineWidth_set(v8::Local<v8::String>, v8::Local<v8::Value> valu qreal w = value->NumberValue(); - if (w > 0 && w != r->context->state.lineWidth) { + if (w > 0 && qIsFinite(w) && w != r->context->state.lineWidth) { r->context->state.lineWidth = w; r->context->buffer()->setLineWidth(w); } @@ -1365,7 +1431,7 @@ static void ctx2d_miterLimit_set(v8::Local<v8::String>, v8::Local<v8::Value> val qreal ml = value->NumberValue(); - if (ml > 0 && ml != r->context->state.miterLimit) { + if (ml > 0 && qIsFinite(ml) && ml != r->context->state.miterLimit) { r->context->state.miterLimit = ml; r->context->buffer()->setMiterLimit(ml); } @@ -1391,7 +1457,7 @@ static void ctx2d_shadowBlur_set(v8::Local<v8::String>, v8::Local<v8::Value> val CHECK_CONTEXT_SETTER(r) qreal blur = value->NumberValue(); - if (blur > 0 && blur != r->context->state.shadowBlur) { + if (blur > 0 && qIsFinite(blur) && blur != r->context->state.shadowBlur) { r->context->state.shadowBlur = blur; r->context->buffer()->setShadowBlur(blur); } @@ -1417,9 +1483,7 @@ static void ctx2d_shadowColor_set(v8::Local<v8::String>, v8::Local<v8::Value> va QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This()); CHECK_CONTEXT_SETTER(r) - QV8Engine *engine = V8ENGINE_ACCESSOR(); - - QColor color = qt_color_from_string(engine->toString(value)); + QColor color = qt_color_from_string(value); if (color.isValid() && color != r->context->state.shadowColor) { r->context->state.shadowColor = color; @@ -1448,9 +1512,8 @@ static void ctx2d_shadowOffsetX_set(v8::Local<v8::String>, v8::Local<v8::Value> QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This()); CHECK_CONTEXT_SETTER(r) - //TODO: check value:infinite or NaN qreal offsetX = value->NumberValue(); - if (offsetX != r->context->state.shadowOffsetX) { + if (qIsFinite(offsetX) && offsetX != r->context->state.shadowOffsetX) { r->context->state.shadowOffsetX = offsetX; r->context->buffer()->setShadowOffsetX(offsetX); } @@ -1474,9 +1537,9 @@ static void ctx2d_shadowOffsetY_set(v8::Local<v8::String>, v8::Local<v8::Value> { QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This()); CHECK_CONTEXT_SETTER(r) - //TODO: check value:infinite or NaN + qreal offsetY = value->NumberValue(); - if (offsetY != r->context->state.shadowOffsetY) { + if (qIsFinite(offsetY) && offsetY != r->context->state.shadowOffsetY) { r->context->state.shadowOffsetY = offsetY; r->context->buffer()->setShadowOffsetY(offsetY); } @@ -1519,10 +1582,15 @@ static v8::Handle<v8::Value> ctx2d_clearRect(const v8::Arguments &args) if (args.Length() == 4) { - r->context->buffer()->clearRect(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue()); + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + qreal w = args[2]->NumberValue(); + qreal h = args[3]->NumberValue(); + + if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(h)) + return args.This(); + + r->context->buffer()->clearRect(x, y, w, h); } return args.This(); @@ -1538,12 +1606,16 @@ static v8::Handle<v8::Value> ctx2d_fillRect(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - if (args.Length() == 4) { - r->context->buffer()->fillRect(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue()); + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + qreal w = args[2]->NumberValue(); + qreal h = args[3]->NumberValue(); + + if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(h)) + return args.This(); + + r->context->buffer()->fillRect(x, y, w, h); } return args.This(); @@ -1566,10 +1638,15 @@ static v8::Handle<v8::Value> ctx2d_strokeRect(const v8::Arguments &args) if (args.Length() == 4) { - r->context->buffer()->strokeRect(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue()); + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + qreal w = args[2]->NumberValue(); + qreal h = args[3]->NumberValue(); + + if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(h)) + return args.This(); + + r->context->buffer()->strokeRect(x, y, w, h); } return args.This(); @@ -1595,7 +1672,17 @@ static v8::Handle<v8::Value> ctx2d_arc(const v8::Arguments &args) antiClockwise = args[5]->BooleanValue(); qreal radius = args[2]->NumberValue(); - //Throws an INDEX_SIZE_ERR exception if the given radius is negative. + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + qreal sa = args[3]->NumberValue(); + qreal ea = args[4]->NumberValue(); + + if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(sa) || !qIsFinite(ea)) + return args.This(); + + if (radius < 0) + V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius"); + r->context->arc(args[0]->NumberValue(), args[1]->NumberValue(), radius, @@ -1633,7 +1720,19 @@ static v8::Handle<v8::Value> ctx2d_arcTo(const v8::Arguments &args) CHECK_CONTEXT(r) + if (args.Length() == 5) { + qreal x1 = args[0]->NumberValue(); + qreal y1 = args[1]->NumberValue(); + qreal x2 = args[2]->NumberValue(); + qreal y2 = args[3]->NumberValue(); + + if (!qIsFinite(x1) || !qIsFinite(y1) || !qIsFinite(x2) || !qIsFinite(y2)) + return args.This(); + + qreal radius = args[4]->NumberValue(); + if (radius < 0) + V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius"); r->context->arcTo(args[0]->NumberValue(), args[1]->NumberValue(), args[2]->NumberValue(), @@ -1686,12 +1785,17 @@ static v8::Handle<v8::Value> ctx2d_bezierCurveTo(const v8::Arguments &args) if (args.Length() == 6) { - r->context->bezierCurveTo(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue(), - args[4]->NumberValue(), - args[5]->NumberValue()); + qreal cp1x = args[0]->NumberValue(); + qreal cp1y = args[1]->NumberValue(); + qreal cp2x = args[2]->NumberValue(); + qreal cp2y = args[3]->NumberValue(); + qreal x = args[4]->NumberValue(); + qreal y = args[5]->NumberValue(); + + if (!qIsFinite(cp1x) || !qIsFinite(cp1y) || !qIsFinite(cp2x) || !qIsFinite(cp2y) || !qIsFinite(x) || !qIsFinite(y)) + return args.This(); + + r->context->bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y); } return args.This(); @@ -1726,7 +1830,12 @@ static v8::Handle<v8::Value> ctx2d_clip(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - r->context->state.clipPath = r->context->m_path; + QPainterPath clipPath = r->context->m_path; + clipPath.closeSubpath(); + if (!r->context->state.clipPath.isEmpty()) + r->context->state.clipPath = clipPath.intersected(r->context->state.clipPath); + else + r->context->state.clipPath = clipPath; r->context->buffer()->clip(r->context->state.clipPath); return args.This(); @@ -1781,8 +1890,13 @@ static v8::Handle<v8::Value> ctx2d_lineTo(const v8::Arguments &args) if (args.Length() == 2) { - r->context->lineTo(args[0]->NumberValue(), - args[1]->NumberValue()); + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + + if (!qIsFinite(x) || !qIsFinite(y)) + return args.This(); + + r->context->lineTo(x, y); } return args.This(); @@ -1798,12 +1912,14 @@ static v8::Handle<v8::Value> ctx2d_moveTo(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - if (args.Length() == 2) { - r->context->moveTo(args[0]->NumberValue(), - args[1]->NumberValue()); - } + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + if (!qIsFinite(x) || !qIsFinite(y)) + return args.This(); + r->context->moveTo(x, y); + } return args.This(); } @@ -1819,12 +1935,16 @@ static v8::Handle<v8::Value> ctx2d_quadraticCurveTo(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - if (args.Length() == 4) { - r->context->quadraticCurveTo(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue()); + qreal cpx = args[0]->NumberValue(); + qreal cpy = args[1]->NumberValue(); + qreal x = args[2]->NumberValue(); + qreal y = args[3]->NumberValue(); + + if (!qIsFinite(cpx) || !qIsFinite(cpy) || !qIsFinite(x) || !qIsFinite(y)) + return args.This(); + + r->context->quadraticCurveTo(cpx, cpy, x, y); } return args.This(); @@ -1842,10 +1962,15 @@ static v8::Handle<v8::Value> ctx2d_rect(const v8::Arguments &args) if (args.Length() == 4) { - r->context->rect(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue()); + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + qreal w = args[2]->NumberValue(); + qreal h = args[3]->NumberValue(); + + if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(h)) + return args.This(); + + r->context->rect(x, y, w, h); } return args.This(); @@ -1862,14 +1987,21 @@ static v8::Handle<v8::Value> ctx2d_roundedRect(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - if (args.Length() == 6) { - r->context->roundedRect(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue(), - args[4]->NumberValue(), - args[5]->NumberValue()); + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + qreal w = args[2]->NumberValue(); + qreal h = args[3]->NumberValue(); + qreal xr = args[4]->NumberValue(); + qreal yr = args[5]->NumberValue(); + + if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(h)) + return args.This(); + + if (!qIsFinite(xr) || !qIsFinite(yr)) + V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "roundedRect(): Invalid arguments"); + + r->context->roundedRect(x, y, w, h, xr, yr); } return args.This(); @@ -1890,10 +2022,16 @@ static v8::Handle<v8::Value> ctx2d_ellipse(const v8::Arguments &args) if (args.Length() == 4) { - r->context->ellipse(args[0]->NumberValue(), - args[1]->NumberValue(), - args[2]->NumberValue(), - args[3]->NumberValue()); + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + qreal w = args[2]->NumberValue(); + qreal h = args[3]->NumberValue(); + + if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(h)) + return args.This(); + + + r->context->ellipse(x, y, w, h); } return args.This(); @@ -1912,11 +2050,13 @@ static v8::Handle<v8::Value> ctx2d_text(const v8::Arguments &args) QV8Engine *engine = V8ENGINE(); if (args.Length() == 3) { - r->context->text(engine->toString(args[0]), - args[1]->NumberValue(), - args[2]->NumberValue()); - } + qreal x = args[1]->NumberValue(); + qreal y = args[2]->NumberValue(); + if (!qIsFinite(x) || !qIsFinite(y)) + return args.This(); + r->context->text(engine->toString(args[0]), x, y); + } return args.This(); } @@ -1952,32 +2092,32 @@ static v8::Handle<v8::Value> ctx2d_isPointInPath(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - bool pointInPath = false; if (args.Length() == 2) { - pointInPath = r->context->isPointInPath(args[0]->NumberValue(), - args[1]->NumberValue()); + qreal x = args[0]->NumberValue(); + qreal y = args[1]->NumberValue(); + if (!qIsFinite(x) || !qIsFinite(y)) + return v8::Boolean::New(false); + pointInPath = r->context->isPointInPath(x, y); } - return v8::Boolean::New(pointInPath); } static v8::Handle<v8::Value> ctx2d_drawFocusRing(const v8::Arguments &args) { - V8THROW_ERROR("Context2D::drawFocusRing is not supported") + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::drawFocusRing is not supported"); return args.This(); } static v8::Handle<v8::Value> ctx2d_setCaretSelectionRect(const v8::Arguments &args) { - V8THROW_ERROR("Context2D::setCaretSelectionRect is not supported") + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::setCaretSelectionRect is not supported"); return args.This(); } static v8::Handle<v8::Value> ctx2d_caretBlinkRate(const v8::Arguments &args) { - V8THROW_ERROR("Context2D::caretBlinkRate is not supported") - + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::caretBlinkRate is not supported"); return args.This(); } // text @@ -1995,7 +2135,7 @@ v8::Handle<v8::Value> ctx2d_font(v8::Local<v8::String>, const v8::AccessorInfo & QV8Engine *engine = V8ENGINE_ACCESSOR(); - return engine->toString(r->context->m_fontString); + return engine->toString(r->context->state.font.toString()); } static void ctx2d_font_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info) @@ -2005,9 +2145,8 @@ static void ctx2d_font_set(v8::Local<v8::String>, v8::Local<v8::Value> value, co QV8Engine *engine = V8ENGINE_ACCESSOR(); QString fs = engine->toString(value); - if (fs != r->context->m_fontString) { - r->context->m_fontString = fs; - QFont font = qt_font_from_string(fs); + QFont font = qt_font_from_string(fs); + if (font != r->context->state.font) { r->context->state.font = font; } } @@ -2067,6 +2206,8 @@ static void ctx2d_textAlign_set(v8::Local<v8::String>, v8::Local<v8::Value> valu ta = QSGContext2D::Right; else if (textAlign == QLatin1String("center")) ta = QSGContext2D::Center; + else + return; if (ta != r->context->state.textAlign) { r->context->state.textAlign = ta; @@ -2129,6 +2270,8 @@ static void ctx2d_textBaseline_set(v8::Local<v8::String>, v8::Local<v8::Value> v tb = QSGContext2D::Bottom; else if (textBaseline == QLatin1String("middle")) tb = QSGContext2D::Middle; + else + return; if (tb != r->context->state.textBaseline) { r->context->state.textBaseline = tb; @@ -2148,16 +2291,15 @@ static v8::Handle<v8::Value> ctx2d_fillText(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - QV8Engine *engine = V8ENGINE(); - if (args.Length() == 3) { - QPainterPath textPath = r->context->createTextGlyphs(args[1]->NumberValue(), - args[2]->NumberValue(), - engine->toString(args[0])); + qreal x = args[1]->NumberValue(); + qreal y = args[2]->NumberValue(); + if (!qIsFinite(x) || !qIsFinite(y)) + return args.This(); + QPainterPath textPath = r->context->createTextGlyphs(x, y, engine->toString(args[0])); r->context->buffer()->fill(textPath); } - return args.This(); } /*! @@ -2173,16 +2315,15 @@ static v8::Handle<v8::Value> ctx2d_strokeText(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - QV8Engine *engine = V8ENGINE(); - if (args.Length() == 3) { - QPainterPath textPath = r->context->createTextGlyphs(args[1]->NumberValue(), - args[2]->NumberValue(), - engine->toString(args[0])); + qreal x = args[1]->NumberValue(); + qreal y = args[2]->NumberValue(); + if (!qIsFinite(x) || !qIsFinite(y)) + return args.This(); + QPainterPath textPath = r->context->createTextGlyphs(x, y, engine->toString(args[0])); r->context->buffer()->stroke(textPath); } - return args.This(); } /*! @@ -2212,7 +2353,6 @@ static v8::Handle<v8::Value> ctx2d_measureText(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - QV8Engine *engine = V8ENGINE(); if (args.Length() == 1) { @@ -2222,7 +2362,6 @@ static v8::Handle<v8::Value> ctx2d_measureText(const v8::Arguments &args) tm->Set(v8::String::New("width"), v8::Number::New(width)); return tm; } - return v8::Undefined(); } @@ -2290,18 +2429,11 @@ static v8::Handle<v8::Value> ctx2d_drawImage(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - QV8Engine *engine = V8ENGINE(); - - //TODO: handle exceptions - qreal sx, sy, sw, sh, dx, dy, dw, dh; - if (args.Length() != 3 && args.Length() != 5 && args.Length() != 9) { - //parameter error + if (!args.Length()) return args.This(); - } - QImage image; if (args[0]->IsString()) { @@ -2314,8 +2446,7 @@ static v8::Handle<v8::Value> ctx2d_drawImage(const v8::Arguments &args) } else if (imageItem) { image = imageItem->pixmap().toImage(); } else { - //wrong image type - return args.This(); + V8THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch"); } } if (args.Length() == 3) { @@ -2346,10 +2477,19 @@ static v8::Handle<v8::Value> ctx2d_drawImage(const v8::Arguments &args) dw = args[7]->NumberValue(); dh = args[8]->NumberValue(); } else { - //error return args.This(); } + if (!qIsFinite(sx) + || !qIsFinite(sy) + || !qIsFinite(sw) + || !qIsFinite(sh) + || !qIsFinite(dx) + || !qIsFinite(dy) + || !qIsFinite(dw) + || !qIsFinite(dh)) + return args.This(); + r->context->buffer()->drawImage(image,sx, sy, sw, sh, dx, dy, dw, dh); return args.This(); @@ -2591,10 +2731,10 @@ v8::Handle<v8::Value> ctx2d_pixelArray_indexed(uint32_t index, const v8::Accesso { QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(args.This()); - if (r && index >= 0 && index < r->image.width() * r->image.height() * 4) { - const int w = r->image.width(); - const int row = (index / 4) / w; - const int col = (index / 4) % w; + if (r && index < static_cast<quint32>(r->image.width() * r->image.height() * 4)) { + const quint32 w = r->image.width(); + const quint32 row = (index / 4) / w; + const quint32 col = (index / 4) % w; const QRgb* pixel = reinterpret_cast<const QRgb*>(r->image.constScanLine(row)); pixel += col; switch (index % 4) { @@ -2616,10 +2756,10 @@ v8::Handle<v8::Value> ctx2d_pixelArray_indexed_set(uint32_t index, v8::Local<v8: QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(info.This()); const int v = value->Uint32Value(); - if (r && index >= 0 && index < r->image.width() * r->image.height() * 4 && v > 0 && v <= 255) { - const int w = r->image.width(); - const int row = (index / 4) / w; - const int col = (index / 4) % w; + if (r && index < static_cast<quint32>(r->image.width() * r->image.height() * 4) && v > 0 && v <= 255) { + const quint32 w = r->image.width(); + const quint32 row = (index / 4) / w; + const quint32 col = (index / 4) % w; QRgb* pixel = reinterpret_cast<QRgb*>(r->image.scanLine(row)); pixel += col; @@ -2661,7 +2801,6 @@ static v8::Handle<v8::Value> ctx2d_createImageData(const v8::Arguments &args) QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This()); CHECK_CONTEXT(r) - QV8Engine *engine = V8ENGINE(); if (args.Length() == 1) { @@ -2680,8 +2819,14 @@ static v8::Handle<v8::Value> ctx2d_createImageData(const v8::Arguments &args) } else if (args.Length() == 2) { qreal w = args[0]->NumberValue(); qreal h = args[1]->NumberValue(); + + if (!qIsFinite(w) || !qIsFinite(h)) + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments"); + if (w > 0 && h > 0) return qt_create_image_data(w, h, engine, QImage()); + else + V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createImageData(): invalid arguments"); } return v8::Undefined(); } @@ -2701,6 +2846,12 @@ static v8::Handle<v8::Value> ctx2d_getImageData(const v8::Arguments &args) qreal y = args[1]->NumberValue(); qreal w = args[2]->NumberValue(); qreal h = args[3]->NumberValue(); + if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(w)) + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "getImageData(): Invalid arguments"); + + if (w <= 0 || h <= 0) + V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "getImageData(): Invalid arguments"); + QImage image = r->context->canvas()->toImage(QRectF(x, y, w, h)); v8::Local<v8::Object> imageData = qt_create_image_data(w, h, engine, image); @@ -2721,12 +2872,15 @@ static v8::Handle<v8::Value> ctx2d_putImageData(const v8::Arguments &args) return v8::Undefined(); if (args[0]->IsNull() || !args[0]->IsObject()) { - V8THROW_ERROR("Context2D::putImageData, the image data type mismatch"); + V8THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "Context2D::putImageData, the image data type mismatch"); } qreal dx = args[1]->NumberValue(); qreal dy = args[2]->NumberValue(); qreal w, h, dirtyX, dirtyY, dirtyWidth, dirtyHeight; + if (!qIsFinite(dx) || !qIsFinite(dy)) + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments"); + v8::Local<v8::Object> imageData = args[0]->ToObject(); QV8Context2DPixelArrayResource *pixelArray = v8_resource_cast<QV8Context2DPixelArrayResource>(imageData->Get(v8::String::New("data"))->ToObject()); if (pixelArray) { @@ -2738,6 +2892,11 @@ static v8::Handle<v8::Value> ctx2d_putImageData(const v8::Arguments &args) dirtyY = args[4]->NumberValue(); dirtyWidth = args[5]->NumberValue(); dirtyHeight = args[6]->NumberValue(); + + if (!qIsFinite(dirtyX) || !qIsFinite(dirtyY) || !qIsFinite(dirtyWidth) || !qIsFinite(dirtyHeight)) + V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments"); + + if (dirtyWidth < 0) { dirtyX = dirtyX+dirtyWidth; dirtyWidth = -dirtyWidth; @@ -2819,18 +2978,16 @@ static v8::Handle<v8::Value> ctx2d_gradient_addColorStop(const v8::Arguments &ar if (args[1]->IsObject()) { color = engine->toVariant(args[1], qMetaTypeId<QColor>()).value<QColor>(); } else { - color = qt_color_from_string(engine->toString(args[1])); + color = qt_color_from_string(args[1]); } - if (pos < 0.0 || pos > 1.0) { - //Throws an INDEX_SIZE_ERR exception - V8THROW_ERROR("CanvasGradient: parameter offset out of range"); + if (pos < 0.0 || pos > 1.0 || !qIsFinite(pos)) { + V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "CanvasGradient: parameter offset out of range"); } if (color.isValid()) { gradient.setColorAt(pos, color); } else { - //Throws a SYNTAX_ERR exception - V8THROW_ERROR("CanvasGradient: parameter color is not a valid color string"); + V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "CanvasGradient: parameter color is not a valid color string"); } style->brush = gradient; } @@ -3273,8 +3430,9 @@ void QSGContext2D::popState() if (newState.miterLimit != state.miterLimit) buffer()->setMiterLimit(newState.miterLimit); - if (newState.clipPath != state.clipPath) + if (newState.clipPath != state.clipPath) { buffer()->clip(newState.clipPath); + } if (newState.shadowBlur != state.shadowBlur) buffer()->setShadowBlur(newState.shadowBlur); @@ -3287,7 +3445,6 @@ void QSGContext2D::popState() if (newState.shadowOffsetY != state.shadowOffsetY) buffer()->setShadowOffsetY(newState.shadowOffsetY); - state = newState; } void QSGContext2D::pushState() @@ -3301,12 +3458,15 @@ void QSGContext2D::reset() newState.matrix = QTransform(); QPainterPath defaultClipPath; - defaultClipPath.addRect(0, 0, m_canvas->canvasSize().width(), m_canvas->canvasSize().height()); + + QRect r(0, 0, m_canvas->canvasSize().width(), m_canvas->canvasSize().height()); + r = r.united(m_canvas->canvasWindow().toRect()); + defaultClipPath.addRect(r); newState.clipPath = defaultClipPath; newState.clipPath.setFillRule(Qt::WindingFill); - newState.strokeStyle = QColor(qRgba(1,1,1,1)); - newState.fillStyle = QColor(qRgba(1,1,1,1)); + newState.strokeStyle = QColor("#000000"); + newState.fillStyle = QColor("#000000"); newState.fillPatternRepeatX = false; newState.fillPatternRepeatY = false; newState.strokePatternRepeatX = false; @@ -3326,10 +3486,10 @@ void QSGContext2D::reset() newState.textAlign = QSGContext2D::Start; newState.textBaseline = QSGContext2D::Alphabetic; - m_fontString.clear(); m_stateStack.clear(); m_stateStack.push(newState); popState(); + m_buffer->clearRect(0, 0, m_canvas->width(), m_canvas->height()); } void QSGContext2D::setV8Engine(QV8Engine *engine) diff --git a/src/declarative/items/context2d/qsgcontext2d_p.h b/src/declarative/items/context2d/qsgcontext2d_p.h index 5354876d5d..10c1e331f9 100644 --- a/src/declarative/items/context2d/qsgcontext2d_p.h +++ b/src/declarative/items/context2d/qsgcontext2d_p.h @@ -174,7 +174,6 @@ public: v8::Local<v8::Value> m_fillStyle; v8::Local<v8::Value> m_strokeStyle; v8::Handle<v8::Value> m_v8path; - QString m_fontString; QV8Engine *m_v8engine; v8::Persistent<v8::Object> m_v8value; }; diff --git a/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp b/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp index 51730d41ec..dff4f9fe75 100644 --- a/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp +++ b/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp @@ -252,7 +252,13 @@ QSGContext2D::State QSGContext2DCommandBuffer::replay(QPainter* p, QSGContext2D: } case QSGContext2D::ClearRect: { + QPainter::CompositionMode cm = p->compositionMode(); + qreal alpha = p->opacity(); + p->setCompositionMode(QPainter::CompositionMode_Source); + p->setOpacity(0); p->fillRect(takeRect(), QColor(qRgba(0, 0, 0, 0))); + p->setCompositionMode(cm); + p->setOpacity(alpha); break; } case QSGContext2D::FillRect: @@ -335,10 +341,12 @@ QSGContext2D::State QSGContext2DCommandBuffer::replay(QPainter* p, QSGContext2D: case QSGContext2D::Fill: { bool hasPattern = p->brush().style() == Qt::TexturePattern; + QPainterPath path = takePath(); + path.closeSubpath(); if (HAS_SHADOW(state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor)) - fillShadowPath(p,takePath(), state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor); + fillShadowPath(p,path, state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor); else - p->fillPath(takePath(), p->brush()); + p->fillPath(path, p->brush()); break; } case QSGContext2D::Stroke: @@ -351,13 +359,9 @@ QSGContext2D::State QSGContext2DCommandBuffer::replay(QPainter* p, QSGContext2D: } case QSGContext2D::Clip: { - QPainterPath clipPath = takePath(); - clipPath.closeSubpath(); - state.clipPath = state.clipPath.intersected(clipPath); - if (!p->clipPath().isEmpty()) - clipPath = clipPath.intersected(p->clipPath()); + state.clipPath = takePath(); p->setClipping(true); - p->setClipPath(clipPath); + p->setClipPath(state.clipPath); break; } case QSGContext2D::GlobalAlpha: diff --git a/src/declarative/items/context2d/qsgcontext2dtexture.cpp b/src/declarative/items/context2d/qsgcontext2dtexture.cpp index 455a46884b..38eeeb648e 100644 --- a/src/declarative/items/context2d/qsgcontext2dtexture.cpp +++ b/src/declarative/items/context2d/qsgcontext2dtexture.cpp @@ -590,8 +590,11 @@ void QSGContext2DFBOTexture::endPainting() void qt_quit_context2d_render_thread() { QThread* thread = globalCanvasThreadRenderInstance(); - thread->quit(); - thread->wait(); + + if (thread->isRunning()) { + thread->exit(0); + thread->wait(1000); + } } QSGContext2DImageTexture::QSGContext2DImageTexture(bool threadRendering) diff --git a/tests/auto/declarative/qsgcanvasitem/data/qt-logo.png b/tests/auto/declarative/qsgcanvasitem/data/qt-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..5ab3a1b0c4618ccce8321db7253b8dcdc86cfa98 GIT binary patch literal 23519 zcmV)VK(D`vP)<h;3K|Lk000e1NJLTq008;`008<31^@s6i0oQD0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBV&fk{L`RCwC#y$QG+S9K?TPVaADw9DEo zOY*+2V8GbMW($x2Atsq5Ko}<9Odyj<zRY}CCSNj;$wC5QNHYHr_=i9Ofv_ZD35x+Q z*nq*iC0YBfC+X?w>FvFqxwoocch#+PZq<9QT9(bdpGw`YySn=Jt$ViL*^r394L96) zVULVk0yo@ngzknLZa6}B!wokap}XOR8;;Q3aKjBp=x(^-MoJ?WcLM&>R?C|R5cJL= za}EXG^IUn@eC|EXtH*+RmQ~M}smDHb3`322p+SR?%M7d>F7&P#$gkYCuGF)2U1@o5 zcc!mFFr+Tf@FxH>>NuhP-lrb-`UmRAQ|g!tPXrggQb9K)V(9hhIfCvIs+TeFo5?$` zT5Ui+*Zj?a@7Jf!&NZM|$b>HEeNXE;6!-`ReuMB^TIVA~ZcOM}fw@rN2BCa28)~(u zX6i7|mjw!bra9kAr2*M2dPi_B*$l$S=^7OB2t)l@Xw)h26OdWs`L&|<^@G0$F}y~> zwNS7B-b=sbsCqGkp3*3(W1Bi|QpaWL*r1LT>K+ZM$02o}devh=5qMrd4iDwwl8xPP z*@iAyIh2F$ViqzPf?8c|IARzHhBuvhoKk;|s6Te9H+DCV9qQPlj&XHNxm)jsBlPsf z&5GdOq=@lV>QDrZ*^rc<ADYW6iLrWB30{0fFI=h!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K&L(w^fQ}K&) z62hM61xr0aR%vF7!J?Nwnmnhz2!9UFFpx7E*knvLBY#`4?AO|A7aw@<)xYf89q%Fj z)#Q!+vnsmt|3MWU$?EwmlkO&IrhWECW3T)lWYYgz#DCq>|G#ef{~GaMJN5rM<-a-p p8}UE=)&EKOU&Hly+4&PX5QWInvX?L?{t4yzQ&-kjLMWPt{tw8XKA8Xj literal 0 HcmV?d00001 diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_arc.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_arc.qml new file mode 100644 index 0000000000..6006a5a4c0 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_arc.qml @@ -0,0 +1,487 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper + +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "arc"; when: windowShown + function test_angle_1() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 0); + ctx.arc(100, 0, 150, Math.PI/2, -Math.PI, true); + ctx.fill(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_angle_2() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 0); + ctx.arc(100, 0, 150, -3*Math.PI/2, -Math.PI, true); + ctx.fill(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_angle_3() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 0); + ctx.arc(100, 0, 150, (512+1/2)*Math.PI, (1024-1)*Math.PI, true); + ctx.fill(); + //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_angle_4() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 60, (512+1/2)*Math.PI, (1024-1)*Math.PI, false); + ctx.fill(); + verify(Helper.comparePixel(ctx,1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx,98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx,1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx,98,48, 0,255,0,255)); + } + function test_angle_5() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 0); + ctx.arc(100, 0, 150, (1024-1)*Math.PI, (512+1/2)*Math.PI, false); + ctx.fill(); + /*FIXME: + actual :[255,0,0,255] + expected:[0,255,0,255] +/- 0 + */ + //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + + function test_angle_6() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 60, (1024-1)*Math.PI, (512+1/2)*Math.PI, true); + ctx.fill(); + + verify(Helper.comparePixel(ctx,1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx,98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx,1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx,98,48, 0,255,0,255)); + } + + function test_empty() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(200, 25, 5, 0, 2*Math.PI, true); + ctx.stroke(); + /*FIXME: + actual :[255,0,0,255] + expected:[0,255,0,255] +/- 0 + */ + //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_nonempty() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arc(200, 25, 5, 0, 2*Math.PI, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_nonfinite() { + skip("FIXME"); + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.arc(Infinity, 0, 50, 0, 2*Math.PI, true); + ctx.arc(-Infinity, 0, 50, 0, 2*Math.PI, true); + ctx.arc(NaN, 0, 50, 0, 2*Math.PI, true); + ctx.arc(0, Infinity, 50, 0, 2*Math.PI, true); + ctx.arc(0, -Infinity, 50, 0, 2*Math.PI, true); + ctx.arc(0, NaN, 50, 0, 2*Math.PI, true); + ctx.arc(0, 0, Infinity, 0, 2*Math.PI, true); + ctx.arc(0, 0, -Infinity, 0, 2*Math.PI, true); + ctx.arc(0, 0, NaN, 0, 2*Math.PI, true); + ctx.arc(0, 0, 50, Infinity, 2*Math.PI, true); + ctx.arc(0, 0, 50, -Infinity, 2*Math.PI, true); + ctx.arc(0, 0, 50, NaN, 2*Math.PI, true); + ctx.arc(0, 0, 50, 0, Infinity, true); + ctx.arc(0, 0, 50, 0, -Infinity, true); + ctx.arc(0, 0, 50, 0, NaN, true); + ctx.arc(Infinity, Infinity, 50, 0, 2*Math.PI, true); + ctx.arc(Infinity, Infinity, Infinity, 0, 2*Math.PI, true); + ctx.arc(Infinity, Infinity, Infinity, Infinity, 2*Math.PI, true); + ctx.arc(Infinity, Infinity, Infinity, Infinity, Infinity, true); + ctx.arc(Infinity, Infinity, Infinity, 0, Infinity, true); + ctx.arc(Infinity, Infinity, 50, Infinity, 2*Math.PI, true); + ctx.arc(Infinity, Infinity, 50, Infinity, Infinity, true); + ctx.arc(Infinity, Infinity, 50, 0, Infinity, true); + ctx.arc(Infinity, 0, Infinity, 0, 2*Math.PI, true); + ctx.arc(Infinity, 0, Infinity, Infinity, 2*Math.PI, true); + ctx.arc(Infinity, 0, Infinity, Infinity, Infinity, true); + ctx.arc(Infinity, 0, Infinity, 0, Infinity, true); + ctx.arc(Infinity, 0, 50, Infinity, 2*Math.PI, true); + ctx.arc(Infinity, 0, 50, Infinity, Infinity, true); + ctx.arc(Infinity, 0, 50, 0, Infinity, true); + ctx.arc(0, Infinity, Infinity, 0, 2*Math.PI, true); + ctx.arc(0, Infinity, Infinity, Infinity, 2*Math.PI, true); + ctx.arc(0, Infinity, Infinity, Infinity, Infinity, true); + ctx.arc(0, Infinity, Infinity, 0, Infinity, true); + ctx.arc(0, Infinity, 50, Infinity, 2*Math.PI, true); + ctx.arc(0, Infinity, 50, Infinity, Infinity, true); + ctx.arc(0, Infinity, 50, 0, Infinity, true); + ctx.arc(0, 0, Infinity, Infinity, 2*Math.PI, true); + ctx.arc(0, 0, Infinity, Infinity, Infinity, true); + ctx.arc(0, 0, Infinity, 0, Infinity, true); + ctx.arc(0, 0, 50, Infinity, Infinity, true); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx,90,45, 0,255,0,255)); + } + function test_end() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(-100, 0); + ctx.arc(-100, 0, 25, -Math.PI/2, Math.PI/2, true); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_negative() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + try { var err = false; + ctx.arc(0, 0, -1, 0, 0, true); + } catch (e) { + if (e.code != DOMException.INDEX_SIZE_ERR) + fail("expected exception of type INDEX_SIZE_ERR, got: "+e.message); + err = true; + } finally { + verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.arc(0, 0, -1, 0, 0, true)"); + } + + } + + function test_scale_1() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.scale(2, 0.5); + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.arc(25, 50, 56, 0, 2*Math.PI, false); + ctx.fill(); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(-25, 50); + ctx.arc(-25, 50, 24, 0, 2*Math.PI, false); + ctx.moveTo(75, 50); + ctx.arc(75, 50, 24, 0, 2*Math.PI, false); + ctx.moveTo(25, -25); + ctx.arc(25, -25, 24, 0, 2*Math.PI, false); + ctx.moveTo(25, 125); + ctx.arc(25, 125, 24, 0, 2*Math.PI, false); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + } + + function test_scale_2() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.scale(100, 100); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 1.2; + ctx.beginPath(); + ctx.arc(0, 0, 0.6, 0, Math.PI/2, false); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_selfintersect_1() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 200; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(100, 50, 25, 0, -Math.PI/2, true); + ctx.stroke(); + ctx.beginPath(); + ctx.arc(0, 0, 25, 0, -Math.PI/2, true); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_selfintersect_2() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 180; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.arc(-50, 50, 25, 0, -Math.PI/2, true); + ctx.stroke(); + ctx.beginPath(); + ctx.arc(100, 0, 25, 0, -Math.PI/2, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 97,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 97,2, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 97,3, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 2,48, 0,255,0,255)); + } + + function test_shape_1() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(50, 50, 50, 0, Math.PI, false); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 20,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_shape_2() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 100; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.arc(50, 50, 50, 0, Math.PI, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 20,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + function test_shape_3() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 100; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(0, 50, 50, 0, -Math.PI/2, false); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_shape_4() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 150; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.arc(-50, 50, 100, 0, -Math.PI/2, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_shape_5() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 200; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(300, 0, 100, 0, 5*Math.PI, false); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_twopie() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 2*Math.PI - 1e-4, true); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 2*Math.PI - 1e-4, false); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 2*Math.PI + 1e-4, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 2*Math.PI + 1e-4, false); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + } + + function test_zero() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 0, true); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 0, false); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00' + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arc(200, 25, 0, 0, Math.PI, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_arcto.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_arcto.qml new file mode 100644 index 0000000000..cc1d88672b --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_arcto.qml @@ -0,0 +1,410 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper + +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "arcTo"; when: windowShown + function test_coincide() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(0, 25, 50, 1000, 1); + ctx.lineTo(100, 25); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arcTo(50, 25, 100, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 100, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_collinear() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 200, 25, 1); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(-100, 25); + ctx.arcTo(0, 25, 100, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 10, 25, 1); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 25); + ctx.arcTo(200, 25, 110, 25, 1); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, -100, 25, 1); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 25); + ctx.arcTo(200, 25, 0, 25, 1); + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(-100, 25); + ctx.arcTo(0, 25, -200, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_subpath() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arcTo(100, 50, 200, 50, 0.1); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.arcTo(0, 25, 50, 250, 0.1); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_negative() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + try { var err = false; + ctx.arcTo(0, 0, 0, 0, -1); + } catch (e) { + if (e.code != DOMException.INDEX_SIZE_ERR) + fail("expectes INDEX_SIZE_ERR, got: "+e.message); + err = true; + } + finally { + verify(err, "should throw INDEX_SIZE_ERR: ctx.arcTo(0, 0, 0, 0, -1)"); + } + } + + function test_nonfinite() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + skip("FIXME"); + + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.arcTo(Infinity, 50, 0, 50, 0); + ctx.arcTo(-Infinity, 50, 0, 50, 0); + ctx.arcTo(NaN, 50, 0, 50, 0); + ctx.arcTo(0, Infinity, 0, 50, 0); + ctx.arcTo(0, -Infinity, 0, 50, 0); + ctx.arcTo(0, NaN, 0, 50, 0); + ctx.arcTo(0, 50, Infinity, 50, 0); + ctx.arcTo(0, 50, -Infinity, 50, 0); + ctx.arcTo(0, 50, NaN, 50, 0); + ctx.arcTo(0, 50, 0, Infinity, 0); + ctx.arcTo(0, 50, 0, -Infinity, 0); + ctx.arcTo(0, 50, 0, NaN, 0); + ctx.arcTo(0, 50, 0, 50, Infinity); + ctx.arcTo(0, 50, 0, 50, -Infinity); + ctx.arcTo(0, 50, 0, 50, NaN); + ctx.arcTo(Infinity, Infinity, 0, 50, 0); + ctx.arcTo(Infinity, Infinity, Infinity, 50, 0); + ctx.arcTo(Infinity, Infinity, Infinity, Infinity, 0); + ctx.arcTo(Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.arcTo(Infinity, Infinity, Infinity, 50, Infinity); + ctx.arcTo(Infinity, Infinity, 0, Infinity, 0); + ctx.arcTo(Infinity, Infinity, 0, Infinity, Infinity); + ctx.arcTo(Infinity, Infinity, 0, 50, Infinity); + ctx.arcTo(Infinity, 50, Infinity, 50, 0); + ctx.arcTo(Infinity, 50, Infinity, Infinity, 0); + ctx.arcTo(Infinity, 50, Infinity, Infinity, Infinity); + ctx.arcTo(Infinity, 50, Infinity, 50, Infinity); + ctx.arcTo(Infinity, 50, 0, Infinity, 0); + ctx.arcTo(Infinity, 50, 0, Infinity, Infinity); + ctx.arcTo(Infinity, 50, 0, 50, Infinity); + ctx.arcTo(0, Infinity, Infinity, 50, 0); + ctx.arcTo(0, Infinity, Infinity, Infinity, 0); + ctx.arcTo(0, Infinity, Infinity, Infinity, Infinity); + ctx.arcTo(0, Infinity, Infinity, 50, Infinity); + ctx.arcTo(0, Infinity, 0, Infinity, 0); + ctx.arcTo(0, Infinity, 0, Infinity, Infinity); + ctx.arcTo(0, Infinity, 0, 50, Infinity); + ctx.arcTo(0, 50, Infinity, Infinity, 0); + ctx.arcTo(0, 50, Infinity, Infinity, Infinity); + ctx.arcTo(0, 50, Infinity, 50, Infinity); + ctx.arcTo(0, 50, 0, Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + } + function test_scale() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 50); + ctx.translate(100, 0); + ctx.scale(0.1, 1); + ctx.arcTo(50, 50, 50, 0, 50); + ctx.lineTo(-1000, 0); + ctx.fill(); + + skip("FIXME"); + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + } + + function test_shape() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + var tol = 1.5; // tolerance to avoid antialiasing artifacts + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 10; + ctx.beginPath(); + ctx.moveTo(10, 25); + ctx.arcTo(75, 25, 75, 60, 20); + ctx.stroke(); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.rect(10, 20, 45, 10); + ctx.moveTo(80, 45); + ctx.arc(55, 45, 25+tol, 0, -Math.PI/2, true); + ctx.arc(55, 45, 15-tol, -Math.PI/2, 0, false); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 64,22, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 72,28, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 73,27, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 78,36, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,46, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,45, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.rect(10, 20, 45, 10); + ctx.moveTo(80, 45); + ctx.arc(55, 45, 25-tol, 0, -Math.PI/2, true); + ctx.arc(55, 45, 15+tol, -Math.PI/2, 0, false); + ctx.fill(); + + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 10; + ctx.beginPath(); + ctx.moveTo(10, 25); + ctx.arcTo(75, 25, 75, 60, 20); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 64,22, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 72,28, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 73,27, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 78,36, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,46, 0,255,0,255)); + ctx.reset(); + + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(-100, -100); + ctx.arcTo(-100, 25, 200, 25, 10); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(200, 25, 200, 50, 10); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 50); + ctx.translate(100, 0); + ctx.arcTo(50, 50, 50, 0, 50); + ctx.lineTo(-100, 0); + ctx.fill(); + + skip("FIXME"); + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + } + function test_zero() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 100, 100, 0); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(0, -25); + ctx.arcTo(50, -25, 50, 50, 0); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, -100, 25, 0); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 25); + ctx.arcTo(200, 25, 50, 25, 0); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_canvas.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_canvas.qml new file mode 100644 index 0000000000..65649df76f --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_canvas.qml @@ -0,0 +1,271 @@ +import QtQuick 2.0 +import QtTest 1.0 + +Rectangle { + id:container + width:100 + height:100 + Component { + id:canvas + Canvas { + id:c + width:10;height:10 + onPaint: { + context.fillStyle = "red"; + context.fillRect(0, 0, 10, 10); + } + property int paintCount:spyPaint.count + property int paintedCount:spyPainted.count + property int canvasSizeChangedCount:spyCanvasSizeChanged.count + property int tileSizeChangedCount:spyTileSizeChanged.count + property int renderInThreadChangedCount:spyRenderInThreadChanged.count + property int canvasWindowChangedCount:spyCanvasWindowChanged.count + property int renderTargetChangedCount:spyRenderTargetChanged.count + property int imageLoadedCount:spyImageLoaded.count + + SignalSpy {id: spyPaint;target:c;signalName: "paint"} + SignalSpy {id: spyPainted;target:c;signalName: "painted"} + SignalSpy {id: spyCanvasSizeChanged;target:c;signalName: "canvasSizeChanged"} + SignalSpy {id: spyTileSizeChanged;target:c;signalName: "tileSizeChanged"} + SignalSpy {id: spyRenderInThreadChanged;target:c;signalName: "renderInThreadChanged"} + SignalSpy {id: spyCanvasWindowChanged;target:c;signalName: "canvasWindowChanged"} + SignalSpy {id: spyRenderTargetChanged;target:c;signalName: "renderTargetChanged"} + SignalSpy {id: spyImageLoaded;target:c;signalName: "imageLoaded"} + } + } + + TestCase { + name: "Canvas"; when: windowShown + function test_canvasSize() { + var c = canvas.createObject(); + verify(c); + + //by default canvasSize is same with canvas' actual size + // when canvas size changes, canvasSize should be changed as well. + compare(c.canvasSize.width, c.width); + compare(c.canvasSize.height, c.height); + c.width = 20; + compare(c.canvasSize.width, 20); + compare(c.canvasSizeChangedCount, 1); + c.height = 5; + compare(c.canvasSizeChangedCount, 2); + compare(c.canvasSize.height, 5); + + //change canvasSize manually, then canvasSize detaches from canvas + //actual size. + c.canvasSize.width = 100; + compare(c.canvasSizeChangedCount, 3); + compare(c.canvasSize.width, 100); + compare(c.width, 20); + c.canvasSize.height = 50; + compare(c.canvasSizeChangedCount, 4); + compare(c.canvasSize.height, 50); + compare(c.height, 5); + + c.width = 10; + compare(c.canvasSizeChangedCount, 4); + compare(c.canvasSize.width, 100); + compare(c.canvasSize.height, 50); + + c.height = 10; + compare(c.canvasSizeChangedCount, 4); + compare(c.canvasSize.width, 100); + compare(c.canvasSize.height, 50); + c.destroy(); + } + function test_tileSize() { + var c = canvas.createObject(); + verify(c); + + compare(c.tileSize.width, c.width); + compare(c.tileSize.height, c.height); + c.width = 20; + compare(c.tileSize.width, 20); + compare(c.tileSizeChangedCount, 1); + c.height = 5; + compare(c.tileSizeChangedCount, 2); + compare(c.tileSize.height, 5); + + c.tileSize.width = 100; + compare(c.tileSizeChangedCount, 3); + compare(c.tileSize.width, 100); + compare(c.width, 20); + c.tileSize.height = 50; + compare(c.tileSizeChangedCount, 4); + compare(c.tileSize.height, 50); + compare(c.height, 5); + + c.width = 10; + compare(c.tileSizeChangedCount, 4); + compare(c.tileSize.width, 100); + compare(c.tileSize.height, 50); + + c.height = 10; + compare(c.tileSizeChangedCount, 4); + compare(c.tileSize.width, 100); + compare(c.tileSize.height, 50); + c.destroy(); + + } + + function test_canvasWindow() { + var c = canvas.createObject(); + verify(c); + compare(c.canvasWindow.x, 0); + compare(c.canvasWindow.y, 0); + compare(c.canvasWindow.width, c.width); + compare(c.canvasWindow.height, c.height); + + c.width = 20; + compare(c.canvasWindow.width, 20); + compare(c.canvasWindowChangedCount, 1); + c.height = 5; + compare(c.canvasWindowChangedCount, 2); + compare(c.canvasWindow.height, 5); + + c.canvasWindow.x = 5; + c.canvasWindow.y = 6; + c.canvasWindow.width = 10; + c.canvasWindow.height =20; + compare(c.canvasWindowChangedCount, 6); + compare(c.canvasWindow.width, 10); + compare(c.canvasWindow.height, 20); + compare(c.canvasWindow.x, 5); + compare(c.canvasWindow.y, 6); + c.destroy(); + + } + function test_renderTargetAndThread() { + var c = canvas.createObject(); + verify(c); + + compare(c.renderTarget, Canvas.FramebufferObject); + verify(!c.renderInThread); + c.renderTarget = Canvas.Image; + compare(c.renderTargetChangedCount, 1); + compare(c.renderInThreadChangedCount, 0); + + compare(c.renderTarget, Canvas.Image); + verify(!c.renderInThread); + c.renderInThread = true; + verify(c.renderInThread); + compare(c.renderTargetChangedCount, 1); + compare(c.renderInThreadChangedCount, 1); + + ignoreWarning("Canvas: render target does not support thread rendering, force to non-thread rendering mode."); + c.renderTarget = Canvas.FramebufferObject; + verify(!c.renderInThread); + compare(c.renderTargetChangedCount, 2); + compare(c.renderInThreadChangedCount, 2); + c.destroy(); + + } + function test_save() { + var c = canvas.createObject(); + verify(c); + + c.renderTarget = Canvas.Image; + c.requestPaint(); + wait(100); + verify(c.save("c.png")); + c.loadImage("c.png"); + wait(200); + compare(c.imageLoadedCount, 1); + verify(c.isImageLoaded("c.png")); + verify(!c.isImageLoading("c.png")); + verify(!c.isImageError("c.png")); + c.destroy(); + + } + function test_toDataURL_data() { + return [{mimeType:"image/png"}, + {mimeType:"image/bmp"}, + {mimeType:"image/jpeg"}, + {mimeType:"image/x-portable-pixmap"}, + {mimeType:"image/tiff"}, + {mimeType:"image/xbm"}, + {mimeType:"image/xpm"}, + ]; + } + + function test_toDataURL(data) { + var c = canvas.createObject(); + verify(c); + + c.renderTarget = Canvas.Image; + var ctx = c.getContext(); + ctx.fillStyle = "red"; + ctx.fillRect(0, 0, c.width, c.height); + + c.requestPaint(); + wait(100); + var dataUrl = c.toDataURL(); + verify(dataUrl != "data:,"); + dataUrl = c.toDataURL("image/invalid"); + verify(dataUrl == "data:,"); + + dataUrl = c.toDataURL(data.mimeType); + verify(dataUrl != "data:,"); + ctx.save(); + ctx.fillStyle = "blue"; + ctx.fillRect(0, 0, c.width, c.height); + ctx.restore(); + + var dataUrl2 = c.toDataURL(data.mimeType); + verify (dataUrl2 != "data:,"); + verify (dataUrl2 != dataUrl); + c.destroy(); + + } + function test_paint() { + var c = canvas.createObject(); + verify(c); + + c.renderTarget = Canvas.Image; + + c.requestPaint(); + wait(200); + compare(c.paintedCount, 1); + compare(c.paintCount, 1); + c.destroy(); + + } + function test_loadImage() { + var c = canvas.createObject(); + verify(c); + + c.loadImage("qt-logo.png"); + wait(200); + compare(c.imageLoadedCount, 1); + verify(c.isImageLoaded("qt-logo.png")); + verify(!c.isImageLoading("qt-logo.png")); + verify(!c.isImageError("qt-logo.png")); + + c.unloadImage("qt-logo.png"); + verify(!c.isImageLoaded("qt-logo.png")); + verify(!c.isImageLoading("qt-logo.png")); + verify(!c.isImageError("qt-logo.png")); + c.destroy(); + + } + + function test_getContext() { + var c = canvas.createObject(); + verify(c); + + var ctx = c.getContext(); + verify(ctx); + compare(ctx.canvas, c); + ctx = c.getContext('2d'); + verify(ctx); + compare(ctx.canvas, c); + ctx = c.getContext('2D'); + verify(ctx); + compare(ctx.canvas, c); + ctx = c.getContext('invalid'); + verify(!ctx); + c.destroy(); + + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_colors.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_colors.qml deleted file mode 100644 index a20a7dfaf9..0000000000 --- a/tests/auto/declarative/qsgcanvasitem/data/tst_colors.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper - -Canvas { - id:canvas; width:1;height:1 - TestCase { - name: "Colors"; when: windowShown - function test_globalAlpha() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = Qt.rgba(1, 0.7, 0.2, 0.5); - ctx.globalAlpha = 0.5; - ctx.fillRect(0,0,1,1); - var d = ctx.getImageData(0,0,1,1).data; - verify(Helper.comparePixel(ctx, 0, 0, 255, 0.7 * 255, 0.2*255, 0.25 * 255)); - } - } -} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_composite.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_composite.qml new file mode 100644 index 0000000000..11e1dce902 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_composite.qml @@ -0,0 +1,380 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget:Canvas.Image + TestCase { + name: "composite"; when: windowShown + function test_clearRect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-atop'; + ctx.clearRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0)); + } + + function test_clip_data() { + return [ {compsite:"copy"}, + {compsite:"destination-atop"}, + {compsite:"destination-in"}, + {compsite:"destination-out"}, + {compsite:"destination-over"}, + {compsite:"lighter"}, + {compsite:"source-atop"}, + {compsite:"source-in"}, + {compsite:"source-out"}, + {compsite:"source-over"}, + {compsite:"xor"} + ]; + } + + function test_clip(data) { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = data.compsite; + ctx.rect(-20, -20, 10, 10); + ctx.clip(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 50, 50); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + } + + function test_globalAlpha() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + compare(ctx.globalAlpha, 1.0); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 2,253,0,255, 2)); + + ctx.reset(); + ctx.globalAlpha = 0.5; + var a = ctx.globalAlpha; // might not be exactly 0.5, if it is rounded/quantised, so remember for future comparisons + ctx.globalAlpha = Infinity; + compare(ctx.globalAlpha, a); + ctx.globalAlpha = -Infinity; + compare(ctx.globalAlpha, a); + ctx.globalAlpha = NaN; + compare(ctx.globalAlpha, a); + + ctx.globalAlpha = 0.5; + a = ctx.globalAlpha; // might not be exactly 0.5, if it is rounded/quantised, so remember for future comparisons + ctx.globalAlpha = 1.1; + compare(ctx.globalAlpha, a); + ctx.globalAlpha = -0.1; + compare(ctx.globalAlpha, a); + ctx.globalAlpha = 0; + compare(ctx.globalAlpha, 0); + ctx.globalAlpha = 1; + compare(ctx.globalAlpha, 1); + + } + + function test_operation() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'Source-over'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'clear'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'darker'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + compare(ctx.globalCompositeOperation, 'source-over'); + + + ctx.reset(); + var modes = ['source-atop', 'source-in', 'source-out', 'source-over', + 'destination-atop', 'destination-in', 'destination-out', 'destination-over', + 'lighter', 'copy', 'xor']; + for (var i = 0; i < modes.length; ++i) + { + ctx.globalCompositeOperation = modes[i]; + compare(ctx.globalCompositeOperation, modes[i]); + } + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'highlight'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'source-over\\0'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'over'; + compare(ctx.globalCompositeOperation, 'xor'); + + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'nonexistent'; + compare(ctx.globalCompositeOperation, 'xor'); + } + + function test_solid() { + skip("FIXME"); + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = Qt.rgba(0, 1, 1, 1.0); + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'copy'; + ctx.fillStyle = Qt.rgba(1, 1, 0, 1.0); + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-atop'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,255,255, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-in'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,255,255, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-out'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-over'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,255,255, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'lighter'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,255,255, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-atop'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-in'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-out'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + // verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-over'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'xor'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + } + function test_transparent() { + + skip("FIXME"); + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'copy'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,255,191, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'copy'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,255,191, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-in'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,95, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-out'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,31, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-over'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,145,109,223, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'lighter'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,127,191,255, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-atop'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,63,191,127, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-in'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,255,95, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-out'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,255,95, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-over'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,36,218,223, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'xor'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,63,191,127, 5)); + + } + + function test_uncovered() { + skip("FIXME"); + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'copy'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-atop'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-in'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-in'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-out'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + } + + } +} \ No newline at end of file diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_drawimage.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_drawimage.qml new file mode 100644 index 0000000000..2f10501041 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_drawimage.qml @@ -0,0 +1,42 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + //TODO + name: "image"; when: windowShown + function test_3args() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_5args() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_9args() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_animated() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_clip() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_composite() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_path() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_fillStyle.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_fillStyle.qml index a4b77ec2b3..8f5a78cec0 100644 --- a/tests/auto/declarative/qsgcanvasitem/data/tst_fillStyle.qml +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_fillStyle.qml @@ -3,7 +3,7 @@ import QtTest 1.0 import "testhelper.js" as Helper Canvas { - id:canvas; width:1;height:1 + id:canvas; width:1;height:1;renderTarget:Canvas.Image TestCase { name: "fillStyle"; when: windowShown function test_default() { @@ -43,7 +43,9 @@ Canvas { compare(ctx.fillStyle, '#ffaa00'); ctx.fillStyle = "rgb (1, 2, 3)"; compare(ctx.fillStyle, '#ffaa00'); - ctx.fillStyle = "rgba(1, 2, 3)"; + ctx.fillStyle = '#fa0'; + + ctx.fillStyle = "rgba(3, 1, 2)"; compare(ctx.fillStyle, '#ffaa00'); ctx.fillStyle = "rgb((3,4,1)"; compare(ctx.fillStyle, '#ffaa00'); @@ -96,9 +98,7 @@ Canvas { ctx.clearRect(0, 0, 1, 1); ctx.fillStyle = 'rgba(0%, 100%, 0%, 0.499)'; ctx.fillRect(0, 0, 1, 1); - //FIXME: currently we only return premultipled pixels - verify(Helper.comparePixel(ctx, 0,0, 0,127,0,255)); - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,127)); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,127)); } function test_hsla() { @@ -106,7 +106,7 @@ Canvas { ctx.reset(); ctx.fillStyle = "hsla(120, 100%, 50%, 0.499)"; ctx.fillRect(0, 0, 1, 1); - verify(Helper.comparePixel(ctx,0,0,0,127,0,255)); + verify(Helper.comparePixel(ctx,0,0,0,255,0,127)); } } diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_fillrect.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_fillrect.qml index 07ddc59a07..2061647268 100644 --- a/tests/auto/declarative/qsgcanvasitem/data/tst_fillrect.qml +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_fillrect.qml @@ -2,7 +2,7 @@ import QtQuick 2.0 import QtTest 1.0 Canvas { - id:canvas; width:1;height:1 + id:canvas; width:1;height:1; renderTarget:Canvas.Image onPaint: { context.fillStyle = "red"; context.fillRect(0, 0, canvas.width, canvas.height); @@ -20,4 +20,4 @@ Canvas { verify(d[3] == 255); } } -} +} \ No newline at end of file diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_gradient.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_gradient.qml new file mode 100644 index 0000000000..d454c2efe1 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_gradient.qml @@ -0,0 +1,981 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "gradient"; when: windowShown + function test_basic() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + var g = ctx.createLinearGradient(0, 0, 0, 50); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + + } + + function test_interpolate() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#ff0'; + ctx.fillRect(0, 0, 100, 50); + var g = ctx.createLinearGradient(0, 0, 100, 0); + g.addColorStop(0, 'rgba(0,0,255, 0)'); + g.addColorStop(1, 'rgba(0,0,255, 1)'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 25,25, 191,191,63,255,3)); + //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,255,3)); + //verify(Helper.comparePixel(ctx, 75,25, 63,63,191,255,3)); + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + g.addColorStop(0, '#ff0'); + g.addColorStop(1, '#00f'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 25,25, 191,191,63,255,3)); + //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,255,3)); + //verify(Helper.comparePixel(ctx, 75,25, 63,63,191,255,3)); + + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + g.addColorStop(0, 'rgba(255,255,0, 0)'); + g.addColorStop(1, 'rgba(0,0,255, 1)'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 25,25, 191,191,63,63,3)); + //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,127,3)); + //verify(Helper.comparePixel(ctx, 75,25, 63,63,191,191,3)); + + ctx.reset(); + canvas.width = 200; + var g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#ff0'); + g.addColorStop(0.5, '#0ff'); + g.addColorStop(1, '#f0f'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 200, 50); + //verify(Helper.comparePixel(ctx, 50,25, 127,255,127,255,3)); + //verify(Helper.comparePixel(ctx, 100,25, 0,255,255,255,3)); + //verify(Helper.comparePixel(ctx, 150,25, 127,127,255,255,3)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + var g = ctx.createLinearGradient(25, 0, 75, 0); + g.addColorStop(0.4, '#0f0'); + g.addColorStop(0.6, '#0f0'); + + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 20,25, 0,255,0,255,2)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + //verify(Helper.comparePixel(ctx, 80,25, 0,255,0,255,2)); + + + ctx.reset(); + ctx.canvas.width = 200; + var g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(0, '#ff0'); + g.addColorStop(0.25, '#00f'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.25, '#ff0'); + g.addColorStop(0.5, '#00f'); + g.addColorStop(0.5, '#0f0'); + g.addColorStop(0.75, '#00f'); + g.addColorStop(0.75, '#f00'); + g.addColorStop(0.75, '#ff0'); + g.addColorStop(0.5, '#0f0'); + g.addColorStop(0.5, '#0f0'); + g.addColorStop(0.5, '#ff0'); + g.addColorStop(1, '#00f'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 200, 50); + //verify(Helper.comparePixel(ctx, 49,25, 0,0,255,255,16)); + //verify(Helper.comparePixel(ctx, 51,25, 255,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 99,25, 0,0,255,255,16)); + //verify(Helper.comparePixel(ctx, 101,25, 255,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 149,25, 0,0,255,255,16)); + //verify(Helper.comparePixel(ctx, 151,25, 255,255,0,255,16)); + ctx.canvas.width = 100; + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + var ps = [ 0, 1/10, 1/4, 1/3, 1/2, 3/4, 1 ]; + for (var p = 0; p < ps.length; ++p) + { + g.addColorStop(ps[p], '#0f0'); + for (var i = 0; i < 15; ++i) + g.addColorStop(ps[p], '#f00'); + g.addColorStop(ps[p], '#0f0'); + } + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 30,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 40,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 60,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 80,25, 0,255,0,255)); + + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 0, 50); + g.addColorStop(0, '#ff0'); + g.addColorStop(1, '#00f'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,12, 191,191,63,255,10)); + //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,255,5)); + //verify(Helper.comparePixel(ctx, 50,37, 63,63,191,255,10)); + + + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var g = ctx.createLinearGradient(50, 25, 50, 25); // zero-length line (undefined direction) + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 40,20, 0,255,0,255,2)); + + + + } + function test_radial() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var g = ctx.createRadialGradient(0, 100, 40, 100, 100, 50); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(210, 25, 100, 230, 25, 101); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(210, 25, 100, 230, 25, 100); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(311, 25, 10, 210, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(30+tol, 40); + ctx.lineTo(110, -20+tol); + ctx.lineTo(110, 100-tol); + ctx.fill(); + + g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(30-tol, 40); + ctx.lineTo(110, -20-tol); + ctx.lineTo(110, 100+tol); + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(230, 25, 100, 100, 25, 101); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(50, 25, 20, 50, 25, 20); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(50, 25, 100, 50, 25, 200); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(50, 25, 200, 50, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(50, 25, 200, 50, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(0.993, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + try { var err = false; + ctx.createRadialGradient(0, 0, -0.1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.createRadialGradient(0, 0, -0.1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, 0, -0.1); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, -0.1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, -0.1, 0, 0, -0.1); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.createRadialGradient(0, 0, -0.1, 0, 0, -0.1)"); } + + + ctx.reset(); + + + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(-Infinity, 0, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(-Infinity, 0, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(NaN, 0, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(NaN, 0, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, -Infinity, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, -Infinity, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, NaN, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, NaN, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, -Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, -Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, NaN, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, NaN, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, -Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, -Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, NaN, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, NaN, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, -Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, -Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, NaN, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, NaN, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, 0, -Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, -Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, 0, NaN); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, NaN)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, Infinity, Infinity)"); } + + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(200, 25, 10, 200, 25, 20); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10); + g.addColorStop(0, '#0f0'); + g.addColorStop(0.001, '#f00'); + g.addColorStop(1, '#f00');ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(150, 25, 50, 200, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(-80, 25, 70, 0, 25, 150); + g.addColorStop(0, '#f00'); + g.addColorStop(0.01, '#0f0'); + g.addColorStop(0.99, '#0f0');g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16));//verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(120, -15, 25, 140, -30, 50); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2); + g.addColorStop(0, '#0f0'); + g.addColorStop(0.5, '#0f0');g.addColorStop(0.51, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.translate(50, 25);ctx.scale(10, 10); + ctx.fillRect(-5, -2.5, 10, 5); + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + ctx.reset(); + ctx.translate(100, 0); + g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2); + g.addColorStop(0, '#0f0');g.addColorStop(0.5, '#0f0'); + g.addColorStop(0.51, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g;ctx.translate(-50, 25); + ctx.scale(10, 10); + ctx.fillRect(-5, -2.5, 10, 5); + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + + ctx.reset(); + g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2); + g.addColorStop(0, '#0f0'); + g.addColorStop(0.5, '#0f0');g.addColorStop(0.51, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50);ctx.translate(50, 25); + ctx.scale(10, 10); + ctx.fillRect(-5, -2.5, 10, 5); + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + + } + function test_linear() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + try { var err = false; + ctx.createLinearGradient(Infinity, 0, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(-Infinity, 0, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(-Infinity, 0, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(NaN, 0, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(NaN, 0, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, Infinity, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, -Infinity, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, -Infinity, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, NaN, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, NaN, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, -Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, -Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, NaN, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, NaN, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, 1, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, 1, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, 1, -Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, 1, -Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, 1, NaN); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, 1, NaN)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, Infinity, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, Infinity, Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, Infinity, 1, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, 1, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, 0, Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, 0, 1, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, 1, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, Infinity, Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, Infinity, 1, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, 1, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, Infinity, Infinity)"); } + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.75, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.translate(-50, 0); + ctx.fillRect(50, 0, 100, 50); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + ctx.reset(); + ctx.translate(100, 0); + g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.75, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.translate(-150, 0); + ctx.fillRect(50, 0, 100, 50); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + + ctx.reset(); + g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.75, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + ctx.translate(-50, 0); + ctx.fillRect(50, 0, 100, 50); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + } + function test_object() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + var g1 = ctx.createLinearGradient(0, 0, 100, 0); + var g2 = ctx.createLinearGradient(0, 0, 100, 0); + ctx.fillStyle = g1; + + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + try { var err = false; + g.addColorStop(0, ""); + } catch (e) { if (e.code != DOMException.SYNTAX_ERR) fail("Failed assertion: expected exception of type SYNTAX_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type SYNTAX_ERR: g.addColorStop(0, \"\")"); } + try { var err = false; + g.addColorStop(0, 'undefined'); + } catch (e) { if (e.code != DOMException.SYNTAX_ERR) fail("Failed assertion: expected exception of type SYNTAX_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type SYNTAX_ERR: g.addColorStop(0, 'undefined')"); } + + + ctx.reset(); + g = ctx.createLinearGradient(0, 0, 100, 0); + try { var err = false; + g.addColorStop(-1, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(-1, '#000')"); } + try { var err = false; + g.addColorStop(2, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(2, '#000')"); } + try { var err = false; + g.addColorStop(Infinity, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(Infinity, '#000')"); } + try { var err = false; + g.addColorStop(-Infinity, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(-Infinity, '#000')"); } + try { var err = false; + g.addColorStop(NaN, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(NaN, '#000')"); } + + + ctx.reset(); + g = ctx.createLinearGradient(-100, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + g.addColorStop(0.1, '#0f0'); + g.addColorStop(0.9, '#0f0'); + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(120, 25, 10, 211, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + + } + + function test_conical() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + var g = ctx.createConicalGradient(10, 10, 50); + //TODO + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_line.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_line.qml new file mode 100644 index 0000000000..baf9987ce3 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_line.qml @@ -0,0 +1,831 @@ +import QtQuick 2.0 +import QtTest 1.0 +import"testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50;renderTarget: Canvas.Image + TestCase { + name: "line"; when: windowShown + function test_default() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + compare(ctx.lineWidth, 1); + compare(ctx.lineCap, 'butt'); + compare(ctx.lineJoin, 'miter'); + compare(ctx.miterLimit, 10); + } + + function test_cross() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 200; + ctx.lineJoin = 'bevel'; + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(110, 50); + ctx.lineTo(110, 60); + ctx.lineTo(100, 60); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + } + + function test_join() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.lineJoin = 'bevel'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.fillRect(10, 10, 20, 20); + ctx.fillRect(20, 20, 20, 20); + ctx.beginPath(); + ctx.moveTo(30, 20); + ctx.lineTo(40-tol, 20); + ctx.lineTo(30, 10+tol); + ctx.fill(); + + ctx.beginPath(); + ctx.moveTo(10, 20); + ctx.lineTo(30, 20); + ctx.lineTo(30, 40); + ctx.stroke(); + + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + + ctx.beginPath(); + ctx.moveTo(60, 20); + ctx.lineTo(80, 20); + ctx.lineTo(80, 40); + ctx.stroke(); + + ctx.fillRect(60, 10, 20, 20); + ctx.fillRect(70, 20, 20, 20); + ctx.beginPath(); + ctx.moveTo(80, 20); + ctx.lineTo(90+tol, 20); + ctx.lineTo(80, 10-tol); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 34,16, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 34,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 35,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 36,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 36,14, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 84,16, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 84,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 85,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 86,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 86,14, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'miter'; + ctx.lineWidth = 200; + + ctx.beginPath(); + ctx.moveTo(100, 50); + ctx.lineTo(100, 1000); + ctx.lineTo(1000, 1000); + ctx.lineTo(1000, 50); + ctx.closePath(); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + + ctx.reset(); + ctx.lineJoin = 'bevel' + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'invalid'; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'ROUND'; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'round\\0'; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'round '; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = ""; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'butt'; + compare(ctx.lineJoin, 'bevel'); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'miter'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.fillRect(10, 10, 30, 20); + ctx.fillRect(20, 10, 20, 30); + + ctx.beginPath(); + ctx.moveTo(10, 20); + ctx.lineTo(30, 20); + ctx.lineTo(30, 40); + ctx.stroke(); + + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + + ctx.beginPath(); + ctx.moveTo(60, 20); + ctx.lineTo(80, 20); + ctx.lineTo(80, 40); + ctx.stroke(); + + ctx.fillRect(60, 10, 30, 20); + ctx.fillRect(70, 10, 20, 30); + + verify(Helper.comparePixel(ctx, 38,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 40,10, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 41,9, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 42,8, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 88,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 89,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 91,9, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 92,8, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'miter'; + ctx.lineWidth = 200; + + ctx.beginPath(); + ctx.moveTo(100, 50); + ctx.lineTo(100, 1000); + ctx.lineTo(1000, 1000); + ctx.lineTo(1000, 50); + ctx.lineTo(100, 50); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 300; + ctx.lineJoin = 'round'; + ctx.beginPath(); + ctx.moveTo(-100, 25); + ctx.lineTo(0, 25); + ctx.lineTo(-100, 25); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.lineJoin = 'round'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.fillRect(10, 10, 20, 20); + ctx.fillRect(20, 20, 20, 20); + ctx.beginPath(); + ctx.moveTo(30, 20); + ctx.arc(30, 20, 10-tol, 0, 2*Math.PI, true); + ctx.fill(); + + ctx.beginPath(); + ctx.moveTo(10, 20); + ctx.lineTo(30, 20); + ctx.lineTo(30, 40); + ctx.stroke(); + + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + + ctx.beginPath(); + ctx.moveTo(60, 20); + ctx.lineTo(80, 20); + ctx.lineTo(80, 40); + ctx.stroke(); + + ctx.fillRect(60, 10, 20, 20); + ctx.fillRect(70, 20, 20, 20); + ctx.beginPath(); + ctx.moveTo(80, 20); + ctx.arc(80, 20, 10+tol, 0, 2*Math.PI, true); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 36,14, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 36,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 37,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 38,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 38,12, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 86,14, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 86,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 87,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 88,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 88,12, 0,255,0,255)); + + ctx.reset(); + ctx.lineJoin = 'bevel' + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'round'; + compare(ctx.lineJoin, 'round'); + + ctx.lineJoin = 'miter'; + compare(ctx.lineJoin, 'miter'); + + } + function test_miter() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 200; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#0f0'; + ctx.miterLimit = 2.614; + ctx.beginPath(); + ctx.moveTo(100, 1000); + ctx.lineTo(100, 100); + ctx.lineTo(1000, 1000); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 2.613; + ctx.beginPath(); + ctx.moveTo(100, 1000); + ctx.lineTo(100, 100); + ctx.lineTo(1000, 1000); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 400; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 1.414; + ctx.beginPath(); + ctx.moveTo(200, 1000); + ctx.lineTo(200, 200); + ctx.lineTo(1000, 201); // slightly non-right-angle to avoid being a special case + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.miterLimit = 1.5; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = 0; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = -1; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = Infinity; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = -Infinity; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = NaN; + compare(ctx.miterLimit, 1.5); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 200; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 1.414; + ctx.beginPath(); + ctx.strokeRect(100, 25, 200, 0); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 1600; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#0f0'; + ctx.miterLimit = 1.083; + ctx.beginPath(); + ctx.moveTo(800, 10000); + ctx.lineTo(800, 300); + ctx.lineTo(10000, -8900); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 1.082; + ctx.beginPath(); + ctx.moveTo(800, 10000); + ctx.lineTo(800, 300); + ctx.lineTo(10000, -8900); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 400; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 1.414; + ctx.beginPath(); + ctx.moveTo(200, 1000); + ctx.lineTo(200, 200); + ctx.lineTo(1000, 200); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.miterLimit = 1.5; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = "1e1"; + compare(ctx.miterLimit, 10); + + ctx.miterLimit = 1/1024; + compare(ctx.miterLimit, 1/1024); + + ctx.miterLimit = 1000; + compare(ctx.miterLimit, 1000); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 400; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#0f0'; + ctx.miterLimit = 1.416; + ctx.beginPath(); + ctx.moveTo(200, 1000); + ctx.lineTo(200, 200); + ctx.lineTo(1000, 201); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + + } + function test_width() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 20; + // Draw a green line over a red box, to check the line is not too small + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(15, 15, 20, 20); + ctx.beginPath(); + ctx.moveTo(25, 15); + ctx.lineTo(25, 35); + ctx.stroke(); + + // Draw a green box over a red line, to check the line is not too large + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(75, 15); + ctx.lineTo(75, 35); + ctx.stroke(); + ctx.fillRect(65, 15, 20, 20); + + verify(Helper.comparePixel(ctx, 14,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 15,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 16,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 34,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 35,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 36,25, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 64,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 66,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 84,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 85,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 86,25, 0,255,0,255)); + + ctx.reset(); + ctx.lineWidth = 1.5; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = 0; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = -1; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = Infinity; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = -Infinity; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = NaN; + compare(ctx.lineWidth, 1.5); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(50, 50); + ctx.strokeStyle = '#0f0'; + ctx.moveTo(0, 0.5); + ctx.lineTo(2, 0.5); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,5, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 4; + // Draw a green line over a red box, to check the line is not too small + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(15, 15, 20, 20); + ctx.save(); + ctx.scale(5, 1); + ctx.beginPath(); + ctx.moveTo(5, 15); + ctx.lineTo(5, 35); + ctx.stroke(); + ctx.restore(); + + // Draw a green box over a red line, to check the line is not too large + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.save(); + ctx.scale(-5, 1); + ctx.beginPath(); + ctx.moveTo(-15, 15); + ctx.lineTo(-15, 35); + ctx.stroke(); + ctx.restore(); + ctx.fillRect(65, 15, 20, 20); + + verify(Helper.comparePixel(ctx, 14,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 15,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 16,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 34,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 35,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 36,25, 0,255,0,255)); + + //verify(Helper.comparePixel(ctx, 64,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 65,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 66,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 84,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 85,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 86,25, 0,255,0,255)); + + ctx.reset(); + ctx.lineWidth = 1.5; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = "1e1"; + compare(ctx.lineWidth, 10); + + ctx.lineWidth = 1/1024; + compare(ctx.lineWidth, 1/1024); + + ctx.lineWidth = 1000; + compare(ctx.lineWidth, 1000); + + } + function test_cap() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineCap = 'butt'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(15, 15, 20, 20); + ctx.beginPath(); + ctx.moveTo(25, 15); + ctx.lineTo(25, 35); + ctx.stroke(); + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(75, 15); + ctx.lineTo(75, 35); + ctx.stroke(); + ctx.fillRect(65, 15, 20, 20); + + verify(Helper.comparePixel(ctx, 25,14, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,16, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,34, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,36, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 75,14, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,16, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,34, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,36, 0,255,0,255)); + + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'bevel'; + ctx.lineCap = 'square'; + ctx.lineWidth = 400; + + ctx.beginPath(); + ctx.moveTo(200, 200); + ctx.lineTo(200, 1000); + ctx.lineTo(1000, 1000); + ctx.lineTo(1000, 200); + ctx.closePath(); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + ctx.reset(); + + ctx.lineCap = 'butt' + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'invalid'; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'ROUND'; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'round\\0'; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'round '; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = ""; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'bevel'; + compare(ctx.lineCap, 'butt'); + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'bevel'; + ctx.lineCap = 'square'; + ctx.lineWidth = 400; + + ctx.beginPath(); + ctx.moveTo(200, 200); + ctx.lineTo(200, 1000); + ctx.lineTo(1000, 1000); + ctx.lineTo(1000, 200); + ctx.lineTo(200, 200); + ctx.stroke(); + + //FIXME:!!! + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.lineCap = 'round'; + ctx.lineWidth = 20; + + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.beginPath(); + ctx.moveTo(35-tol, 15); + ctx.arc(25, 15, 10-tol, 0, Math.PI, true); + ctx.arc(25, 35, 10-tol, Math.PI, 0, true); + ctx.fill(); + + ctx.beginPath(); + ctx.moveTo(25, 15); + ctx.lineTo(25, 35); + ctx.stroke(); + + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + + ctx.beginPath(); + ctx.moveTo(75, 15); + ctx.lineTo(75, 35); + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(85+tol, 15); + ctx.arc(75, 15, 10+tol, 0, Math.PI, true); + ctx.arc(75, 35, 10+tol, Math.PI, 0, true); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 17,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 32,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 17,43, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,43, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 32,43, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 67,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 82,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 67,43, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,43, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 82,43, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineCap = 'square'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(15, 5, 20, 40); + ctx.beginPath(); + ctx.moveTo(25, 15); + ctx.lineTo(25, 35); + ctx.stroke(); + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(75, 15); + ctx.lineTo(75, 35); + ctx.stroke(); + ctx.fillRect(65, 5, 20, 40); + + verify(Helper.comparePixel(ctx, 25,4, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,5, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,46, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 75,4, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,5, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,46, 0,255,0,255)); + + ctx.reset(); + ctx.lineCap = 'butt' + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'round'; + compare(ctx.lineCap, 'round'); + + ctx.lineCap = 'square'; + compare(ctx.lineCap, 'square'); + + } + } +} \ No newline at end of file diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_path.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_path.qml new file mode 100644 index 0000000000..b04ccf5458 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_path.qml @@ -0,0 +1,1443 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper + +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "path"; when: windowShown + + function test_basic() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.closePath(); + ctx.fillStyle = '#f00'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.rect(0, 0, 100, 50); + ctx.restore(); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + canvas.width = 100; + ctx.rect(0, 0, 100, 50); + canvas.width = 100; + ctx.fillStyle = '#f00'; + ctx.fill(); + //verify(Helper.comparePixel(ctx, 20,20, 0,0,0,0)); + } + function test_beginPath() { + var ctx = canvas.getContext('2d'); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.rect(0, 0, 100, 50); + ctx.beginPath(); + ctx.fillStyle = '#f00'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_closePath() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.closePath(); + ctx.fillStyle = '#f00'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.moveTo(-100, 25); + ctx.lineTo(-100, -100); + ctx.lineTo(200, -100); + ctx.lineTo(200, 25); + ctx.closePath(); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.moveTo(-100, 25); + ctx.lineTo(-100, -1000); + ctx.closePath(); + ctx.lineTo(1000, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_isPointInPath() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.arc(50, 25, 10, 0, Math.PI, false); + verify(!ctx.isPointInPath(50, 10)); + verify(!ctx.isPointInPath(50, 20)); + //verify(!ctx.isPointInPath(50, 30)); + verify(!ctx.isPointInPath(50, 40)); + verify(!ctx.isPointInPath(30, 20)); + verify(!ctx.isPointInPath(70, 20)); + verify(!ctx.isPointInPath(30, 30)); + verify(!ctx.isPointInPath(70, 30)); + + ctx.reset(); + ctx.rect(0, 0, 20, 20); + verify(ctx.isPointInPath(10, 10)); + verify(!ctx.isPointInPath(30, 10)); + + ctx.reset(); + ctx.rect(20, 0, 20, 20); + //verify(ctx.isPointInPath(10, 10)); + verify(ctx.isPointInPath(30, 10)); + + ctx.reset(); + ctx.bezierCurveTo(50, -50, 50, 100, 75, 25); + verify(!ctx.isPointInPath(25, 20)); + verify(!ctx.isPointInPath(25, 30)); + //verify(ctx.isPointInPath(30, 20)); + verify(!ctx.isPointInPath(30, 30)); + //verify(!ctx.isPointInPath(40, 2)); + //verify(ctx.isPointInPath(40, 20)); + verify(!ctx.isPointInPath(40, 30)); + verify(!ctx.isPointInPath(40, 47)); + //verify(ctx.isPointInPath(45, 20)); + //verify(!ctx.isPointInPath(45, 30)); + //verify(!ctx.isPointInPath(55, 20)); + //verify(ctx.isPointInPath(55, 30)); + verify(!ctx.isPointInPath(60, 2)); + //verify(!ctx.isPointInPath(60, 20)); + verify(ctx.isPointInPath(60, 30)); + verify(!ctx.isPointInPath(60, 47)); + verify(!ctx.isPointInPath(70, 20)); + verify(ctx.isPointInPath(70, 30)); + verify(!ctx.isPointInPath(75, 20)); + verify(!ctx.isPointInPath(75, 30)); + + ctx.reset(); + ctx.arc(50, 25, 10, 0, 7, false); + verify(!ctx.isPointInPath(50, 10)); + //verify(ctx.isPointInPath(50, 20)); + //verify(ctx.isPointInPath(50, 30)); + verify(!ctx.isPointInPath(50, 40)); + verify(!ctx.isPointInPath(30, 20)); + verify(!ctx.isPointInPath(70, 20)); + verify(!ctx.isPointInPath(30, 30)); + //verify(!ctx.isPointInPath(70, 30)); + + ctx.reset(); + ctx.rect(0, 0, 20, 20); + verify(ctx.isPointInPath(0, 0)); + verify(ctx.isPointInPath(10, 0)); + //verify(ctx.isPointInPath(20, 0)); + //verify(ctx.isPointInPath(20, 10)); + //verify(ctx.isPointInPath(20, 20)); + //verify(ctx.isPointInPath(10, 20)); + //verify(ctx.isPointInPath(0, 20)); + verify(ctx.isPointInPath(0, 10)); + verify(!ctx.isPointInPath(10, -0.01)); + verify(!ctx.isPointInPath(10, 20.01)); + verify(!ctx.isPointInPath(-0.01, 10)); + //verify(!ctx.isPointInPath(20.01, 10)); + + ctx.reset(); + verify(!ctx.isPointInPath(0, 0)); + + + ctx.reset(); + ctx.rect(-100, -50, 200, 100); + //verify(ctx.isPointInPath(Infinity, 0)); + //verify(ctx.isPointInPath(-Infinity, 0)); + //verify(ctx.isPointInPath(NaN, 0)); + //verify(ctx.isPointInPath(0, Infinity)); + //verify(ctx.isPointInPath(0, -Infinity)); + //verify(ctx.isPointInPath(0, NaN)); + //verify(ctx.isPointInPath(NaN, NaN)); + + ctx.reset(); + ctx.rect(0, -100, 20, 20); + ctx.rect(20, -10, 20, 20); + verify(!ctx.isPointInPath(10, -110)); + verify(ctx.isPointInPath(10, -90)); + verify(!ctx.isPointInPath(10, -70)); + //verify(!ctx.isPointInPath(30, -20)); + //verify(ctx.isPointInPath(30, 0)); + //verify(!ctx.isPointInPath(30, 20)); + + ctx.reset(); + ctx.rect(0, 0, 20, 20); + ctx.beginPath(); + ctx.rect(20, 0, 20, 20); + ctx.closePath(); + ctx.rect(40, 0, 20, 20); + verify(!ctx.isPointInPath(10, 10)); + verify(ctx.isPointInPath(30, 10)); + verify(ctx.isPointInPath(50, 10)); + + ctx.reset(); + ctx.translate(50, 0); + ctx.rect(0, 0, 20, 20); + verify(!ctx.isPointInPath(-40, 10)); + verify(!ctx.isPointInPath(10, 10)); + //verify(!ctx.isPointInPath(49, 10)); + verify(ctx.isPointInPath(51, 10)); + verify(ctx.isPointInPath(69, 10)); + verify(!ctx.isPointInPath(71, 10)); + + ctx.reset(); + ctx.rect(50, 0, 20, 20); + ctx.translate(50, 0); + verify(!ctx.isPointInPath(-40, 10)); + verify(!ctx.isPointInPath(10, 10)); + //verify(!ctx.isPointInPath(49, 10)); + verify(ctx.isPointInPath(51, 10)); + verify(ctx.isPointInPath(69, 10)); + verify(!ctx.isPointInPath(71, 10)); + + ctx.reset(); + ctx.scale(-1, 1); + ctx.rect(-70, 0, 20, 20); + verify(!ctx.isPointInPath(-40, 10)); + verify(!ctx.isPointInPath(10, 10)); + //verify(!ctx.isPointInPath(49, 10)); + verify(ctx.isPointInPath(51, 10)); + verify(ctx.isPointInPath(69, 10)); + verify(!ctx.isPointInPath(71, 10)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(20, 0); + ctx.lineTo(20, 20); + ctx.lineTo(0, 20); + verify(ctx.isPointInPath(10, 10)); + //verify(!ctx.isPointInPath(30, 10)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(50, 0); + ctx.lineTo(50, 50); + ctx.lineTo(0, 50); + ctx.lineTo(0, 0); + ctx.lineTo(10, 10); + ctx.lineTo(10, 40); + ctx.lineTo(40, 40); + ctx.lineTo(40, 10); + ctx.lineTo(10, 10); + + verify(ctx.isPointInPath(5, 5)); + verify(ctx.isPointInPath(25, 5)); + verify(ctx.isPointInPath(45, 5)); + verify(ctx.isPointInPath(5, 25)); + verify(!ctx.isPointInPath(25, 25)); + verify(ctx.isPointInPath(45, 25)); + verify(ctx.isPointInPath(5, 45)); + verify(ctx.isPointInPath(25, 45)); + verify(ctx.isPointInPath(45, 45)); + } + + + function test_fill() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#00f'; + ctx.fillRect(0, 0, 100, 50); + + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.lineTo(100, 50); + ctx.fillStyle = '#f00'; + ctx.fill(); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 10,40, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#000'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.rect(0, 0, 100, 50); + ctx.closePath(); + ctx.rect(10, 10, 80, 30); + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255, 1)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.lineTo(0, 0); + ctx.lineTo(100, 0); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.lineTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.moveTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.lineTo(-20, -20); + ctx.lineTo(120, -20); + ctx.lineTo(120, 70); + ctx.lineTo(-20, 70); + ctx.lineTo(-20, -20); + ctx.lineTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + function test_stroke() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(40, 25); + ctx.moveTo(60, 25); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#000'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.lineWidth = 50; + ctx.moveTo(0, 20); + ctx.lineTo(100, 20); + ctx.moveTo(0, 30); + ctx.lineTo(100, 30); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arcTo(50, 25, 150, 25, 10); + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 10, 0, 0, false); + ctx.stroke(); + + // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.lineTo(50, 25); + ctx.closePath(); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 400; + ctx.lineJoin = 'miter'; + ctx.miterLimit = 1.4; + + ctx.beginPath(); + ctx.moveTo(-1000, 200, 0, 0); + ctx.lineTo(-100, 200); + ctx.lineTo(-100, 200); + ctx.lineTo(-100, 200); + ctx.lineTo(-100, 1000); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.quadraticCurveTo(50, 25, 50, 25); + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.bezierCurveTo(50, 25, 50, 25, 50, 25); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.lineTo(50, 25); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.rect(50, 25, 0, 0); + ctx.stroke(); + + ctx.strokeRect(50, 25, 0, 0); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(25, 12.5, 50, 25); + ctx.save(); + ctx.scale(50, 25); + ctx.strokeStyle = '#0f0'; + ctx.stroke(); + ctx.restore(); + + ctx.beginPath(); + ctx.rect(-25, -12.5, 150, 75); + ctx.save(); + ctx.scale(50, 25); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + ctx.restore(); + + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(25, 12.5, 50, 25); + ctx.save(); + ctx.rotate(Math.PI/2); + ctx.scale(25, 50); + ctx.strokeStyle = '#0f0'; + ctx.stroke(); + ctx.restore(); + + ctx.beginPath(); + ctx.rect(-25, -12.5, 150, 75); + ctx.save(); + ctx.rotate(Math.PI/2); + ctx.scale(25, 50); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + ctx.restore(); + + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.save(); + ctx.beginPath(); + ctx.moveTo(49, -50); + ctx.lineTo(201, -50); + ctx.rotate(Math.PI/4); + ctx.scale(1, 283); + ctx.strokeStyle = '#0f0'; + ctx.stroke(); + ctx.restore(); + + ctx.save(); + ctx.beginPath(); + ctx.translate(-150, 0); + ctx.moveTo(49, -50); + ctx.lineTo(199, -50); + ctx.rotate(Math.PI/4); + ctx.scale(1, 142); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + ctx.restore(); + + ctx.save(); + ctx.beginPath(); + ctx.translate(-150, 0); + ctx.moveTo(49, -50); + ctx.lineTo(199, -50); + ctx.rotate(Math.PI/4); + ctx.scale(1, 142); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + ctx.restore(); + + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 50; + ctx.moveTo(-100, 25); + ctx.lineTo(-100, -100); + ctx.lineTo(200, -100); + ctx.lineTo(200, 25); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + + ctx.closePath(); + ctx.strokeStyle = '#0f0'; + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 40; + ctx.moveTo(0, 10); + ctx.lineTo(100, 10); + ctx.moveTo(100, 40); + ctx.lineTo(0, 40); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + function test_clip() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(0, 0, 100, 50); + ctx.clip(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(-100, 0, 100, 50); + ctx.clip(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.clip(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(0, 0, 50, 50); + ctx.clip(); + ctx.beginPath(); + ctx.rect(50, 0, 50, 50) + ctx.clip(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.clip(); + + ctx.lineTo(0, 0); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.lineTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.clip(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.clip(); + + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.lineTo(0, 0); + ctx.clip(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_moveTo() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.rect(0, 0, 10, 50); + ctx.moveTo(100, 0); + ctx.lineTo(10, 0); + ctx.lineTo(10, 50); + ctx.lineTo(100, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 90,25, 0,255,0,255)); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.moveTo(0, 25); + ctx.moveTo(100, 25); + ctx.moveTo(0, 25); + ctx.lineTo(100, 25); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.moveTo(100, 0); + ctx.moveTo(100, 50); + ctx.moveTo(0, 50); + ctx.fillStyle = '#f00'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.moveTo(Infinity, 50); + ctx.moveTo(-Infinity, 50); + ctx.moveTo(NaN, 50); + ctx.moveTo(0, Infinity); + ctx.moveTo(0, -Infinity); + ctx.moveTo(0, NaN); + ctx.moveTo(Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_lineTo() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.lineTo(100, 50); + ctx.stroke(); + // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.lineTo(0, 25); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(-100, -100); + ctx.lineTo(0, 25); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.lineTo(Infinity, 50); + ctx.lineTo(-Infinity, 50); + ctx.lineTo(NaN, 50); + ctx.lineTo(0, Infinity); + ctx.lineTo(0, -Infinity); + ctx.lineTo(0, NaN); + ctx.lineTo(Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + } + function test_bezierCurveTo() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.bezierCurveTo(100, 25, 100, 25, 100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.bezierCurveTo(100, 50, 200, 50, 200, 50); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.bezierCurveTo(0, 25, 100, 25, 100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.bezierCurveTo(Infinity, 50, 0, 50, 0, 50); + ctx.bezierCurveTo(-Infinity, 50, 0, 50, 0, 50); + ctx.bezierCurveTo(NaN, 50, 0, 50, 0, 50); + ctx.bezierCurveTo(0, Infinity, 0, 50, 0, 50); + ctx.bezierCurveTo(0, -Infinity, 0, 50, 0, 50); + ctx.bezierCurveTo(0, NaN, 0, 50, 0, 50); + ctx.bezierCurveTo(0, 50, Infinity, 50, 0, 50); + ctx.bezierCurveTo(0, 50, -Infinity, 50, 0, 50); + ctx.bezierCurveTo(0, 50, NaN, 50, 0, 50); + ctx.bezierCurveTo(0, 50, 0, Infinity, 0, 50); + ctx.bezierCurveTo(0, 50, 0, -Infinity, 0, 50); + ctx.bezierCurveTo(0, 50, 0, NaN, 0, 50); + ctx.bezierCurveTo(0, 50, 0, 50, Infinity, 50); + ctx.bezierCurveTo(0, 50, 0, 50, -Infinity, 50); + ctx.bezierCurveTo(0, 50, 0, 50, NaN, 50); + ctx.bezierCurveTo(0, 50, 0, 50, 0, Infinity); + ctx.bezierCurveTo(0, 50, 0, 50, 0, -Infinity); + ctx.bezierCurveTo(0, 50, 0, 50, 0, NaN); + ctx.bezierCurveTo(Infinity, Infinity, 0, 50, 0, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, 0, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, 0, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, Infinity, 0, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, 0, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, 50, 0, Infinity); + ctx.bezierCurveTo(0, Infinity, Infinity, 50, 0, 50); + ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(0, Infinity, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(0, Infinity, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(0, Infinity, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(0, Infinity, 0, Infinity, 0, 50); + ctx.bezierCurveTo(0, Infinity, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(0, Infinity, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(0, Infinity, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(0, Infinity, 0, 50, Infinity, 50); + ctx.bezierCurveTo(0, Infinity, 0, 50, Infinity, Infinity); + ctx.bezierCurveTo(0, Infinity, 0, 50, 0, Infinity); + ctx.bezierCurveTo(0, 50, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(0, 50, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(0, 50, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(0, 50, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(0, 50, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(0, 50, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(0, 50, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(0, 50, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(0, 50, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(0, 50, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(0, 50, 0, 50, Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.scale(1000, 1000); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 0.055; + ctx.beginPath(); + ctx.moveTo(-2, 3.1); + ctx.bezierCurveTo(-2, -1, 2.1, -1, 2.1, 3.1); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 55; + ctx.beginPath(); + ctx.moveTo(-2000, 3100); + ctx.bezierCurveTo(-2000, -1000, 2100, -1000, 2100, 3100); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + } + function test_quadraticCurveTo() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.quadraticCurveTo(100, 25, 100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.quadraticCurveTo(100, 50, 200, 50); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.quadraticCurveTo(0, 25, 100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.quadraticCurveTo(Infinity, 50, 0, 50); + ctx.quadraticCurveTo(-Infinity, 50, 0, 50); + ctx.quadraticCurveTo(NaN, 50, 0, 50); + ctx.quadraticCurveTo(0, Infinity, 0, 50); + ctx.quadraticCurveTo(0, -Infinity, 0, 50); + ctx.quadraticCurveTo(0, NaN, 0, 50); + ctx.quadraticCurveTo(0, 50, Infinity, 50); + ctx.quadraticCurveTo(0, 50, -Infinity, 50); + ctx.quadraticCurveTo(0, 50, NaN, 50); + ctx.quadraticCurveTo(0, 50, 0, Infinity); + ctx.quadraticCurveTo(0, 50, 0, -Infinity); + ctx.quadraticCurveTo(0, 50, 0, NaN); + ctx.quadraticCurveTo(Infinity, Infinity, 0, 50); + ctx.quadraticCurveTo(Infinity, Infinity, Infinity, 50); + ctx.quadraticCurveTo(Infinity, Infinity, Infinity, Infinity); + ctx.quadraticCurveTo(Infinity, Infinity, 0, Infinity); + ctx.quadraticCurveTo(Infinity, 50, Infinity, 50); + ctx.quadraticCurveTo(Infinity, 50, Infinity, Infinity); + ctx.quadraticCurveTo(Infinity, 50, 0, Infinity); + ctx.quadraticCurveTo(0, Infinity, Infinity, 50); + ctx.quadraticCurveTo(0, Infinity, Infinity, Infinity); + ctx.quadraticCurveTo(0, Infinity, 0, Infinity); + ctx.quadraticCurveTo(0, 50, Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.scale(1000, 1000); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 0.055; + ctx.beginPath(); + ctx.moveTo(-1, 1.05); + ctx.quadraticCurveTo(0, -1, 1.2, 1.05); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 55; + ctx.beginPath(); + ctx.moveTo(-1000, 1050); + ctx.quadraticCurveTo(0, -1000, 1200, 1050); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + function test_rect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.rect(0, 0, 100, 50); + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 200; + ctx.lineJoin = 'miter'; + ctx.rect(100, 50, 100, 100); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.rect(200, 100, 400, 1000); + ctx.lineTo(-2000, -1000); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 450; + ctx.lineCap = 'round'; + ctx.lineJoin = 'bevel'; + ctx.rect(150, 150, 2000, 2000); + ctx.lineTo(160, 160); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.beginPath(); + ctx.fillStyle = '#0f0'; + ctx.rect(0, 0, 50, 25); + ctx.rect(100, 0, -50, 25); + ctx.rect(0, 50, 50, -25); + ctx.rect(100, 50, -50, -25); + ctx.fill(); + verify(Helper.comparePixel(ctx, 25,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,37, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,37, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.beginPath(); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.moveTo(-100, 25); + ctx.lineTo(-50, 25); + ctx.rect(200, 25, 1, 1); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.rect(Infinity, 50, 1, 1); + ctx.rect(-Infinity, 50, 1, 1); + ctx.rect(NaN, 50, 1, 1); + ctx.rect(0, Infinity, 1, 1); + ctx.rect(0, -Infinity, 1, 1); + ctx.rect(0, NaN, 1, 1); + ctx.rect(0, 50, Infinity, 1); + ctx.rect(0, 50, -Infinity, 1); + ctx.rect(0, 50, NaN, 1); + ctx.rect(0, 50, 1, Infinity); + ctx.rect(0, 50, 1, -Infinity); + ctx.rect(0, 50, 1, NaN); + ctx.rect(Infinity, Infinity, 1, 1); + ctx.rect(Infinity, Infinity, Infinity, 1); + ctx.rect(Infinity, Infinity, Infinity, Infinity); + ctx.rect(Infinity, Infinity, 1, Infinity); + ctx.rect(Infinity, 50, Infinity, 1); + ctx.rect(Infinity, 50, Infinity, Infinity); + ctx.rect(Infinity, 50, 1, Infinity); + ctx.rect(0, Infinity, Infinity, 1); + ctx.rect(0, Infinity, Infinity, Infinity); + ctx.rect(0, Infinity, 1, Infinity); + ctx.rect(0, 50, Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 90; + ctx.beginPath(); + ctx.rect(45, 20, 10, 10); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.beginPath(); + ctx.fillStyle = '#f00'; + ctx.rect(0, 0, 50, 50); + ctx.rect(100, 50, -50, -50); + ctx.rect(0, 25, 100, -25); + ctx.rect(100, 25, -100, 25); + ctx.fill(); + verify(Helper.comparePixel(ctx, 25,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,37, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,37, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.rect(0, 50, 100, 0); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.rect(50, -100, 0, 250); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.rect(50, 25, 0, 0); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.rect(100, 25, 0, 0); + ctx.lineTo(0, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.moveTo(0, 0); + ctx.rect(100, 25, 0, 0); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineJoin = 'miter'; + ctx.miterLimit = 1.5; + ctx.lineWidth = 200; + ctx.beginPath(); + ctx.rect(100, 25, 1000, 0); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_clearRect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.rect(0, 0, 100, 50); + ctx.clearRect(0, 0, 16, 16); + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_fillRect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.beginPath(); + ctx.rect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 16, 16); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_strokeRect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.beginPath(); + ctx.rect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 5; + ctx.strokeRect(0, 0, 16, 16); + ctx.fillStyle = '#0f0'; + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(-100, 0); + ctx.rect(100, 0, 100, 50); + ctx.translate(0, -100); + ctx.fillStyle = '#0f0'; + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.moveTo(0, 0); + ctx.translate(100, 0); + ctx.lineTo(0, 0); + ctx.translate(0, 50); + ctx.lineTo(0, 0); + ctx.translate(-100, 0); + ctx.lineTo(0, 0); + ctx.translate(1000, 1000); + ctx.rotate(Math.PI/2); + ctx.scale(0.1, 0.1); + ctx.fill(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.translate(-100, 0); + ctx.rect(0, 0, 100, 50); + ctx.fill(); + ctx.translate(100, 0); + ctx.fill(); + + ctx.beginPath(); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.translate(0, -50); + ctx.moveTo(0, 25); + ctx.lineTo(100, 25); + ctx.stroke(); + ctx.translate(0, 50); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_pattern.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_pattern.qml new file mode 100644 index 0000000000..dd5b6628e8 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_pattern.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + //TODO + name: "pattern"; when: windowShown + function test_basic() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_animated() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_image() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_modified() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_paint() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_repeat() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_pixel.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_pixel.qml new file mode 100644 index 0000000000..1a3793d7a3 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_pixel.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + //TODO + name: "pixel"; when: windowShown + function test_createImageData() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_getImageData() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_object() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_putImageData() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_filters() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_shadow.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_shadow.qml new file mode 100644 index 0000000000..4405ca6c0e --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_shadow.qml @@ -0,0 +1,59 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + //TODO + + name: "shadow"; when: windowShown + function test_basic() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_blur() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + + function test_clip() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + + function test_composite() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + + function test_enable() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + + function test_gradient() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_image() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_offset() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_pattern() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_stroke() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_tranform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_state.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_state.qml new file mode 100644 index 0000000000..f0040ce0a4 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_state.qml @@ -0,0 +1,389 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "state"; when: windowShown + function test_bitmap() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.restore(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_clip() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.rect(0, 0, 1, 1); + ctx.clip(); + ctx.restore(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + function test_fillStyle() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + // Test that restore() undoes any modifications + var old = ctx.fillStyle; + ctx.save(); + ctx.fillStyle = "#ff0000"; + ctx.restore(); + compare(ctx.fillStyle, old); + + // Also test that save() doesn't modify the values + ctx.fillStyle = "#ff0000"; + old = ctx.fillStyle; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "#ff0000" + ctx.save(); + compare(ctx.fillStyle, old); + ctx.restore(); + } + function test_font() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.font; + ctx.save(); + ctx.font = "25px serif"; + ctx.restore(); + compare(ctx.font, old); + + // Also test that save() doesn't modify the values + ctx.font = "25px serif"; + old = ctx.font; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "25px serif" + ctx.save(); + compare(ctx.font, old); + ctx.restore(); + } + function test_globalAlpha() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.globalAlpha; + ctx.save(); + ctx.globalAlpha = 0.5; + ctx.restore(); + compare(ctx.globalAlpha, old); + + // Also test that save() doesn't modify the values + ctx.globalAlpha = 0.5; + old = ctx.globalAlpha; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 0.5 + ctx.save(); + compare(ctx.globalAlpha, old); + ctx.restore(); + } + function test_globalCompositeOperation() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.globalCompositeOperation; + ctx.save(); + ctx.globalCompositeOperation = "copy"; + ctx.restore(); + compare(ctx.globalCompositeOperation, old); + + // Also test that save() doesn't modify the values + ctx.globalCompositeOperation = "copy"; + old = ctx.globalCompositeOperation; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "copy" + ctx.save(); + compare(ctx.globalCompositeOperation, old); + ctx.restore(); + } + function test_lineCap() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.lineCap; + ctx.save(); + ctx.lineCap = "round"; + ctx.restore(); + compare(ctx.lineCap, old); + + // Also test that save() doesn't modify the values + ctx.lineCap = "round"; + old = ctx.lineCap; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "round" + ctx.save(); + compare(ctx.lineCap, old); + ctx.restore(); + } + function test_lineJoin() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.lineJoin; + ctx.save(); + ctx.lineJoin = "round"; + ctx.restore(); + compare(ctx.lineJoin, old); + + // Also test that save() doesn't modify the values + ctx.lineJoin = "round"; + old = ctx.lineJoin; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "round" + ctx.save(); + compare(ctx.lineJoin, old); + ctx.restore(); + } + function test_lineWidth() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.lineJoin; + ctx.save(); + ctx.lineJoin = "round"; + ctx.restore(); + compare(ctx.lineJoin, old, "ctx.lineJoin", "old"); + + // Also test that save() doesn't modify the values + ctx.lineJoin = "round"; + old = ctx.lineJoin; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "round" + ctx.save(); + compare(ctx.lineJoin, old); + ctx.restore(); + } + function test_miterLimit() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.miterLimit; + ctx.save(); + ctx.miterLimit = 0.5; + ctx.restore(); + compare(ctx.miterLimit, old); + + // Also test that save() doesn't modify the values + ctx.miterLimit = 0.5; + old = ctx.miterLimit; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 0.5 + ctx.save(); + compare(ctx.miterLimit, old); + ctx.restore(); + } + function test_path() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.rect(0, 0, 100, 50); + ctx.restore(); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_shadow() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.shadowBlur; + ctx.save(); + ctx.shadowBlur = 5; + ctx.restore(); + compare(ctx.shadowBlur, old); + + // Also test that save() doesn't modify the values + ctx.shadowBlur = 5; + old = ctx.shadowBlur; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 5 + ctx.save(); + compare(ctx.shadowBlur, old); + ctx.restore(); + + // Test that restore() undoes any modifications + var old = ctx.shadowColor; + ctx.save(); + ctx.shadowColor = "#ff0000"; + ctx.restore(); + compare(ctx.shadowColor, old); + + // Also test that save() doesn't modify the values + ctx.shadowColor = "#ff0000"; + old = ctx.shadowColor; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "#ff0000" + ctx.save(); + compare(ctx.shadowColor, old); + ctx.restore(); + + // Test that restore() undoes any modifications + var old = ctx.shadowOffsetX; + ctx.save(); + ctx.shadowOffsetX = 5; + ctx.restore(); + compare(ctx.shadowOffsetX, old); + + // Also test that save() doesn't modify the values + ctx.shadowOffsetX = 5; + old = ctx.shadowOffsetX; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 5 + ctx.save(); + compare(ctx.shadowOffsetX, old); + ctx.restore(); + + // Test that restore() undoes any modifications + var old = ctx.shadowOffsetY; + ctx.save(); + ctx.shadowOffsetY = 5; + ctx.restore(); + compare(ctx.shadowOffsetY, old); + + // Also test that save() doesn't modify the values + ctx.shadowOffsetY = 5; + old = ctx.shadowOffsetY; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 5 + ctx.save(); + compare(ctx.shadowOffsetY, old); + ctx.restore(); + + } + function test_stack() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.lineWidth = 1; + ctx.save(); + ctx.lineWidth = 2; + ctx.save(); + ctx.lineWidth = 3; + compare(ctx.lineWidth, 3); + ctx.restore(); + compare(ctx.lineWidth, 2); + ctx.restore(); + compare(ctx.lineWidth, 1); + + var limit = 512; + for (var i = 1; i < limit; ++i) + { + ctx.save(); + ctx.lineWidth = i; + } + for (var i = limit-1; i > 0; --i) + { + compare(ctx.lineWidth, i); + ctx.restore(); + } + + for (var i = 0; i < 16; ++i) + ctx.restore(); + ctx.lineWidth = 0.5; + ctx.restore(); + compare(ctx.lineWidth, 0.5); + + } + function test_strokeStyle() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.strokeStyle; + ctx.save(); + ctx.strokeStyle = "#ff0000"; + ctx.restore(); + compare(ctx.strokeStyle, old); + + // Also test that save() doesn't modify the values + ctx.strokeStyle = "#ff0000"; + old = ctx.strokeStyle; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "#ff0000" + ctx.save(); + compare(ctx.strokeStyle, old); + ctx.restore(); + + + } + + function test_text() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.textAlign; + ctx.save(); + ctx.textAlign = "center"; + ctx.restore(); + compare(ctx.textAlign, old); + + // Also test that save() doesn't modify the values + ctx.textAlign = "center"; + old = ctx.textAlign; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "center" + ctx.save(); + compare(ctx.textAlign, old); + ctx.restore(); + + // Test that restore() undoes any modifications + var old = ctx.textBaseline; + ctx.save(); + ctx.textBaseline = "bottom"; + ctx.restore(); + compare(ctx.textBaseline, old); + + // Also test that save() doesn't modify the values + ctx.textBaseline = "bottom"; + old = ctx.textBaseline; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "bottom" + ctx.save(); + compare(ctx.textBaseline, old); + ctx.restore(); + + + } + + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.translate(200, 0); + ctx.restore(); + ctx.fillStyle = '#f00'; + ctx.fillRect(-200, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + } + + + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_strokeStyle.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_strokeStyle.qml index 84f830d636..6b42f8a770 100644 --- a/tests/auto/declarative/qsgcanvasitem/data/tst_strokeStyle.qml +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_strokeStyle.qml @@ -3,7 +3,7 @@ import QtTest 1.0 import "testhelper.js" as Helper Canvas { - id:canvas; width:1;height:1 + id:canvas; width:100;height:50; renderTarget:Canvas.Image TestCase { name: "strokeStyle"; when: windowShown function test_default() { diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_text.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_text.qml new file mode 100644 index 0000000000..baeb17c9fb --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_text.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + //TODO + name: "text"; when: windowShown + function test_baseLine() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_align() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_stroke() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_fill() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_font() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_measure() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_transform.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_transform.qml new file mode 100644 index 0000000000..834a22f549 --- /dev/null +++ b/tests/auto/declarative/qsgcanvasitem/data/tst_transform.qml @@ -0,0 +1,487 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "transform"; when: windowShown + function test_order() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(2, 1); + ctx.rotate(Math.PI / 2); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, -50, 50, 50); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + } + function test_rotate() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(Math.PI / 2); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, -100, 50, 100); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.rotate(Infinity); + ctx.rotate(-Infinity); + ctx.rotate(NaN); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(Math.PI); // should fail obviously if this is 3.1 degrees + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(Math.PI * (1 + 4096)); // == pi (mod 2*pi) + // We need about pi +/- 0.001 in order to get correct-looking results + // 32-bit floats can store pi*4097 with precision 2^-10, so that should + // be safe enough on reasonable implementations + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,2, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,47, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(-Math.PI * (1 + 4096)); + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,2, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,47, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(0); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + } + function test_scale() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(2, 4); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 12.5); + verify(Helper.comparePixel(ctx, 90,40, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(1e5, 1e5); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 1, 1); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(Math.sqrt(2), Math.sqrt(2)); + ctx.scale(Math.sqrt(2), Math.sqrt(2)); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 25); + verify(Helper.comparePixel(ctx, 90,40, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.save(); + ctx.scale(-1, 1); + ctx.fillStyle = '#0f0'; + ctx.fillRect(-50, 0, 50, 50); + ctx.restore(); + + ctx.save(); + ctx.scale(1, -1); + ctx.fillStyle = '#0f0'; + ctx.fillRect(50, -50, 50, 50); + ctx.restore(); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.scale(Infinity, 0.1); + ctx.scale(-Infinity, 0.1); + ctx.scale(NaN, 0.1); + ctx.scale(0.1, Infinity); + ctx.scale(0.1, -Infinity); + ctx.scale(0.1, NaN); + ctx.scale(Infinity, Infinity); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.save(); + ctx.translate(50, 0); + ctx.scale(0, 1); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.restore(); + + ctx.save(); + ctx.translate(0, 25); + ctx.scale(1, 0); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.restore(); + + // Firefox has a bug where it renders the canvas as empty and toDataURL throws an exception + canvas.toDataURL(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_setTransform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.setTransform(1/2,0, 0,1/2, 0,0); + ctx.setTransform(2,0, 0,2, 0,0); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 25); + verify(Helper.comparePixel(ctx, 75,35, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.setTransform(Infinity, 0, 0, 0, 0, 0); + ctx.setTransform(-Infinity, 0, 0, 0, 0, 0); + ctx.setTransform(NaN, 0, 0, 0, 0, 0); + ctx.setTransform(0, Infinity, 0, 0, 0, 0); + ctx.setTransform(0, -Infinity, 0, 0, 0, 0); + ctx.setTransform(0, NaN, 0, 0, 0, 0); + ctx.setTransform(0, 0, Infinity, 0, 0, 0); + ctx.setTransform(0, 0, -Infinity, 0, 0, 0); + ctx.setTransform(0, 0, NaN, 0, 0, 0); + ctx.setTransform(0, 0, 0, Infinity, 0, 0); + ctx.setTransform(0, 0, 0, -Infinity, 0, 0); + ctx.setTransform(0, 0, 0, NaN, 0, 0); + ctx.setTransform(0, 0, 0, 0, Infinity, 0); + ctx.setTransform(0, 0, 0, 0, -Infinity, 0); + ctx.setTransform(0, 0, 0, 0, NaN, 0); + ctx.setTransform(0, 0, 0, 0, 0, Infinity); + ctx.setTransform(0, 0, 0, 0, 0, -Infinity); + ctx.setTransform(0, 0, 0, 0, 0, NaN); + ctx.setTransform(Infinity, Infinity, 0, 0, 0, 0); + ctx.setTransform(Infinity, Infinity, Infinity, 0, 0, 0); + ctx.setTransform(Infinity, Infinity, Infinity, Infinity, 0, 0); + ctx.setTransform(Infinity, Infinity, Infinity, Infinity, Infinity, 0); + ctx.setTransform(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.setTransform(Infinity, Infinity, Infinity, Infinity, 0, Infinity); + ctx.setTransform(Infinity, Infinity, Infinity, 0, Infinity, 0); + ctx.setTransform(Infinity, Infinity, Infinity, 0, Infinity, Infinity); + ctx.setTransform(Infinity, Infinity, Infinity, 0, 0, Infinity); + ctx.setTransform(Infinity, Infinity, 0, Infinity, 0, 0); + ctx.setTransform(Infinity, Infinity, 0, Infinity, Infinity, 0); + ctx.setTransform(Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.setTransform(Infinity, Infinity, 0, Infinity, 0, Infinity); + ctx.setTransform(Infinity, Infinity, 0, 0, Infinity, 0); + ctx.setTransform(Infinity, Infinity, 0, 0, Infinity, Infinity); + ctx.setTransform(Infinity, Infinity, 0, 0, 0, Infinity); + ctx.setTransform(Infinity, 0, Infinity, 0, 0, 0); + ctx.setTransform(Infinity, 0, Infinity, Infinity, 0, 0); + ctx.setTransform(Infinity, 0, Infinity, Infinity, Infinity, 0); + ctx.setTransform(Infinity, 0, Infinity, Infinity, Infinity, Infinity); + ctx.setTransform(Infinity, 0, Infinity, Infinity, 0, Infinity); + ctx.setTransform(Infinity, 0, Infinity, 0, Infinity, 0); + ctx.setTransform(Infinity, 0, Infinity, 0, Infinity, Infinity); + ctx.setTransform(Infinity, 0, Infinity, 0, 0, Infinity); + ctx.setTransform(Infinity, 0, 0, Infinity, 0, 0); + ctx.setTransform(Infinity, 0, 0, Infinity, Infinity, 0); + ctx.setTransform(Infinity, 0, 0, Infinity, Infinity, Infinity); + ctx.setTransform(Infinity, 0, 0, Infinity, 0, Infinity); + ctx.setTransform(Infinity, 0, 0, 0, Infinity, 0); + ctx.setTransform(Infinity, 0, 0, 0, Infinity, Infinity); + ctx.setTransform(Infinity, 0, 0, 0, 0, Infinity); + ctx.setTransform(0, Infinity, Infinity, 0, 0, 0); + ctx.setTransform(0, Infinity, Infinity, Infinity, 0, 0); + ctx.setTransform(0, Infinity, Infinity, Infinity, Infinity, 0); + ctx.setTransform(0, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.setTransform(0, Infinity, Infinity, Infinity, 0, Infinity); + ctx.setTransform(0, Infinity, Infinity, 0, Infinity, 0); + ctx.setTransform(0, Infinity, Infinity, 0, Infinity, Infinity); + ctx.setTransform(0, Infinity, Infinity, 0, 0, Infinity); + ctx.setTransform(0, Infinity, 0, Infinity, 0, 0); + ctx.setTransform(0, Infinity, 0, Infinity, Infinity, 0); + ctx.setTransform(0, Infinity, 0, Infinity, Infinity, Infinity); + ctx.setTransform(0, Infinity, 0, Infinity, 0, Infinity); + ctx.setTransform(0, Infinity, 0, 0, Infinity, 0); + ctx.setTransform(0, Infinity, 0, 0, Infinity, Infinity); + ctx.setTransform(0, Infinity, 0, 0, 0, Infinity); + ctx.setTransform(0, 0, Infinity, Infinity, 0, 0); + ctx.setTransform(0, 0, Infinity, Infinity, Infinity, 0); + ctx.setTransform(0, 0, Infinity, Infinity, Infinity, Infinity); + ctx.setTransform(0, 0, Infinity, Infinity, 0, Infinity); + ctx.setTransform(0, 0, Infinity, 0, Infinity, 0); + ctx.setTransform(0, 0, Infinity, 0, Infinity, Infinity); + ctx.setTransform(0, 0, Infinity, 0, 0, Infinity); + ctx.setTransform(0, 0, 0, Infinity, Infinity, 0); + ctx.setTransform(0, 0, 0, Infinity, Infinity, Infinity); + ctx.setTransform(0, 0, 0, Infinity, 0, Infinity); + ctx.setTransform(0, 0, 0, 0, Infinity, Infinity); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + // Create green with a red square ring inside it + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.fillRect(20, 10, 60, 30); + ctx.fillStyle = '#0f0'; + ctx.fillRect(40, 20, 20, 10); + + // Draw a skewed shape to fill that gap, to make sure it is aligned correctly + ctx.setTransform(1,4, 2,3, 5,6); + // Post-transform coordinates: + // [[20,10],[80,10],[80,40],[20,40],[20,10],[40,20],[40,30],[60,30],[60,20],[40,20],[20,10]]; + // Hence pre-transform coordinates: + var pts=[[-7.4,11.2],[-43.4,59.2],[-31.4,53.2],[4.6,5.2],[-7.4,11.2], + [-15.4,25.2],[-11.4,23.2],[-23.4,39.2],[-27.4,41.2],[-15.4,25.2], + [-7.4,11.2]]; + ctx.beginPath(); + ctx.moveTo(pts[0][0], pts[0][1]); + for (var i = 0; i < pts.length; ++i) + ctx.lineTo(pts[i][0], pts[i][1]); + ctx.fill(); + /* + //FIXME: + verify(Helper.comparePixel(ctx, 21,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 21,39, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,39, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 61,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,31, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 61,31, 0,255,0,255)); + */ + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.transform(1,0, 0,1, 0,0); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.transform(1,2, 3,4, 5,6); + ctx.transform(-2,1, 3/2,-1/2, 1,-2); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.transform(Infinity, 0, 0, 0, 0, 0); + ctx.transform(-Infinity, 0, 0, 0, 0, 0); + ctx.transform(NaN, 0, 0, 0, 0, 0); + ctx.transform(0, Infinity, 0, 0, 0, 0); + ctx.transform(0, -Infinity, 0, 0, 0, 0); + ctx.transform(0, NaN, 0, 0, 0, 0); + ctx.transform(0, 0, Infinity, 0, 0, 0); + ctx.transform(0, 0, -Infinity, 0, 0, 0); + ctx.transform(0, 0, NaN, 0, 0, 0); + ctx.transform(0, 0, 0, Infinity, 0, 0); + ctx.transform(0, 0, 0, -Infinity, 0, 0); + ctx.transform(0, 0, 0, NaN, 0, 0); + ctx.transform(0, 0, 0, 0, Infinity, 0); + ctx.transform(0, 0, 0, 0, -Infinity, 0); + ctx.transform(0, 0, 0, 0, NaN, 0); + ctx.transform(0, 0, 0, 0, 0, Infinity); + ctx.transform(0, 0, 0, 0, 0, -Infinity); + ctx.transform(0, 0, 0, 0, 0, NaN); + ctx.transform(Infinity, Infinity, 0, 0, 0, 0); + ctx.transform(Infinity, Infinity, Infinity, 0, 0, 0); + ctx.transform(Infinity, Infinity, Infinity, Infinity, 0, 0); + ctx.transform(Infinity, Infinity, Infinity, Infinity, Infinity, 0); + ctx.transform(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.transform(Infinity, Infinity, Infinity, Infinity, 0, Infinity); + ctx.transform(Infinity, Infinity, Infinity, 0, Infinity, 0); + ctx.transform(Infinity, Infinity, Infinity, 0, Infinity, Infinity); + ctx.transform(Infinity, Infinity, Infinity, 0, 0, Infinity); + ctx.transform(Infinity, Infinity, 0, Infinity, 0, 0); + ctx.transform(Infinity, Infinity, 0, Infinity, Infinity, 0); + ctx.transform(Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.transform(Infinity, Infinity, 0, Infinity, 0, Infinity); + ctx.transform(Infinity, Infinity, 0, 0, Infinity, 0); + ctx.transform(Infinity, Infinity, 0, 0, Infinity, Infinity); + ctx.transform(Infinity, Infinity, 0, 0, 0, Infinity); + ctx.transform(Infinity, 0, Infinity, 0, 0, 0); + ctx.transform(Infinity, 0, Infinity, Infinity, 0, 0); + ctx.transform(Infinity, 0, Infinity, Infinity, Infinity, 0); + ctx.transform(Infinity, 0, Infinity, Infinity, Infinity, Infinity); + ctx.transform(Infinity, 0, Infinity, Infinity, 0, Infinity); + ctx.transform(Infinity, 0, Infinity, 0, Infinity, 0); + ctx.transform(Infinity, 0, Infinity, 0, Infinity, 0); + ctx.transform(Infinity, 0, Infinity, 0, Infinity, Infinity); + ctx.transform(Infinity, 0, Infinity, 0, 0, Infinity); + ctx.transform(Infinity, 0, 0, Infinity, 0, 0); + ctx.transform(Infinity, 0, 0, Infinity, Infinity, 0); + ctx.transform(Infinity, 0, 0, Infinity, Infinity, Infinity); + ctx.transform(Infinity, 0, 0, Infinity, 0, Infinity); + ctx.transform(Infinity, 0, 0, 0, Infinity, 0); + ctx.transform(Infinity, 0, 0, 0, Infinity, Infinity); + ctx.transform(Infinity, 0, 0, 0, 0, Infinity); + ctx.transform(0, Infinity, Infinity, 0, 0, 0); + ctx.transform(0, Infinity, Infinity, Infinity, 0, 0); + ctx.transform(0, Infinity, Infinity, Infinity, Infinity, 0); + ctx.transform(0, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.transform(0, Infinity, Infinity, Infinity, 0, Infinity); + ctx.transform(0, Infinity, Infinity, 0, Infinity, 0); + ctx.transform(0, Infinity, Infinity, 0, Infinity, Infinity); + ctx.transform(0, Infinity, Infinity, 0, 0, Infinity); + ctx.transform(0, Infinity, 0, Infinity, 0, 0); + ctx.transform(0, Infinity, 0, Infinity, Infinity, 0); + ctx.transform(0, Infinity, 0, Infinity, Infinity, Infinity); + ctx.transform(0, Infinity, 0, Infinity, 0, Infinity); + ctx.transform(0, Infinity, 0, 0, Infinity, 0); + ctx.transform(0, Infinity, 0, 0, Infinity, Infinity); + ctx.transform(0, Infinity, 0, 0, 0, Infinity); + ctx.transform(0, 0, Infinity, Infinity, 0, 0); + ctx.transform(0, 0, Infinity, Infinity, Infinity, 0); + ctx.transform(0, 0, Infinity, Infinity, Infinity, Infinity); + ctx.transform(0, 0, Infinity, Infinity, 0, Infinity); + ctx.transform(0, 0, Infinity, 0, Infinity, 0); + ctx.transform(0, 0, Infinity, 0, Infinity, Infinity); + ctx.transform(0, 0, Infinity, 0, 0, Infinity); + ctx.transform(0, 0, 0, Infinity, Infinity, 0); + ctx.transform(0, 0, 0, Infinity, Infinity, Infinity); + ctx.transform(0, 0, 0, Infinity, 0, Infinity); + ctx.transform(0, 0, 0, 0, Infinity, Infinity); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + // Create green with a red square ring inside it + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.fillRect(20, 10, 60, 30); + ctx.fillStyle = '#0f0'; + ctx.fillRect(40, 20, 20, 10); + + // Draw a skewed shape to fill that gap, to make sure it is aligned correctly + ctx.transform(1,4, 2,3, 5,6); + // Post-transform coordinates: + // [[20,10],[80,10],[80,40],[20,40],[20,10],[40,20],[40,30],[60,30],[60,20],[40,20],[20,10]]; + // Hence pre-transform coordinates: + var pts=[[-7.4,11.2],[-43.4,59.2],[-31.4,53.2],[4.6,5.2],[-7.4,11.2], + [-15.4,25.2],[-11.4,23.2],[-23.4,39.2],[-27.4,41.2],[-15.4,25.2], + [-7.4,11.2]]; + ctx.beginPath(); + ctx.moveTo(pts[0][0], pts[0][1]); + for (var i = 0; i < pts.length; ++i) + ctx.lineTo(pts[i][0], pts[i][1]); + ctx.fill(); + /* + //FIXME: + verify(Helper.comparePixel(ctx, 21,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 21,39, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,39, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 61,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,31, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 61,31, 0,255,0,255)); + */ + } + function test_translate() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 50); + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -50, 100, 50); + verify(Helper.comparePixel(ctx, 90,40, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.translate(Infinity, 0.1); + ctx.translate(-Infinity, 0.1); + ctx.translate(NaN, 0.1); + ctx.translate(0.1, Infinity); + ctx.translate(0.1, -Infinity); + ctx.translate(0.1, NaN); + ctx.translate(Infinity, Infinity); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + } + } +} diff --git a/tests/auto/declarative/qsgcanvasitem/qsgcanvasitem.pro b/tests/auto/declarative/qsgcanvasitem/qsgcanvasitem.pro index 62b1611fda..c237f9316a 100644 --- a/tests/auto/declarative/qsgcanvasitem/qsgcanvasitem.pro +++ b/tests/auto/declarative/qsgcanvasitem/qsgcanvasitem.pro @@ -8,3 +8,26 @@ SOURCES += tst_qsgcanvasitem.cpp importFiles.files = data importFiles.path = . DEPLOYMENT += importFiles + +OTHER_FILES += \ + data/testhelper.js \ + data/tst_transform.qml \ + data/tst_text.qml \ + data/tst_strokeStyle.qml \ + data/tst_state.qml \ + data/tst_shadow.qml \ + data/tst_pattern.qml \ + data/tst_path.qml \ + data/tst_line.qml \ + data/tst_fillStyle.qml \ + data/tst_fillrect.qml \ + data/tst_drawimage.qml \ + data/tst_composite.qml \ + data/tst_canvas.qml \ + data/tst_pixel.qml \ + data/tst_gradient.qml \ + data/tst_arcto.qml \ + data/tst_arc.qml + + + -- GitLab