Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: tracing/tracing/ui/base/table_test.html

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tracing/tracing/ui/base/table.html ('k') | tracing/tracing/ui/brushing_state.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2014 The Chromium Authors. All rights reserved. 3 Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/ui/base/deep_utils.html"> 8 <link rel="import" href="/tracing/ui/base/deep_utils.html">
9 <link rel="import" href="/tracing/ui/base/table.html"> 9 <link rel="import" href="/tracing/ui/base/table.html">
10 10
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 { 1009 {
1010 a: 'second', 1010 a: 'second',
1011 b: '2' 1011 b: '2'
1012 } 1012 }
1013 ]; 1013 ];
1014 table.rebuild(); 1014 table.rebuild();
1015 this.addHTMLOutput(table); 1015 this.addHTMLOutput(table);
1016 1016
1017 table.selectedTableRow = table.tableRows[0]; 1017 table.selectedTableRow = table.tableRows[0];
1018 assert.equal(table.selectedColumnIndex, 1); 1018 assert.equal(table.selectedColumnIndex, 1);
1019 var selectedCell = table.selectedCell;
1020 assert.strictEqual(selectedCell.row, table.tableRows[0]);
1021 assert.strictEqual(selectedCell.column, columns[1]);
1022 assert.strictEqual(selectedCell.value, '1');
1019 1023
1020 table.performKeyCommand_('ARROW_DOWN'); 1024 table.performKeyCommand_('ARROW_DOWN');
1021 table.performKeyCommand_('ARROW_RIGHT'); 1025 table.performKeyCommand_('ARROW_RIGHT');
1022 table.performKeyCommand_('ARROW_RIGHT'); 1026 table.performKeyCommand_('ARROW_RIGHT');
1023 table.performKeyCommand_('ARROW_LEFT'); 1027 table.performKeyCommand_('ARROW_LEFT');
1024 assert.equal(table.selectedTableRow, table.tableRows[1]); 1028 assert.equal(table.selectedTableRow, table.tableRows[1]);
1025 assert.equal(table.selectedColumnIndex, 2); 1029 assert.equal(table.selectedColumnIndex, 2);
1030 selectedCell = table.selectedCell;
1031 assert.strictEqual(selectedCell.row, table.tableRows[1]);
1032 assert.strictEqual(selectedCell.column, columns[2]);
1033 assert.strictEqual(selectedCell.value, 4);
1026 1034
1027 table.selectedTableRow = undefined; 1035 table.selectedTableRow = undefined;
1028 assert.equal(table.selectedTableRow, undefined); 1036 assert.isUndefined(table.selectedTableRow);
1029 assert.equal(table.selectedColumnIndex, undefined); 1037 assert.isUndefined(table.selectedColumnIndex);
1030 assert.equal(table.selectedColumnIndex, undefined); 1038 assert.isUndefined(table.selectedColumnIndex);
1039 assert.isUndefined(table.selectedCell);
1031 }); 1040 });
1032 1041
1033 test('cellSelectionNested', function() { 1042 test('cellSelectionNested', function() {
1034 var columns = [ 1043 var columns = [
1035 { 1044 {
1036 title: 'Title', 1045 title: 'Title',
1037 value: function(row) { return row.a; }, 1046 value: function(row) { return row.a; },
1038 width: '150px', 1047 width: '150px',
1039 supportsCellSelection: false 1048 supportsCellSelection: false
1040 }, 1049 },
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 // Sort by value. 1464 // Sort by value.
1456 table.sortColumnIndex = 1; 1465 table.sortColumnIndex = 1;
1457 1466
1458 // Rebuild the table synchronously instead of waiting for scheduleRebuild_'s 1467 // Rebuild the table synchronously instead of waiting for scheduleRebuild_'s
1459 // setTimeout(0). 1468 // setTimeout(0).
1460 table.rebuild(); 1469 table.rebuild();
1461 1470
1462 // Check that 'A' is still expanded. 1471 // Check that 'A' is still expanded.
1463 assert.isDefined(tr.b.findDeepElementMatchingPredicate(table, isB)); 1472 assert.isDefined(tr.b.findDeepElementMatchingPredicate(table, isB));
1464 }); 1473 });
1474
1475 test('columnSelection', function() {
1476 var table = document.createElement('tr-ui-b-table');
1477 table.tableColumns = [
1478 {
1479 title: 'Name',
1480 value: (row) => row.name
1481 },
1482 {
1483 title: 'colA',
1484 selectable: true,
1485 value: (row) => row.a,
1486 cmp: (rowA, rowB) => rowA.a - rowB.a
1487 },
1488 {
1489 title: 'colB',
1490 selectable: true,
1491 value: (row) => row.b,
1492 cmp: (rowA, rowB) => rowA.b - rowB.b
1493 }
1494 ];
1495 table.tableRows = [
1496 {name: 'foo', a: 42, b: -42},
1497 {name: 'bar', a: 57, b: 133}
1498 ];
1499 table.rebuild();
1500 table.selectionMode = SelectionMode.CELL;
1501 this.addHTMLOutput(table);
1502
1503 var eventCount = 0;
1504 table.addEventListener('selected-column-changed', event => ++eventCount);
1505
1506 assert.throws(function() {
1507 table.selectedTableColumn = table.tableColumns[0];
1508 });
1509
1510 table.selectedTableColumn = table.tableColumns[1];
1511 assert.strictEqual(eventCount, 1);
1512 assert.strictEqual(table.tableColumns[1], table.selectedTableColumn);
1513
1514 table.selectedTableColumn = table.tableColumns[2];
1515 assert.strictEqual(eventCount, 2);
1516 assert.strictEqual(table.tableColumns[2], table.selectedTableColumn);
1517
1518 table.selectedTableColumn = undefined;
1519 assert.strictEqual(eventCount, 3);
1520 assert.isUndefined(table.selectedTableColumn);
1521 });
1465 }); 1522 });
1466 </script> 1523 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/ui/base/table.html ('k') | tracing/tracing/ui/brushing_state.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698