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..e739c8ee576923dad4fd90a8f9618e62fe137c19 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,44 @@ 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. |
+ Widget* parent = new Widget; |
sky
2017/05/08 21:24:29
Is this leaked? Was you're using WIDGET_OWNS_NATIV
Qiang(Joe) Xu
2017/05/08 22:00:40
changed to std::unique_ptr
|
+ 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)); |
+ parent->Show(); |
sky
2017/05/08 21:24:29
Isn't the bug scenario in the bug where the parent
Qiang(Joe) Xu
2017/05/08 22:00:40
In the last, I tested when parent is hidden. But t
|
+ |
+ // Add a child bubble window to the above parent window. |
+ Widget* child = new Widget; |
+ 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 child bubble window is added as the transient child. |
+ wm::TransientWindowManager* manager = |
+ wm::TransientWindowManager::Get(child->GetNativeWindow()); |
+ ASSERT_EQ(parent->GetNativeWindow(), manager->transient_parent()); |
+ ASSERT_TRUE(parent->IsVisible()); |
+ ASSERT_TRUE(child->IsVisible()); |
+ |
+ // Hide the parent window should make the transient child bubble invisible. |
+ parent->Hide(); |
+ 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 |