OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/aura_shell/modal_container_layout_manager.h" | 5 #include "ui/aura_shell/modal_container_layout_manager.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "ui/aura/desktop.h" | 8 #include "ui/aura/root_window.h" |
9 #include "ui/aura/test/event_generator.h" | 9 #include "ui/aura/test/event_generator.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
11 #include "ui/aura_shell/shell.h" | 11 #include "ui/aura_shell/shell.h" |
12 #include "ui/aura_shell/shell_window_ids.h" | 12 #include "ui/aura_shell/shell_window_ids.h" |
13 #include "ui/aura_shell/test/aura_shell_test_base.h" | 13 #include "ui/aura_shell/test/aura_shell_test_base.h" |
14 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
15 #include "ui/views/widget/widget_delegate.h" | 15 #include "ui/views/widget/widget_delegate.h" |
16 | 16 |
17 namespace aura_shell { | 17 namespace aura_shell { |
18 namespace test { | 18 namespace test { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 EXPECT_EQ(GetDefaultContainer(), transient->parent()); | 93 EXPECT_EQ(GetDefaultContainer(), transient->parent()); |
94 | 94 |
95 // The transient should be destroyed with its parent. | 95 // The transient should be destroyed with its parent. |
96 parent.reset(); | 96 parent.reset(); |
97 EXPECT_TRUE(destruction_observer.destroyed()); | 97 EXPECT_TRUE(destruction_observer.destroyed()); |
98 } | 98 } |
99 | 99 |
100 TEST_F(ModalContainerLayoutManagerTest, ModalTransient) { | 100 TEST_F(ModalContainerLayoutManagerTest, ModalTransient) { |
101 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false)); | 101 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false)); |
102 // parent should be active. | 102 // parent should be active. |
103 EXPECT_EQ(parent.get(), aura::Desktop::GetInstance()->active_window()); | 103 EXPECT_EQ(parent.get(), aura::RootWindow::GetInstance()->active_window()); |
104 | 104 |
105 aura::Window* t1 = TestWindow::OpenTestWindow(parent.get(), true); | 105 aura::Window* t1 = TestWindow::OpenTestWindow(parent.get(), true); |
106 TransientWindowObserver do1; | 106 TransientWindowObserver do1; |
107 t1->AddObserver(&do1); | 107 t1->AddObserver(&do1); |
108 | 108 |
109 EXPECT_EQ(parent.get(), t1->transient_parent()); | 109 EXPECT_EQ(parent.get(), t1->transient_parent()); |
110 EXPECT_EQ(GetModalContainer(), t1->parent()); | 110 EXPECT_EQ(GetModalContainer(), t1->parent()); |
111 | 111 |
112 // t1 should now be active. | 112 // t1 should now be active. |
113 EXPECT_EQ(t1, aura::Desktop::GetInstance()->active_window()); | 113 EXPECT_EQ(t1, aura::RootWindow::GetInstance()->active_window()); |
114 | 114 |
115 // Attempting to click the parent should result in no activation change. | 115 // Attempting to click the parent should result in no activation change. |
116 aura::test::EventGenerator e1(parent.get()); | 116 aura::test::EventGenerator e1(parent.get()); |
117 e1.ClickLeftButton(); | 117 e1.ClickLeftButton(); |
118 EXPECT_EQ(t1, aura::Desktop::GetInstance()->active_window()); | 118 EXPECT_EQ(t1, aura::RootWindow::GetInstance()->active_window()); |
119 | 119 |
120 // Now open another modal transient parented to the original modal transient. | 120 // Now open another modal transient parented to the original modal transient. |
121 aura::Window* t2 = TestWindow::OpenTestWindow(t1, true); | 121 aura::Window* t2 = TestWindow::OpenTestWindow(t1, true); |
122 TransientWindowObserver do2; | 122 TransientWindowObserver do2; |
123 t2->AddObserver(&do2); | 123 t2->AddObserver(&do2); |
124 | 124 |
125 EXPECT_EQ(t2, aura::Desktop::GetInstance()->active_window()); | 125 EXPECT_EQ(t2, aura::RootWindow::GetInstance()->active_window()); |
126 | 126 |
127 EXPECT_EQ(t1, t2->transient_parent()); | 127 EXPECT_EQ(t1, t2->transient_parent()); |
128 EXPECT_EQ(GetModalContainer(), t2->parent()); | 128 EXPECT_EQ(GetModalContainer(), t2->parent()); |
129 | 129 |
130 // t2 should still be active, even after clicking on t1. | 130 // t2 should still be active, even after clicking on t1. |
131 aura::test::EventGenerator e2(t1); | 131 aura::test::EventGenerator e2(t1); |
132 e2.ClickLeftButton(); | 132 e2.ClickLeftButton(); |
133 EXPECT_EQ(t2, aura::Desktop::GetInstance()->active_window()); | 133 EXPECT_EQ(t2, aura::RootWindow::GetInstance()->active_window()); |
134 | 134 |
135 // Both transients should be destroyed with parent. | 135 // Both transients should be destroyed with parent. |
136 parent.reset(); | 136 parent.reset(); |
137 EXPECT_TRUE(do1.destroyed()); | 137 EXPECT_TRUE(do1.destroyed()); |
138 EXPECT_TRUE(do2.destroyed()); | 138 EXPECT_TRUE(do2.destroyed()); |
139 } | 139 } |
140 | 140 |
141 // Tests that we can activate an unrelated window after a modal window is closed | 141 // Tests that we can activate an unrelated window after a modal window is closed |
142 // for a window. | 142 // for a window. |
143 TEST_F(ModalContainerLayoutManagerTest, CanActivateAfterEndModalSession) { | 143 TEST_F(ModalContainerLayoutManagerTest, CanActivateAfterEndModalSession) { |
144 scoped_ptr<aura::Window> unrelated(TestWindow::OpenTestWindow(NULL, false)); | 144 scoped_ptr<aura::Window> unrelated(TestWindow::OpenTestWindow(NULL, false)); |
145 unrelated->SetBounds(gfx::Rect(100, 100, 50, 50)); | 145 unrelated->SetBounds(gfx::Rect(100, 100, 50, 50)); |
146 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false)); | 146 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false)); |
147 // parent should be active. | 147 // parent should be active. |
148 EXPECT_EQ(parent.get(), aura::Desktop::GetInstance()->active_window()); | 148 EXPECT_EQ(parent.get(), aura::RootWindow::GetInstance()->active_window()); |
149 | 149 |
150 scoped_ptr<aura::Window> transient( | 150 scoped_ptr<aura::Window> transient( |
151 TestWindow::OpenTestWindow(parent.get(), true)); | 151 TestWindow::OpenTestWindow(parent.get(), true)); |
152 // t1 should now be active. | 152 // t1 should now be active. |
153 EXPECT_EQ(transient.get(), aura::Desktop::GetInstance()->active_window()); | 153 EXPECT_EQ(transient.get(), aura::RootWindow::GetInstance()->active_window()); |
154 | 154 |
155 // Attempting to click the parent should result in no activation change. | 155 // Attempting to click the parent should result in no activation change. |
156 aura::test::EventGenerator e1(parent.get()); | 156 aura::test::EventGenerator e1(parent.get()); |
157 e1.ClickLeftButton(); | 157 e1.ClickLeftButton(); |
158 EXPECT_EQ(transient.get(), aura::Desktop::GetInstance()->active_window()); | 158 EXPECT_EQ(transient.get(), aura::RootWindow::GetInstance()->active_window()); |
159 | 159 |
160 // Now close the transient. | 160 // Now close the transient. |
161 transient.reset(); | 161 transient.reset(); |
162 | 162 |
163 // parent should now be active again. | 163 // parent should now be active again. |
164 EXPECT_EQ(parent.get(), aura::Desktop::GetInstance()->active_window()); | 164 EXPECT_EQ(parent.get(), aura::RootWindow::GetInstance()->active_window()); |
165 | 165 |
166 // Attempting to click unrelated should activate it. | 166 // Attempting to click unrelated should activate it. |
167 aura::test::EventGenerator e2(unrelated.get()); | 167 aura::test::EventGenerator e2(unrelated.get()); |
168 e2.ClickLeftButton(); | 168 e2.ClickLeftButton(); |
169 EXPECT_EQ(unrelated.get(), aura::Desktop::GetInstance()->active_window()); | 169 EXPECT_EQ(unrelated.get(), aura::RootWindow::GetInstance()->active_window()); |
170 } | 170 } |
171 | 171 |
172 } // namespace test | 172 } // namespace test |
173 } // namespace aura_shell | 173 } // namespace aura_shell |
OLD | NEW |