зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1293845 - Update tests to handle new webidl.
MozReview-Commit-ID: 7hcluLAw7gx
This commit is contained in:
Родитель
aed6c57564
Коммит
ae6d979f8a
|
@ -66,10 +66,26 @@ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, c);
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative y");
|
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative y");
|
||||||
gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
|
gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative level");
|
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative level");
|
||||||
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "no image data");
|
if (contextVersion >= 2) {
|
||||||
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
var text = "Should throw with no image data.";
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "null pixels");
|
try {
|
||||||
|
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
||||||
|
testFailed(text);
|
||||||
|
} catch(e) {
|
||||||
|
testPassed(text);
|
||||||
|
}
|
||||||
|
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no image data");
|
||||||
|
} else {
|
||||||
|
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
||||||
|
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "no image data");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contextVersion < 2) {
|
||||||
|
// In WebGL2, null coerces to 0 for the PBO entrypoint.
|
||||||
|
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
||||||
|
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "null pixels");
|
||||||
|
}
|
||||||
|
|
||||||
// GL_INVALID_VALUE may be generated if level is greater than log 2 max, where max is the returned value of GL_MAX_TEXTURE_SIZE.
|
// GL_INVALID_VALUE may be generated if level is greater than log 2 max, where max is the returned value of GL_MAX_TEXTURE_SIZE.
|
||||||
// GL_INVALID_OPERATION is generated if the texture array has not been defined by a previous glTexImage2D or glCopyTexImage2D operation whose internalformat matches the format of glTexSubImage2D.
|
// GL_INVALID_OPERATION is generated if the texture array has not been defined by a previous glTexImage2D or glCopyTexImage2D operation whose internalformat matches the format of glTexSubImage2D.
|
||||||
|
|
|
@ -108,14 +108,14 @@ function testCopyBuffers(srcTarget, dstTarget, copyRead, copyWrite) {
|
||||||
if (expectedGLError == gl.NO_ERROR) {
|
if (expectedGLError == gl.NO_ERROR) {
|
||||||
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Copying should work");
|
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Copying should work");
|
||||||
|
|
||||||
var retBuffer = new ArrayBuffer(length);
|
var retBuffer = new Uint8Array(length);
|
||||||
gl.getBufferSubData(dstTarget, 0, retBuffer);
|
gl.getBufferSubData(dstTarget, 0, retBuffer);
|
||||||
wtu.glErrorShouldBe(gl, gl.NO_ERROR,
|
wtu.glErrorShouldBe(gl, gl.NO_ERROR,
|
||||||
"gl.getBufferSubData(" + targetToString(gl, dstTarget) +
|
"gl.getBufferSubData(" + targetToString(gl, dstTarget) +
|
||||||
", 0, retBuffer) should work");
|
", 0, retBuffer) should work");
|
||||||
|
|
||||||
var failed = false;
|
var failed = false;
|
||||||
var retArray = new Float32Array(retBuffer);
|
var retArray = new Float32Array(retBuffer.buffer);
|
||||||
for (var i = 0; i < vertices.length; i++) {
|
for (var i = 0; i < vertices.length; i++) {
|
||||||
if (originalData[i] != retArray[i]) {
|
if (originalData[i] != retArray[i]) {
|
||||||
failed = true;
|
failed = true;
|
||||||
|
|
|
@ -60,13 +60,12 @@ gl.bufferData(gl.ARRAY_BUFFER, floatArray, gl.STATIC_DRAW);
|
||||||
|
|
||||||
debug("");
|
debug("");
|
||||||
debug("Test that getBufferSubData successfully works reading buffer data from gl.ARRAY_BUFFER");
|
debug("Test that getBufferSubData successfully works reading buffer data from gl.ARRAY_BUFFER");
|
||||||
var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT);
|
var retArray = new Float32Array(vertices.length);
|
||||||
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, arrBuffer);
|
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, retArray);
|
||||||
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "gl.getBufferSubData(gl.ARRAY_BUFFER, 0, arrBuffer) should WORK");
|
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "gl.getBufferSubData(gl.ARRAY_BUFFER, 0, arrBuffer) should WORK");
|
||||||
|
|
||||||
debug("Check array data to match original data set by the buffer");
|
debug("Check array data to match original data set by the buffer");
|
||||||
var failed = false;
|
var failed = false;
|
||||||
var retArray = new Float32Array(arrBuffer);
|
|
||||||
for (var i = 0; i < vertices.length; i++) {
|
for (var i = 0; i < vertices.length; i++) {
|
||||||
if (floatArray[i] != retArray[i]) {
|
if (floatArray[i] != retArray[i]) {
|
||||||
failed = true;
|
failed = true;
|
||||||
|
@ -79,29 +78,25 @@ else
|
||||||
testPassed("The returned array buffer matches original data");
|
testPassed("The returned array buffer matches original data");
|
||||||
|
|
||||||
debug("Test that getBufferSubData fails when given a buffer with its size larger than the original data");
|
debug("Test that getBufferSubData fails when given a buffer with its size larger than the original data");
|
||||||
var extraLargeBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT + 1);
|
var extraLargeBuffer = new Uint8Array(vertices.length * Float32Array.BYTES_PER_ELEMENT + 1);
|
||||||
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, extraLargeBuffer);
|
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, extraLargeBuffer);
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, 0, extraLargeBuffer) with extra length should generate INVALID_VALUE");
|
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, 0, extraLargeBuffer) with extra length should generate INVALID_VALUE");
|
||||||
|
|
||||||
debug("Test that getBufferSubData fails when offset summed with buffer length is larger than the size of the original data size");
|
debug("Test that getBufferSubData fails when offset summed with buffer length is larger than the size of the original data size");
|
||||||
gl.getBufferSubData(gl.ARRAY_BUFFER, vertices.length * Float32Array.BYTES_PER_ELEMENT + 1, arrBuffer);
|
gl.getBufferSubData(gl.ARRAY_BUFFER, vertices.length * Float32Array.BYTES_PER_ELEMENT + 1, retArray);
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, vertices.length * Float32Array.BYTES_PER_ELEMENT + 1, arrBuffer) with offset larger than original data size should generate INVALID_VALUE");
|
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, vertices.length * Float32Array.BYTES_PER_ELEMENT + 1, arrBuffer) with offset larger than original data size should generate INVALID_VALUE");
|
||||||
gl.getBufferSubData(gl.ARRAY_BUFFER, 1, arrBuffer);
|
gl.getBufferSubData(gl.ARRAY_BUFFER, 1, retArray);
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, 1, arrBuffer) with offset and length larger than buffer size should generate INVALID_VALUE");
|
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, 1, arrBuffer) with offset and length larger than buffer size should generate INVALID_VALUE");
|
||||||
|
|
||||||
debug("Test that getBufferSubData fails when 0 is bound to the target");
|
debug("Test that getBufferSubData fails when 0 is bound to the target");
|
||||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
||||||
gl.getBufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, arrBuffer);
|
gl.getBufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, retArray);
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "gl.getBufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, arrBuffer) should generate INVALID_OPERATION");
|
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "gl.getBufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, arrBuffer) should generate INVALID_OPERATION");
|
||||||
|
|
||||||
debug("Test that getBufferSubData fails when offset is less than 0");
|
debug("Test that getBufferSubData fails when offset is less than 0");
|
||||||
gl.getBufferSubData(gl.ARRAY_BUFFER, -1, arrBuffer);
|
gl.getBufferSubData(gl.ARRAY_BUFFER, -1, retArray);
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, -1, arrBuffer) should generate INVALID_VALUE");
|
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, -1, arrBuffer) should generate INVALID_VALUE");
|
||||||
|
|
||||||
debug("Test that getBufferSubData fails when given a null buffer");
|
|
||||||
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, null);
|
|
||||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, 0, null) should generate INVALID_VALUE");
|
|
||||||
|
|
||||||
finishTest();
|
finishTest();
|
||||||
|
|
||||||
var successfullyParsed = true;
|
var successfullyParsed = true;
|
||||||
|
|
|
@ -1239,10 +1239,9 @@ var checkFloatBuffer = function(gl, target, expected, opt_msg, opt_errorRange) {
|
||||||
if (opt_errorRange === undefined)
|
if (opt_errorRange === undefined)
|
||||||
opt_errorRange = 0.001;
|
opt_errorRange = 0.001;
|
||||||
|
|
||||||
var outData = new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT * expected.length);
|
var floatArray = new Float32Array(expected.length);
|
||||||
gl.getBufferSubData(target, 0, outData);
|
gl.getBufferSubData(target, 0, floatArray);
|
||||||
|
|
||||||
var floatArray = new Float32Array(outData);
|
|
||||||
for (var i = 0; i < expected.length; i++) {
|
for (var i = 0; i < expected.length; i++) {
|
||||||
if (Math.abs(floatArray[i] - expected[i]) > opt_errorRange) {
|
if (Math.abs(floatArray[i] - expected[i]) > opt_errorRange) {
|
||||||
testFailed(opt_msg);
|
testFailed(opt_msg);
|
||||||
|
|
|
@ -187,7 +187,7 @@ function Test() {
|
||||||
EnsureNoError(gl);
|
EnsureNoError(gl);
|
||||||
gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, 0);
|
gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, 0);
|
||||||
EnsureNoError(gl);
|
EnsureNoError(gl);
|
||||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data.buffer);
|
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
|
||||||
EnsureNoError(gl);
|
EnsureNoError(gl);
|
||||||
TestIsUNormColor(RED, data, 0);
|
TestIsUNormColor(RED, data, 0);
|
||||||
TestIsUNormColor(BLUE, data, 4);
|
TestIsUNormColor(BLUE, data, 4);
|
||||||
|
@ -197,7 +197,7 @@ function Test() {
|
||||||
section('Subrect readback');
|
section('Subrect readback');
|
||||||
data = ClearBufferPair(gl, 8);
|
data = ClearBufferPair(gl, 8);
|
||||||
gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 0);
|
gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 0);
|
||||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data.buffer);
|
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
|
||||||
EnsureNoError(gl);
|
EnsureNoError(gl);
|
||||||
TestIsUNormColor(WHITE, data, 0);
|
TestIsUNormColor(WHITE, data, 0);
|
||||||
TestIsUNormColor(ZERO, data, 4);
|
TestIsUNormColor(ZERO, data, 4);
|
||||||
|
@ -205,7 +205,7 @@ function Test() {
|
||||||
section('ReadPixels offset:4');
|
section('ReadPixels offset:4');
|
||||||
data = ClearBufferPair(gl, 16);
|
data = ClearBufferPair(gl, 16);
|
||||||
gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 4);
|
gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 4);
|
||||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data.buffer);
|
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
|
||||||
EnsureNoError(gl);
|
EnsureNoError(gl);
|
||||||
TestIsUNormColor(ZERO, data, 0);
|
TestIsUNormColor(ZERO, data, 0);
|
||||||
TestIsUNormColor(WHITE, data, 4);
|
TestIsUNormColor(WHITE, data, 4);
|
||||||
|
@ -214,7 +214,7 @@ function Test() {
|
||||||
|
|
||||||
section('ReadPixels offset:5');
|
section('ReadPixels offset:5');
|
||||||
gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 5);
|
gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 5);
|
||||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data.buffer);
|
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
|
||||||
EnsureNoError(gl);
|
EnsureNoError(gl);
|
||||||
TestIsUNormColor(ZERO, data, 0);
|
TestIsUNormColor(ZERO, data, 0);
|
||||||
TestIsUNormColor(WHITE, data, 4); // Should remain from previous read.
|
TestIsUNormColor(WHITE, data, 4); // Should remain from previous read.
|
||||||
|
@ -225,7 +225,7 @@ function Test() {
|
||||||
section('GetBufferSubData src too small');
|
section('GetBufferSubData src too small');
|
||||||
data = ClearBufferPair(gl, 16);
|
data = ClearBufferPair(gl, 16);
|
||||||
EnsureNoError(gl);
|
EnsureNoError(gl);
|
||||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data.buffer);
|
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data);
|
||||||
TestError(gl, gl.INVALID_VALUE);
|
TestError(gl, gl.INVALID_VALUE);
|
||||||
TestIsUNormColor(ZERO, data, 0);
|
TestIsUNormColor(ZERO, data, 0);
|
||||||
TestIsUNormColor(ZERO, data, 4);
|
TestIsUNormColor(ZERO, data, 4);
|
||||||
|
@ -235,7 +235,7 @@ function Test() {
|
||||||
section('GetBufferSubData offset:1');
|
section('GetBufferSubData offset:1');
|
||||||
data = new Uint8Array(15);
|
data = new Uint8Array(15);
|
||||||
gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 8);
|
gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 8);
|
||||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data.buffer);
|
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data);
|
||||||
EnsureNoError(gl);
|
EnsureNoError(gl);
|
||||||
TestIsUNormColor(ZERO, data, 0);
|
TestIsUNormColor(ZERO, data, 0);
|
||||||
TestIsUNormColor(ZERO, data, 3);
|
TestIsUNormColor(ZERO, data, 3);
|
||||||
|
|
|
@ -156,8 +156,8 @@ function TestScreenColor(gl, r, g, b, a) {
|
||||||
gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW);
|
gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW);
|
||||||
|
|
||||||
var arr2 = new SharedArrayBuffer(8*4);
|
var arr2 = new SharedArrayBuffer(8*4);
|
||||||
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, arr2);
|
|
||||||
var view2 = new Float32Array(arr2);
|
var view2 = new Float32Array(arr2);
|
||||||
|
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, view2);
|
||||||
var equal = true;
|
var equal = true;
|
||||||
for(var i = 0; i < 8; ++i) {
|
for(var i = 0; i < 8; ++i) {
|
||||||
if (view[i] != view2[i]) equal = false;
|
if (view[i] != view2[i]) equal = false;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче