OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <title></title> | |
5 <style> | |
6 | |
7 </style> | |
8 <script src= | |
9 "http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"> | |
10 </script> | |
11 <script src="../../cr.js"></script> | |
12 <script src="../event_target.js"></script> | |
13 <script src="../ui.js"></script> | |
14 <script src="array_data_model.js"></script> | |
15 <script src="list_selection_model.js"></script> | |
16 <script src="list_selection_controller.js"></script> | |
17 <script src="list_item.js"></script> | |
18 <script src="list.js"></script> | |
19 <script src="grid.js"></script> | |
20 <script> | |
21 | |
22 goog.require('goog.testing.jsunit'); | |
23 | |
24 </script> | |
25 | |
26 </head> | |
27 <body> | |
28 | |
29 <script> | |
30 | |
31 function testGetColumnCount() { | |
32 var g = cr.ui.Grid.prototype; | |
33 g.measured_ = { | |
34 height: 8, | |
35 marginTop: 0, | |
36 marginBottom: 0, | |
37 width: 10, | |
38 marginLeft: 0, | |
39 marginRight: 0 | |
40 }; | |
41 var columns = g.getColumnCount_(); | |
42 g.measured_.width = 0; | |
43 columns = g.getColumnCount_(); | |
44 // Item width equals 0. | |
45 assertEquals(0, columns); | |
46 | |
47 g.measured_.width = 10; | |
48 columns = g.getColumnCount_(); | |
49 // No item in the list. | |
50 assertEquals(0, columns); | |
51 | |
52 g.dataModel_ = new cr.ui.ArrayDataModel([0, 1, 2]); | |
53 g.clientWidthWithoutScrollbar_ = 8; | |
54 columns = g.getColumnCount_(); | |
55 // Client width is smaller than item width. | |
56 assertEquals(0, columns); | |
57 | |
58 g.clientWidthWithoutScrollbar_ = 20; | |
59 // Client height can fit two rows. | |
60 g.clientHeight_ = 16; | |
61 columns = g.getColumnCount_(); | |
62 assertEquals(2, columns); | |
63 | |
64 // Client height can not fit two rows. A scroll bar is needed. | |
65 g.clientHeight_ = 15; | |
66 g.clientWidthWithScrollbar_ = 18; | |
67 columns = g.getColumnCount_(); | |
68 // Can not fit two columns due to the scroll bar. | |
69 assertEquals(1, columns); | |
70 | |
71 g.clientHeight_ = 16; | |
72 g.measured_.marginTop = 1; | |
73 columns = g.getColumnCount_(); | |
74 // Can fit two columns due to uncollapse margin. | |
75 assertEquals(2, columns); | |
76 | |
77 g.measured_.marginBottom = 1; | |
78 columns = g.getColumnCount_(); | |
79 // Can not fit two columns due to margin. | |
80 assertEquals(1, columns); | |
81 | |
82 g.measured_.marginTop = 0; | |
83 g.measured_.marginBottom = 0; | |
84 g.measured_.marginLeft = 1; | |
85 columns = g.getColumnCount_(); | |
86 // Can fit two columns due to uncollapse margin. | |
87 assertEquals(2, columns); | |
88 | |
89 g.measured_.marginRight = 1; | |
90 columns = g.getColumnCount_(); | |
91 // Can not fit two columns due to margin on left and right side. | |
92 assertEquals(1, columns); | |
93 } | |
94 | |
95 </script> | |
96 | |
97 </body> | |
98 </html> | |
OLD | NEW |