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

Side by Side Diff: views/box_layout_unittest.cc

Issue 3108029: Display an infobar when content settings were created. (Closed)
Patch Set: updates Created 10 years, 4 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 | « views/box_layout.cc ('k') | views/examples/widget_example.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/box_layout.h" 6 #include "views/box_layout.h"
7 #include "views/view.h" 7 #include "views/view.h"
8 8
9 class StaticSizedView : public views::View { 9 class StaticSizedView : public views::View {
10 public: 10 public:
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 virtual void SetUp() { 24 virtual void SetUp() {
25 host_.reset(new views::View); 25 host_.reset(new views::View);
26 } 26 }
27 27
28 scoped_ptr<views::View> host_; 28 scoped_ptr<views::View> host_;
29 scoped_ptr<views::BoxLayout> layout_; 29 scoped_ptr<views::BoxLayout> layout_;
30 }; 30 };
31 31
32 TEST_F(BoxLayoutTest, Empty) { 32 TEST_F(BoxLayoutTest, Empty) {
33 layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 10, 20)); 33 layout_.reset(
34 new views::BoxLayout(views::BoxLayout::kHorizontal, 10, 10, 20));
34 EXPECT_EQ(gfx::Size(20, 20), layout_->GetPreferredSize(host_.get())); 35 EXPECT_EQ(gfx::Size(20, 20), layout_->GetPreferredSize(host_.get()));
35 } 36 }
36 37
37 TEST_F(BoxLayoutTest, AlignmentHorizontal) { 38 TEST_F(BoxLayoutTest, AlignmentHorizontal) {
38 layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0)); 39 layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
39 views::View* v1 = new StaticSizedView(gfx::Size(10, 20)); 40 views::View* v1 = new StaticSizedView(gfx::Size(10, 20));
40 host_->AddChildView(v1); 41 host_->AddChildView(v1);
41 views::View* v2 = new StaticSizedView(gfx::Size(10, 10)); 42 views::View* v2 = new StaticSizedView(gfx::Size(10, 10));
42 host_->AddChildView(v2); 43 host_->AddChildView(v2);
43 EXPECT_EQ(gfx::Size(20, 20), layout_->GetPreferredSize(host_.get())); 44 EXPECT_EQ(gfx::Size(20, 20), layout_->GetPreferredSize(host_.get()));
44 host_->SetBounds(0, 0, 20, 20); 45 host_->SetBounds(0, 0, 20, 20);
45 layout_->Layout(host_.get()); 46 layout_->Layout(host_.get());
46 EXPECT_EQ(gfx::Rect(0, 0, 10, 20), v1->bounds()); 47 EXPECT_EQ(gfx::Rect(0, 0, 10, 20), v1->bounds());
47 EXPECT_EQ(gfx::Rect(10, 0, 10, 20), v2->bounds()); 48 EXPECT_EQ(gfx::Rect(10, 0, 10, 20), v2->bounds());
48 } 49 }
49 50
50 TEST_F(BoxLayoutTest, AlignmentVertical) { 51 TEST_F(BoxLayoutTest, AlignmentVertical) {
51 layout_.reset(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0)); 52 layout_.reset(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
52 views::View* v1 = new StaticSizedView(gfx::Size(20, 10)); 53 views::View* v1 = new StaticSizedView(gfx::Size(20, 10));
53 host_->AddChildView(v1); 54 host_->AddChildView(v1);
54 views::View* v2 = new StaticSizedView(gfx::Size(10, 10)); 55 views::View* v2 = new StaticSizedView(gfx::Size(10, 10));
55 host_->AddChildView(v2); 56 host_->AddChildView(v2);
56 EXPECT_EQ(gfx::Size(20, 20), layout_->GetPreferredSize(host_.get())); 57 EXPECT_EQ(gfx::Size(20, 20), layout_->GetPreferredSize(host_.get()));
57 host_->SetBounds(0, 0, 20, 20); 58 host_->SetBounds(0, 0, 20, 20);
58 layout_->Layout(host_.get()); 59 layout_->Layout(host_.get());
59 EXPECT_EQ(gfx::Rect(0, 0, 20, 10), v1->bounds()); 60 EXPECT_EQ(gfx::Rect(0, 0, 20, 10), v1->bounds());
60 EXPECT_EQ(gfx::Rect(0, 10, 20, 10), v2->bounds()); 61 EXPECT_EQ(gfx::Rect(0, 10, 20, 10), v2->bounds());
61 } 62 }
62 63
63 TEST_F(BoxLayoutTest, Spacing) { 64 TEST_F(BoxLayoutTest, Spacing) {
64 layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 7, 8)); 65 layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 7, 7, 8));
65 views::View* v1 = new StaticSizedView(gfx::Size(10, 20)); 66 views::View* v1 = new StaticSizedView(gfx::Size(10, 20));
66 host_->AddChildView(v1); 67 host_->AddChildView(v1);
67 views::View* v2 = new StaticSizedView(gfx::Size(10, 20)); 68 views::View* v2 = new StaticSizedView(gfx::Size(10, 20));
68 host_->AddChildView(v2); 69 host_->AddChildView(v2);
69 EXPECT_EQ(gfx::Size(42, 34), layout_->GetPreferredSize(host_.get())); 70 EXPECT_EQ(gfx::Size(42, 34), layout_->GetPreferredSize(host_.get()));
70 host_->SetBounds(0, 0, 100, 100); 71 host_->SetBounds(0, 0, 100, 100);
71 layout_->Layout(host_.get()); 72 layout_->Layout(host_.get());
72 EXPECT_EQ(gfx::Rect(7, 7, 10, 86), v1->bounds()); 73 EXPECT_EQ(gfx::Rect(7, 7, 10, 86), v1->bounds());
73 EXPECT_EQ(gfx::Rect(25, 7, 10, 86), v2->bounds()); 74 EXPECT_EQ(gfx::Rect(25, 7, 10, 86), v2->bounds());
74 } 75 }
75 76
76 TEST_F(BoxLayoutTest, Overflow) { 77 TEST_F(BoxLayoutTest, Overflow) {
77 layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0)); 78 layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
78 views::View* v1 = new StaticSizedView(gfx::Size(20, 20)); 79 views::View* v1 = new StaticSizedView(gfx::Size(20, 20));
79 host_->AddChildView(v1); 80 host_->AddChildView(v1);
80 views::View* v2 = new StaticSizedView(gfx::Size(10, 20)); 81 views::View* v2 = new StaticSizedView(gfx::Size(10, 20));
81 host_->AddChildView(v2); 82 host_->AddChildView(v2);
82 host_->SetBounds(0, 0, 10, 10); 83 host_->SetBounds(0, 0, 10, 10);
83 layout_->Layout(host_.get()); 84 layout_->Layout(host_.get());
84 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), v1->bounds()); 85 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), v1->bounds());
85 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), v2->bounds()); 86 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), v2->bounds());
86 } 87 }
87 88
88 TEST_F(BoxLayoutTest, NoSpace) { 89 TEST_F(BoxLayoutTest, NoSpace) {
89 layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 10, 10)); 90 layout_.reset(
91 new views::BoxLayout(views::BoxLayout::kHorizontal, 10, 10, 10));
90 views::View* childView = new StaticSizedView(gfx::Size(20, 20)); 92 views::View* childView = new StaticSizedView(gfx::Size(20, 20));
91 host_->AddChildView(childView); 93 host_->AddChildView(childView);
92 host_->SetBounds(0, 0, 10, 10); 94 host_->SetBounds(0, 0, 10, 10);
93 layout_->Layout(host_.get()); 95 layout_->Layout(host_.get());
94 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), childView->bounds()); 96 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), childView->bounds());
95 } 97 }
96 98
97 TEST_F(BoxLayoutTest, InvisibleChild) { 99 TEST_F(BoxLayoutTest, InvisibleChild) {
98 layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 10, 10)); 100 layout_.reset(
101 new views::BoxLayout(views::BoxLayout::kHorizontal, 10, 10, 10));
99 views::View* v1 = new StaticSizedView(gfx::Size(20, 20)); 102 views::View* v1 = new StaticSizedView(gfx::Size(20, 20));
100 v1->SetVisible(false); 103 v1->SetVisible(false);
101 host_->AddChildView(v1); 104 host_->AddChildView(v1);
102 views::View* v2 = new StaticSizedView(gfx::Size(10, 10)); 105 views::View* v2 = new StaticSizedView(gfx::Size(10, 10));
103 host_->AddChildView(v2); 106 host_->AddChildView(v2);
104 EXPECT_EQ(gfx::Size(30, 30), layout_->GetPreferredSize(host_.get())); 107 EXPECT_EQ(gfx::Size(30, 30), layout_->GetPreferredSize(host_.get()));
105 host_->SetBounds(0, 0, 30, 30); 108 host_->SetBounds(0, 0, 30, 30);
106 layout_->Layout(host_.get()); 109 layout_->Layout(host_.get());
107 EXPECT_EQ(gfx::Rect(10, 10, 10, 10), v2->bounds()); 110 EXPECT_EQ(gfx::Rect(10, 10, 10, 10), v2->bounds());
108 } 111 }
OLDNEW
« no previous file with comments | « views/box_layout.cc ('k') | views/examples/widget_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698