зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1293845 - Update tests to handle new webidl.
MozReview-Commit-ID: 7hcluLAw7gx
This commit is contained in:
Родитель
70dfbdbec9
Коммит
6434d6daf4
|
@ -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");
|
||||
gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
|
||||
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");
|
||||
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
||||
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "null pixels");
|
||||
|
||||
if (contextVersion >= 2) {
|
||||
var text = "Should throw with no image data.";
|
||||
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_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) {
|
||||
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Copying should work");
|
||||
|
||||
var retBuffer = new ArrayBuffer(length);
|
||||
var retBuffer = new Uint8Array(length);
|
||||
gl.getBufferSubData(dstTarget, 0, retBuffer);
|
||||
wtu.glErrorShouldBe(gl, gl.NO_ERROR,
|
||||
"gl.getBufferSubData(" + targetToString(gl, dstTarget) +
|
||||
", 0, retBuffer) should work");
|
||||
|
||||
var failed = false;
|
||||
var retArray = new Float32Array(retBuffer);
|
||||
var retArray = new Float32Array(retBuffer.buffer);
|
||||
for (var i = 0; i < vertices.length; i++) {
|
||||
if (originalData[i] != retArray[i]) {
|
||||
failed = true;
|
||||
|
|
|
@ -60,13 +60,12 @@ gl.bufferData(gl.ARRAY_BUFFER, floatArray, gl.STATIC_DRAW);
|
|||
|
||||
debug("");
|
||||
debug("Test that getBufferSubData successfully works reading buffer data from gl.ARRAY_BUFFER");
|
||||
var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT);
|
||||
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, arrBuffer);
|
||||
var retArray = new Float32Array(vertices.length);
|
||||
gl.getBufferSubData(gl.ARRAY_BUFFER, 0, retArray);
|
||||
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");
|
||||
var failed = false;
|
||||
var retArray = new Float32Array(arrBuffer);
|
||||
for (var i = 0; i < vertices.length; i++) {
|
||||
if (floatArray[i] != retArray[i]) {
|
||||
failed = true;
|
||||
|
@ -79,29 +78,25 @@ else
|
|||
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");
|
||||
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);
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
|
||||
debug("Test that getBufferSubData fails when 0 is bound to the target");
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
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();
|
||||
|
||||
var successfullyParsed = true;
|
||||
|
|
|
@ -1239,10 +1239,9 @@ var checkFloatBuffer = function(gl, target, expected, opt_msg, opt_errorRange) {
|
|||
if (opt_errorRange === undefined)
|
||||
opt_errorRange = 0.001;
|
||||
|
||||
var outData = new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT * expected.length);
|
||||
gl.getBufferSubData(target, 0, outData);
|
||||
var floatArray = new Float32Array(expected.length);
|
||||
gl.getBufferSubData(target, 0, floatArray);
|
||||
|
||||
var floatArray = new Float32Array(outData);
|
||||
for (var i = 0; i < expected.length; i++) {
|
||||
if (Math.abs(floatArray[i] - expected[i]) > opt_errorRange) {
|
||||
testFailed(opt_msg);
|
||||
|
|
|
@ -187,7 +187,7 @@ function Test() {
|
|||
EnsureNoError(gl);
|
||||
gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, 0);
|
||||
EnsureNoError(gl);
|
||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data.buffer);
|
||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
|
||||
EnsureNoError(gl);
|
||||
TestIsUNormColor(RED, data, 0);
|
||||
TestIsUNormColor(BLUE, data, 4);
|
||||
|
@ -197,7 +197,7 @@ function Test() {
|
|||
section('Subrect readback');
|
||||
data = ClearBufferPair(gl, 8);
|
||||
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);
|
||||
TestIsUNormColor(WHITE, data, 0);
|
||||
TestIsUNormColor(ZERO, data, 4);
|
||||
|
@ -205,7 +205,7 @@ function Test() {
|
|||
section('ReadPixels offset:4');
|
||||
data = ClearBufferPair(gl, 16);
|
||||
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);
|
||||
TestIsUNormColor(ZERO, data, 0);
|
||||
TestIsUNormColor(WHITE, data, 4);
|
||||
|
@ -214,7 +214,7 @@ function Test() {
|
|||
|
||||
section('ReadPixels offset: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);
|
||||
TestIsUNormColor(ZERO, data, 0);
|
||||
TestIsUNormColor(WHITE, data, 4); // Should remain from previous read.
|
||||
|
@ -225,7 +225,7 @@ function Test() {
|
|||
section('GetBufferSubData src too small');
|
||||
data = ClearBufferPair(gl, 16);
|
||||
EnsureNoError(gl);
|
||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data.buffer);
|
||||
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data);
|
||||
TestError(gl, gl.INVALID_VALUE);
|
||||
TestIsUNormColor(ZERO, data, 0);
|
||||
TestIsUNormColor(ZERO, data, 4);
|
||||
|
@ -235,7 +235,7 @@ function Test() {
|
|||
section('GetBufferSubData offset:1');
|
||||
data = new Uint8Array(15);
|
||||
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);
|
||||
TestIsUNormColor(ZERO, data, 0);
|
||||
TestIsUNormColor(ZERO, data, 3);
|
||||
|
|
Загрузка…
Ссылка в новой задаче