diff --git a/tests/auto/FileUploader.html b/tests/auto/FileUploader.html index 6b6425b84..ea365a09b 100644 --- a/tests/auto/FileUploader.html +++ b/tests/auto/FileUploader.html @@ -75,20 +75,22 @@ "Item is an instance of plupload.ChunkUploader."); deepEqual(item.getOptions(), { - chunk_size: 0, file_data_name: 'file', headers: false, http_method: 'POST', multipart: true, params: {}, send_file_name: false, - stop_on_fail: true, url: 'upload.php' }, "Options have expected values."); }); + up.bind('resumed', function() { + this.start(); + }); + up.bind('processed', function() { QUnit.start(); }); @@ -102,6 +104,62 @@ }); +test("Options: chunk_size='200kb'", function() { + var self = this; + + var dispatched = { + 'started': 0, + 'beforestart': 0, + //'chunkuploadfailed': 0, + 'chunkuploaded': 0, + 'progress': 0, + //'paused': 0 + }; + + var up = new plupload.FileUploader(this.file, this.queue); + + var chunkSize = plupload.parseSize('10kb'); + var chunksNum = Math.ceil(this.file.size / chunkSize); + + // monitor events + plupload.each(dispatched, function(num, type) { + up.bind(type, function() { + dispatched[type]++; + }); + }); + + up.bind('resumed', function() { + this.start(); + }); + + up.bind('started', function() { + + ok(true, "started event has been dispatched."); + + equal(self.queue.stats.queued, chunksNum, + chunksNum + " item(s) added to the queue."); + + var item = getItemAt(0, self.queue); + ok(item instanceof plupload.ChunkUploader, + "Item is an instance of plupload.ChunkUploader."); + + + }); + + up.bind('processed', function() { + QUnit.start(); + plupload.each(dispatched, function(num, type) { + ok(num > 0, type + ' has been dispatched ' + num + ' times.'); + }); + }); + + up.setOption('chunk_size', chunkSize); + + QUnit.stop(); + up.start(); +}); + + // test options immutability in uploadCHunk() // _options.chunk_size set and not