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

Side by Side Diff: ui/views/controls/scroll_view_unittest.cc

Issue 2480813003: Reduce views::Border creation verbosity by promoting factory functions (Closed)
Patch Set: fix bad merge Created 4 years, 1 month 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 | « ui/views/controls/scroll_view.cc ('k') | ui/views/controls/styled_label_unittest.cc » ('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) 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/controls/scroll_view.h" 5 #include "ui/views/controls/scroll_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/test/test_timeouts.h" 9 #include "base/test/test_timeouts.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 View* contents = InstallContents(); 275 View* contents = InstallContents();
276 scroll_view_.Layout(); 276 scroll_view_.Layout();
277 EXPECT_EQ("0,0 100x100", contents->parent()->bounds().ToString()); 277 EXPECT_EQ("0,0 100x100", contents->parent()->bounds().ToString());
278 } 278 }
279 279
280 // Verifies the viewport and content is sized to fit the available space for 280 // Verifies the viewport and content is sized to fit the available space for
281 // bounded scroll view. 281 // bounded scroll view.
282 TEST_F(ScrollViewTest, BoundedViewportSizedToFit) { 282 TEST_F(ScrollViewTest, BoundedViewportSizedToFit) {
283 View* contents = InstallContents(); 283 View* contents = InstallContents();
284 scroll_view_.ClipHeightTo(100, 200); 284 scroll_view_.ClipHeightTo(100, 200);
285 scroll_view_.SetBorder(Border::CreateSolidBorder(2, 0)); 285 scroll_view_.SetBorder(CreateSolidBorder(2, 0));
286 scroll_view_.Layout(); 286 scroll_view_.Layout();
287 EXPECT_EQ("2,2 96x96", contents->parent()->bounds().ToString()); 287 EXPECT_EQ("2,2 96x96", contents->parent()->bounds().ToString());
288 288
289 // Make sure the width of |contents| is set properly not to overflow the 289 // Make sure the width of |contents| is set properly not to overflow the
290 // viewport. 290 // viewport.
291 EXPECT_EQ(96, contents->width()); 291 EXPECT_EQ(96, contents->width());
292 } 292 }
293 293
294 // Verifies the scrollbars are added as necessary. 294 // Verifies the scrollbars are added as necessary.
295 // If on Mac, test the non-overlay scrollbars. 295 // If on Mac, test the non-overlay scrollbars.
(...skipping 30 matching lines...) Expand all
326 EXPECT_EQ(100 - scroll_view_.GetScrollBarHeight(), 326 EXPECT_EQ(100 - scroll_view_.GetScrollBarHeight(),
327 contents->parent()->height()); 327 contents->parent()->height());
328 CheckScrollbarVisibility(scroll_view_, VERTICAL, true); 328 CheckScrollbarVisibility(scroll_view_, VERTICAL, true);
329 CheckScrollbarVisibility(scroll_view_, HORIZONTAL, true); 329 CheckScrollbarVisibility(scroll_view_, HORIZONTAL, true);
330 330
331 // Add a border, test vertical scrollbar. 331 // Add a border, test vertical scrollbar.
332 const int kTopPadding = 1; 332 const int kTopPadding = 1;
333 const int kLeftPadding = 2; 333 const int kLeftPadding = 2;
334 const int kBottomPadding = 3; 334 const int kBottomPadding = 3;
335 const int kRightPadding = 4; 335 const int kRightPadding = 4;
336 scroll_view_.SetBorder(Border::CreateEmptyBorder( 336 scroll_view_.SetBorder(CreateEmptyBorder(kTopPadding, kLeftPadding,
337 kTopPadding, kLeftPadding, kBottomPadding, kRightPadding)); 337 kBottomPadding, kRightPadding));
338 contents->SetBounds(0, 0, 50, 400); 338 contents->SetBounds(0, 0, 50, 400);
339 scroll_view_.Layout(); 339 scroll_view_.Layout();
340 EXPECT_EQ( 340 EXPECT_EQ(
341 100 - scroll_view_.GetScrollBarWidth() - kLeftPadding - kRightPadding, 341 100 - scroll_view_.GetScrollBarWidth() - kLeftPadding - kRightPadding,
342 contents->parent()->width()); 342 contents->parent()->width());
343 EXPECT_EQ(100 - kTopPadding - kBottomPadding, contents->parent()->height()); 343 EXPECT_EQ(100 - kTopPadding - kBottomPadding, contents->parent()->height());
344 EXPECT_TRUE(!scroll_view_.horizontal_scroll_bar() || 344 EXPECT_TRUE(!scroll_view_.horizontal_scroll_bar() ||
345 !scroll_view_.horizontal_scroll_bar()->visible()); 345 !scroll_view_.horizontal_scroll_bar()->visible());
346 ASSERT_TRUE(scroll_view_.vertical_scroll_bar() != NULL); 346 ASSERT_TRUE(scroll_view_.vertical_scroll_bar() != NULL);
347 EXPECT_TRUE(scroll_view_.vertical_scroll_bar()->visible()); 347 EXPECT_TRUE(scroll_view_.vertical_scroll_bar()->visible());
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 // Scroll via ScrollView API. Should be reflected on the impl side. 893 // Scroll via ScrollView API. Should be reflected on the impl side.
894 offset.set_y(kDefaultHeight * 4); 894 offset.set_y(kDefaultHeight * 4);
895 scroll_view->contents()->ScrollRectToVisible(offset); 895 scroll_view->contents()->ScrollRectToVisible(offset);
896 EXPECT_EQ(gfx::ScrollOffset(0, offset.y()), test_api.CurrentOffset()); 896 EXPECT_EQ(gfx::ScrollOffset(0, offset.y()), test_api.CurrentOffset());
897 897
898 EXPECT_TRUE(compositor->GetScrollOffsetForLayer(layer_id, &impl_offset)); 898 EXPECT_TRUE(compositor->GetScrollOffsetForLayer(layer_id, &impl_offset));
899 EXPECT_EQ(gfx::ScrollOffset(0, offset.y()), impl_offset); 899 EXPECT_EQ(gfx::ScrollOffset(0, offset.y()), impl_offset);
900 } 900 }
901 901
902 } // namespace views 902 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scroll_view.cc ('k') | ui/views/controls/styled_label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698