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

Side by Side 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, 10 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/rendering/border.cc ('k') | ui/views/run_all_unittests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <algorithm>
6
7 #include "gfx/canvas.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/views/rendering/border.h"
10 #include "ui/views/view.h"
11
12 namespace ui {
13
14 class BorderTest : public testing::Test {
15 public:
16 BorderTest() {}
17 virtual ~BorderTest() {}
18
19 private:
20 DISALLOW_COPY_AND_ASSIGN(BorderTest);
21 };
22
23 class TestBorder : public Border {
24 public:
25 TestBorder() : painted_(false) {}
26
27 bool painted() const { return painted_; }
28
29 // Overridden from Border:
30 virtual void Paint(const View* view, gfx::Canvas* canvas) const {
31 painted_ = true;
32 }
33
34 private:
35 mutable bool painted_;
36
37 DISALLOW_COPY_AND_ASSIGN(TestBorder);
38 };
39
40 TEST_F(BorderTest, Basic) {
41 const int kViewSize = 100;
42 View v;
43 v.SetBounds(10, 10, kViewSize, kViewSize);
44
45 // With no border, the content size is the view size.
46 EXPECT_EQ(gfx::Rect(0, 0, kViewSize, kViewSize), v.GetContentsBounds());
47
48 const int kViewInset = 10;
49 v.SetBorder(Border::CreateTransparentBorder(
50 gfx::Insets(kViewInset, kViewInset, kViewInset, kViewInset)));
51
52 // With the border, the content bounds are inset by the border's insets.
53 EXPECT_EQ(gfx::Rect(kViewInset, kViewInset, kViewSize - 2 * kViewInset,
54 kViewSize - 2 * kViewInset),
55 v.GetContentsBounds());
56
57 TestBorder* border = new TestBorder;
58 v.SetBorder(border);
59 v.OnPaint(NULL);
60 EXPECT_TRUE(border->painted());
61 }
62
63 } // namespace ui
OLDNEW
« 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