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

Unified Diff: ui/views/rendering/border_unittest.cc

Issue 6286013: V2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/rendering/border.cc ('k') | ui/views/run_all_unittests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/rendering/border_unittest.cc
===================================================================
--- ui/views/rendering/border_unittest.cc (revision 0)
+++ ui/views/rendering/border_unittest.cc (revision 0)
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 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 <algorithm>
+
+#include "gfx/canvas.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/views/rendering/border.h"
+#include "ui/views/view.h"
+
+namespace ui {
+
+class BorderTest : public testing::Test {
+ public:
+ BorderTest() {}
+ virtual ~BorderTest() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BorderTest);
+};
+
+class TestBorder : public Border {
+ public:
+ TestBorder() : painted_(false) {}
+
+ bool painted() const { return painted_; }
+
+ // Overridden from Border:
+ virtual void Paint(const View* view, gfx::Canvas* canvas) const {
+ painted_ = true;
+ }
+
+ private:
+ mutable bool painted_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestBorder);
+};
+
+TEST_F(BorderTest, Basic) {
+ const int kViewSize = 100;
+ View v;
+ v.SetBounds(10, 10, kViewSize, kViewSize);
+
+ // With no border, the content size is the view size.
+ EXPECT_EQ(gfx::Rect(0, 0, kViewSize, kViewSize), v.GetContentsBounds());
+
+ const int kViewInset = 10;
+ v.SetBorder(Border::CreateTransparentBorder(
+ gfx::Insets(kViewInset, kViewInset, kViewInset, kViewInset)));
+
+ // With the border, the content bounds are inset by the border's insets.
+ EXPECT_EQ(gfx::Rect(kViewInset, kViewInset, kViewSize - 2 * kViewInset,
+ kViewSize - 2 * kViewInset),
+ v.GetContentsBounds());
+
+ TestBorder* border = new TestBorder;
+ v.SetBorder(border);
+ v.OnPaint(NULL);
+ EXPECT_TRUE(border->painted());
+}
+
+} // namespace ui
Property changes on: ui\views\rendering\border_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « ui/views/rendering/border.cc ('k') | ui/views/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698