7 function testGetColumnCount() {
8 var g
= cr
.ui
.Grid
.prototype;
17 var columns
= g
.getColumnCount_();
18 g
.measured_
.width
= 0;
19 columns
= g
.getColumnCount_();
20 // Item width equals 0.
21 assertEquals(0, columns
);
23 g
.measured_
.width
= 10;
24 columns
= g
.getColumnCount_();
25 // No item in the list.
26 assertEquals(0, columns
);
28 g
.dataModel_
= new cr
.ui
.ArrayDataModel([0, 1, 2]);
29 g
.clientWidthWithoutScrollbar_
= 8;
30 columns
= g
.getColumnCount_();
31 // Client width is smaller than item width.
32 assertEquals(0, columns
);
34 g
.clientWidthWithoutScrollbar_
= 20;
35 // Client height can fit two rows.
37 columns
= g
.getColumnCount_();
38 assertEquals(2, columns
);
40 // Client height can not fit two rows. A scroll bar is needed.
42 g
.clientWidthWithScrollbar_
= 18;
43 columns
= g
.getColumnCount_();
44 // Can not fit two columns due to the scroll bar.
45 assertEquals(1, columns
);
48 g
.measured_
.marginTop
= 1;
49 columns
= g
.getColumnCount_();
50 // Can fit two columns due to uncollapse margin.
51 assertEquals(2, columns
);
53 g
.measured_
.marginBottom
= 1;
54 columns
= g
.getColumnCount_();
55 // Can not fit two columns due to margin.
56 assertEquals(1, columns
);
58 g
.measured_
.marginTop
= 0;
59 g
.measured_
.marginBottom
= 0;
60 g
.measured_
.marginLeft
= 1;
61 columns
= g
.getColumnCount_();
62 // Can fit two columns due to uncollapse margin.
63 assertEquals(2, columns
);
65 g
.measured_
.marginRight
= 1;
66 columns
= g
.getColumnCount_();
67 // Can not fit two columns due to margin on left and right side.
68 assertEquals(1, columns
);