OLD | NEW |
1 function initialize_DataGridTest() | 1 function initialize_DataGridTest() |
2 { | 2 { |
3 | 3 |
4 InspectorTest.preloadModule("data_grid"); | 4 InspectorTest.preloadModule("data_grid"); |
5 | 5 |
6 InspectorTest.dumpDataGrid = function(root, descentIntoCollapsed, prefix) | 6 InspectorTest.dumpDataGrid = function(root, descentIntoCollapsed, prefix) |
7 { | 7 { |
8 if (!prefix) | 8 if (!prefix) |
9 prefix = ""; | 9 prefix = ""; |
10 var suffix = root.selected ? " <- selected" : ""; | 10 var suffix = root.selected ? " <- selected" : ""; |
(...skipping 10 matching lines...) Expand all Loading... |
21 return; | 21 return; |
22 for (var child of root.children) | 22 for (var child of root.children) |
23 InspectorTest.dumpDataGrid(child, descentIntoCollapsed, prefix + " "); | 23 InspectorTest.dumpDataGrid(child, descentIntoCollapsed, prefix + " "); |
24 } | 24 } |
25 | 25 |
26 InspectorTest.validateDataGrid = function(root) | 26 InspectorTest.validateDataGrid = function(root) |
27 { | 27 { |
28 var children = root.children; | 28 var children = root.children; |
29 for (var i = 0; i < children.length; ++i) { | 29 for (var i = 0; i < children.length; ++i) { |
30 var child = children[i]; | 30 var child = children[i]; |
31 if (child.parent !== root) | 31 if (child.parent() !== root) |
32 throw "Wrong parent for child " + child.data.id + " of " + root.data
.id; | 32 throw "Wrong parent for child " + child.data.id + " of " + root.data
.id; |
33 if (child.nextSibling !== (i + 1 === children.length ? null : children[i
+ 1])) | 33 if (child.nextSibling !== (i + 1 === children.length ? null : children[i
+ 1])) |
34 throw "Wrong child.nextSibling for " + child.data.id + " (" + i + "
of " + children.length + ") "; | 34 throw "Wrong child.nextSibling for " + child.data.id + " (" + i + "
of " + children.length + ") "; |
35 if (child.previousSibling !== (i ? children[i - 1] : null)) | 35 if (child.previousSibling !== (i ? children[i - 1] : null)) |
36 throw "Wrong child.previousSibling for " + child.data.id + " (" + i
+ " of " + children.length + ") "; | 36 throw "Wrong child.previousSibling for " + child.data.id + " (" + i
+ " of " + children.length + ") "; |
37 if (child.parent && !child.parent._isRoot && child.depth !== root.depth
+ 1) | 37 if (child.parent() && !child.parent()._isRoot && child.depth !== root.de
pth + 1) |
38 throw "Wrong depth for " + child.data.id + " expected " + (root.dept
h + 1) + " but got " + child.depth; | 38 throw "Wrong depth for " + child.data.id + " expected " + (root.dept
h + 1) + " but got " + child.depth; |
39 InspectorTest.validateDataGrid(child); | 39 InspectorTest.validateDataGrid(child); |
40 } | 40 } |
41 var selectedNode = root.dataGrid.selectedNode; | 41 var selectedNode = root.dataGrid.selectedNode; |
42 if (!root.parent && selectedNode) { | 42 if (!root.parent() && selectedNode) { |
43 if (!selectedNode.selectable) | 43 if (!selectedNode.selectable) |
44 throw "Selected node is not selectable"; | 44 throw "Selected node is not selectable"; |
45 for (var node = selectedNode; node && node !== root; node = node.parent)
{ } | 45 for (var node = selectedNode; node && node !== root; node = node.parent(
)) { } |
46 if (!node) | 46 if (!node) |
47 throw "Selected node (" + selectedNode.data.id + ") is not within th
e DataGrid"; | 47 throw "Selected node (" + selectedNode.data.id + ") is not within th
e DataGrid"; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 InspectorTest.dumpAndValidateDataGrid = function(root) | 51 InspectorTest.dumpAndValidateDataGrid = function(root) |
52 { | 52 { |
53 InspectorTest.dumpDataGrid(root); | 53 InspectorTest.dumpDataGrid(root); |
54 InspectorTest.validateDataGrid(root); | 54 InspectorTest.validateDataGrid(root); |
55 } | 55 } |
56 | 56 |
57 } | 57 } |
OLD | NEW |