OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:html'; | 5 import 'dart:html'; |
6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
7 import 'dart:web_gl'; | 7 import 'dart:web_gl'; |
8 import 'dart:web_gl' as gl; | 8 import 'dart:web_gl' as gl; |
9 | 9 |
10 import 'package:expect/minitest.dart'; | 10 import 'package:expect/minitest.dart'; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 expect(context, isRenderingContext); | 52 expect(context, isRenderingContext); |
53 | 53 |
54 context = canvas.getContext3d(depth: false); | 54 context = canvas.getContext3d(depth: false); |
55 expect(context, isNotNull); | 55 expect(context, isNotNull); |
56 expect(context, isRenderingContext); | 56 expect(context, isRenderingContext); |
57 }); | 57 }); |
58 | 58 |
59 test('texImage2D', () { | 59 test('texImage2D', () { |
60 var canvas = new CanvasElement(); | 60 var canvas = new CanvasElement(); |
61 var context = canvas.getContext3d(); | 61 var context = canvas.getContext3d(); |
62 var pixels = new Uint8List.fromList([0,0,3,255,0,0,0,0,0,0]); | 62 var pixels = new Uint8List.fromList([0, 0, 3, 255, 0, 0, 0, 0, 0, 0]); |
63 context.texImage2DUntyped(1, 1, 1, 1, 10, 10, 1, 1, pixels); | 63 context.texImage2DUntyped(1, 1, 1, 1, 10, 10, 1, 1, pixels); |
64 | 64 |
65 canvas = new CanvasElement(); | 65 canvas = new CanvasElement(); |
66 document.body.children.add(canvas); | 66 document.body.children.add(canvas); |
67 var context2 = canvas.getContext('2d'); | 67 var context2 = canvas.getContext('2d'); |
68 context.texImage2DData(1, 1, 1, 1, 10, | 68 context.texImage2DData( |
69 context2.getImageData(10, 10, 10, 10)); | 69 1, 1, 1, 1, 10, context2.getImageData(10, 10, 10, 10)); |
70 | 70 |
71 context.texImage2DImage(1, 1, 1, 1, 10, new ImageElement()); | 71 context.texImage2DImage(1, 1, 1, 1, 10, new ImageElement()); |
72 context.texImage2DCanvas(1, 1, 1, 1, 10, new CanvasElement()); | 72 context.texImage2DCanvas(1, 1, 1, 1, 10, new CanvasElement()); |
73 context.texImage2DVideo(1, 1, 1, 1, 10, new VideoElement()); | 73 context.texImage2DVideo(1, 1, 1, 1, 10, new VideoElement()); |
74 }); | 74 }); |
75 | 75 |
76 test('texSubImage2D', () { | 76 test('texSubImage2D', () { |
77 var canvas = new CanvasElement(); | 77 var canvas = new CanvasElement(); |
78 var context = canvas.getContext3d(); | 78 var context = canvas.getContext3d(); |
79 var pixels = new Uint8List.fromList([0,0,3,255,0,0,0,0,0,0]); | 79 var pixels = new Uint8List.fromList([0, 0, 3, 255, 0, 0, 0, 0, 0, 0]); |
80 context.texSubImage2DUntyped(1, 1, 1, 1, 10, 10, 1, 1, pixels); | 80 context.texSubImage2DUntyped(1, 1, 1, 1, 10, 10, 1, 1, pixels); |
81 | 81 |
82 canvas = new CanvasElement(); | 82 canvas = new CanvasElement(); |
83 document.body.children.add(canvas); | 83 document.body.children.add(canvas); |
84 var context2 = canvas.getContext('2d'); | 84 var context2 = canvas.getContext('2d'); |
85 context.texSubImage2DData(1, 1, 1, 1, 1, 10, | 85 context.texSubImage2DData( |
86 context2.getImageData(10, 10, 10, 10)); | 86 1, 1, 1, 1, 1, 10, context2.getImageData(10, 10, 10, 10)); |
87 | 87 |
88 context.texSubImage2DImage(1, 1, 1, 1, 1, 10, new ImageElement()); | 88 context.texSubImage2DImage(1, 1, 1, 1, 1, 10, new ImageElement()); |
89 context.texSubImage2DCanvas(1, 1, 1, 1, 1, 10, new CanvasElement()); | 89 context.texSubImage2DCanvas(1, 1, 1, 1, 1, 10, new CanvasElement()); |
90 context.texSubImage2DVideo(1, 1, 1, 1, 1, 10, new VideoElement()); | 90 context.texSubImage2DVideo(1, 1, 1, 1, 1, 10, new VideoElement()); |
91 }); | 91 }); |
92 | 92 |
93 test('getContextAttributes', () { | 93 test('getContextAttributes', () { |
94 var canvas = new CanvasElement(); | 94 var canvas = new CanvasElement(); |
95 var context = canvas.getContext3d(); | 95 var context = canvas.getContext3d(); |
96 var attributes = context.getContextAttributes(); | 96 var attributes = context.getContextAttributes(); |
97 | 97 |
98 expect(attributes, isNotNull); | 98 expect(attributes, isNotNull); |
99 expect(attributes, isContextAttributes); | 99 expect(attributes, isContextAttributes); |
100 | 100 |
101 expect(attributes.alpha, isBoolean); | 101 expect(attributes.alpha, isBoolean); |
102 expect(attributes.antialias, isBoolean); | 102 expect(attributes.antialias, isBoolean); |
103 expect(attributes.depth, isBoolean); | 103 expect(attributes.depth, isBoolean); |
104 expect(attributes.premultipliedAlpha, isBoolean); | 104 expect(attributes.premultipliedAlpha, isBoolean); |
105 expect(attributes.preserveDrawingBuffer, isBoolean); | 105 expect(attributes.preserveDrawingBuffer, isBoolean); |
106 expect(attributes.stencil, isBoolean); | 106 expect(attributes.stencil, isBoolean); |
107 }); | 107 }); |
108 } | 108 } |
109 }); | 109 }); |
110 } | 110 } |
111 | 111 |
112 Matcher isBoolean = anyOf(isTrue, isFalse); | 112 Matcher isBoolean = anyOf(isTrue, isFalse); |
OLD | NEW |