Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(797)

Unified Diff: tests/html/canvasrenderingcontext2d_test.dart

Issue 11028068: Replacing non-portable CanvasRenderingContext.setFillColor with more portable variants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Integrating latest build. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/canvas_using_html_test.dart ('k') | tests/html/html.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/canvasrenderingcontext2d_test.dart
diff --git a/tests/html/canvasrenderingcontext2d_test.dart b/tests/html/canvasrenderingcontext2d_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..100e5137c36584d631ffd3604d642b3126d4d98a
--- /dev/null
+++ b/tests/html/canvasrenderingcontext2d_test.dart
@@ -0,0 +1,84 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library('url_test');
+#import('../../pkg/unittest/unittest.dart');
+#import('../../pkg/unittest/html_config.dart');
+#import('dart:html');
+
+main() {
+ useHtmlConfiguration();
+ var canvas = new CanvasElement();
+ canvas.width = 100;
+ canvas.height = 100;
+
+ var context = canvas.context2d;
+
+ Uint8ClampedArray readPixel() {
+ var imageData = context.getImageData(2, 2, 1, 1);
+ return imageData.data;
+ }
+
+ test('setFillColorRgb', () {
+ context.setFillColorRgb(255, 0, 255, 1);
+ context.fillRect(0, 0, canvas.width, canvas.height);
+ expect(readPixel(), [255, 0, 255, 255]);
+ });
+
+ test('setFillColorHsl hue', () {
+ context.setFillColorHsl(0, 100, 50);
+ context.fillRect(0, 0, canvas.width, canvas.height);
+ expect(readPixel(), [255, 0, 0, 255]);
+ });
+
+ test('setFillColorHsl hue 2', () {
+ context.setFillColorHsl(240, 100, 50);
+ context.fillRect(0, 0, canvas.width, canvas.height);
+ expect(readPixel(), [0, 0, 255, 255]);
+ });
+
+ test('setFillColorHsl sat', () {
+ context.setFillColorHsl(0, 0, 50);
+ context.fillRect(0, 0, canvas.width, canvas.height);
+ var pixel = readPixel();
+ // Some rounding errors in the browsers.
+ expect(pixel[0], closeTo(127, 1));
+ expect(pixel[1], closeTo(127, 1));
+ expect(pixel[2], closeTo(127, 1));
+ expect(pixel[3], 255);
+ });
+
+ test('setStrokeColorRgb', () {
+ context.setStrokeColorRgb(255, 0, 255, 1);
+ context.lineWidth = 10;
+ context.strokeRect(0, 0, canvas.width, canvas.height);
+ expect(readPixel(), [255, 0, 255, 255]);
+ });
+
+ test('setStrokeColorHsl hue', () {
+ context.setStrokeColorHsl(0, 100, 50);
+ context.lineWidth = 10;
+ context.strokeRect(0, 0, canvas.width, canvas.height);
+ expect(readPixel(), [255, 0, 0, 255]);
+ });
+
+ test('setStrokeColorHsl hue 2', () {
+ context.setStrokeColorHsl(240, 100, 50);
+ context.lineWidth = 10;
+ context.strokeRect(0, 0, canvas.width, canvas.height);
+ expect(readPixel(), [0, 0, 255, 255]);
+ });
+
+ test('setStrokeColorHsl sat', () {
+ context.setStrokeColorHsl(0, 0, 50);
+ context.lineWidth = 10;
+ context.strokeRect(0, 0, canvas.width, canvas.height);
+ var pixel = readPixel();
+ // Some rounding errors in the browsers.
+ expect(pixel[0], closeTo(127, 1));
+ expect(pixel[1], closeTo(127, 1));
+ expect(pixel[2], closeTo(127, 1));
+ expect(pixel[3], 255);
+ });
+}
« no previous file with comments | « tests/html/canvas_using_html_test.dart ('k') | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698