OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/native/native_view_host.h" | 5 #include "ui/views/controls/native/native_view_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/views/controls/native/native_view_host_test_base.h" | 10 #include "ui/views/controls/native/native_view_host_test_base.h" |
11 #include "ui/views/test/views_test_base.h" | 11 #include "ui/views/test/views_test_base.h" |
12 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 | 15 |
16 class NativeViewHostTest : public test::NativeViewHostTestBase { | 16 class NativeViewHostTest : public test::NativeViewHostTestBase { |
17 public: | 17 public: |
18 NativeViewHostTest() { | 18 NativeViewHostTest() { |
19 } | 19 } |
20 | 20 |
21 virtual void SetUp() OVERRIDE { | 21 virtual void SetUp() override { |
22 ViewsTestBase::SetUp(); | 22 ViewsTestBase::SetUp(); |
23 CreateTopLevel(); | 23 CreateTopLevel(); |
24 } | 24 } |
25 | 25 |
26 private: | 26 private: |
27 DISALLOW_COPY_AND_ASSIGN(NativeViewHostTest); | 27 DISALLOW_COPY_AND_ASSIGN(NativeViewHostTest); |
28 }; | 28 }; |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // View implementation used by NativeViewHierarchyChanged to count number of | 32 // View implementation used by NativeViewHierarchyChanged to count number of |
33 // times NativeViewHierarchyChanged() is invoked. | 33 // times NativeViewHierarchyChanged() is invoked. |
34 class NativeViewHierarchyChangedTestView : public View { | 34 class NativeViewHierarchyChangedTestView : public View { |
35 public: | 35 public: |
36 NativeViewHierarchyChangedTestView() : notification_count_(0) { | 36 NativeViewHierarchyChangedTestView() : notification_count_(0) { |
37 } | 37 } |
38 | 38 |
39 void ResetCount() { | 39 void ResetCount() { |
40 notification_count_ = 0; | 40 notification_count_ = 0; |
41 } | 41 } |
42 | 42 |
43 int notification_count() const { return notification_count_; } | 43 int notification_count() const { return notification_count_; } |
44 | 44 |
45 // Overriden from View: | 45 // Overriden from View: |
46 virtual void NativeViewHierarchyChanged() OVERRIDE { | 46 virtual void NativeViewHierarchyChanged() override { |
47 ++notification_count_; | 47 ++notification_count_; |
48 View::NativeViewHierarchyChanged(); | 48 View::NativeViewHierarchyChanged(); |
49 } | 49 } |
50 | 50 |
51 private: | 51 private: |
52 int notification_count_; | 52 int notification_count_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(NativeViewHierarchyChangedTestView); | 54 DISALLOW_COPY_AND_ASSIGN(NativeViewHierarchyChangedTestView); |
55 }; | 55 }; |
56 | 56 |
(...skipping 10 matching lines...) Expand all Loading... |
67 void ResetParentChanges() { | 67 void ResetParentChanges() { |
68 num_parent_changes_ = 0; | 68 num_parent_changes_ = 0; |
69 } | 69 } |
70 | 70 |
71 int num_parent_changes() const { | 71 int num_parent_changes() const { |
72 return num_parent_changes_; | 72 return num_parent_changes_; |
73 } | 73 } |
74 | 74 |
75 // Overriden from NativeViewHost: | 75 // Overriden from NativeViewHost: |
76 virtual void ViewHierarchyChanged( | 76 virtual void ViewHierarchyChanged( |
77 const ViewHierarchyChangedDetails& details) OVERRIDE { | 77 const ViewHierarchyChangedDetails& details) override { |
78 gfx::NativeView parent_before = native_view() ? | 78 gfx::NativeView parent_before = native_view() ? |
79 GetNativeParent(native_view()) : NULL; | 79 GetNativeParent(native_view()) : NULL; |
80 NativeViewHost::ViewHierarchyChanged(details); | 80 NativeViewHost::ViewHierarchyChanged(details); |
81 gfx::NativeView parent_after = native_view() ? | 81 gfx::NativeView parent_after = native_view() ? |
82 GetNativeParent(native_view()) : NULL; | 82 GetNativeParent(native_view()) : NULL; |
83 if (parent_before != parent_after) | 83 if (parent_before != parent_after) |
84 ++num_parent_changes_; | 84 ++num_parent_changes_; |
85 } | 85 } |
86 | 86 |
87 private: | 87 private: |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 host0->ResetParentChanges(); | 264 host0->ResetParentChanges(); |
265 host1->ResetParentChanges(); | 265 host1->ResetParentChanges(); |
266 EXPECT_EQ(0, host0->num_parent_changes()); | 266 EXPECT_EQ(0, host0->num_parent_changes()); |
267 EXPECT_EQ(0, host1->num_parent_changes()); | 267 EXPECT_EQ(0, host1->num_parent_changes()); |
268 child0->GetContentsView()->AddChildView(view1); | 268 child0->GetContentsView()->AddChildView(view1); |
269 EXPECT_EQ(0, host0->num_parent_changes()); | 269 EXPECT_EQ(0, host0->num_parent_changes()); |
270 EXPECT_EQ(2, host1->num_parent_changes()); | 270 EXPECT_EQ(2, host1->num_parent_changes()); |
271 } | 271 } |
272 | 272 |
273 } // namespace views | 273 } // namespace views |
OLD | NEW |