Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 library WebGL1Test; | 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library web_gl_test; | |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_config.dart'; | 7 import '../../pkg/unittest/lib/html_individual_config.dart'; |
| 4 import 'dart:html'; | 8 import 'dart:html'; |
| 5 | 9 |
| 6 // Test that WebGL is present in dart:html API | 10 // Test that WebGL is present in dart:html API |
| 7 | 11 |
| 8 main() { | 12 main() { |
| 9 useHtmlConfiguration(); | 13 useHtmlIndividualConfiguration(); |
| 10 | 14 |
| 11 test('simple', () { | 15 group('supported', () { |
| 12 var canvas = document.createElement("canvas"); | 16 test('supported', () { |
| 13 var gl = canvas.getContext("experimental-webgl"); | 17 expect(WebGLRenderingContext.supported, true); |
| 14 var shader = gl.createShader(WebGLRenderingContext.VERTEX_SHADER); | 18 }); |
| 15 gl.shaderSource(shader, "void main() { }"); | 19 }); |
| 16 gl.compileShader(shader); | 20 |
| 17 var success = | 21 group('functional', () { |
| 18 gl.getShaderParameter(shader, WebGLRenderingContext.COMPILE_STATUS); | 22 test('unsupported fails', () { |
| 19 expect(success, isTrue); | 23 var canvas = new CanvasElement(); |
| 24 var gl = canvas.getContext3d(); | |
| 25 if (WebGLRenderingContext.supported) { | |
| 26 expect(gl, isNotNull); | |
| 27 expect(gl is WebGLRenderingContext, true); | |
|
Anton Muhin
2013/01/29 12:05:59
new IsInstanceOf<...>? overall, it looks like you
blois
2013/01/29 21:50:08
Interesting- I only see one other test which uses
| |
| 28 } else { | |
| 29 expect(gl, null); | |
| 30 } | |
| 31 }); | |
| 32 | |
| 33 if (WebGLRenderingContext.supported) { | |
| 34 test('simple', () { | |
| 35 var canvas = new CanvasElement(); | |
| 36 var gl = canvas.getContext("experimental-webgl"); | |
|
Anton Muhin
2013/01/29 12:05:59
nit: mix of ' and "
blois
2013/01/29 21:50:08
Done.
| |
| 37 var shader = gl.createShader(WebGLRenderingContext.VERTEX_SHADER); | |
| 38 gl.shaderSource(shader, "void main() { }"); | |
| 39 gl.compileShader(shader); | |
| 40 var success = | |
| 41 gl.getShaderParameter(shader, WebGLRenderingContext.COMPILE_STATUS); | |
| 42 expect(success, isTrue); | |
| 43 }); | |
| 44 | |
| 45 test('getContext3d', () { | |
| 46 var canvas = new CanvasElement(); | |
| 47 var gl = canvas.getContext3d(); | |
| 48 expect(gl, isNotNull); | |
| 49 expect(gl is WebGLRenderingContext, true); | |
| 50 | |
| 51 gl = canvas.getContext3d(depth: false); | |
| 52 expect(gl, isNotNull); | |
| 53 expect(gl is WebGLRenderingContext, true); | |
| 54 }); | |
| 55 } | |
| 20 }); | 56 }); |
| 21 } | 57 } |
| OLD | NEW |