| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // |widget| has the toplevel NativeWidget. | 75 // |widget| has the toplevel NativeWidget. |
| 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. |
| 86 if (IsAuraMusClient()) |
| 87 return; |
| 88 |
| 85 internal::NativeWidgetPrivate* child_widget = CreateNativeSubWidget(); | 89 internal::NativeWidgetPrivate* child_widget = CreateNativeSubWidget(); |
| 86 { | 90 { |
| 87 ScopedTestWidget toplevel_widget(CreateNativeWidget()); | 91 ScopedTestWidget toplevel_widget(CreateNativeWidget()); |
| 88 | 92 |
| 89 // |toplevel_widget| owns |child_host|. | 93 // |toplevel_widget| owns |child_host|. |
| 90 NativeViewHost* child_host = new NativeViewHost; | 94 NativeViewHost* child_host = new NativeViewHost; |
| 91 toplevel_widget->GetWidget()->SetContentsView(child_host); | 95 toplevel_widget->GetWidget()->SetContentsView(child_host); |
| 92 | 96 |
| 93 // |child_host| hosts |child_widget|'s NativeView. | 97 // |child_host| hosts |child_widget|'s NativeView. |
| 94 child_host->Attach(child_widget->GetWidget()->GetNativeView()); | 98 child_host->Attach(child_widget->GetWidget()->GetNativeView()); |
| 95 | 99 |
| 96 EXPECT_EQ(toplevel_widget.get(), | 100 EXPECT_EQ(toplevel_widget.get(), |
| 97 internal::NativeWidgetPrivate::GetTopLevelNativeWidget( | 101 internal::NativeWidgetPrivate::GetTopLevelNativeWidget( |
| 98 child_widget->GetWidget()->GetNativeView())); | 102 child_widget->GetWidget()->GetNativeView())); |
| 99 } | 103 } |
| 100 // NativeViewHost only had a weak reference to the |child_widget|'s | 104 // NativeViewHost only had a weak reference to the |child_widget|'s |
| 101 // NativeView. Delete it and the associated Widget. | 105 // NativeView. Delete it and the associated Widget. |
| 102 child_widget->CloseNow(); | 106 child_widget->CloseNow(); |
| 103 } | 107 } |
| 104 | 108 |
| 105 } // namespace views | 109 } // namespace views |
| OLD | NEW |