Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/test/data/webui/grid_test.html

Issue 916353002: cr.ui.Grid: Consider padding to determine the number of columns in a row. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move the padding-measuring code to updateMetrics_. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/grid.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 4
5 <script> 5 <script>
6 6
7 function testGetColumnCount() { 7 function testGetColumnCount() {
8 var g = cr.ui.Grid.prototype; 8 var g = cr.ui.Grid.prototype;
9 g.measured_ = { 9 g.measured_ = {
10 height: 8, 10 height: 8,
11 marginTop: 0, 11 marginTop: 0,
12 marginBottom: 0, 12 marginBottom: 0,
13 width: 10, 13 width: 10,
14 marginLeft: 0, 14 marginLeft: 0,
15 marginRight: 0 15 marginRight: 0
16 }; 16 };
17 var columns = g.getColumnCount_(); 17 var columns = g.getColumnCount_();
18 g.measured_.width = 0; 18 g.measured_.width = 0;
19 columns = g.getColumnCount_(); 19 columns = g.getColumnCount_();
20 // Item width equals 0. 20 // Item width equals 0.
21 assertEquals(0, columns); 21 assertEquals(0, columns);
22 22
23 g.measured_.width = 10; 23 g.measured_.width = 10;
24 columns = g.getColumnCount_(); 24 columns = g.getColumnCount_();
25 // No item in the list. 25 // No item in the list.
26 assertEquals(0, columns); 26 assertEquals(0, columns);
27 27
28 g.dataModel_ = new cr.ui.ArrayDataModel([0, 1, 2]); 28 g.dataModel_ = new cr.ui.ArrayDataModel([0, 1, 2]);
29 g.horizontalPadding_ = 0;
29 g.clientWidthWithoutScrollbar_ = 8; 30 g.clientWidthWithoutScrollbar_ = 8;
30 columns = g.getColumnCount_(); 31 columns = g.getColumnCount_();
31 // Client width is smaller than item width. 32 // Client width is smaller than item width.
32 assertEquals(0, columns); 33 assertEquals(0, columns);
33 34
34 g.clientWidthWithoutScrollbar_ = 20; 35 g.clientWidthWithoutScrollbar_ = 20;
35 // Client height can fit two rows. 36 // Client height can fit two rows.
36 g.clientHeight_ = 16; 37 g.clientHeight_ = 16;
37 columns = g.getColumnCount_(); 38 columns = g.getColumnCount_();
38 assertEquals(2, columns); 39 assertEquals(2, columns);
(...skipping 20 matching lines...) Expand all
59 g.measured_.marginBottom = 0; 60 g.measured_.marginBottom = 0;
60 g.measured_.marginLeft = 1; 61 g.measured_.marginLeft = 1;
61 columns = g.getColumnCount_(); 62 columns = g.getColumnCount_();
62 // Can fit two columns due to uncollapse margin. 63 // Can fit two columns due to uncollapse margin.
63 assertEquals(2, columns); 64 assertEquals(2, columns);
64 65
65 g.measured_.marginRight = 1; 66 g.measured_.marginRight = 1;
66 columns = g.getColumnCount_(); 67 columns = g.getColumnCount_();
67 // Can not fit two columns due to margin on left and right side. 68 // Can not fit two columns due to margin on left and right side.
68 assertEquals(1, columns); 69 assertEquals(1, columns);
70
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);
77
78 g.horizontalPadding_ = 3;
79 columns = g.getColumnCount_();
80 // Can not fit two columns due to bigger horizontal padding.
81 assertEquals(1, columns);
69 } 82 }
70 83
71 </script> 84 </script>
72 85
73 </body> 86 </body>
74 </html> 87 </html>
OLDNEW
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/grid.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698