| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #library('url_test'); | |
| 6 #import('../../pkg/unittest/unittest.dart'); | |
| 7 #import('../../pkg/unittest/html_config.dart'); | |
| 8 #import('dart:html'); | |
| 9 | |
| 10 main() { | |
| 11 useHtmlConfiguration(); | |
| 12 var canvas = new CanvasElement(); | |
| 13 canvas.width = 100; | |
| 14 canvas.height = 100; | |
| 15 | |
| 16 var context = canvas.context2d; | |
| 17 | |
| 18 Uint8ClampedArray readPixel() { | |
| 19 var imageData = context.getImageData(2, 2, 1, 1); | |
| 20 return imageData.data; | |
| 21 } | |
| 22 | |
| 23 test('setFillColorRgb', () { | |
| 24 context.setFillColorRgb(255, 0, 255, 1); | |
| 25 context.fillRect(0, 0, canvas.width, canvas.height); | |
| 26 expect(readPixel(), [255, 0, 255, 255]); | |
| 27 }); | |
| 28 | |
| 29 test('setFillColorHsl hue', () { | |
| 30 context.setFillColorHsl(0, 100, 50); | |
| 31 context.fillRect(0, 0, canvas.width, canvas.height); | |
| 32 expect(readPixel(), [255, 0, 0, 255]); | |
| 33 }); | |
| 34 | |
| 35 test('setFillColorHsl hue 2', () { | |
| 36 context.setFillColorHsl(240, 100, 50); | |
| 37 context.fillRect(0, 0, canvas.width, canvas.height); | |
| 38 expect(readPixel(), [0, 0, 255, 255]); | |
| 39 }); | |
| 40 | |
| 41 test('setFillColorHsl sat', () { | |
| 42 context.setFillColorHsl(0, 0, 50); | |
| 43 context.fillRect(0, 0, canvas.width, canvas.height); | |
| 44 var pixel = readPixel(); | |
| 45 // Some rounding errors in the browsers. | |
| 46 expect(pixel[0], closeTo(127, 1)); | |
| 47 expect(pixel[1], closeTo(127, 1)); | |
| 48 expect(pixel[2], closeTo(127, 1)); | |
| 49 expect(pixel[3], 255); | |
| 50 }); | |
| 51 | |
| 52 test('setStrokeColorRgb', () { | |
| 53 context.setStrokeColorRgb(255, 0, 255, 1); | |
| 54 context.lineWidth = 10; | |
| 55 context.strokeRect(0, 0, canvas.width, canvas.height); | |
| 56 expect(readPixel(), [255, 0, 255, 255]); | |
| 57 }); | |
| 58 | |
| 59 test('setStrokeColorHsl hue', () { | |
| 60 context.setStrokeColorHsl(0, 100, 50); | |
| 61 context.lineWidth = 10; | |
| 62 context.strokeRect(0, 0, canvas.width, canvas.height); | |
| 63 expect(readPixel(), [255, 0, 0, 255]); | |
| 64 }); | |
| 65 | |
| 66 test('setStrokeColorHsl hue 2', () { | |
| 67 context.setStrokeColorHsl(240, 100, 50); | |
| 68 context.lineWidth = 10; | |
| 69 context.strokeRect(0, 0, canvas.width, canvas.height); | |
| 70 expect(readPixel(), [0, 0, 255, 255]); | |
| 71 }); | |
| 72 | |
| 73 test('setStrokeColorHsl sat', () { | |
| 74 context.setStrokeColorHsl(0, 0, 50); | |
| 75 context.lineWidth = 10; | |
| 76 context.strokeRect(0, 0, canvas.width, canvas.height); | |
| 77 var pixel = readPixel(); | |
| 78 // Some rounding errors in the browsers. | |
| 79 expect(pixel[0], closeTo(127, 1)); | |
| 80 expect(pixel[1], closeTo(127, 1)); | |
| 81 expect(pixel[2], closeTo(127, 1)); | |
| 82 expect(pixel[3], 255); | |
| 83 }); | |
| 84 } | |
| OLD | NEW |