Bug 1305230 - Splitting test_fileapi_slice in four files, r=me

--HG--
rename : dom/file/tests/test_fileapi_slice2.html => dom/file/tests/test_fileapi_slice_memFile_1.html
rename : dom/file/tests/test_fileapi_slice2.html => dom/file/tests/test_fileapi_slice_memFile_2.html
rename : dom/file/tests/test_fileapi_slice.html => dom/file/tests/test_fileapi_slice_realFile_1.html
rename : dom/file/tests/test_fileapi_slice.html => dom/file/tests/test_fileapi_slice_realFile_2.html
This commit is contained in:
Andrea Marchesini 2017-10-17 13:21:39 +02:00
Родитель 91ed8fdbd6
Коммит 87100dfe4e
7 изменённых файлов: 116 добавлений и 26 удалений

Просмотреть файл

@ -1,3 +1,6 @@
const RANGE_1 = 1;
const RANGE_2 = 2;
function testBlob(file, contents, testName) {
// Load file using FileReader
return new Promise(resolve => {
@ -83,7 +86,7 @@ function testBlob(file, contents, testName) {
});
}
function testSlice(file, size, type, contents, fileType) {
function testSlice(file, size, type, contents, fileType, range) {
is(file.type, type, fileType + " file is correct type");
is(file.size, size, fileType + " file is correct size");
ok(file instanceof File, fileType + " file is a File");
@ -109,27 +112,38 @@ function testSlice(file, size, type, contents, fileType) {
is(slice.slice(0, 10, "hello/world").size, 10, fileType + " slice-slice hello/world size");
// Start, end, expected size
var indexes = [[0, size, size],
[0, 1234, 1234],
[size-500, size, 500],
[size-500, size+500, 500],
[size+500, size+1500, 0],
[0, 0, 0],
[1000, 1000, 0],
[size, size, 0],
[undefined, undefined, size],
[0, undefined, size],
[100, undefined, size-100],
[-100, undefined, 100],
[100, -100, size-200],
[-size-100, undefined, size],
[-2*size-100, 500, 500],
[0, -size-100, 0],
[100, -size-100, 0],
[50, -size+100, 50],
[0, 33000, 33000],
[1000, 34000, 33000],
];
var indexes_range_1 = [[0, size, size],
[0, 1234, 1234],
[size-500, size, 500],
[size-500, size+500, 500],
[size+500, size+1500, 0],
[0, 0, 0],
[1000, 1000, 0],
[size, size, 0],
[undefined, undefined, size],
[0, undefined, size],
];
var indexes_range_2 = [[100, undefined, size-100],
[-100, undefined, 100],
[100, -100, size-200],
[-size-100, undefined, size],
[-2*size-100, 500, 500],
[0, -size-100, 0],
[100, -size-100, 0],
[50, -size+100, 50],
[0, 33000, 33000],
[1000, 34000, 33000],
];
let indexes;
if (range == RANGE_1) {
indexes = indexes_range_1;
} else if (range == RANGE_2) {
indexes = indexes_range_2;
} else {
throw "Invalid range!"
}
function runNextTest() {
if (indexes.length == 0) {

Просмотреть файл

@ -22,9 +22,13 @@ support-files = file_ipc_messagemanager_blob.html
[test_nonascii_blob_url.html]
[test_file_negative_date.html]
[test_fileapi.html]
[test_fileapi_slice.html]
[test_fileapi_slice_realFile_1.html]
skip-if = (toolkit == 'android') # Android: Bug 775227
[test_fileapi_slice2.html]
[test_fileapi_slice_realFile_2.html]
skip-if = (toolkit == 'android') # Android: Bug 775227
[test_fileapi_slice_memFile_1.html]
skip-if = (toolkit == 'android') # Android: Bug 775227
[test_fileapi_slice_memFile_2.html]
skip-if = (toolkit == 'android') # Android: Bug 775227
[test_fileapi_slice_image.html]
skip-if = (toolkit == 'android') # Android: Bug 775227

Просмотреть файл

@ -17,6 +17,7 @@
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestLongerTimeout(4);
// Create files containing data we'll test with. We'll want long
// strings to ensure they span multiple buffers while loading

Просмотреть файл

@ -16,12 +16,13 @@
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestLongerTimeout(4);
createCanvasURL()
.then(data => {
let cx = $("canvas").getContext('2d');
let memFile = cx.canvas.mozGetAsFile("image/png");
return testSlice(memFile, data.length, "image/png", data, "memFile");
return testSlice(memFile, data.length, "image/png", data, "memFile", RANGE_1);
})
.then(SimpleTest.finish);

Просмотреть файл

@ -0,0 +1,32 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for File API + Slice (in memory)</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="common_blob.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display">
<canvas id=canvas width=1100 height=1100 hidden moz-opaque></canvas>
</p>
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestLongerTimeout(4);
createCanvasURL()
.then(data => {
let cx = $("canvas").getContext('2d');
let memFile = cx.canvas.mozGetAsFile("image/png");
return testSlice(memFile, data.length, "image/png", data, "memFile", RANGE_2);
})
.then(SimpleTest.finish);
</script>
</body>
</html>

Просмотреть файл

@ -16,6 +16,7 @@
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestLongerTimeout(4);
let canvasData;
@ -26,7 +27,7 @@ createCanvasURL()
})
.then(file => {
return testSlice(file, canvasData.length, "", canvasData, "fileFile");
return testSlice(file, canvasData.length, "", canvasData, "fileFile", RANGE_1);
})
.then(SimpleTest.finish);

Просмотреть файл

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for File API + Slice (in file)</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="common_blob.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display">
<canvas id=canvas width=1100 height=1100 hidden moz-opaque></canvas>
</p>
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestLongerTimeout(4);
let canvasData;
createCanvasURL()
.then(data => {
canvasData = data;
return createFile(data, "basicTestFile");
})
.then(file => {
return testSlice(file, canvasData.length, "", canvasData, "fileFile", RANGE_2);
})
.then(SimpleTest.finish);
</script>
</body>
</html>