source: Dev/branches/rest-dojo-ui/client/util/doh/tests/robot.html @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.8 KB
Line 
1<html>
2<head>
3        <style>
4                @import "../robot/robot.css";
5        </style>
6        <script src="../runner.js"></script>
7        <script src="../robot.js"></script>
8</head>
9<body>
10<form>
11<input type="text" value="hi" id="textbox" style="position:absolute; left:0px; top:20px; font-family:system;"></input>
12</form>
13<script>
14var textbox=document.getElementById('textbox');
15var BACKSPACE=8;
16var END=35;
17var LEFT_ARROW=37;
18var SHIFT=16;
19doh.register("doh.robot",[
20{
21        name:"dojorobot1",
22        timeout:6900,
23        setUp:function(){
24                textbox.value="hi";
25        },
26        runTest:function(){
27                var d=new doh.Deferred();
28                doh.robot.mouseMove(30, 30, 500);
29                doh.robot.mouseClick({left:true}, 500);
30                doh.robot.typeKeys(" again", 500, 2500);
31                doh.robot.sequence(function(){
32                        if(textbox.value=="hi again"){
33                                textbox.value += ": passed";
34                                d.callback(true);
35                        }else{
36                                textbox.value += ": failed";
37                                d.errback(new Error("Expected value 'hi again', got "+textbox.value));
38                        }
39                }, 900);
40                return d;
41        }
42},
43{
44        name:"shiftarrow",
45        timeout:10000,
46        setUp:function(){
47                textbox.value="hi again";
48        },
49        runTest:function(){
50                var d=new doh.Deferred();
51                doh.robot.keyPress(END,500);
52                // test shift+arrow with keyPress
53                for(var i=0; i<3; i++){
54                        doh.robot.keyPress(LEFT_ARROW,500,{shift:true});
55                }
56                // test shift+arrow with keyDown then keyUp
57                doh.robot.keyDown(SHIFT,500);
58                for(var i=0; i<3; i++){
59                        doh.robot.keyDown(LEFT_ARROW,500);
60                        doh.robot.keyUp(LEFT_ARROW,20);
61                }
62                doh.robot.keyUp(SHIFT,500);
63                doh.robot.keyPress(BACKSPACE,500);
64                doh.robot.sequence(function(){
65                        if(textbox.value=="hi"){
66                                textbox.value += ": passed";
67                                d.callback(true);
68                        }else{
69                                textbox.value += ": failed";
70                                d.errback(new Error("Expected value 'hi', got "+textbox.value));
71                        }
72                }, 900);
73                return d;
74        }
75}
76]);
77doh.run();
78</script>
79</body>
80</html>
Note: See TracBrowser for help on using the repository browser.