Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / webui / grid_test.html
blob889af6330b1a61d1ec08065f0c44bdfa8547da22
1 <!DOCTYPE html>
2 <html>
3 <body>
5 <script>
7 function testGetColumnCount() {
8 var g = cr.ui.Grid.prototype;
9 g.measured_ = {
10 height: 8,
11 marginTop: 0,
12 marginBottom: 0,
13 width: 10,
14 marginLeft: 0,
15 marginRight: 0
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.horizontalPadding_ = 0;
30 g.clientWidthWithoutScrollbar_ = 8;
31 columns = g.getColumnCount_();
32 // Client width is smaller than item width.
33 assertEquals(0, columns);
35 g.clientWidthWithoutScrollbar_ = 20;
36 // Client height can fit two rows.
37 g.clientHeight_ = 16;
38 columns = g.getColumnCount_();
39 assertEquals(2, columns);
41 // Client height can not fit two rows. A scroll bar is needed.
42 g.clientHeight_ = 15;
43 g.clientWidthWithScrollbar_ = 18;
44 columns = g.getColumnCount_();
45 // Can not fit two columns due to the scroll bar.
46 assertEquals(1, columns);
48 g.clientHeight_ = 16;
49 g.measured_.marginTop = 1;
50 columns = g.getColumnCount_();
51 // Can fit two columns due to uncollapse margin.
52 assertEquals(2, columns);
54 g.measured_.marginBottom = 1;
55 columns = g.getColumnCount_();
56 // Can not fit two columns due to margin.
57 assertEquals(1, columns);
59 g.measured_.marginTop = 0;
60 g.measured_.marginBottom = 0;
61 g.measured_.marginLeft = 1;
62 columns = g.getColumnCount_();
63 // Can fit two columns due to uncollapse margin.
64 assertEquals(2, columns);
66 g.measured_.marginRight = 1;
67 columns = g.getColumnCount_();
68 // Can not fit two columns due to margin on left and right side.
69 assertEquals(1, columns);
71 g.measured_.marginRight = 0;
72 g.horizontalPadding_ = 2;
73 g.clientWidthWithoutScrollbar_ = 22;
74 columns = g.getColumnCount_();
75 // Can fit two columns as (22-2=)20px width is avaiable for grid items.
76 assertEquals(2, columns);
78 g.horizontalPadding_ = 3;
79 columns = g.getColumnCount_();
80 // Can not fit two columns due to bigger horizontal padding.
81 assertEquals(1, columns);
84 </script>
86 </body>
87 </html>