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

Side by Side Diff: ui/views/layout/grid_layout_unittest.cc

Issue 185653012: rAc - fix off-by-small-number error in grid layout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « ui/views/layout/grid_layout.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/layout/grid_layout.h" 5 #include "ui/views/layout/grid_layout.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/views/view.h" 9 #include "ui/views/view.h"
10 10
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 layout.AddView(&v2); 339 layout.AddView(&v2);
340 340
341 host.SetBounds(0, 0, 120, 20); 341 host.SetBounds(0, 0, 120, 20);
342 layout.Layout(&host); 342 layout.Layout(&host);
343 ExpectViewBoundsEquals(0, 0, 80, 20, &v1); 343 ExpectViewBoundsEquals(0, 0, 80, 20, &v1);
344 ExpectViewBoundsEquals(110, 0, 10, 10, &v2); 344 ExpectViewBoundsEquals(110, 0, 10, 10, &v2);
345 345
346 RemoveAll(); 346 RemoveAll();
347 } 347 }
348 348
349 // Tests that space leftover due to rounding is distributed to the last
350 // resizable column.
351 TEST_F(GridLayoutTest, HorizontalResizeTest3) {
352 SettableSizeView v1(gfx::Size(10, 10));
353 SettableSizeView v2(gfx::Size(10, 10));
354 SettableSizeView v3(gfx::Size(10, 10));
355 ColumnSet* c1 = layout.AddColumnSet(0);
356 c1->AddColumn(GridLayout::FILL, GridLayout::LEADING,
357 1, GridLayout::USE_PREF, 0, 0);
358 c1->AddColumn(GridLayout::FILL, GridLayout::LEADING,
359 1, GridLayout::USE_PREF, 0, 0);
360 c1->AddColumn(GridLayout::TRAILING, GridLayout::LEADING,
361 0, GridLayout::USE_PREF, 0, 0);
362 layout.StartRow(0, 0);
363 layout.AddView(&v1);
364 layout.AddView(&v2);
365 layout.AddView(&v3);
366
367 host.SetBounds(0, 0, 31, 10);
368 layout.Layout(&host);
369 ExpectViewBoundsEquals(0, 0, 10, 10, &v1);
370 ExpectViewBoundsEquals(10, 0, 11, 10, &v2);
371 ExpectViewBoundsEquals(21, 0, 10, 10, &v3);
372
373 RemoveAll();
374 }
375
349 TEST_F(GridLayoutTest, TestVerticalResize1) { 376 TEST_F(GridLayoutTest, TestVerticalResize1) {
350 SettableSizeView v1(gfx::Size(50, 20)); 377 SettableSizeView v1(gfx::Size(50, 20));
351 SettableSizeView v2(gfx::Size(10, 10)); 378 SettableSizeView v2(gfx::Size(10, 10));
352 ColumnSet* c1 = layout.AddColumnSet(0); 379 ColumnSet* c1 = layout.AddColumnSet(0);
353 c1->AddColumn(GridLayout::FILL, GridLayout::FILL, 380 c1->AddColumn(GridLayout::FILL, GridLayout::FILL,
354 1, GridLayout::USE_PREF, 0, 0); 381 1, GridLayout::USE_PREF, 0, 0);
355 layout.StartRow(1, 0); 382 layout.StartRow(1, 0);
356 layout.AddView(&v1); 383 layout.AddView(&v1);
357 layout.StartRow(0, 0); 384 layout.StartRow(0, 0);
358 layout.AddView(&v2); 385 layout.AddView(&v2);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 EXPECT_EQ(gfx::Size(10, 20), pref); 660 EXPECT_EQ(gfx::Size(10, 20), pref);
634 661
635 layout.set_minimum_size(gfx::Size(40, 40)); 662 layout.set_minimum_size(gfx::Size(40, 40));
636 GetPreferredSize(); 663 GetPreferredSize();
637 EXPECT_EQ(gfx::Size(40, 40), pref); 664 EXPECT_EQ(gfx::Size(40, 40), pref);
638 665
639 RemoveAll(); 666 RemoveAll();
640 } 667 }
641 668
642 } // namespace views 669 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/layout/grid_layout.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698