| Index: ui/file_manager/file_manager/foreground/js/ui/file_table_unittest.js
|
| diff --git a/ui/file_manager/file_manager/foreground/js/ui/file_table_unittest.js b/ui/file_manager/file_manager/foreground/js/ui/file_table_unittest.js
|
| index a2f67ce29a4f7b349c7aefb0ec050e3e201ae714..dc28e2c555cd067545a8c86beb9e2904b0f14b09 100644
|
| --- a/ui/file_manager/file_manager/foreground/js/ui/file_table_unittest.js
|
| +++ b/ui/file_manager/file_manager/foreground/js/ui/file_table_unittest.js
|
| @@ -183,3 +183,44 @@ function testExportAndRestoreColumnConfigWithHidingColumn() {
|
| assertArrayEquals(expectedWidths, getColumnWidths(newModel));
|
| assertEquals(expectedTotalWidth, newModel.totalWidth);
|
| }
|
| +
|
| +function testNormalizeWidth() {
|
| + var newContentWidth = 150;
|
| + var expectedWidths = [10, 20, 30, 40, 50];
|
| +
|
| + for (var i = 0; i < model.size; i++) {
|
| + model.setWidth(i, expectedWidths[i] * 17);
|
| + }
|
| +
|
| + // Resizes columns proportionally
|
| + model.normalizeWidths(newContentWidth);
|
| +
|
| + assertArrayEquals(expectedWidths, getColumnWidths(model));
|
| + assertEquals(newContentWidth, model.totalWidth);
|
| +}
|
| +
|
| +function testNormalizeWidthWithSmallWidth() {
|
| + model.normalizeWidths(10); // not enough width to contain all columns
|
| +
|
| + // Should keep the minimum width.
|
| + getColumnWidths(model).map(function(width) {
|
| + assertEquals(FileTableColumnModel.MIN_WIDTH_, width);
|
| + });
|
| +}
|
| +
|
| +function testSetWidthAndKeepTotal() {
|
| + // Make sure to take column snapshot. Required for setWidthAndKeepTotal.
|
| + model.initializeColumnPos();
|
| +
|
| + // Attempt to expand the 3rd column exceeding the window.
|
| + model.setWidthAndKeepTotal(2, 400);
|
| +
|
| + // Should keep the minimum width.
|
| + getColumnWidths(model).map(function(width) {
|
| + assertTrue(width >= FileTableColumnModel.MIN_WIDTH_);
|
| + });
|
| + var minWidth = FileTableColumnModel.MIN_WIDTH_;
|
| + // Total width = 500.
|
| + expectedWidths = [100, 100, 500 - 100 * 2 - minWidth * 2, minWidth, minWidth];
|
| + assertArrayEquals(expectedWidths, getColumnWidths(model));
|
| +}
|
|
|