aboutsummaryrefslogtreecommitdiffstats
path: root/addon/js_upload/file-uploader/tests/test-handler-queue.htm
blob: 52e3b3a58b62d2aea017457e5ccb0f134bf2361a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE HTML>
<html>
<head>  
    <script src="jquery-1.4.2.min.js" type="text/javascript"></script>
    
    <link href="qunit/qunit/qunit.css" rel="stylesheet" type="text/css" media="screen" />
    <script src="qunit/qunit/qunit.js" type="text/javascript"></script>
    
    <script src="../client/fileuploader.js" type="text/javascript" ></script>
    <script>
jQuery(function(){

    function getHandler(){
        if(qq.UploadHandlerXhr.isSupported()){           
            return qq.UploadHandlerXhr;                        
        } else {
            return qq.UploadHandlerForm;
        }
    }    

    asyncTest("upload", function() {                                      
            expect(2);
                            
            var data = {stringOne: 'rtdfghdfhfh',stringTwo: 'dfsgsdfgsdg',stringThree: 'dfsgfhdfhdg'};
            var savedId;
                                                    
            var uploadHandler = new (getHandler())({
                action: 'action-handler-queue-test.php',
                maxConnections: 1,
                onComplete: function(id, fileName, response){
                    if (!response.success){
                        ok(false, 'server did not receive file')
                        return;    
                    }
                    
                    delete response.success;
                    delete response.qqfile;
                    
                    same(response, data, 'server received file and data');                                                              
                }
            });
                
                
            $('#testinput1, #testinput2').change(upload);    
            
            function upload(){
                setTimeout(start, 9000);
                
                var file = this;
                if (uploadHandler instanceof qq.UploadHandlerXhr){
                    file = this.files[0];
                }
                var id = uploadHandler.add(file);        
                uploadHandler.upload(id, data);                
            }
            
            
    });
});
    </script>  
</head>
<body> 
    <h1 id="qunit-header">File uploader tests</h1> 
    <h2 id="qunit-banner"></h2> 
    <h2 id="qunit-userAgent"></h2> 
    <ol id="qunit-tests"></ol>

        
    <p>
        Please select a file for each input below,
        should be less than 4 sec, between selection.
    </p>

    
    <input id="testinput1" type="file">
    <input id="testinput2" type="file">
        
</body> 
</html>