Chromium Code Reviews| Index: ui/views/widget/native_widget_aura_unittest.cc |
| diff --git a/ui/views/widget/native_widget_aura_unittest.cc b/ui/views/widget/native_widget_aura_unittest.cc |
| index 8583f051b95103e525894c9e382dff4ca0571c53..36d5f58aaf8686d55aa91cc434b8985b1fc6aa9c 100644 |
| --- a/ui/views/widget/native_widget_aura_unittest.cc |
| +++ b/ui/views/widget/native_widget_aura_unittest.cc |
| @@ -27,6 +27,7 @@ |
| #include "ui/wm/core/base_focus_rules.h" |
| #include "ui/wm/core/default_activation_client.h" |
| #include "ui/wm/core/focus_controller.h" |
| +#include "ui/wm/core/transient_window_manager.h" |
| namespace views { |
| namespace { |
| @@ -651,5 +652,39 @@ TEST_F(NativeWidgetAuraTest, PreventFocusOnNonActivableWindow) { |
| EXPECT_TRUE(delegate2.view()->HasFocus()); |
| } |
| +// Tests that the transient child bubble window is only visible if the parent is |
| +// visible. |
| +TEST_F(NativeWidgetAuraTest, VisibilityOfChildBubbleWindow) { |
| + // Create a parent window. |
| + std::unique_ptr<Widget> parent(new Widget); |
|
sky
2017/05/08 22:42:11
No need for the unique_ptr here, declare parent on
Qiang(Joe) Xu
2017/05/08 22:55:57
Done.
|
| + Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW); |
| + parent_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| + parent_params.context = root_window(); |
| + parent->Init(parent_params); |
| + parent->SetBounds(gfx::Rect(0, 0, 480, 320)); |
| + |
| + // Add a child bubble window to the above parent window and show it. |
| + std::unique_ptr<Widget> child(new Widget); |
|
sky
2017/05/08 22:42:11
Same comment here.
Qiang(Joe) Xu
2017/05/08 22:55:57
Done.
|
| + Widget::InitParams child_params(Widget::InitParams::TYPE_BUBBLE); |
| + child_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| + child_params.parent = parent->GetNativeWindow(); |
| + child->Init(child_params); |
| + child->SetBounds(gfx::Rect(0, 0, 200, 200)); |
| + child->Show(); |
| + |
| + // Check that the bubble window is added as the transient child and it is |
| + // hidden because parent window is hidden. |
| + wm::TransientWindowManager* manager = |
| + wm::TransientWindowManager::Get(child->GetNativeWindow()); |
| + EXPECT_EQ(parent->GetNativeWindow(), manager->transient_parent()); |
| + EXPECT_FALSE(parent->IsVisible()); |
| + EXPECT_FALSE(child->IsVisible()); |
| + |
| + // Show the parent window should make the transient child bubble visible. |
| + parent->Show(); |
| + EXPECT_TRUE(parent->IsVisible()); |
| + EXPECT_TRUE(child->IsVisible()); |
| +} |
| + |
| } // namespace |
| } // namespace views |