summaryrefslogtreecommitdiffstats
path: root/views/box_layout_unittest.cc
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-06 07:48:58 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-06 07:48:58 +0000
commit0af29d8cedd97d4604619dd4ab2b5e0a0805ecb1 (patch)
tree3c9f00670a268464b963443a7de96728fb32e0be /views/box_layout_unittest.cc
parent6e094094ed8b96e68b30e8628e8a169719edda27 (diff)
downloadchromium_src-0af29d8cedd97d4604619dd4ab2b5e0a0805ecb1.zip
chromium_src-0af29d8cedd97d4604619dd4ab2b5e0a0805ecb1.tar.gz
chromium_src-0af29d8cedd97d4604619dd4ab2b5e0a0805ecb1.tar.bz2
Display warning banner in Win preferences dialog for managed options.
BUG=43423 TEST=box_layout_unittest.cc, manual UI tests. Review URL: http://codereview.chromium.org/2738002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51655 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/box_layout_unittest.cc')
-rw-r--r--views/box_layout_unittest.cc108
1 files changed, 108 insertions, 0 deletions
diff --git a/views/box_layout_unittest.cc b/views/box_layout_unittest.cc
new file mode 100644
index 0000000..712b2ef
--- /dev/null
+++ b/views/box_layout_unittest.cc
@@ -0,0 +1,108 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "views/box_layout.h"
+#include "views/view.h"
+
+class StaticSizedView : public views::View {
+ public:
+ explicit StaticSizedView(const gfx::Size& size)
+ : size_(size) { }
+
+ virtual gfx::Size GetPreferredSize() {
+ return size_;
+ }
+
+ private:
+ gfx::Size size_;
+};
+
+class BoxLayoutTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ host_.reset(new views::View);
+ }
+
+ scoped_ptr<views::View> host_;
+ scoped_ptr<views::BoxLayout> layout_;
+};
+
+TEST_F(BoxLayoutTest, Empty) {
+ layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 10, 20));
+ EXPECT_EQ(gfx::Size(20, 20), layout_->GetPreferredSize(host_.get()));
+}
+
+TEST_F(BoxLayoutTest, AlignmentHorizontal) {
+ layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0));
+ views::View* v1 = new StaticSizedView(gfx::Size(10, 20));
+ host_->AddChildView(v1);
+ views::View* v2 = new StaticSizedView(gfx::Size(10, 10));
+ host_->AddChildView(v2);
+ EXPECT_EQ(gfx::Size(20, 20), layout_->GetPreferredSize(host_.get()));
+ host_->SetBounds(0, 0, 20, 20);
+ layout_->Layout(host_.get());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 20), v1->bounds());
+ EXPECT_EQ(gfx::Rect(10, 0, 10, 20), v2->bounds());
+}
+
+TEST_F(BoxLayoutTest, AlignmentVertical) {
+ layout_.reset(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0));
+ views::View* v1 = new StaticSizedView(gfx::Size(20, 10));
+ host_->AddChildView(v1);
+ views::View* v2 = new StaticSizedView(gfx::Size(10, 10));
+ host_->AddChildView(v2);
+ EXPECT_EQ(gfx::Size(20, 20), layout_->GetPreferredSize(host_.get()));
+ host_->SetBounds(0, 0, 20, 20);
+ layout_->Layout(host_.get());
+ EXPECT_EQ(gfx::Rect(0, 0, 20, 10), v1->bounds());
+ EXPECT_EQ(gfx::Rect(0, 10, 20, 10), v2->bounds());
+}
+
+TEST_F(BoxLayoutTest, Spacing) {
+ layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 7, 8));
+ views::View* v1 = new StaticSizedView(gfx::Size(10, 20));
+ host_->AddChildView(v1);
+ views::View* v2 = new StaticSizedView(gfx::Size(10, 20));
+ host_->AddChildView(v2);
+ EXPECT_EQ(gfx::Size(42, 34), layout_->GetPreferredSize(host_.get()));
+ host_->SetBounds(0, 0, 100, 100);
+ layout_->Layout(host_.get());
+ EXPECT_EQ(gfx::Rect(7, 7, 10, 86), v1->bounds());
+ EXPECT_EQ(gfx::Rect(25, 7, 10, 86), v2->bounds());
+}
+
+TEST_F(BoxLayoutTest, Overflow) {
+ layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0));
+ views::View* v1 = new StaticSizedView(gfx::Size(20, 20));
+ host_->AddChildView(v1);
+ views::View* v2 = new StaticSizedView(gfx::Size(10, 20));
+ host_->AddChildView(v2);
+ host_->SetBounds(0, 0, 10, 10);
+ layout_->Layout(host_.get());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 10), v1->bounds());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), v2->bounds());
+}
+
+TEST_F(BoxLayoutTest, NoSpace) {
+ layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 10, 10));
+ views::View* childView = new StaticSizedView(gfx::Size(20, 20));
+ host_->AddChildView(childView);
+ host_->SetBounds(0, 0, 10, 10);
+ layout_->Layout(host_.get());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0), childView->bounds());
+}
+
+TEST_F(BoxLayoutTest, InvisibleChild) {
+ layout_.reset(new views::BoxLayout(views::BoxLayout::kHorizontal, 10, 10));
+ views::View* v1 = new StaticSizedView(gfx::Size(20, 20));
+ v1->SetVisible(false);
+ host_->AddChildView(v1);
+ views::View* v2 = new StaticSizedView(gfx::Size(10, 10));
+ host_->AddChildView(v2);
+ EXPECT_EQ(gfx::Size(30, 30), layout_->GetPreferredSize(host_.get()));
+ host_->SetBounds(0, 0, 30, 30);
+ layout_->Layout(host_.get());
+ EXPECT_EQ(gfx::Rect(10, 10, 10, 10), v2->bounds());
+}