- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / webui / grid_test.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4
5 <script>
6
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
16   };
17   var columns = g.getColumnCount_();
18   g.measured_.width = 0;
19   columns = g.getColumnCount_();
20   // Item width equals 0.
21   assertEquals(0, columns);
22
23   g.measured_.width = 10;
24   columns = g.getColumnCount_();
25   // No item in the list.
26   assertEquals(0, columns);
27
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);
33
34   g.clientWidthWithoutScrollbar_ = 20;
35   // Client height can fit two rows.
36   g.clientHeight_ = 16;
37   columns = g.getColumnCount_();
38   assertEquals(2, columns);
39
40   // Client height can not fit two rows. A scroll bar is needed.
41   g.clientHeight_ = 15;
42   g.clientWidthWithScrollbar_ = 18;
43   columns = g.getColumnCount_();
44   // Can not fit two columns due to the scroll bar.
45   assertEquals(1, columns);
46
47   g.clientHeight_ = 16;
48   g.measured_.marginTop = 1;
49   columns = g.getColumnCount_();
50   // Can fit two columns due to uncollapse margin.
51   assertEquals(2, columns);
52
53   g.measured_.marginBottom = 1;
54   columns = g.getColumnCount_();
55   // Can not fit two columns due to margin.
56   assertEquals(1, columns);
57
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);
64
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);
69 }
70
71 </script>
72
73 </body>
74 </html>