4 <script src="jquery-1.4.2.min.js" type="text/javascript"></script>
6 <!-- test iwth jquery ui dialog -->
7 <link href="jquery-ui/ui-lightness/jquery-ui-1.8.4.custom.css" rel="stylesheet" type="text/css" media="screen" />
8 <script src="jquery-ui/jquery-ui-1.8.4.custom.min.js" type="text/javascript"></script>
10 <link href="qunit/qunit/qunit.css" rel="stylesheet" type="text/css" media="screen" />
11 <script src="qunit/qunit/qunit.js" type="text/javascript"></script>
13 <link href="../client/fileuploader.css" rel="stylesheet" type="text/css">
14 <script src="../client/fileuploader.js" type="text/javascript" ></script>
18 $("#dialog").dialog();
20 asyncTest("qq.FileUploader", function() {
23 var submitFileName, submitId;
25 var uploader = new qq.FileUploader({
26 element: document.getElementById('file-uploader'),
27 action: 'action-acceptance.php',
32 allowedExtensions: ['txt', 'val', 'webm'],
35 onSubmit: function(id, fileName){
36 if (fileName == '5text.txt'){
38 submitFileName = fileName;
39 } else if (fileName == '6text.txt'){
40 uploader.setParams({'new':'newvalue'});
42 same(uploader.getInProgress(), 0, 'getFilesInProgress');
44 setTimeout(function(){
45 same(uploader.getInProgress(), 1, 'getFilesInProgress');
47 } else if (fileName == '8text.txt'){
49 setTimeout(function(){
50 same(uploader.getInProgress(), 0, 'all uploads should have finished');
51 start(); // check test results
57 onComplete: function(id, fileName, responseJSON){
59 if (fileName == '4text.txt'){
60 same(responseJSON, {}, 'should be empty if server returned malformed json');
61 } else if (fileName == '5text.txt'){
62 same(submitId, id, "id in both callbacks match");
63 same(submitFileName, fileName, "filename in both callbacks match");
64 ok(responseJSON.one === 'value1' && responseJSON.two === 'value2', "server received default params");
65 same(responseJSON.fileName, fileName, "filename in onComplete correct");
66 } else if (fileName == '6text.txt'){
67 ok(responseJSON['new'] === 'newvalue' && responseJSON.one == null, "server received new params");
68 same(uploader.getInProgress(), 0, 'upload should have finished');
69 } else if (fileName == '8text.txt'){
70 ok(false, "upload should be cancelled by returning false in onSubmit");
79 <h1 id="qunit-header">File uploader tests</h1>
80 <h2 id="qunit-banner"></h2>
81 <h2 id="qunit-userAgent"></h2>
82 <ol id="qunit-tests"></ol>
84 <p>select files in sample-files dir, following order</p>
86 <li>select 1imagelong...long.gif, invalid ext error should appear</li>
87 <li>select 2larger.txt, invalid size message should appear (in FF3.6+,Safari4+,Chrome without doing request)</li>
88 <li>select 3empty.txt, invalid size message should appear (in FF3.6+,Safari4+,Chrome without doing request)</li>
89 <li>select 4text.txt, uploaded file should be marked as failed (server returns jsgkdfgu4eyij)</li>
90 <li>select 5text.txt, callback argument tests</li>
91 <li>select 6text.txt, setParams, isUploading</li>
92 <li>select 7small.txt, too small size message should appear (in FF3.6+,Safari4+,Chrome without doing request)</li>
93 <li>select 8text.txt, returning false in onSubmit cancells upload, file should not be added to list</li>
95 In FF,Chrome, select all files using drag-and-drop, only 1 error should appear.
99 <div id="dialog" title="Basic dialog">
100 File uploader inside a dialog
101 <div id="file-uploader"></div>