| 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) | 7 #if defined(OS_WIN) && !defined(USE_AURA) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 #endif | 73 #endif |
| 74 | 74 |
| 75 } // namespace | 75 } // namespace |
| 76 | 76 |
| 77 // Verifies NativeViewHierarchyChanged is sent. | 77 // Verifies NativeViewHierarchyChanged is sent. |
| 78 TEST_F(NativeViewHostTest, NativeViewHierarchyChanged) { | 78 TEST_F(NativeViewHostTest, NativeViewHierarchyChanged) { |
| 79 // Create the top level widget. | 79 // Create the top level widget. |
| 80 scoped_ptr<Widget> toplevel(new Widget); | 80 scoped_ptr<Widget> toplevel(new Widget); |
| 81 Widget::InitParams toplevel_params(Widget::InitParams::TYPE_WINDOW); | 81 Widget::InitParams toplevel_params = |
| 82 toplevel_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 82 CreateParams(Widget::InitParams::TYPE_POPUP); |
| 83 toplevel->Init(toplevel_params); | 83 toplevel->Init(toplevel_params); |
| 84 toplevel->SetContentsView(new View); | 84 toplevel->SetContentsView(new View); |
| 85 | 85 |
| 86 // And the child widget. | 86 // And the child widget. |
| 87 NativeViewHierarchyChangedTestView* test_view = | 87 NativeViewHierarchyChangedTestView* test_view = |
| 88 new NativeViewHierarchyChangedTestView; | 88 new NativeViewHierarchyChangedTestView; |
| 89 scoped_ptr<Widget> child(new Widget); | 89 scoped_ptr<Widget> child(new Widget); |
| 90 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL); | 90 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL); |
| 91 child_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 91 child_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 92 child_params.parent_widget = toplevel.get(); | 92 child_params.parent_widget = toplevel.get(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 112 | 112 |
| 113 // Attaching should send both an attach and detach and reset parent. | 113 // Attaching should send both an attach and detach and reset parent. |
| 114 host->Attach(child->GetNativeView()); | 114 host->Attach(child->GetNativeView()); |
| 115 EXPECT_EQ(1, test_view->attached_count()); | 115 EXPECT_EQ(1, test_view->attached_count()); |
| 116 EXPECT_EQ(1, test_view->detached_count()); | 116 EXPECT_EQ(1, test_view->detached_count()); |
| 117 EXPECT_EQ(toplevel->GetNativeView(), | 117 EXPECT_EQ(toplevel->GetNativeView(), |
| 118 GetNativeParent(child->GetNativeView())); | 118 GetNativeParent(child->GetNativeView())); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace views | 121 } // namespace views |
| OLD | NEW |