|
75 | 75 | "Item is an instance of plupload.ChunkUploader.");
|
76 | 76 |
|
77 | 77 | deepEqual(item.getOptions(), {
|
78 |
| - chunk_size: 0, |
79 | 78 | file_data_name: 'file',
|
80 | 79 | headers: false,
|
81 | 80 | http_method: 'POST',
|
82 | 81 | multipart: true,
|
83 | 82 | params: {},
|
84 | 83 | send_file_name: false,
|
85 |
| - stop_on_fail: true, |
86 | 84 | url: 'upload.php'
|
87 | 85 | },
|
88 | 86 | "Options have expected values.");
|
89 | 87 |
|
90 | 88 | });
|
91 | 89 |
|
| 90 | + up.bind('resumed', function() { |
| 91 | + this.start(); |
| 92 | + }); |
| 93 | + |
92 | 94 | up.bind('processed', function() {
|
93 | 95 | QUnit.start();
|
94 | 96 | });
|
|
102 | 104 | });
|
103 | 105 |
|
104 | 106 |
|
| 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 | + |
105 | 163 | // test options immutability in uploadCHunk()
|
106 | 164 |
|
107 | 165 | // _options.chunk_size set and not
|
|
0 commit comments