| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<title>doh.robot DataGrid tests</title> |
| 6 |
|
| 7 |
<style> |
| 8 |
@import "../../../../util/doh/robot/robot.css"; |
| 9 |
</style> |
| 10 |
|
| 11 |
|
| 12 |
<script type="text/javascript" src="../../../../dojo/dojo.js" |
| 13 |
data-dojo-config="isDebug: true"></script> |
| 14 |
<script type="text/javascript"> |
| 15 |
dojo.require("dijit.dijit"); // optimize: load dijit layer |
| 16 |
dojo.require("dijit.robotx"); |
| 17 |
dojo.require("dijit.tests.helpers"); // functions to help test |
| 18 |
|
| 19 |
dojo.addOnLoad(function(){ |
| 20 |
|
| 21 |
doh.robot.initRobot('_DataGrid.html'); |
| 22 |
|
| 23 |
doh.register("dojo.data integration", |
| 24 |
[ |
| 25 |
{ |
| 26 |
name: "user sort", |
| 27 |
grid: null, |
| 28 |
timeout:15000, |
| 29 |
setUp: function(){ |
| 30 |
var params = new dojo.global.Object(); |
| 31 |
params.id = 'prog_grid_1'; |
| 32 |
params.structure = dojo.global.structure1; |
| 33 |
params.store = dojo.global.structure1_store1; |
| 34 |
params.query = { id: '*' }; |
| 35 |
this.grid = new dojo.global.dojox.grid.DataGrid(params,dojo.byId('prog_grid_1')); |
| 36 |
this.grid.startup(); |
| 37 |
}, |
| 38 |
runTest: function(){ |
| 39 |
var d = new doh.Deferred(); |
| 40 |
var _this=this; |
| 41 |
var initialFocus = dojo.byId('initialfocus'); |
| 42 |
initialFocus.focus(); |
| 43 |
// now move focus to ID header of prog grid |
| 44 |
var tabCount = dojo.isIE? 2:(dojo.isFF?3:5); |
| 45 |
for(var i=0; i<tabCount; i++){ |
| 46 |
doh.robot.keyPress(dojo.keys.TAB,500); |
| 47 |
} |
| 48 |
doh.robot.keyPress(dojo.keys.SPACE,500); |
| 49 |
doh.robot.keyPress(dojo.keys.SPACE,500); |
| 50 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 51 |
var item=_this.grid.getItem(0); |
| 52 |
doh.is(99,item.id,"first item should have had id==99 due to reverse sort"); |
| 53 |
}),7000); |
| 54 |
return d; |
| 55 |
}, |
| 56 |
tearDown: function(){ |
| 57 |
var node = dojo.create('div',{id:this.grid.domNode.id, rowSelector:"20px"}); |
| 58 |
dojo.style(node,{width: "100%",height:"100px"}); |
| 59 |
var parent = this.grid.domNode.parentNode; |
| 60 |
this.grid.destroyRecursive(); |
| 61 |
parent.appendChild(node); |
| 62 |
this.grid = null; |
| 63 |
} |
| 64 |
} |
| 65 |
]); |
| 66 |
doh.register("UI verification",[ |
| 67 |
{ |
| 68 |
name: "edit columns", |
| 69 |
timeout:60000, |
| 70 |
grid: null, |
| 71 |
setUp:function(){ |
| 72 |
this.grid = dijit.byId('markup_grid_1'); |
| 73 |
}, |
| 74 |
runTest: function(){ |
| 75 |
// see also "edit reordered columns" test below |
| 76 |
var d = new doh.Deferred(); |
| 77 |
var grid=this.grid; |
| 78 |
var initialFocus = dojo.byId('initialfocus'); |
| 79 |
initialFocus.focus(); |
| 80 |
// now move focus to first ID cell of markup grid |
| 81 |
var tabCount = dojo.isIE? 3:(dojo.isFF?4:6); |
| 82 |
for(var i=0; i<tabCount; i++){ |
| 83 |
doh.robot.keyPress(dojo.keys.TAB,500); |
| 84 |
} |
| 85 |
// precondition: cells still arranged to id date priority mark status message amount amount |
| 86 |
var editorids=[null,'dijit_form_DateTextBox_0','dijit_form_ComboBox_0','dijit_form_CheckBox_0',null,'dijit_Editor_0','dijit_form_CurrencyTextBox_0','dijit_form_HorizontalSlider_0']; |
| 87 |
function nextTest(i){ |
| 88 |
if(i==editorids.length){ |
| 89 |
d.callback(true); |
| 90 |
return; |
| 91 |
} |
| 92 |
if(!editorids[i]){ |
| 93 |
doh.robot.keyPress(dojo.keys.RIGHT_ARROW,500); |
| 94 |
doh.robot.sequence(function(){ |
| 95 |
nextTest(i+1); |
| 96 |
},500); |
| 97 |
return; |
| 98 |
} |
| 99 |
doh.robot.sequence(function(){ |
| 100 |
var cells=dojo.query("td.dojoxGridCell",grid.views.views[1].scrollboxNode); |
| 101 |
doh.robot.keyPress(dojo.keys.ENTER,500); |
| 102 |
doh.robot.sequence(function(){ |
| 103 |
try{ |
| 104 |
// this better have opened the expected editor or something very bad happened |
| 105 |
doh.isNot(undefined,dijit.byId(editorids[i]),"Editing the "+i+" field of the 1st row did not open the expected editor."); |
| 106 |
doh.t(dijit.byId(editorids[i]).focused); |
| 107 |
grid.edit.cancel(); |
| 108 |
doh.robot.keyPress(dojo.keys.RIGHT_ARROW,500); |
| 109 |
doh.robot.sequence(function(){ |
| 110 |
nextTest(i+1); |
| 111 |
},500); |
| 112 |
}catch(e){ |
| 113 |
d.callback(e); |
| 114 |
} |
| 115 |
},2000); |
| 116 |
},500); |
| 117 |
} |
| 118 |
nextTest(0); |
| 119 |
return d; |
| 120 |
}, |
| 121 |
tearDown:function(){ |
| 122 |
// done editing |
| 123 |
|
| 124 |
this.grid.edit.cancel(); |
| 125 |
this.grid = null; |
| 126 |
} |
| 127 |
} |
| 128 |
]); |
| 129 |
doh.register("Context Menu",[ |
| 130 |
{ |
| 131 |
name: "invoke context menu", |
| 132 |
timeout:10000, |
| 133 |
grid: null, |
| 134 |
setUp:function(){ |
| 135 |
this.grid = dijit.byId('markup_grid_1'); |
| 136 |
}, |
| 137 |
runTest: function(){ |
| 138 |
|
| 139 |
var d = new doh.Deferred(); |
| 140 |
var grid=this.grid; |
| 141 |
var initialFocus = dojo.byId('initialfocus'); |
| 142 |
initialFocus.focus(); |
| 143 |
// now move focus to first header cell of markup grid |
| 144 |
var tabCount = dojo.isIE? 2:(dojo.isFF?3:5); |
| 145 |
for(var i=0; i<tabCount; i++){ |
| 146 |
doh.robot.keyPress(dojo.keys.TAB,500); |
| 147 |
} |
| 148 |
// move to Date Column Header |
| 149 |
doh.robot.keyPress(dojo.keys.RIGHT_ARROW,500); |
| 150 |
// open context menu via keyboard |
| 151 |
if (dojo.isMac) { |
| 152 |
doh.robot.keyPress(dojo.keys.SPACE, 500, { |
| 153 |
ctrl: true |
| 154 |
}); |
| 155 |
}else { |
| 156 |
doh.robot.keyPress(dojo.keys.F10, 500, { |
| 157 |
shift: true |
| 158 |
}); |
| 159 |
} |
| 160 |
|
| 161 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 162 |
var menu = dijit.byId("gridMenu"); |
| 163 |
doh.t(isVisible(menu), "menu is now shown"); |
| 164 |
doh.robot.keyPress(dojo.keys.ESCAPE,0, {}, true); // close context menu |
| 165 |
}), 1500); |
| 166 |
|
| 167 |
return d; |
| 168 |
|
| 169 |
}, |
| 170 |
tearDown:function(){ |
| 171 |
this.grid = null; |
| 172 |
} |
| 173 |
} |
| 174 |
]); |
| 175 |
doh.run(); |
| 176 |
}); |
| 177 |
</script> |
| 178 |
</head> |
| 179 |
</html> |