Files
sdk/tests/html/webgl_1_test.dart
T
blois@google.com 8cb540948f Adding supported checks for WebGL
Also fixed the getContext method to have the proper signature (bug 4883).

Also adding an easy accessor for context3d.

Not sure if additional Dartium changes will be needed, Anton?

BUG=

Review URL: https://codereview.chromium.org//12077039

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17860 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-30 17:45:13 +00:00

58 lines
1.7 KiB
Dart

// Copyright (c) 2013, 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 web_gl_test;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_individual_config.dart';
import 'dart:html';
// Test that WebGL is present in dart:html API
main() {
useHtmlIndividualConfiguration();
group('supported', () {
test('supported', () {
expect(WebGLRenderingContext.supported, isTrue);
});
});
group('functional', () {
test('unsupported fails', () {
var canvas = new CanvasElement();
var gl = canvas.getContext3d();
if (WebGLRenderingContext.supported) {
expect(gl, isNotNull);
expect(gl, new isInstanceOf<WebGLRenderingContext>());
} else {
expect(gl, isNull);
}
});
if (WebGLRenderingContext.supported) {
test('simple', () {
var canvas = new CanvasElement();
var gl = canvas.getContext('experimental-webgl');
var shader = gl.createShader(WebGLRenderingContext.VERTEX_SHADER);
gl.shaderSource(shader, 'void main() { }');
gl.compileShader(shader);
var success =
gl.getShaderParameter(shader, WebGLRenderingContext.COMPILE_STATUS);
expect(success, isTrue);
});
test('getContext3d', () {
var canvas = new CanvasElement();
var gl = canvas.getContext3d();
expect(gl, isNotNull);
expect(gl, new isInstanceOf<WebGLRenderingContext>());
gl = canvas.getContext3d(depth: false);
expect(gl, isNotNull);
expect(gl, new isInstanceOf<WebGLRenderingContext>());
});
}
});
}