f81052f2c8
BUG= R=jmesserly@google.com Review URL: https://codereview.chromium.org//18577002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24709 260f80e4-7a28-3924-810f-c04153c831b5
95 lines
3.2 KiB
Dart
95 lines
3.2 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';
|
|
import 'dart:typed_data';
|
|
import 'dart:web_gl';
|
|
import 'dart:web_gl' as gl;
|
|
|
|
// Test that WebGL is present in dart:web_gl API
|
|
|
|
main() {
|
|
useHtmlIndividualConfiguration();
|
|
|
|
group('supported', () {
|
|
test('supported', () {
|
|
expect(RenderingContext.supported, isTrue);
|
|
});
|
|
});
|
|
|
|
group('functional', () {
|
|
test('unsupported fails', () {
|
|
var canvas = new CanvasElement();
|
|
var context = canvas.getContext3d();
|
|
if (RenderingContext.supported) {
|
|
expect(context, isNotNull);
|
|
expect(context, new isInstanceOf<RenderingContext>());
|
|
} else {
|
|
expect(context, isNull);
|
|
}
|
|
});
|
|
|
|
if (RenderingContext.supported) {
|
|
test('simple', () {
|
|
var canvas = new CanvasElement();
|
|
var context = canvas.getContext('experimental-webgl');
|
|
var shader = context.createShader(gl.VERTEX_SHADER);
|
|
context.shaderSource(shader, 'void main() { }');
|
|
context.compileShader(shader);
|
|
var success = context.getShaderParameter(shader, gl.COMPILE_STATUS);
|
|
expect(success, isTrue);
|
|
});
|
|
|
|
test('getContext3d', () {
|
|
var canvas = new CanvasElement();
|
|
var context = canvas.getContext3d();
|
|
expect(context, isNotNull);
|
|
expect(context, new isInstanceOf<RenderingContext>());
|
|
|
|
context = canvas.getContext3d(depth: false);
|
|
expect(context, isNotNull);
|
|
expect(context, new isInstanceOf<RenderingContext>());
|
|
});
|
|
|
|
test('texImage2D', () {
|
|
var canvas = new CanvasElement();
|
|
var context = canvas.getContext3d();
|
|
var pixels = new Uint8List.fromList([0,0,3,255,0,0,0,0,0,0]);
|
|
context.texImage2D(1, 1, 1, 1, 10, 10, 1, 1, pixels);
|
|
|
|
canvas = new CanvasElement();
|
|
document.body.children.add(canvas);
|
|
var context2 = canvas.getContext('2d');
|
|
context.texImage2DData(1, 1, 1, 1, 10,
|
|
context2.getImageData(10, 10, 10, 10));
|
|
|
|
context.texImage2DImage(1, 1, 1, 1, 10, new ImageElement());
|
|
context.texImage2DCanvas(1, 1, 1, 1, 10, new CanvasElement());
|
|
context.texImage2DVideo(1, 1, 1, 1, 10, new VideoElement());
|
|
});
|
|
|
|
test('texSubImage2D', () {
|
|
var canvas = new CanvasElement();
|
|
var context = canvas.getContext3d();
|
|
var pixels = new Uint8List.fromList([0,0,3,255,0,0,0,0,0,0]);
|
|
context.texSubImage2D(1, 1, 1, 1, 10, 10, 1, 1, pixels);
|
|
|
|
canvas = new CanvasElement();
|
|
document.body.children.add(canvas);
|
|
var context2 = canvas.getContext('2d');
|
|
context.texSubImage2DData(1, 1, 1, 1, 1, 10,
|
|
context2.getImageData(10, 10, 10, 10));
|
|
|
|
context.texSubImage2DImage(1, 1, 1, 1, 1, 10, new ImageElement());
|
|
context.texSubImage2DCanvas(1, 1, 1, 1, 1, 10, new CanvasElement());
|
|
context.texSubImage2DVideo(1, 1, 1, 1, 1, 10, new VideoElement());
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|