Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: ash/wm/system_modal_container_layout_manager_unittest.cc

Issue 10442017: Rename GetRootWindow() -> GetPrimaryRootWindow() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git-try -b linux_chromeos,win_aura Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ash/wm/system_modal_container_layout_manager.h" 5 #include "ash/wm/system_modal_container_layout_manager.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 TransientWindowObserver do1; 137 TransientWindowObserver do1;
138 t1->AddObserver(&do1); 138 t1->AddObserver(&do1);
139 139
140 EXPECT_EQ(parent.get(), t1->transient_parent()); 140 EXPECT_EQ(parent.get(), t1->transient_parent());
141 EXPECT_EQ(GetModalContainer(), t1->parent()); 141 EXPECT_EQ(GetModalContainer(), t1->parent());
142 142
143 // t1 should now be active. 143 // t1 should now be active.
144 EXPECT_TRUE(wm::IsActiveWindow(t1)); 144 EXPECT_TRUE(wm::IsActiveWindow(t1));
145 145
146 // Attempting to click the parent should result in no activation change. 146 // Attempting to click the parent should result in no activation change.
147 aura::test::EventGenerator e1(Shell::GetRootWindow(), parent.get()); 147 aura::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), parent.get());
148 e1.ClickLeftButton(); 148 e1.ClickLeftButton();
149 EXPECT_TRUE(wm::IsActiveWindow(t1)); 149 EXPECT_TRUE(wm::IsActiveWindow(t1));
150 150
151 // Now open another modal transient parented to the original modal transient. 151 // Now open another modal transient parented to the original modal transient.
152 aura::Window* t2 = TestWindow::OpenTestWindow(t1, true); 152 aura::Window* t2 = TestWindow::OpenTestWindow(t1, true);
153 TransientWindowObserver do2; 153 TransientWindowObserver do2;
154 t2->AddObserver(&do2); 154 t2->AddObserver(&do2);
155 155
156 EXPECT_TRUE(wm::IsActiveWindow(t2)); 156 EXPECT_TRUE(wm::IsActiveWindow(t2));
157 157
158 EXPECT_EQ(t1, t2->transient_parent()); 158 EXPECT_EQ(t1, t2->transient_parent());
159 EXPECT_EQ(GetModalContainer(), t2->parent()); 159 EXPECT_EQ(GetModalContainer(), t2->parent());
160 160
161 // t2 should still be active, even after clicking on t1. 161 // t2 should still be active, even after clicking on t1.
162 aura::test::EventGenerator e2(Shell::GetRootWindow(), t1); 162 aura::test::EventGenerator e2(Shell::GetPrimaryRootWindow(), t1);
163 e2.ClickLeftButton(); 163 e2.ClickLeftButton();
164 EXPECT_TRUE(wm::IsActiveWindow(t2)); 164 EXPECT_TRUE(wm::IsActiveWindow(t2));
165 165
166 // Both transients should be destroyed with parent. 166 // Both transients should be destroyed with parent.
167 parent.reset(); 167 parent.reset();
168 EXPECT_TRUE(do1.destroyed()); 168 EXPECT_TRUE(do1.destroyed());
169 EXPECT_TRUE(do2.destroyed()); 169 EXPECT_TRUE(do2.destroyed());
170 } 170 }
171 171
172 // Fails on Mac only. Needs to be implemented. http://crbug.com/111279. 172 // Fails on Mac only. Needs to be implemented. http://crbug.com/111279.
(...skipping 12 matching lines...) Expand all
185 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false)); 185 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false));
186 // parent should be active. 186 // parent should be active.
187 EXPECT_TRUE(wm::IsActiveWindow(parent.get())); 187 EXPECT_TRUE(wm::IsActiveWindow(parent.get()));
188 188
189 scoped_ptr<aura::Window> transient( 189 scoped_ptr<aura::Window> transient(
190 TestWindow::OpenTestWindow(parent.get(), true)); 190 TestWindow::OpenTestWindow(parent.get(), true));
191 // t1 should now be active. 191 // t1 should now be active.
192 EXPECT_TRUE(wm::IsActiveWindow(transient.get())); 192 EXPECT_TRUE(wm::IsActiveWindow(transient.get()));
193 193
194 // Attempting to click the parent should result in no activation change. 194 // Attempting to click the parent should result in no activation change.
195 aura::test::EventGenerator e1(Shell::GetRootWindow(), parent.get()); 195 aura::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), parent.get());
196 e1.ClickLeftButton(); 196 e1.ClickLeftButton();
197 EXPECT_TRUE(wm::IsActiveWindow(transient.get())); 197 EXPECT_TRUE(wm::IsActiveWindow(transient.get()));
198 198
199 // Now close the transient. 199 // Now close the transient.
200 transient.reset(); 200 transient.reset();
201 201
202 MessageLoopForUI::current()->RunAllPending(); 202 MessageLoopForUI::current()->RunAllPending();
203 203
204 // parent should now be active again. 204 // parent should now be active again.
205 EXPECT_TRUE(wm::IsActiveWindow(parent.get())); 205 EXPECT_TRUE(wm::IsActiveWindow(parent.get()));
206 206
207 // Attempting to click unrelated should activate it. 207 // Attempting to click unrelated should activate it.
208 aura::test::EventGenerator e2(Shell::GetRootWindow(), unrelated.get()); 208 aura::test::EventGenerator e2(Shell::GetPrimaryRootWindow(), unrelated.get());
209 e2.ClickLeftButton(); 209 e2.ClickLeftButton();
210 EXPECT_TRUE(wm::IsActiveWindow(unrelated.get())); 210 EXPECT_TRUE(wm::IsActiveWindow(unrelated.get()));
211 } 211 }
212 212
213 TEST_F(SystemModalContainerLayoutManagerTest, EventFocusContainers) { 213 TEST_F(SystemModalContainerLayoutManagerTest, EventFocusContainers) {
214 // Create a normal window and attempt to receive a click event. 214 // Create a normal window and attempt to receive a click event.
215 EventTestWindow* main_delegate = new EventTestWindow(false); 215 EventTestWindow* main_delegate = new EventTestWindow(false);
216 scoped_ptr<aura::Window> main(main_delegate->OpenTestWindow(NULL)); 216 scoped_ptr<aura::Window> main(main_delegate->OpenTestWindow(NULL));
217 EXPECT_TRUE(wm::IsActiveWindow(main.get())); 217 EXPECT_TRUE(wm::IsActiveWindow(main.get()));
218 aura::test::EventGenerator e1(Shell::GetRootWindow(), main.get()); 218 aura::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), main.get());
219 e1.ClickLeftButton(); 219 e1.ClickLeftButton();
220 EXPECT_EQ(1, main_delegate->mouse_presses()); 220 EXPECT_EQ(1, main_delegate->mouse_presses());
221 221
222 // Create a modal window for the main window and verify that the main window 222 // Create a modal window for the main window and verify that the main window
223 // no longer receives mouse events. 223 // no longer receives mouse events.
224 EventTestWindow* transient_delegate = new EventTestWindow(true); 224 EventTestWindow* transient_delegate = new EventTestWindow(true);
225 aura::Window* transient = transient_delegate->OpenTestWindow(main.get()); 225 aura::Window* transient = transient_delegate->OpenTestWindow(main.get());
226 EXPECT_TRUE(wm::IsActiveWindow(transient)); 226 EXPECT_TRUE(wm::IsActiveWindow(transient));
227 e1.ClickLeftButton(); 227 e1.ClickLeftButton();
228 EXPECT_EQ(1, transient_delegate->mouse_presses()); 228 EXPECT_EQ(1, transient_delegate->mouse_presses());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 views::Widget* widget = 274 views::Widget* widget =
275 views::Widget::CreateWindowWithParent(new TestWindow(false), NULL); 275 views::Widget::CreateWindowWithParent(new TestWindow(false), NULL);
276 scoped_ptr<aura::Window> widget_window(widget->GetNativeView()); 276 scoped_ptr<aura::Window> widget_window(widget->GetNativeView());
277 CaptureTrackingView* view = new CaptureTrackingView; 277 CaptureTrackingView* view = new CaptureTrackingView;
278 widget->GetContentsView()->AddChildView(view); 278 widget->GetContentsView()->AddChildView(view);
279 view->SetBoundsRect(widget->GetContentsView()->bounds()); 279 view->SetBoundsRect(widget->GetContentsView()->bounds());
280 widget->Show(); 280 widget->Show();
281 281
282 gfx::Point center(view->width() / 2, view->height() / 2); 282 gfx::Point center(view->width() / 2, view->height() / 2);
283 views::View::ConvertPointToScreen(view, &center); 283 views::View::ConvertPointToScreen(view, &center);
284 aura::test::EventGenerator generator(Shell::GetRootWindow(), center); 284 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), center);
285 generator.PressLeftButton(); 285 generator.PressLeftButton();
286 EXPECT_TRUE(view->got_press()); 286 EXPECT_TRUE(view->got_press());
287 scoped_ptr<aura::Window> modal_window( 287 scoped_ptr<aura::Window> modal_window(
288 TestWindow::OpenTestWindow(widget->GetNativeView(), true)); 288 TestWindow::OpenTestWindow(widget->GetNativeView(), true));
289 modal_window->Show(); 289 modal_window->Show();
290 EXPECT_TRUE(view->got_capture_lost()); 290 EXPECT_TRUE(view->got_capture_lost());
291 } 291 }
292 292
293 // Verifies that the window gets moved into the visible screen area upon screen 293 // Verifies that the window gets moved into the visible screen area upon screen
294 // resize. 294 // resize.
295 TEST_F(SystemModalContainerLayoutManagerTest, KeepVisible) { 295 TEST_F(SystemModalContainerLayoutManagerTest, KeepVisible) {
296 GetModalContainer()->SetBounds(gfx::Rect(0, 0, 1024, 768)); 296 GetModalContainer()->SetBounds(gfx::Rect(0, 0, 1024, 768));
297 scoped_ptr<aura::Window> main(TestWindow::OpenTestWindow(GetModalContainer(), 297 scoped_ptr<aura::Window> main(TestWindow::OpenTestWindow(GetModalContainer(),
298 true)); 298 true));
299 main->SetBounds(gfx::Rect(924, 668, 100, 100)); 299 main->SetBounds(gfx::Rect(924, 668, 100, 100));
300 // We set now the bounds of the root window to something new which will 300 // We set now the bounds of the root window to something new which will
301 // Then trigger the repos operation. 301 // Then trigger the repos operation.
302 GetModalContainer()->SetBounds(gfx::Rect(0, 0, 800, 600)); 302 GetModalContainer()->SetBounds(gfx::Rect(0, 0, 800, 600));
303 303
304 gfx::Rect bounds = main->bounds(); 304 gfx::Rect bounds = main->bounds();
305 EXPECT_EQ(bounds, gfx::Rect(700, 500, 100, 100)); 305 EXPECT_EQ(bounds, gfx::Rect(700, 500, 100, 100));
306 } 306 }
307 307
308 } // namespace test 308 } // namespace test
309 } // namespace ash 309 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/system_gesture_event_filter_unittest.cc ('k') | ash/wm/toplevel_window_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698