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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "ui/views/controls/native/native_view_host.h" | 7 #include "ui/views/controls/native/native_view_host.h" |
8 #include "ui/views/test/views_test_base.h" | 8 #include "ui/views/test/views_test_base.h" |
9 #include "ui/views/view.h" | 9 #include "ui/views/view.h" |
10 #include "ui/views/widget/native_widget_private.h" | 10 #include "ui/views/widget/native_widget_private.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 TEST_F(NativeWidgetTest, GetTopLevelNativeWidget1) { | 76 TEST_F(NativeWidgetTest, GetTopLevelNativeWidget1) { |
77 ScopedTestWidget widget(CreateNativeWidget()); | 77 ScopedTestWidget widget(CreateNativeWidget()); |
78 EXPECT_EQ(widget.get(), | 78 EXPECT_EQ(widget.get(), |
79 internal::NativeWidgetPrivate::GetTopLevelNativeWidget( | 79 internal::NativeWidgetPrivate::GetTopLevelNativeWidget( |
80 widget->GetWidget()->GetNativeView())); | 80 widget->GetWidget()->GetNativeView())); |
81 } | 81 } |
82 | 82 |
83 // |toplevel_widget| has the toplevel NativeWidget. | 83 // |toplevel_widget| has the toplevel NativeWidget. |
84 TEST_F(NativeWidgetTest, GetTopLevelNativeWidget2) { | 84 TEST_F(NativeWidgetTest, GetTopLevelNativeWidget2) { |
85 // This test relies on GetContext(). http://crbug.com/663809. | 85 // This test relies on GetContext(). http://crbug.com/663809. |
86 if (IsAuraMusClient()) | 86 if (IsMus()) |
87 return; | 87 return; |
88 | 88 |
89 internal::NativeWidgetPrivate* child_widget = CreateNativeSubWidget(); | 89 internal::NativeWidgetPrivate* child_widget = CreateNativeSubWidget(); |
90 { | 90 { |
91 ScopedTestWidget toplevel_widget(CreateNativeWidget()); | 91 ScopedTestWidget toplevel_widget(CreateNativeWidget()); |
92 | 92 |
93 // |toplevel_widget| owns |child_host|. | 93 // |toplevel_widget| owns |child_host|. |
94 NativeViewHost* child_host = new NativeViewHost; | 94 NativeViewHost* child_host = new NativeViewHost; |
95 toplevel_widget->GetWidget()->SetContentsView(child_host); | 95 toplevel_widget->GetWidget()->SetContentsView(child_host); |
96 | 96 |
97 // |child_host| hosts |child_widget|'s NativeView. | 97 // |child_host| hosts |child_widget|'s NativeView. |
98 child_host->Attach(child_widget->GetWidget()->GetNativeView()); | 98 child_host->Attach(child_widget->GetWidget()->GetNativeView()); |
99 | 99 |
100 EXPECT_EQ(toplevel_widget.get(), | 100 EXPECT_EQ(toplevel_widget.get(), |
101 internal::NativeWidgetPrivate::GetTopLevelNativeWidget( | 101 internal::NativeWidgetPrivate::GetTopLevelNativeWidget( |
102 child_widget->GetWidget()->GetNativeView())); | 102 child_widget->GetWidget()->GetNativeView())); |
103 } | 103 } |
104 // NativeViewHost only had a weak reference to the |child_widget|'s | 104 // NativeViewHost only had a weak reference to the |child_widget|'s |
105 // NativeView. Delete it and the associated Widget. | 105 // NativeView. Delete it and the associated Widget. |
106 child_widget->CloseNow(); | 106 child_widget->CloseNow(); |
107 } | 107 } |
108 | 108 |
109 } // namespace views | 109 } // namespace views |
OLD | NEW |