OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
9 #include "ui/views/rendering/border.h" | 9 #include "ui/views/rendering/border.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 OnPaint(NULL); | 46 OnPaint(NULL); |
47 } | 47 } |
48 | 48 |
49 private: | 49 private: |
50 DISALLOW_COPY_AND_ASSIGN(PaintableView); | 50 DISALLOW_COPY_AND_ASSIGN(PaintableView); |
51 }; | 51 }; |
52 | 52 |
53 TEST_F(BorderTest, Basic) { | 53 TEST_F(BorderTest, Basic) { |
54 const int kViewSize = 100; | 54 const int kViewSize = 100; |
55 PaintableView v; | 55 PaintableView v; |
56 v.SetBounds(10, 10, kViewSize, kViewSize); | 56 v.SetBounds(gfx::Rect(10, 10, kViewSize, kViewSize)); |
57 | 57 |
58 // With no border, the content size is the view size. | 58 // With no border, the content size is the view size. |
59 EXPECT_EQ(gfx::Rect(0, 0, kViewSize, kViewSize), v.GetContentsBounds()); | 59 EXPECT_EQ(gfx::Rect(0, 0, kViewSize, kViewSize), v.GetContentsBounds()); |
60 | 60 |
61 const int kViewInset = 10; | 61 const int kViewInset = 10; |
62 v.SetBorder(Border::CreateTransparentBorder( | 62 v.SetBorder(Border::CreateTransparentBorder( |
63 gfx::Insets(kViewInset, kViewInset, kViewInset, kViewInset))); | 63 gfx::Insets(kViewInset, kViewInset, kViewInset, kViewInset))); |
64 | 64 |
65 // With the border, the content bounds are inset by the border's insets. | 65 // With the border, the content bounds are inset by the border's insets. |
66 EXPECT_EQ(gfx::Rect(kViewInset, kViewInset, kViewSize - 2 * kViewInset, | 66 EXPECT_EQ(gfx::Rect(kViewInset, kViewInset, kViewSize - 2 * kViewInset, |
67 kViewSize - 2 * kViewInset), | 67 kViewSize - 2 * kViewInset), |
68 v.GetContentsBounds()); | 68 v.GetContentsBounds()); |
69 | 69 |
70 TestBorder* border = new TestBorder; | 70 TestBorder* border = new TestBorder; |
71 v.SetBorder(border); | 71 v.SetBorder(border); |
72 v.CallOnPaintWithNULLCanvas(); | 72 v.CallOnPaintWithNULLCanvas(); |
73 EXPECT_TRUE(border->painted()); | 73 EXPECT_TRUE(border->painted()); |
74 } | 74 } |
75 | 75 |
76 } // namespace ui | 76 } // namespace ui |
OLD | NEW |