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 #if defined(OS_WIN) && !defined(USE_AURA) | |
8 #include <windows.h> | |
9 #endif | |
10 | |
11 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ui/aura/window.h" |
13 #include "ui/views/test/views_test_base.h" | 10 #include "ui/views/test/views_test_base.h" |
14 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
15 | 12 |
16 #if defined(USE_AURA) | |
17 #include "ui/aura/window.h" | |
18 #endif | |
19 | |
20 namespace views { | 13 namespace views { |
21 | 14 |
22 class NativeViewHostTest : public ViewsTestBase { | 15 class NativeViewHostTest : public ViewsTestBase { |
23 public: | 16 public: |
24 NativeViewHostTest() { | 17 NativeViewHostTest() { |
25 } | 18 } |
26 | 19 |
27 virtual void SetUp() OVERRIDE { | 20 virtual void SetUp() OVERRIDE { |
28 ViewsTestBase::SetUp(); | 21 ViewsTestBase::SetUp(); |
29 | 22 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 ++notification_count_; | 79 ++notification_count_; |
87 View::NativeViewHierarchyChanged(); | 80 View::NativeViewHierarchyChanged(); |
88 } | 81 } |
89 | 82 |
90 private: | 83 private: |
91 int notification_count_; | 84 int notification_count_; |
92 | 85 |
93 DISALLOW_COPY_AND_ASSIGN(NativeViewHierarchyChangedTestView); | 86 DISALLOW_COPY_AND_ASSIGN(NativeViewHierarchyChangedTestView); |
94 }; | 87 }; |
95 | 88 |
96 #if defined(USE_AURA) | |
97 aura::Window* GetNativeParent(aura::Window* window) { | 89 aura::Window* GetNativeParent(aura::Window* window) { |
98 return window->parent(); | 90 return window->parent(); |
99 } | 91 } |
100 #elif defined(OS_WIN) | |
101 HWND GetNativeParent(HWND window) { | |
102 return GetParent(window); | |
103 } | |
104 #endif | |
105 | 92 |
106 class ViewHierarchyChangedTestHost : public NativeViewHost { | 93 class ViewHierarchyChangedTestHost : public NativeViewHost { |
107 public: | 94 public: |
108 ViewHierarchyChangedTestHost() | 95 ViewHierarchyChangedTestHost() |
109 : num_parent_changes_(0) { | 96 : num_parent_changes_(0) { |
110 } | 97 } |
111 | 98 |
112 void ResetParentChanges() { | 99 void ResetParentChanges() { |
113 num_parent_changes_ = 0; | 100 num_parent_changes_ = 0; |
114 } | 101 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 host0->ResetParentChanges(); | 276 host0->ResetParentChanges(); |
290 host1->ResetParentChanges(); | 277 host1->ResetParentChanges(); |
291 EXPECT_EQ(0, host0->num_parent_changes()); | 278 EXPECT_EQ(0, host0->num_parent_changes()); |
292 EXPECT_EQ(0, host1->num_parent_changes()); | 279 EXPECT_EQ(0, host1->num_parent_changes()); |
293 child0->GetContentsView()->AddChildView(view1); | 280 child0->GetContentsView()->AddChildView(view1); |
294 EXPECT_EQ(0, host0->num_parent_changes()); | 281 EXPECT_EQ(0, host0->num_parent_changes()); |
295 EXPECT_EQ(2, host1->num_parent_changes()); | 282 EXPECT_EQ(2, host1->num_parent_changes()); |
296 } | 283 } |
297 | 284 |
298 } // namespace views | 285 } // namespace views |
OLD | NEW |