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

Side by Side Diff: ui/views/controls/native/native_view_host_unittest.cc

Issue 339663003: Revert of Implement NativeViewHostAura::InstallClip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
OLDNEW
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/test/views_test_base.h" 10 #include "ui/views/test/views_test_base.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // Verifies NativeViewHierarchyChanged is sent. 127 // Verifies NativeViewHierarchyChanged is sent.
128 TEST_F(NativeViewHostTest, NativeViewHierarchyChanged) { 128 TEST_F(NativeViewHostTest, NativeViewHierarchyChanged) {
129 // Create a child widget. 129 // Create a child widget.
130 NativeViewHierarchyChangedTestView* test_view = 130 NativeViewHierarchyChangedTestView* test_view =
131 new NativeViewHierarchyChangedTestView; 131 new NativeViewHierarchyChangedTestView;
132 NativeViewHost* host = new NativeViewHost; 132 NativeViewHost* host = new NativeViewHost;
133 scoped_ptr<Widget> child(CreateChildForHost(toplevel()->GetNativeView(), 133 scoped_ptr<Widget> child(CreateChildForHost(toplevel()->GetNativeView(),
134 toplevel()->GetRootView(), 134 toplevel()->GetRootView(),
135 test_view, 135 test_view,
136 host)); 136 host));
137 #if defined(USE_AURA) 137
138 // One notification is generated from inserting the native view into the
139 // clipping window.
140 EXPECT_EQ(1, test_view->notification_count());
141 #else
142 EXPECT_EQ(0, test_view->notification_count()); 138 EXPECT_EQ(0, test_view->notification_count());
143 #endif
144 test_view->ResetCount(); 139 test_view->ResetCount();
145 140
146 // Detaching should send a NativeViewHierarchyChanged() notification and 141 // Detaching should send a NativeViewHierarchyChanged() notification and
147 // change the parent. 142 // change the parent.
148 host->Detach(); 143 host->Detach();
149 EXPECT_EQ(1, test_view->notification_count()); 144 EXPECT_EQ(1, test_view->notification_count());
150 EXPECT_NE(toplevel()->GetNativeView(), 145 EXPECT_NE(toplevel()->GetNativeView(),
151 GetNativeParent(child->GetNativeView())); 146 GetNativeParent(child->GetNativeView()));
152 test_view->ResetCount(); 147 test_view->ResetCount();
153 148
154 // Attaching should send a NativeViewHierarchyChanged() notification and 149 // Attaching should send a NativeViewHierarchyChanged() notification and
155 // reset the parent. 150 // reset the parent.
156 host->Attach(child->GetNativeView()); 151 host->Attach(child->GetNativeView());
157 EXPECT_EQ(1, test_view->notification_count()); 152 EXPECT_EQ(1, test_view->notification_count());
158 #if defined(USE_AURA)
159 // There is a clipping window inserted above the native view that needs to be
160 // accounted for when looking at the relationship between the native views.
161 EXPECT_EQ(toplevel()->GetNativeView(),
162 GetNativeParent(GetNativeParent(child->GetNativeView())));
163 #else
164 EXPECT_EQ(toplevel()->GetNativeView(), 153 EXPECT_EQ(toplevel()->GetNativeView(),
165 GetNativeParent(child->GetNativeView())); 154 GetNativeParent(child->GetNativeView()));
166 #endif
167 } 155 }
168 156
169 // Verifies ViewHierarchyChanged handles NativeViewHost remove, add and move 157 // Verifies ViewHierarchyChanged handles NativeViewHost remove, add and move
170 // (reparent) operations with correct parent changes. 158 // (reparent) operations with correct parent changes.
171 // This exercises the non-recursive code paths in 159 // This exercises the non-recursive code paths in
172 // View::PropagateRemoveNotifications() and View::PropagateAddNotifications(). 160 // View::PropagateRemoveNotifications() and View::PropagateAddNotifications().
173 TEST_F(NativeViewHostTest, ViewHierarchyChangedForHost) { 161 TEST_F(NativeViewHostTest, ViewHierarchyChangedForHost) {
174 // Original tree: 162 // Original tree:
175 // toplevel 163 // toplevel
176 // +-- host0 (NativeViewHost) 164 // +-- host0 (NativeViewHost)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 host0->ResetParentChanges(); 276 host0->ResetParentChanges();
289 host1->ResetParentChanges(); 277 host1->ResetParentChanges();
290 EXPECT_EQ(0, host0->num_parent_changes()); 278 EXPECT_EQ(0, host0->num_parent_changes());
291 EXPECT_EQ(0, host1->num_parent_changes()); 279 EXPECT_EQ(0, host1->num_parent_changes());
292 child0->GetContentsView()->AddChildView(view1); 280 child0->GetContentsView()->AddChildView(view1);
293 EXPECT_EQ(0, host0->num_parent_changes()); 281 EXPECT_EQ(0, host0->num_parent_changes());
294 EXPECT_EQ(2, host1->num_parent_changes()); 282 EXPECT_EQ(2, host1->num_parent_changes());
295 } 283 }
296 284
297 } // namespace views 285 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/native/native_view_host_aura_unittest.cc ('k') | ui/views/controls/native/native_view_host_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698