/
datatable-unittest.js
293 lines (255 loc) · 13.3 KB
/
datatable-unittest.js
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/**
* Copyright (C) 2009 Orbeon, Inc.
*
* lib program is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
*
* lib program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
*/
var testCase = {
name: "datatable",
test314415: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314415', function() {
ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() {
ORBEON.xforms.Document.setValue("show", "true");
}, function() {
// Check the table structure
var table = YAHOO.util.Dom.get('my-accordion$_314415-table$_314415-table-table·1');
thiss.checkTableStructure(table, 1, true);
ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() {
ORBEON.xforms.Document.setValue("show", "false");
}, function() {
table = YAHOO.util.Dom.get('my-accordion$_314415-table$_314415-table-table·1');
YAHOO.util.Assert.isNull(table, "The table should have been deleted");
ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() {
ORBEON.xforms.Document.setValue("show", "true");
}, function() {
// Check the table structure
table = YAHOO.util.Dom.get('my-accordion$_314415-table$_314415-table-table·1');
thiss.checkTableStructure(table, 1, true);
thiss.closeAccordionCase(thiss, '_314415');
});
});
});
}
)
;
},
test314422: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314422', function() {
ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() {
ORBEON.xforms.Document.setValue("maxLength", "1000");
}, function() {
// Check the table structure
var table = YAHOO.util.Dom.get('my-accordion$_314422-table$_314422-table-table');
thiss.checkColumnValues(table, 1, false, [0, 1, 2, 3, 4]);
var container = YAHOO.util.Dom.get('my-accordion$_314422-table$_314422-table-container');
thiss.checkPaginationLinks(container, ['-<< first', '-< prev', '-1', '+2', '+3', '+4', '+5', '+6', '+7', '+8', '+next >', '+last >>']);
var link6 = YAHOO.util.Dom.get('my-accordion$_314422-table$xf-30·6');
ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() {
YAHOO.util.UserAction.click(link6, {clientX: 1});
}, function() {
thiss.checkColumnValues(table, 1, false, [25, 26, 27, 28, 29]);
thiss.checkPaginationLinks(container, ['+<< first', '+< prev', '+1', '+2', '+3', '+4', '+5', '-6', '+7', '+8', '+next >', '+last >>']);
ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() {
ORBEON.xforms.Document.setValue("maxLength", "30");
}, function() {
// Test the status after clicking on "last"
thiss.checkColumnValues(table, 1, false, [35, 37]);
thiss.checkPaginationLinks(container, ['+<< first', '+< prev', '+1', '-2', '-next >', '-last >>']);
thiss.closeAccordionCase(thiss, '_314422');
});
});
});
});
}
,
test314359: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314359', function() {
// Check the table structure
var table = YAHOO.util.Dom.get('my-accordion$table-314359$table-314359-table');
thiss.checkIsSplit(table, true);
thiss.checkTableStructure(table, 2, true);
thiss.checkCellClasses(table, true);
thiss.checkCellStyles(table, true);
thiss.closeAccordionCase(thiss, '_314359');
});
}
,
test314217: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314217', function() {
var tbody = YAHOO.util.Dom.get('my-accordion$table-314217$table-314217-tbody');
var bodyContainer = tbody.parentNode.parentNode;
thiss.checkHorizontalScrollbar(bodyContainer);
thiss.closeAccordionCase(thiss, '_314217');
});
}
,
testWidths: function() {
var thiss = this;
thiss.openAccordionCase(thiss, 'widths', function() {
var table = YAHOO.util.Dom.get('my-accordion$table-widths$table-widths-table');
thiss.checkRowWidth(table.tHead.rows[0]);
thiss.checkTableAndContainerWidths(YAHOO.util.Dom.get('my-accordion$table-widths$table-widths-table'));
thiss.closeAccordionCase(thiss, 'widths');
});
}
,
testWidthsResizeable: function() {
var thiss = this;
thiss.openAccordionCase(thiss, 'widths-resizeable', function() {
var table = YAHOO.util.Dom.get('my-accordion$table-widths-resizeable$table-widths-resizeable-table');
thiss.checkRowWidth(table.tHead.rows[0]);
thiss.checkTableAndContainerWidths(table);
thiss.closeAccordionCase(thiss, 'widths-resizeable');
});
}
,
testWidthsResizeable100pxRight: function() {
var thiss = this;
thiss.openAccordionCase(thiss, 'widths-resizeable', function() {
var table = YAHOO.util.Dom.get('my-accordion$table-widths-resizeable$table-widths-resizeable-table');
var th1 = table.tHead.rows[0].cells[0];
var th2 = table.tHead.rows[0].cells[1];
var width1 = th1.clientWidth;
var width2 = th2.clientWidth;
thiss.resizeColumn(th2, 100, 10);
thiss.checkTableAndContainerWidths(table);
YAHOO.util.Assert.areEqual(width1, th1.clientWidth, "The width of the first column shouldn't change (before: " + width1 + ", after: " + width2 + ").");
YAHOO.util.Assert.areEqual(width2 + 100, th2.clientWidth, "The width of the second column should be " + (width2 + 100) + ", not " + th2.clientWidth);
thiss.checkRowWidth(table.tHead.rows[0]);
thiss.closeAccordionCase(thiss, 'widths-resizeable');
});
}
,
testWidthsResizeable100pxLeft: function() {
var thiss = this;
thiss.openAccordionCase(thiss, 'widths-resizeable', function() {
var table = YAHOO.util.Dom.get('my-accordion$table-widths-resizeable$table-widths-resizeable-table');
var th1 = table.tHead.rows[0].cells[0];
var th2 = table.tHead.rows[0].cells[1];
var width1 = th1.clientWidth;
var width2 = th2.clientWidth;
thiss.resizeColumn(th2, -100, 10);
thiss.checkTableAndContainerWidths(table);
YAHOO.util.Assert.areEqual(width1, th1.clientWidth, "The wdith of the first column shouldn't change (before: " + width1 + ", after: " + width2 + ").");
YAHOO.util.Assert.areEqual(width2 - 100, th2.clientWidth, "The width of the second column should be " + (width2 - 100) + ", not " + th2.clientWidth);
thiss.checkRowWidth(table.tHead.rows[0]);
thiss.closeAccordionCase(thiss, 'widths-resizeable');
});
}
,
testWidthsResizeable10MorePxLeft: function() {
var thiss = this;
thiss.openAccordionCase(thiss, 'widths-resizeable', function() {
var table = YAHOO.util.Dom.get('my-accordion$table-widths-resizeable$table-widths-resizeable-table');
var th1 = table.tHead.rows[0].cells[0];
var th2 = table.tHead.rows[0].cells[1];
var width1 = th1.clientWidth;
var width2 = th2.clientWidth;
thiss.resizeColumn(th2, -10);
thiss.checkTableAndContainerWidths(table);
thiss.checkRowWidth(table.tHead.rows[0]);
YAHOO.util.Assert.areEqual(width1, th1.clientWidth, "The wdith of the first column shouldn't change (before: " + width1 + ", after: " + width2 + ").");
YAHOO.util.Assert.areEqual(width2 - 10, th2.clientWidth, "The width of the second column should be " + (width2 - 10) + ", not " + th2.clientWidth);
thiss.closeAccordionCase(thiss, 'widths-resizeable');
});
}
,
test314216: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314216', function() {
var th = YAHOO.util.Dom.get('my-accordion$table-314216$th-314216-2');
var resizerliner = ORBEON.widgets.datatable.utils.getFirstChildByTagAndClassName(th, 'div', 'yui-dt-resizerliner');
var liner = ORBEON.widgets.datatable.utils.getFirstChildByTagAndClassName(resizerliner, 'div', 'yui-dt-liner');
var resizer = ORBEON.widgets.datatable.utils.getFirstChildByTagAndClassName(resizerliner, 'div', 'yui-dt-resizer');
thiss.resizeColumn(th, -100, 5);
YAHOO.util.Assert.isTrue(th.clientWidth > 0, 'The column width should be greater than 0, not ' + th.clientWidth);
thiss.checkTableAndContainerWidths(YAHOO.util.Dom.get('my-accordion$table-314216$table-314216-table'));
thiss.checkCellWidth(th);
thiss.closeAccordionCase(thiss, '_314216');
});
}
,
test314209: function() {
var thiss = this;
thiss.closeAccordionCase(thiss, '_314209', function() {
thiss.openAccordionCase(thiss, '_314209', function() {
var table = YAHOO.util.Dom.get('my-accordion$table-314209$table-314209-table');
var visibility = YAHOO.util.Dom.getStyle(table, 'visibility');
YAHOO.util.Assert.isTrue(visibility == 'visible' || visibility == 'inherit', 'Visibility should be visible or inherit, not ' + visibility);
// unfortunately, I haven't found any way to check that the table is actually visible!
thiss.closeAccordionCase(thiss, '_314209');
});
});
}
,
test314211: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314211', function() {
var table = YAHOO.util.Dom.get('my-accordion$table-314211$table-314211-table');
YAHOO.util.Assert.isTrue(table.clientWidth < 300, 'The table width (' + table.clientWidth + "px) should be small, let's say < 300px...");
thiss.closeAccordionCase(thiss, '_314211');
});
}
,
test314174: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314174');
//TODO: test something here!
thiss.closeAccordionCase(thiss, '_314174');
}
,
test314210: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314210', function() {
var headerTable = YAHOO.util.Dom.get('my-accordion$table-314210$table-314210-table');
YAHOO.util.Assert.isTrue(headerTable.clientWidth > headerTable.parentNode.clientWidth, 'The table header width (' + headerTable.clientWidth + 'px) should be larger than its container width (' + headerTable.parentNode.clientWidth + 'px).');
thiss.closeAccordionCase(thiss, '_314210');
});
}
,
test314292: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314292', function() {
window.resizeBy(-50, 0);
thiss.wait(function() {
var table = YAHOO.util.Dom.get('my-accordion$table-314292$table-314292-table');
// The following test seems to detect the root cause of this bug
thiss.checkEmbeddedWidthAndHeight(table.parentNode.parentNode);
thiss.checkTableAndContainerWidths(table);
var tableX = YAHOO.util.Dom.getX(table);
var containerX = YAHOO.util.Dom.getX(table.parentNode.parentNode);
// The next one actually checks that the table does not overlap the border of the main container
// but is isn't 100% reliable
// YAHOO.util.Assert.areEqual(containerX, tableX - 1, 'The table left (' + tableX + ") should be 1 px right to the container left (" + containerX + ')');
window.resizeBy(50, 0);
thiss.closeAccordionCase(thiss, '_314292');
}, 500);
});
}
,
EOS: ""
}
ORBEON.xforms.Events.orbeonLoadedEvent.subscribe(function() {
for (var property in ORBEON.widgets.datatable.unittests_lib) {
testCase[property] = ORBEON.widgets.datatable.unittests_lib[property];
}
YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase(testCase));
AccordionMenu.setting('my-accordion$dl', {animation: true, seconds: 0.001, openedIds: [], dependent: false, easeOut: false});
if (parent && parent.TestManager) {
parent.TestManager.load();
} else {
new YAHOO.tool.TestLogger();
YAHOO.tool.TestRunner.run();
}
});