diff options
author | Andy Shaw <andy.shaw@qt.io> | 2019-02-13 14:08:49 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2019-02-14 06:26:36 +0000 |
commit | 0148243a77a42de1ba6170a1da3977b3026c1927 (patch) | |
tree | 663b864b4bec3a7a454cf0dce9ca0b888e470f9d /tests/auto | |
parent | 68d0377736a541fa29d1aaba6b7aa4a4cf8781ef (diff) |
Canvas: Handle switching between object and string based colors
When switching between the two it should respect whatever the color is
regardless of whether it is a color value or a string based color. This
also accounts for "invalid" colors as this should set the stroke-style
to be #000000 to be inline with the default stroke-style indicated in
the specification.
Change-Id: I00bee6c9a85787762271882838510b4187798ee0
Fixes: QTBUG-42155
Fixes: QTBUG-52959
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml b/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml index 22803a19ce..a3f1ab0a9b 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml @@ -3,6 +3,8 @@ import QtQuick 2.0 CanvasTestCase { id:testCase name: "strokeStyle" + property color anotherColor: "#0000ff" + property color emptyColor function init_data() { return testData("2d"); } function test_default(row) { var canvas = createCanvasObject(row); @@ -46,4 +48,37 @@ CanvasTestCase { comparePixel(ctx,0,0,255,255,255,255); canvas.destroy() } + function test_colorFromObjectToString(row) { + var canvas = createCanvasObject(row); + var ctx = canvas.getContext('2d'); + + ctx.reset(); + ctx.strokeStyle = anotherColor + ctx.strokeStyle = "red"; + compare(ctx.strokeStyle, "#ff0000"); + + ctx.strokeStyle = anotherColor + ctx.strokeStyle = "black"; + compare(ctx.strokeStyle, "#000000"); + + ctx.strokeStyle = "white"; + ctx.strokeStyle = anotherColor + compare(ctx.strokeStyle, "#0000ff"); + canvas.destroy() + } + function test_withInvalidColor(row) { + var canvas = createCanvasObject(row); + var ctx = canvas.getContext('2d'); + + ctx.reset(); + ctx.strokeStyle = emptyColor + compare(ctx.strokeStyle, "#000000"); + ctx.strokeStyle = "red"; + compare(ctx.strokeStyle, "#ff0000"); + ctx.strokeStyle = emptyColor + compare(ctx.strokeStyle, "#000000"); + ctx.strokeStyle = anotherColor; + compare(ctx.strokeStyle, "#0000ff"); + canvas.destroy() + } } |