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

Side by Side Diff: views/grid_layout_unittest.cc

Issue 115309: Remove even more ATL dependencies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « views/controls/tree/tree_view.cc ('k') | views/view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "views/grid_layout.h" 6 #include "views/grid_layout.h"
7 #include "views/view.h" 7 #include "views/view.h"
8 8
9 using views::ColumnSet; 9 using views::ColumnSet;
10 using views::GridLayout; 10 using views::GridLayout;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 for (int i = host.GetChildViewCount() - 1; i >= 0; i--) { 46 for (int i = host.GetChildViewCount() - 1; i >= 0; i--) {
47 host.RemoveChildView(host.GetChildViewAt(i)); 47 host.RemoveChildView(host.GetChildViewAt(i));
48 } 48 }
49 } 49 }
50 50
51 void GetPreferredSize() { 51 void GetPreferredSize() {
52 pref = layout->GetPreferredSize(&host); 52 pref = layout->GetPreferredSize(&host);
53 } 53 }
54 54
55 gfx::Size pref; 55 gfx::Size pref;
56 CRect bounds; 56 gfx::Rect bounds;
57 View host; 57 View host;
58 GridLayout* layout; 58 GridLayout* layout;
59 }; 59 };
60 60
61 class GridLayoutAlignmentTest : public testing::Test { 61 class GridLayoutAlignmentTest : public testing::Test {
62 public: 62 public:
63 GridLayoutAlignmentTest() : 63 GridLayoutAlignmentTest() :
64 host(), 64 host(),
65 v1(gfx::Size(10, 20)), 65 v1(gfx::Size(10, 20)),
66 layout(new GridLayout(&host)) {} 66 layout(new GridLayout(&host)) {}
67 67
68 virtual void SetUp() { 68 virtual void SetUp() {
69 } 69 }
70 70
71 virtual void TearDown() { 71 virtual void TearDown() {
72 delete layout; 72 delete layout;
73 } 73 }
74 74
75 virtual void RemoveAll() { 75 virtual void RemoveAll() {
76 for (int i = host.GetChildViewCount() - 1; i >= 0; i--) { 76 for (int i = host.GetChildViewCount() - 1; i >= 0; i--) {
77 host.RemoveChildView(host.GetChildViewAt(i)); 77 host.RemoveChildView(host.GetChildViewAt(i));
78 } 78 }
79 } 79 }
80 80
81 void TestAlignment(GridLayout::Alignment alignment, CRect* bounds) { 81 void TestAlignment(GridLayout::Alignment alignment, gfx::Rect* bounds) {
82 ColumnSet* c1 = layout->AddColumnSet(0); 82 ColumnSet* c1 = layout->AddColumnSet(0);
83 c1->AddColumn(alignment, alignment, 1, GridLayout::USE_PREF, 0, 0); 83 c1->AddColumn(alignment, alignment, 1, GridLayout::USE_PREF, 0, 0);
84 layout->StartRow(1, 0); 84 layout->StartRow(1, 0);
85 layout->AddView(&v1); 85 layout->AddView(&v1);
86 gfx::Size pref = layout->GetPreferredSize(&host); 86 gfx::Size pref = layout->GetPreferredSize(&host);
87 EXPECT_TRUE(gfx::Size(10, 20) == pref); 87 EXPECT_EQ(gfx::Size(10, 20), pref);
88 host.SetBounds(0, 0, 100, 100); 88 host.SetBounds(0, 0, 100, 100);
89 layout->Layout(&host); 89 layout->Layout(&host);
90 *bounds = v1.bounds().ToRECT(); 90 *bounds = v1.bounds();
91 RemoveAll(); 91 RemoveAll();
92 } 92 }
93 93
94 View host; 94 View host;
95 SettableSizeView v1; 95 SettableSizeView v1;
96 GridLayout* layout; 96 GridLayout* layout;
97 }; 97 };
98 98
99 TEST_F(GridLayoutAlignmentTest, Fill) { 99 TEST_F(GridLayoutAlignmentTest, Fill) {
100 CRect bounds; 100 gfx::Rect bounds;
101 TestAlignment(GridLayout::FILL, &bounds); 101 TestAlignment(GridLayout::FILL, &bounds);
102 EXPECT_TRUE(CRect(0, 0, 100, 100) == bounds); 102 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), bounds);
103 } 103 }
104 104
105 TEST_F(GridLayoutAlignmentTest, Leading) { 105 TEST_F(GridLayoutAlignmentTest, Leading) {
106 CRect bounds; 106 gfx::Rect bounds;
107 TestAlignment(GridLayout::LEADING, &bounds); 107 TestAlignment(GridLayout::LEADING, &bounds);
108 EXPECT_TRUE(CRect(0, 0, 10, 20) == bounds); 108 EXPECT_EQ(gfx::Rect(0, 0, 10, 20), bounds);
109 } 109 }
110 110
111 TEST_F(GridLayoutAlignmentTest, Center) { 111 TEST_F(GridLayoutAlignmentTest, Center) {
112 CRect bounds; 112 gfx::Rect bounds;
113 TestAlignment(GridLayout::CENTER, &bounds); 113 TestAlignment(GridLayout::CENTER, &bounds);
114 EXPECT_TRUE(CRect(45, 40, 55, 60) == bounds); 114 EXPECT_EQ(gfx::Rect(45, 40, 10, 20), bounds);
115 } 115 }
116 116
117 TEST_F(GridLayoutAlignmentTest, Trailing) { 117 TEST_F(GridLayoutAlignmentTest, Trailing) {
118 CRect bounds; 118 gfx::Rect bounds;
119 TestAlignment(GridLayout::TRAILING, &bounds); 119 TestAlignment(GridLayout::TRAILING, &bounds);
120 EXPECT_TRUE(CRect(90, 80, 100, 100) == bounds); 120 EXPECT_EQ(gfx::Rect(90, 80, 10, 20), bounds);
121 } 121 }
122 122
123 TEST_F(GridLayoutTest, TwoColumns) { 123 TEST_F(GridLayoutTest, TwoColumns) {
124 SettableSizeView v1(gfx::Size(10, 20)); 124 SettableSizeView v1(gfx::Size(10, 20));
125 SettableSizeView v2(gfx::Size(20, 20)); 125 SettableSizeView v2(gfx::Size(20, 20));
126 ColumnSet* c1 = layout->AddColumnSet(0); 126 ColumnSet* c1 = layout->AddColumnSet(0);
127 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 127 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
128 0, GridLayout::USE_PREF, 0, 0); 128 0, GridLayout::USE_PREF, 0, 0);
129 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 129 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
130 0, GridLayout::USE_PREF, 0, 0); 130 0, GridLayout::USE_PREF, 0, 0);
131 layout->StartRow(0, 0); 131 layout->StartRow(0, 0);
132 layout->AddView(&v1); 132 layout->AddView(&v1);
133 layout->AddView(&v2); 133 layout->AddView(&v2);
134 134
135 GetPreferredSize(); 135 GetPreferredSize();
136 EXPECT_TRUE(gfx::Size(30, 20) == pref); 136 EXPECT_EQ(gfx::Size(30, 20), pref);
137 137
138 host.SetBounds(0, 0, pref.width(), pref.height()); 138 host.SetBounds(0, 0, pref.width(), pref.height());
139 layout->Layout(&host); 139 layout->Layout(&host);
140 ExpectViewBoundsEquals(0, 0, 10, 20, &v1); 140 ExpectViewBoundsEquals(0, 0, 10, 20, &v1);
141 ExpectViewBoundsEquals(10, 0, 20, 20, &v2); 141 ExpectViewBoundsEquals(10, 0, 20, 20, &v2);
142 142
143 RemoveAll(); 143 RemoveAll();
144 } 144 }
145 145
146 TEST_F(GridLayoutTest, ColSpan1) { 146 TEST_F(GridLayoutTest, ColSpan1) {
147 SettableSizeView v1(gfx::Size(100, 20)); 147 SettableSizeView v1(gfx::Size(100, 20));
148 SettableSizeView v2(gfx::Size(10, 40)); 148 SettableSizeView v2(gfx::Size(10, 40));
149 ColumnSet* c1 = layout->AddColumnSet(0); 149 ColumnSet* c1 = layout->AddColumnSet(0);
150 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 150 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
151 0, GridLayout::USE_PREF, 0, 0); 151 0, GridLayout::USE_PREF, 0, 0);
152 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 152 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
153 1, GridLayout::USE_PREF, 0, 0); 153 1, GridLayout::USE_PREF, 0, 0);
154 layout->StartRow(0, 0); 154 layout->StartRow(0, 0);
155 layout->AddView(&v1, 2, 1); 155 layout->AddView(&v1, 2, 1);
156 layout->StartRow(0, 0); 156 layout->StartRow(0, 0);
157 layout->AddView(&v2); 157 layout->AddView(&v2);
158 158
159 GetPreferredSize(); 159 GetPreferredSize();
160 EXPECT_TRUE(gfx::Size(100, 60) == pref); 160 EXPECT_EQ(gfx::Size(100, 60), pref);
161 161
162 host.SetBounds(0, 0, pref.width(), pref.height()); 162 host.SetBounds(0, 0, pref.width(), pref.height());
163 layout->Layout(&host); 163 layout->Layout(&host);
164 ExpectViewBoundsEquals(0, 0, 100, 20, &v1); 164 ExpectViewBoundsEquals(0, 0, 100, 20, &v1);
165 ExpectViewBoundsEquals(0, 20, 10, 40, &v2); 165 ExpectViewBoundsEquals(0, 20, 10, 40, &v2);
166 166
167 RemoveAll(); 167 RemoveAll();
168 } 168 }
169 169
170 TEST_F(GridLayoutTest, ColSpan2) { 170 TEST_F(GridLayoutTest, ColSpan2) {
171 SettableSizeView v1(gfx::Size(100, 20)); 171 SettableSizeView v1(gfx::Size(100, 20));
172 SettableSizeView v2(gfx::Size(10, 20)); 172 SettableSizeView v2(gfx::Size(10, 20));
173 ColumnSet* c1 = layout->AddColumnSet(0); 173 ColumnSet* c1 = layout->AddColumnSet(0);
174 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 174 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
175 1, GridLayout::USE_PREF, 0, 0); 175 1, GridLayout::USE_PREF, 0, 0);
176 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 176 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
177 0, GridLayout::USE_PREF, 0, 0); 177 0, GridLayout::USE_PREF, 0, 0);
178 layout->StartRow(0, 0); 178 layout->StartRow(0, 0);
179 layout->AddView(&v1, 2, 1); 179 layout->AddView(&v1, 2, 1);
180 layout->StartRow(0, 0); 180 layout->StartRow(0, 0);
181 layout->SkipColumns(1); 181 layout->SkipColumns(1);
182 layout->AddView(&v2); 182 layout->AddView(&v2);
183 183
184 GetPreferredSize(); 184 GetPreferredSize();
185 EXPECT_TRUE(gfx::Size(100, 40) == pref); 185 EXPECT_EQ(gfx::Size(100, 40), pref);
186 186
187 host.SetBounds(0, 0, pref.width(), pref.height()); 187 host.SetBounds(0, 0, pref.width(), pref.height());
188 layout->Layout(&host); 188 layout->Layout(&host);
189 ExpectViewBoundsEquals(0, 0, 100, 20, &v1); 189 ExpectViewBoundsEquals(0, 0, 100, 20, &v1);
190 ExpectViewBoundsEquals(90, 20, 10, 20, &v2); 190 ExpectViewBoundsEquals(90, 20, 10, 20, &v2);
191 191
192 RemoveAll(); 192 RemoveAll();
193 } 193 }
194 194
195 TEST_F(GridLayoutTest, ColSpan3) { 195 TEST_F(GridLayoutTest, ColSpan3) {
196 SettableSizeView v1(gfx::Size(100, 20)); 196 SettableSizeView v1(gfx::Size(100, 20));
197 SettableSizeView v2(gfx::Size(10, 20)); 197 SettableSizeView v2(gfx::Size(10, 20));
198 SettableSizeView v3(gfx::Size(10, 20)); 198 SettableSizeView v3(gfx::Size(10, 20));
199 ColumnSet* c1 = layout->AddColumnSet(0); 199 ColumnSet* c1 = layout->AddColumnSet(0);
200 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 200 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
201 0, GridLayout::USE_PREF, 0, 0); 201 0, GridLayout::USE_PREF, 0, 0);
202 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 202 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
203 0, GridLayout::USE_PREF, 0, 0); 203 0, GridLayout::USE_PREF, 0, 0);
204 layout->StartRow(0, 0); 204 layout->StartRow(0, 0);
205 layout->AddView(&v1, 2, 1); 205 layout->AddView(&v1, 2, 1);
206 layout->StartRow(0, 0); 206 layout->StartRow(0, 0);
207 layout->AddView(&v2); 207 layout->AddView(&v2);
208 layout->AddView(&v3); 208 layout->AddView(&v3);
209 209
210 GetPreferredSize(); 210 GetPreferredSize();
211 EXPECT_TRUE(gfx::Size(100, 40) == pref); 211 EXPECT_EQ(gfx::Size(100, 40), pref);
212 212
213 host.SetBounds(0, 0, pref.width(), pref.height()); 213 host.SetBounds(0, 0, pref.width(), pref.height());
214 layout->Layout(&host); 214 layout->Layout(&host);
215 ExpectViewBoundsEquals(0, 0, 100, 20, &v1); 215 ExpectViewBoundsEquals(0, 0, 100, 20, &v1);
216 ExpectViewBoundsEquals(0, 20, 10, 20, &v2); 216 ExpectViewBoundsEquals(0, 20, 10, 20, &v2);
217 ExpectViewBoundsEquals(50, 20, 10, 20, &v3); 217 ExpectViewBoundsEquals(50, 20, 10, 20, &v3);
218 218
219 RemoveAll(); 219 RemoveAll();
220 } 220 }
221 221
222 222
223 TEST_F(GridLayoutTest, ColSpan4) { 223 TEST_F(GridLayoutTest, ColSpan4) {
224 views::ColumnSet* set = layout->AddColumnSet(0); 224 views::ColumnSet* set = layout->AddColumnSet(0);
225 225
226 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, 226 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
227 GridLayout::USE_PREF, 0, 0); 227 GridLayout::USE_PREF, 0, 0);
228 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, 228 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
229 GridLayout::USE_PREF, 0, 0); 229 GridLayout::USE_PREF, 0, 0);
230 230
231 SettableSizeView v1(gfx::Size(10, 10)); 231 SettableSizeView v1(gfx::Size(10, 10));
232 SettableSizeView v2(gfx::Size(10, 10)); 232 SettableSizeView v2(gfx::Size(10, 10));
233 SettableSizeView v3(gfx::Size(25, 20)); 233 SettableSizeView v3(gfx::Size(25, 20));
234 layout->StartRow(0, 0); 234 layout->StartRow(0, 0);
235 layout->AddView(&v1); 235 layout->AddView(&v1);
236 layout->AddView(&v2); 236 layout->AddView(&v2);
237 layout->StartRow(0, 0); 237 layout->StartRow(0, 0);
238 layout->AddView(&v3, 2, 1); 238 layout->AddView(&v3, 2, 1);
239 239
240 GetPreferredSize(); 240 GetPreferredSize();
241 EXPECT_TRUE(gfx::Size(25, 30) == pref); 241 EXPECT_EQ(gfx::Size(25, 30), pref);
242 242
243 host.SetBounds(0, 0, pref.width(), pref.height()); 243 host.SetBounds(0, 0, pref.width(), pref.height());
244 layout->Layout(&host); 244 layout->Layout(&host);
245 ExpectViewBoundsEquals(0, 0, 10, 10, &v1); 245 ExpectViewBoundsEquals(0, 0, 10, 10, &v1);
246 ExpectViewBoundsEquals(12, 0, 10, 10, &v2); 246 ExpectViewBoundsEquals(12, 0, 10, 10, &v2);
247 ExpectViewBoundsEquals(0, 10, 25, 20, &v3); 247 ExpectViewBoundsEquals(0, 10, 25, 20, &v3);
248 248
249 RemoveAll(); 249 RemoveAll();
250 } 250 }
251 251
252 TEST_F(GridLayoutTest, SameSizeColumns) { 252 TEST_F(GridLayoutTest, SameSizeColumns) {
253 SettableSizeView v1(gfx::Size(50, 20)); 253 SettableSizeView v1(gfx::Size(50, 20));
254 SettableSizeView v2(gfx::Size(10, 10)); 254 SettableSizeView v2(gfx::Size(10, 10));
255 ColumnSet* c1 = layout->AddColumnSet(0); 255 ColumnSet* c1 = layout->AddColumnSet(0);
256 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 256 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
257 0, GridLayout::USE_PREF, 0, 0); 257 0, GridLayout::USE_PREF, 0, 0);
258 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 258 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
259 0, GridLayout::USE_PREF, 0, 0); 259 0, GridLayout::USE_PREF, 0, 0);
260 c1->LinkColumnSizes(0, 1, -1); 260 c1->LinkColumnSizes(0, 1, -1);
261 layout->StartRow(0, 0); 261 layout->StartRow(0, 0);
262 layout->AddView(&v1); 262 layout->AddView(&v1);
263 layout->AddView(&v2); 263 layout->AddView(&v2);
264 264
265 gfx::Size pref = layout->GetPreferredSize(&host); 265 gfx::Size pref = layout->GetPreferredSize(&host);
266 EXPECT_TRUE(gfx::Size(100, 20) == pref); 266 EXPECT_EQ(gfx::Size(100, 20), pref);
267 267
268 host.SetBounds(0, 0, pref.width(), pref.height()); 268 host.SetBounds(0, 0, pref.width(), pref.height());
269 layout->Layout(&host); 269 layout->Layout(&host);
270 ExpectViewBoundsEquals(0, 0, 50, 20, &v1); 270 ExpectViewBoundsEquals(0, 0, 50, 20, &v1);
271 ExpectViewBoundsEquals(50, 0, 10, 10, &v2); 271 ExpectViewBoundsEquals(50, 0, 10, 10, &v2);
272 272
273 RemoveAll(); 273 RemoveAll();
274 } 274 }
275 275
276 TEST_F(GridLayoutTest, HorizontalResizeTest1) { 276 TEST_F(GridLayoutTest, HorizontalResizeTest1) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 SettableSizeView v2(gfx::Size(10, 10)); 318 SettableSizeView v2(gfx::Size(10, 10));
319 ColumnSet* c1 = layout->AddColumnSet(0); 319 ColumnSet* c1 = layout->AddColumnSet(0);
320 c1->AddColumn(GridLayout::FILL, GridLayout::FILL, 320 c1->AddColumn(GridLayout::FILL, GridLayout::FILL,
321 1, GridLayout::USE_PREF, 0, 0); 321 1, GridLayout::USE_PREF, 0, 0);
322 layout->StartRow(1, 0); 322 layout->StartRow(1, 0);
323 layout->AddView(&v1); 323 layout->AddView(&v1);
324 layout->StartRow(0, 0); 324 layout->StartRow(0, 0);
325 layout->AddView(&v2); 325 layout->AddView(&v2);
326 326
327 GetPreferredSize(); 327 GetPreferredSize();
328 EXPECT_TRUE(gfx::Size(50, 30) == pref); 328 EXPECT_EQ(gfx::Size(50, 30), pref);
329 329
330 host.SetBounds(0, 0, 50, 100); 330 host.SetBounds(0, 0, 50, 100);
331 layout->Layout(&host); 331 layout->Layout(&host);
332 ExpectViewBoundsEquals(0, 0, 50, 90, &v1); 332 ExpectViewBoundsEquals(0, 0, 50, 90, &v1);
333 ExpectViewBoundsEquals(0, 90, 50, 10, &v2); 333 ExpectViewBoundsEquals(0, 90, 50, 10, &v2);
334 334
335 RemoveAll(); 335 RemoveAll();
336 } 336 }
337 337
338 TEST_F(GridLayoutTest, Insets) { 338 TEST_F(GridLayoutTest, Insets) {
339 SettableSizeView v1(gfx::Size(10, 20)); 339 SettableSizeView v1(gfx::Size(10, 20));
340 ColumnSet* c1 = layout->AddColumnSet(0); 340 ColumnSet* c1 = layout->AddColumnSet(0);
341 layout->SetInsets(1, 2, 3, 4); 341 layout->SetInsets(1, 2, 3, 4);
342 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 342 c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
343 0, GridLayout::USE_PREF, 0, 0); 343 0, GridLayout::USE_PREF, 0, 0);
344 layout->StartRow(0, 0); 344 layout->StartRow(0, 0);
345 layout->AddView(&v1); 345 layout->AddView(&v1);
346 346
347 GetPreferredSize(); 347 GetPreferredSize();
348 EXPECT_TRUE(gfx::Size(16, 24) == pref); 348 EXPECT_EQ(gfx::Size(16, 24), pref);
349 349
350 host.SetBounds(0, 0, pref.width(), pref.height()); 350 host.SetBounds(0, 0, pref.width(), pref.height());
351 layout->Layout(&host); 351 layout->Layout(&host);
352 ExpectViewBoundsEquals(2, 1, 10, 20, &v1); 352 ExpectViewBoundsEquals(2, 1, 10, 20, &v1);
353 353
354 RemoveAll(); 354 RemoveAll();
355 } 355 }
356 356
357 TEST_F(GridLayoutTest, FixedSize) { 357 TEST_F(GridLayoutTest, FixedSize) {
358 layout->SetInsets(2, 2, 2, 2); 358 layout->SetInsets(2, 2, 2, 2);
(...skipping 29 matching lines...) Expand all
388 View* view = host.GetChildViewAt(row * column_count + i); 388 View* view = host.GetChildViewAt(row * column_count + i);
389 ExpectViewBoundsEquals( 389 ExpectViewBoundsEquals(
390 2 + title_width * i + (title_width - pref_width) / 2, 390 2 + title_width * i + (title_width - pref_width) / 2,
391 2 + pref_height * row, 391 2 + pref_height * row,
392 pref_width, 392 pref_width,
393 pref_height, view); 393 pref_height, view);
394 } 394 }
395 } 395 }
396 396
397 GetPreferredSize(); 397 GetPreferredSize();
398 EXPECT_TRUE(gfx::Size(column_count * title_width + 4, 398 EXPECT_EQ(gfx::Size(column_count * title_width + 4,
399 row_count * pref_height + 4) == pref); 399 row_count * pref_height + 4), pref);
400 } 400 }
401 401
402 TEST_F(GridLayoutTest, RowSpanWithPaddingRow) { 402 TEST_F(GridLayoutTest, RowSpanWithPaddingRow) {
403 views::ColumnSet* set = layout->AddColumnSet(0); 403 views::ColumnSet* set = layout->AddColumnSet(0);
404 404
405 set->AddColumn(views::GridLayout::CENTER, 405 set->AddColumn(views::GridLayout::CENTER,
406 views::GridLayout::CENTER, 406 views::GridLayout::CENTER,
407 0, 407 0,
408 views::GridLayout::FIXED, 408 views::GridLayout::FIXED,
409 10, 409 10,
(...skipping 21 matching lines...) Expand all
431 0); 431 0);
432 432
433 layout->StartRow(0, 0); 433 layout->StartRow(0, 0);
434 layout->AddView(new SettableSizeView(gfx::Size(20, 10))); 434 layout->AddView(new SettableSizeView(gfx::Size(20, 10)));
435 layout->AddView(new SettableSizeView(gfx::Size(20, 40)), 1, 2); 435 layout->AddView(new SettableSizeView(gfx::Size(20, 40)), 1, 2);
436 layout->StartRow(1, 0); 436 layout->StartRow(1, 0);
437 views::View* s3 = new SettableSizeView(gfx::Size(20, 10)); 437 views::View* s3 = new SettableSizeView(gfx::Size(20, 10));
438 layout->AddView(s3); 438 layout->AddView(s3);
439 439
440 GetPreferredSize(); 440 GetPreferredSize();
441 EXPECT_TRUE(gfx::Size(40, 40) == pref); 441 EXPECT_EQ(gfx::Size(40, 40), pref);
442 442
443 host.SetBounds(0, 0, pref.width(), pref.height()); 443 host.SetBounds(0, 0, pref.width(), pref.height());
444 layout->Layout(&host); 444 layout->Layout(&host);
445 ExpectViewBoundsEquals(0, 10, 20, 10, s3); 445 ExpectViewBoundsEquals(0, 10, 20, 10, s3);
446 } 446 }
447 447
448 TEST_F(GridLayoutTest, RowSpan2) { 448 TEST_F(GridLayoutTest, RowSpan2) {
449 views::ColumnSet* set = layout->AddColumnSet(0); 449 views::ColumnSet* set = layout->AddColumnSet(0);
450 450
451 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 451 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
452 0, GridLayout::USE_PREF, 0, 0); 452 0, GridLayout::USE_PREF, 0, 0);
453 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 453 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
454 0,GridLayout::USE_PREF, 0, 0); 454 0,GridLayout::USE_PREF, 0, 0);
455 455
456 layout->StartRow(0, 0); 456 layout->StartRow(0, 0);
457 layout->AddView(new SettableSizeView(gfx::Size(20, 20))); 457 layout->AddView(new SettableSizeView(gfx::Size(20, 20)));
458 views::View* s3 = new SettableSizeView(gfx::Size(64, 64)); 458 views::View* s3 = new SettableSizeView(gfx::Size(64, 64));
459 layout->AddView(s3, 1, 3); 459 layout->AddView(s3, 1, 3);
460 460
461 layout->AddPaddingRow(0, 10); 461 layout->AddPaddingRow(0, 10);
462 462
463 layout->StartRow(0, 0); 463 layout->StartRow(0, 0);
464 layout->AddView(new SettableSizeView(gfx::Size(10, 20))); 464 layout->AddView(new SettableSizeView(gfx::Size(10, 20)));
465 465
466 GetPreferredSize(); 466 GetPreferredSize();
467 EXPECT_TRUE(gfx::Size(84, 64) == pref); 467 EXPECT_EQ(gfx::Size(84, 64), pref);
468 468
469 host.SetBounds(0, 0, pref.width(), pref.height()); 469 host.SetBounds(0, 0, pref.width(), pref.height());
470 layout->Layout(&host); 470 layout->Layout(&host);
471 ExpectViewBoundsEquals(20, 0, 64, 64, s3); 471 ExpectViewBoundsEquals(20, 0, 64, 64, s3);
472 } 472 }
473 473
474 TEST_F(GridLayoutTest, FixedViewWidth) { 474 TEST_F(GridLayoutTest, FixedViewWidth) {
475 views::ColumnSet* set = layout->AddColumnSet(0); 475 views::ColumnSet* set = layout->AddColumnSet(0);
476 476
477 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 477 set->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
(...skipping 27 matching lines...) Expand all
505 layout->AddView(view, 1, 1, GridLayout::LEADING, GridLayout::LEADING, 0, 10); 505 layout->AddView(view, 1, 1, GridLayout::LEADING, GridLayout::LEADING, 0, 10);
506 506
507 GetPreferredSize(); 507 GetPreferredSize();
508 EXPECT_EQ(30, pref.width()); 508 EXPECT_EQ(30, pref.width());
509 EXPECT_EQ(10, pref.height()); 509 EXPECT_EQ(10, pref.height());
510 510
511 host.SetBounds(0, 0, pref.width(), pref.height()); 511 host.SetBounds(0, 0, pref.width(), pref.height());
512 layout->Layout(&host); 512 layout->Layout(&host);
513 ExpectViewBoundsEquals(0, 0, 30, 10, view); 513 ExpectViewBoundsEquals(0, 0, 30, 10, view);
514 } 514 }
OLDNEW
« no previous file with comments | « views/controls/tree/tree_view.cc ('k') | views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698