| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/wm/core/transient_window_manager.h" | 5 #include "ui/wm/core/transient_window_manager.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/visibility_client.h" | 7 #include "ui/aura/client/visibility_client.h" |
| 8 #include "ui/aura/client/window_tree_client.h" | 8 #include "ui/aura/client/window_tree_client.h" |
| 9 #include "ui/aura/layout_manager.h" | 9 #include "ui/aura/layout_manager.h" |
| 10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // different parent. | 109 // different parent. |
| 110 parent->StackChildAtTop(w1.get()); | 110 parent->StackChildAtTop(w1.get()); |
| 111 ASSERT_EQ(2u, parent->children().size()); | 111 ASSERT_EQ(2u, parent->children().size()); |
| 112 EXPECT_EQ(w3.get(), parent->children()[0]); | 112 EXPECT_EQ(w3.get(), parent->children()[0]); |
| 113 EXPECT_EQ(w1.get(), parent->children()[1]); | 113 EXPECT_EQ(w1.get(), parent->children()[1]); |
| 114 | 114 |
| 115 // Hiding parent should hide transient children. | 115 // Hiding parent should hide transient children. |
| 116 EXPECT_TRUE(w2->IsVisible()); | 116 EXPECT_TRUE(w2->IsVisible()); |
| 117 w1->Hide(); | 117 w1->Hide(); |
| 118 EXPECT_FALSE(w2->IsVisible()); | 118 EXPECT_FALSE(w2->IsVisible()); |
| 119 |
| 120 // And they should stay hidden even after the parent became visible. |
| 121 w1->Show(); |
| 122 EXPECT_FALSE(w2->IsVisible()); |
| 123 |
| 124 // Hidden transient child should stay hidden regardless of |
| 125 // parent's visibility. |
| 126 w2->Hide(); |
| 127 EXPECT_FALSE(w2->IsVisible()); |
| 128 w1->Hide(); |
| 129 EXPECT_FALSE(w2->IsVisible()); |
| 130 w1->Show(); |
| 131 EXPECT_FALSE(w2->IsVisible()); |
| 132 |
| 133 // Transient child can be shown even if the transient parent is hidden. |
| 134 w1->Hide(); |
| 135 EXPECT_FALSE(w2->IsVisible()); |
| 136 w2->Show(); |
| 137 EXPECT_TRUE(w2->IsVisible()); |
| 138 w1->Show(); |
| 139 EXPECT_TRUE(w2->IsVisible()); |
| 140 |
| 141 // When the parent_controls_visibility is true, TransientWindowManager |
| 142 // controls the children's visibility. It stays invisible even if |
| 143 // Window::Show() is called, and gets shown when the parent becomes visible. |
| 144 wm::TransientWindowManager::Get(w2)->set_parent_controls_visibility(true); |
| 145 w1->Hide(); |
| 146 EXPECT_FALSE(w2->IsVisible()); |
| 147 w2->Show(); |
| 148 EXPECT_FALSE(w2->IsVisible()); |
| 149 w1->Show(); |
| 150 EXPECT_TRUE(w2->IsVisible()); |
| 151 |
| 152 // Hiding a transient child that is hidden by the transient parent |
| 153 // is not currently handled and will be shown anyway. |
| 154 w1->Hide(); |
| 155 EXPECT_FALSE(w2->IsVisible()); |
| 156 w2->Hide(); |
| 157 EXPECT_FALSE(w2->IsVisible()); |
| 158 w1->Show(); |
| 159 EXPECT_TRUE(w2->IsVisible()); |
| 119 } | 160 } |
| 120 | 161 |
| 121 // Tests that transient children are stacked as a unit when using stack above. | 162 // Tests that transient children are stacked as a unit when using stack above. |
| 122 TEST_F(TransientWindowManagerTest, TransientChildrenGroupAbove) { | 163 TEST_F(TransientWindowManagerTest, TransientChildrenGroupAbove) { |
| 123 scoped_ptr<Window> parent(CreateTestWindowWithId(0, root_window())); | 164 scoped_ptr<Window> parent(CreateTestWindowWithId(0, root_window())); |
| 124 scoped_ptr<Window> w1(CreateTestWindowWithId(1, parent.get())); | 165 scoped_ptr<Window> w1(CreateTestWindowWithId(1, parent.get())); |
| 125 Window* w11 = CreateTestWindowWithId(11, parent.get()); | 166 Window* w11 = CreateTestWindowWithId(11, parent.get()); |
| 126 scoped_ptr<Window> w2(CreateTestWindowWithId(2, parent.get())); | 167 scoped_ptr<Window> w2(CreateTestWindowWithId(2, parent.get())); |
| 127 Window* w21 = CreateTestWindowWithId(21, parent.get()); | 168 Window* w21 = CreateTestWindowWithId(21, parent.get()); |
| 128 Window* w211 = CreateTestWindowWithId(211, parent.get()); | 169 Window* w211 = CreateTestWindowWithId(211, parent.get()); |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 EXPECT_EQ(0, test_observer.remove_count()); | 698 EXPECT_EQ(0, test_observer.remove_count()); |
| 658 | 699 |
| 659 RemoveTransientChild(parent.get(), w1.get()); | 700 RemoveTransientChild(parent.get(), w1.get()); |
| 660 EXPECT_EQ(1, test_observer.add_count()); | 701 EXPECT_EQ(1, test_observer.add_count()); |
| 661 EXPECT_EQ(1, test_observer.remove_count()); | 702 EXPECT_EQ(1, test_observer.remove_count()); |
| 662 | 703 |
| 663 TransientWindowManager::Get(parent.get())->RemoveObserver(&test_observer); | 704 TransientWindowManager::Get(parent.get())->RemoveObserver(&test_observer); |
| 664 } | 705 } |
| 665 | 706 |
| 666 } // namespace wm | 707 } // namespace wm |
| OLD | NEW |