Index: tracing/tracing/ui/base/table_test.html |
diff --git a/tracing/tracing/ui/base/table_test.html b/tracing/tracing/ui/base/table_test.html |
index b2ca65577d6b0f56d4f1871359bc0a254c6cdd31..ac2f9a2ac9153335aa36727dd4da4f3a83c86bd6 100644 |
--- a/tracing/tracing/ui/base/table_test.html |
+++ b/tracing/tracing/ui/base/table_test.html |
@@ -1016,6 +1016,10 @@ tr.b.unittest.testSuite(function() { |
table.selectedTableRow = table.tableRows[0]; |
assert.equal(table.selectedColumnIndex, 1); |
+ var selectedCell = table.selectedCell; |
+ assert.strictEqual(selectedCell.row, table.tableRows[0]); |
+ assert.strictEqual(selectedCell.column, columns[1]); |
+ assert.strictEqual(selectedCell.value, '1'); |
table.performKeyCommand_('ARROW_DOWN'); |
table.performKeyCommand_('ARROW_RIGHT'); |
@@ -1023,11 +1027,16 @@ tr.b.unittest.testSuite(function() { |
table.performKeyCommand_('ARROW_LEFT'); |
assert.equal(table.selectedTableRow, table.tableRows[1]); |
assert.equal(table.selectedColumnIndex, 2); |
+ selectedCell = table.selectedCell; |
+ assert.strictEqual(selectedCell.row, table.tableRows[1]); |
+ assert.strictEqual(selectedCell.column, columns[2]); |
+ assert.strictEqual(selectedCell.value, 4); |
table.selectedTableRow = undefined; |
- assert.equal(table.selectedTableRow, undefined); |
- assert.equal(table.selectedColumnIndex, undefined); |
- assert.equal(table.selectedColumnIndex, undefined); |
+ assert.isUndefined(table.selectedTableRow); |
+ assert.isUndefined(table.selectedColumnIndex); |
+ assert.isUndefined(table.selectedColumnIndex); |
+ assert.isUndefined(table.selectedCell); |
}); |
test('cellSelectionNested', function() { |
@@ -1462,5 +1471,53 @@ tr.b.unittest.testSuite(function() { |
// Check that 'A' is still expanded. |
assert.isDefined(tr.b.findDeepElementMatchingPredicate(table, isB)); |
}); |
+ |
+ test('columnSelection', function() { |
+ var table = document.createElement('tr-ui-b-table'); |
+ table.tableColumns = [ |
+ { |
+ title: 'Name', |
+ value: (row) => row.name |
+ }, |
+ { |
+ title: 'colA', |
+ selectable: true, |
+ value: (row) => row.a, |
+ cmp: (rowA, rowB) => rowA.a - rowB.a |
+ }, |
+ { |
+ title: 'colB', |
+ selectable: true, |
+ value: (row) => row.b, |
+ cmp: (rowA, rowB) => rowA.b - rowB.b |
+ } |
+ ]; |
+ table.tableRows = [ |
+ {name: 'foo', a: 42, b: -42}, |
+ {name: 'bar', a: 57, b: 133} |
+ ]; |
+ table.rebuild(); |
+ table.selectionMode = SelectionMode.CELL; |
+ this.addHTMLOutput(table); |
+ |
+ var eventCount = 0; |
+ table.addEventListener('selected-column-changed', event => ++eventCount); |
+ |
+ assert.throws(function() { |
+ table.selectedTableColumn = table.tableColumns[0]; |
+ }); |
+ |
+ table.selectedTableColumn = table.tableColumns[1]; |
+ assert.strictEqual(eventCount, 1); |
+ assert.strictEqual(table.tableColumns[1], table.selectedTableColumn); |
+ |
+ table.selectedTableColumn = table.tableColumns[2]; |
+ assert.strictEqual(eventCount, 2); |
+ assert.strictEqual(table.tableColumns[2], table.selectedTableColumn); |
+ |
+ table.selectedTableColumn = undefined; |
+ assert.strictEqual(eventCount, 3); |
+ assert.isUndefined(table.selectedTableColumn); |
+ }); |
}); |
</script> |