Skip to content

Commit f5cd267

Browse files
author
Davit Barbakadze
committed
FileUploader: Test chunk_size.
1 parent 29e453e commit f5cd267

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

tests/auto/FileUploader.html

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,22 @@
7575
"Item is an instance of plupload.ChunkUploader.");
7676

7777
deepEqual(item.getOptions(), {
78-
chunk_size: 0,
7978
file_data_name: 'file',
8079
headers: false,
8180
http_method: 'POST',
8281
multipart: true,
8382
params: {},
8483
send_file_name: false,
85-
stop_on_fail: true,
8684
url: 'upload.php'
8785
},
8886
"Options have expected values.");
8987

9088
});
9189

90+
up.bind('resumed', function() {
91+
this.start();
92+
});
93+
9294
up.bind('processed', function() {
9395
QUnit.start();
9496
});
@@ -102,6 +104,62 @@
102104
});
103105

104106

107+
test("Options: chunk_size='200kb'", function() {
108+
var self = this;
109+
110+
var dispatched = {
111+
'started': 0,
112+
'beforestart': 0,
113+
//'chunkuploadfailed': 0,
114+
'chunkuploaded': 0,
115+
'progress': 0,
116+
//'paused': 0
117+
};
118+
119+
var up = new plupload.FileUploader(this.file, this.queue);
120+
121+
var chunkSize = plupload.parseSize('10kb');
122+
var chunksNum = Math.ceil(this.file.size / chunkSize);
123+
124+
// monitor events
125+
plupload.each(dispatched, function(num, type) {
126+
up.bind(type, function() {
127+
dispatched[type]++;
128+
});
129+
});
130+
131+
up.bind('resumed', function() {
132+
this.start();
133+
});
134+
135+
up.bind('started', function() {
136+
137+
ok(true, "started event has been dispatched.");
138+
139+
equal(self.queue.stats.queued, chunksNum,
140+
chunksNum + " item(s) added to the queue.");
141+
142+
var item = getItemAt(0, self.queue);
143+
ok(item instanceof plupload.ChunkUploader,
144+
"Item is an instance of plupload.ChunkUploader.");
145+
146+
147+
});
148+
149+
up.bind('processed', function() {
150+
QUnit.start();
151+
plupload.each(dispatched, function(num, type) {
152+
ok(num > 0, type + ' has been dispatched ' + num + ' times.');
153+
});
154+
});
155+
156+
up.setOption('chunk_size', chunkSize);
157+
158+
QUnit.stop();
159+
up.start();
160+
});
161+
162+
105163
// test options immutability in uploadCHunk()
106164

107165
// _options.chunk_size set and not

0 commit comments

Comments
 (0)