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

Side by Side Diff: ash/extended_desktop_unittest.cc

Issue 64933002: Eliminate Shell::RootWindowList in favor of aura::Window::Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month 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/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 #include "ash/display/display_manager.h" 6 #include "ash/display/display_manager.h"
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 class MoveWindowByClickEventHandler : public ui::EventHandler { 68 class MoveWindowByClickEventHandler : public ui::EventHandler {
69 public: 69 public:
70 explicit MoveWindowByClickEventHandler(aura::Window* target) 70 explicit MoveWindowByClickEventHandler(aura::Window* target)
71 : target_(target) {} 71 : target_(target) {}
72 virtual ~MoveWindowByClickEventHandler() {} 72 virtual ~MoveWindowByClickEventHandler() {}
73 73
74 private: 74 private:
75 // ui::EventHandler overrides: 75 // ui::EventHandler overrides:
76 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { 76 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
77 if (event->type() == ui::ET_MOUSE_RELEASED) { 77 if (event->type() == ui::ET_MOUSE_RELEASED) {
78 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 78 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
79 DCHECK_LT(1u, root_windows.size()); 79 DCHECK_LT(1u, root_windows.size());
80 root_windows[1]->AddChild(target_); 80 root_windows[1]->AddChild(target_);
81 } 81 }
82 } 82 }
83 83
84 aura::Window* target_; 84 aura::Window* target_;
85 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventHandler); 85 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventHandler);
86 }; 86 };
87 87
88 // An event handler which records the event's locations. 88 // An event handler which records the event's locations.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 }; 155 };
156 156
157 // Test conditions that root windows in extended desktop mode 157 // Test conditions that root windows in extended desktop mode
158 // must satisfy. 158 // must satisfy.
159 TEST_F(ExtendedDesktopTest, Basic) { 159 TEST_F(ExtendedDesktopTest, Basic) {
160 if (!SupportsMultipleDisplays()) 160 if (!SupportsMultipleDisplays())
161 return; 161 return;
162 162
163 UpdateDisplay("1000x600,600x400"); 163 UpdateDisplay("1000x600,600x400");
164 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 164 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
165 165
166 // All root windows must have the root window controller. 166 // All root windows must have the root window controller.
167 ASSERT_EQ(2U, root_windows.size()); 167 ASSERT_EQ(2U, root_windows.size());
168 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); 168 for (aura::Window::Windows::const_iterator iter = root_windows.begin();
169 iter != root_windows.end(); ++iter) { 169 iter != root_windows.end(); ++iter) {
170 EXPECT_TRUE(internal::GetRootWindowController(*iter) != NULL); 170 EXPECT_TRUE(internal::GetRootWindowController(*iter) != NULL);
171 } 171 }
172 // Make sure root windows share the same controllers. 172 // Make sure root windows share the same controllers.
173 EXPECT_EQ(aura::client::GetFocusClient(root_windows[0]), 173 EXPECT_EQ(aura::client::GetFocusClient(root_windows[0]),
174 aura::client::GetFocusClient(root_windows[1])); 174 aura::client::GetFocusClient(root_windows[1]));
175 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]), 175 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]),
176 aura::client::GetActivationClient(root_windows[1])); 176 aura::client::GetActivationClient(root_windows[1]));
177 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]), 177 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]),
178 aura::client::GetCaptureClient(root_windows[1])); 178 aura::client::GetCaptureClient(root_windows[1]));
179 } 179 }
180 180
181 TEST_F(ExtendedDesktopTest, Activation) { 181 TEST_F(ExtendedDesktopTest, Activation) {
182 if (!SupportsMultipleDisplays()) 182 if (!SupportsMultipleDisplays())
183 return; 183 return;
184 184
185 UpdateDisplay("1000x600,600x400"); 185 UpdateDisplay("1000x600,600x400");
186 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 186 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
187 187
188 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 188 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
189 views::Widget* widget_on_2nd = 189 views::Widget* widget_on_2nd =
190 CreateTestWidget(gfx::Rect(1200, 10, 100, 100)); 190 CreateTestWidget(gfx::Rect(1200, 10, 100, 100));
191 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); 191 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
192 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow()); 192 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow());
193 193
194 EXPECT_EQ(widget_on_2nd->GetNativeView(), 194 EXPECT_EQ(widget_on_2nd->GetNativeView(),
195 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow()); 195 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow());
196 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); 196 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView()));
(...skipping 13 matching lines...) Expand all
210 EXPECT_EQ(widget_on_2nd->GetNativeView(), 210 EXPECT_EQ(widget_on_2nd->GetNativeView(),
211 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow()); 211 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow());
212 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); 212 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView()));
213 } 213 }
214 214
215 TEST_F(ExtendedDesktopTest, SystemModal) { 215 TEST_F(ExtendedDesktopTest, SystemModal) {
216 if (!SupportsMultipleDisplays()) 216 if (!SupportsMultipleDisplays())
217 return; 217 return;
218 218
219 UpdateDisplay("1000x600,600x400"); 219 UpdateDisplay("1000x600,600x400");
220 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 220 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
221 221
222 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 222 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
223 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); 223 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
224 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); 224 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
225 EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow()); 225 EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow());
226 226
227 // Open system modal. Make sure it's on 2nd root window and active. 227 // Open system modal. Make sure it's on 2nd root window and active.
228 views::Widget* modal_widget = views::Widget::CreateWindowWithContextAndBounds( 228 views::Widget* modal_widget = views::Widget::CreateWindowWithContextAndBounds(
229 new ModalWidgetDelegate(), 229 new ModalWidgetDelegate(),
230 CurrentContext(), 230 CurrentContext(),
(...skipping 17 matching lines...) Expand all
248 event_generator.ClickLeftButton(); 248 event_generator.ClickLeftButton();
249 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); 249 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
250 EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow()); 250 EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow());
251 } 251 }
252 252
253 TEST_F(ExtendedDesktopTest, TestCursor) { 253 TEST_F(ExtendedDesktopTest, TestCursor) {
254 if (!SupportsMultipleDisplays()) 254 if (!SupportsMultipleDisplays())
255 return; 255 return;
256 256
257 UpdateDisplay("1000x600,600x400"); 257 UpdateDisplay("1000x600,600x400");
258 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 258 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
259 EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type()); 259 aura::WindowEventDispatcher* dispatcher0 = root_windows[0]->GetDispatcher();
260 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type()); 260 aura::WindowEventDispatcher* dispatcher1 = root_windows[1]->GetDispatcher();
261 EXPECT_EQ(ui::kCursorPointer, dispatcher0->last_cursor().native_type());
262 EXPECT_EQ(ui::kCursorPointer, dispatcher1->last_cursor().native_type());
261 Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorCopy); 263 Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorCopy);
262 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type()); 264 EXPECT_EQ(ui::kCursorCopy, dispatcher0->last_cursor().native_type());
263 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); 265 EXPECT_EQ(ui::kCursorCopy, dispatcher1->last_cursor().native_type());
264 } 266 }
265 267
266 TEST_F(ExtendedDesktopTest, TestCursorLocation) { 268 TEST_F(ExtendedDesktopTest, TestCursorLocation) {
267 if (!SupportsMultipleDisplays()) 269 if (!SupportsMultipleDisplays())
268 return; 270 return;
269 271
270 UpdateDisplay("1000x600,600x400"); 272 UpdateDisplay("1000x600,600x400");
271 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 273 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
272 aura::test::WindowTestApi root_window0_test_api(root_windows[0]); 274 aura::test::WindowTestApi root_window0_test_api(root_windows[0]);
273 aura::test::WindowTestApi root_window1_test_api(root_windows[1]); 275 aura::test::WindowTestApi root_window1_test_api(root_windows[1]);
274 276
275 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); 277 root_windows[0]->MoveCursorTo(gfx::Point(10, 10));
276 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); 278 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString());
277 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); 279 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
278 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); 280 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
279 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); 281 root_windows[1]->MoveCursorTo(gfx::Point(10, 20));
280 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); 282 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString());
281 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); 283 EXPECT_FALSE(root_window0_test_api.ContainsMouse());
282 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); 284 EXPECT_TRUE(root_window1_test_api.ContainsMouse());
283 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); 285 root_windows[0]->MoveCursorTo(gfx::Point(20, 10));
284 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); 286 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString());
285 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); 287 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
286 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); 288 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
287 } 289 }
288 290
289 TEST_F(ExtendedDesktopTest, CycleWindows) { 291 TEST_F(ExtendedDesktopTest, CycleWindows) {
290 if (!SupportsMultipleDisplays()) 292 if (!SupportsMultipleDisplays())
291 return; 293 return;
292 294
293 UpdateDisplay("700x500,500x500"); 295 UpdateDisplay("700x500,500x500");
294 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 296 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
295 297
296 WindowCycleController* controller = 298 WindowCycleController* controller =
297 Shell::GetInstance()->window_cycle_controller(); 299 Shell::GetInstance()->window_cycle_controller();
298 300
299 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 301 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
300 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); 302 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow());
301 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); 303 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
302 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); 304 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow());
303 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); 305 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
304 306
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); 338 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
337 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); 339 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
338 } 340 }
339 341
340 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { 342 TEST_F(ExtendedDesktopTest, GetRootWindowAt) {
341 if (!SupportsMultipleDisplays()) 343 if (!SupportsMultipleDisplays())
342 return; 344 return;
343 345
344 UpdateDisplay("700x500,500x500"); 346 UpdateDisplay("700x500,500x500");
345 SetSecondaryDisplayLayout(DisplayLayout::LEFT); 347 SetSecondaryDisplayLayout(DisplayLayout::LEFT);
346 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 348 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
347 349
348 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); 350 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100)));
349 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); 351 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100)));
350 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); 352 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300)));
351 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); 353 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300)));
352 354
353 // Zero origin. 355 // Zero origin.
354 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); 356 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0)));
355 357
356 // Out of range point should return the primary root window 358 // Out of range point should return the primary root window
357 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); 359 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0)));
358 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); 360 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100)));
359 } 361 }
360 362
361 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { 363 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) {
362 if (!SupportsMultipleDisplays()) 364 if (!SupportsMultipleDisplays())
363 return; 365 return;
364 366
365 UpdateDisplay("700x500,500x500"); 367 UpdateDisplay("700x500,500x500");
366 SetSecondaryDisplayLayout(DisplayLayout::LEFT); 368 SetSecondaryDisplayLayout(DisplayLayout::LEFT);
367 369
368 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 370 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
369 371
370 // Containing rect. 372 // Containing rect.
371 EXPECT_EQ(root_windows[1], 373 EXPECT_EQ(root_windows[1],
372 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); 374 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50)));
373 EXPECT_EQ(root_windows[0], 375 EXPECT_EQ(root_windows[0],
374 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); 376 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50)));
375 377
376 // Intersecting rect. 378 // Intersecting rect.
377 EXPECT_EQ(root_windows[1], 379 EXPECT_EQ(root_windows[1],
378 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300))); 380 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300)));
(...skipping 17 matching lines...) Expand all
396 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); 398 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50)));
397 EXPECT_EQ(root_windows[0], 399 EXPECT_EQ(root_windows[0],
398 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); 400 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)));
399 } 401 }
400 402
401 TEST_F(ExtendedDesktopTest, Capture) { 403 TEST_F(ExtendedDesktopTest, Capture) {
402 if (!SupportsMultipleDisplays()) 404 if (!SupportsMultipleDisplays())
403 return; 405 return;
404 406
405 UpdateDisplay("1000x600,600x400"); 407 UpdateDisplay("1000x600,600x400");
406 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 408 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
407 409
408 aura::test::EventCountDelegate r1_d1; 410 aura::test::EventCountDelegate r1_d1;
409 aura::test::EventCountDelegate r1_d2; 411 aura::test::EventCountDelegate r1_d2;
410 aura::test::EventCountDelegate r2_d1; 412 aura::test::EventCountDelegate r2_d1;
411 413
412 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( 414 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
413 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); 415 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
414 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( 416 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
415 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); 417 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
416 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( 418 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // Make sure the mouse_moved_handler_ is properly reset. 457 // Make sure the mouse_moved_handler_ is properly reset.
456 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset()); 458 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset());
457 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset()); 459 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset());
458 } 460 }
459 461
460 TEST_F(ExtendedDesktopTest, MoveWindow) { 462 TEST_F(ExtendedDesktopTest, MoveWindow) {
461 if (!SupportsMultipleDisplays()) 463 if (!SupportsMultipleDisplays())
462 return; 464 return;
463 465
464 UpdateDisplay("1000x600,600x400"); 466 UpdateDisplay("1000x600,600x400");
465 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 467 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
466 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 468 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
467 469
468 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); 470 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
469 471
470 d1->SetBounds(gfx::Rect(1010, 10, 100, 100)); 472 d1->SetBounds(gfx::Rect(1010, 10, 100, 100));
471 EXPECT_EQ("1010,10 100x100", 473 EXPECT_EQ("1010,10 100x100",
472 d1->GetWindowBoundsInScreen().ToString()); 474 d1->GetWindowBoundsInScreen().ToString());
473 475
474 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); 476 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
475 477
(...skipping 17 matching lines...) Expand all
493 } 495 }
494 496
495 // Verifies if the mouse event arrives to the window even when the window 497 // Verifies if the mouse event arrives to the window even when the window
496 // moves to another root in a pre-target handler. See: crbug.com/157583 498 // moves to another root in a pre-target handler. See: crbug.com/157583
497 TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) { 499 TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) {
498 if (!SupportsMultipleDisplays()) 500 if (!SupportsMultipleDisplays())
499 return; 501 return;
500 502
501 UpdateDisplay("1000x600,600x400"); 503 UpdateDisplay("1000x600,600x400");
502 504
503 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 505 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
504 aura::test::EventCountDelegate delegate; 506 aura::test::EventCountDelegate delegate;
505 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( 507 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
506 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); 508 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
507 MoveWindowByClickEventHandler event_handler(window.get()); 509 MoveWindowByClickEventHandler event_handler(window.get());
508 window->AddPreTargetHandler(&event_handler); 510 window->AddPreTargetHandler(&event_handler);
509 511
510 aura::test::EventGenerator& event_generator(GetEventGenerator()); 512 aura::test::EventGenerator& event_generator(GetEventGenerator());
511 513
512 event_generator.MoveMouseToCenterOf(window.get()); 514 event_generator.MoveMouseToCenterOf(window.get());
513 event_generator.ClickLeftButton(); 515 event_generator.ClickLeftButton();
514 // Both mouse pressed and released arrive at the window and its delegate. 516 // Both mouse pressed and released arrive at the window and its delegate.
515 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset()); 517 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset());
516 // Also event_handler moves the window to another root at mouse release. 518 // Also event_handler moves the window to another root at mouse release.
517 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 519 EXPECT_EQ(root_windows[1], window->GetRootWindow());
518 } 520 }
519 521
520 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { 522 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) {
521 if (!SupportsMultipleDisplays()) 523 if (!SupportsMultipleDisplays())
522 return; 524 return;
523 525
524 UpdateDisplay("1000x1000,1000x1000"); 526 UpdateDisplay("1000x1000,1000x1000");
525 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 527 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
526 528
527 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching( 529 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching(
528 root_windows[0]->GetBoundsInScreen()); 530 root_windows[0]->GetBoundsInScreen());
529 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching( 531 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching(
530 root_windows[1]->GetBoundsInScreen()); 532 root_windows[1]->GetBoundsInScreen());
531 EXPECT_NE(display0.id(), display1.id()); 533 EXPECT_NE(display0.id(), display1.id());
532 534
533 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); 535 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100));
534 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); 536 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
535 537
(...skipping 11 matching lines...) Expand all
547 EXPECT_EQ("500,10 1000x100", 549 EXPECT_EQ("500,10 1000x100",
548 d1->GetWindowBoundsInScreen().ToString()); 550 d1->GetWindowBoundsInScreen().ToString());
549 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); 551 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
550 } 552 }
551 553
552 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { 554 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
553 if (!SupportsMultipleDisplays()) 555 if (!SupportsMultipleDisplays())
554 return; 556 return;
555 557
556 UpdateDisplay("1000x600,600x400"); 558 UpdateDisplay("1000x600,600x400");
557 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 559 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
558 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 560 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
559 views::Widget* w1_t1 = CreateTestWidgetWithParent( 561 views::Widget* w1_t1 = CreateTestWidgetWithParent(
560 w1, gfx::Rect(50, 50, 50, 50), false /* transient */); 562 w1, gfx::Rect(50, 50, 50, 50), false /* transient */);
561 // Transient child of the transient child. 563 // Transient child of the transient child.
562 views::Widget* w1_t11 = CreateTestWidgetWithParent( 564 views::Widget* w1_t11 = CreateTestWidgetWithParent(
563 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */); 565 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */);
564 566
565 views::Widget* w11 = CreateTestWidgetWithParent( 567 views::Widget* w11 = CreateTestWidgetWithParent(
566 w1, gfx::Rect(10, 10, 40, 40), true /* child */); 568 w1, gfx::Rect(10, 10, 40, 40), true /* child */);
567 views::Widget* w11_t1 = CreateTestWidgetWithParent( 569 views::Widget* w11_t1 = CreateTestWidgetWithParent(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 w1_t1->GetWindowBoundsInScreen().ToString()); 609 w1_t1->GetWindowBoundsInScreen().ToString());
608 } 610 }
609 611
610 // Test if the Window::ConvertPointToTarget works across root windows. 612 // Test if the Window::ConvertPointToTarget works across root windows.
611 // TODO(oshima): Move multiple display suport and this test to aura. 613 // TODO(oshima): Move multiple display suport and this test to aura.
612 TEST_F(ExtendedDesktopTest, ConvertPoint) { 614 TEST_F(ExtendedDesktopTest, ConvertPoint) {
613 if (!SupportsMultipleDisplays()) 615 if (!SupportsMultipleDisplays())
614 return; 616 return;
615 gfx::Screen* screen = Shell::GetInstance()->screen(); 617 gfx::Screen* screen = Shell::GetInstance()->screen();
616 UpdateDisplay("1000x600,600x400"); 618 UpdateDisplay("1000x600,600x400");
617 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 619 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
618 gfx::Display display_1 = screen->GetDisplayNearestWindow(root_windows[0]); 620 gfx::Display display_1 = screen->GetDisplayNearestWindow(root_windows[0]);
619 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); 621 EXPECT_EQ("0,0", display_1.bounds().origin().ToString());
620 gfx::Display display_2 = screen->GetDisplayNearestWindow(root_windows[1]); 622 gfx::Display display_2 = screen->GetDisplayNearestWindow(root_windows[1]);
621 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); 623 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString());
622 624
623 aura::Window* d1 = 625 aura::Window* d1 =
624 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); 626 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView();
625 aura::Window* d2 = 627 aura::Window* d2 =
626 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView(); 628 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView();
627 EXPECT_EQ(root_windows[0], d1->GetRootWindow()); 629 EXPECT_EQ(root_windows[0], d1->GetRootWindow());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 EXPECT_FALSE(tray->HasSystemBubble()); 700 EXPECT_FALSE(tray->HasSystemBubble());
699 UpdateDisplay("500x600,600x400"); 701 UpdateDisplay("500x600,600x400");
700 EXPECT_FALSE(tray->HasSystemBubble()); 702 EXPECT_FALSE(tray->HasSystemBubble());
701 } 703 }
702 704
703 TEST_F(ExtendedDesktopTest, StayInSameRootWindow) { 705 TEST_F(ExtendedDesktopTest, StayInSameRootWindow) {
704 if (!SupportsMultipleDisplays()) 706 if (!SupportsMultipleDisplays())
705 return; 707 return;
706 708
707 UpdateDisplay("100x100,200x200"); 709 UpdateDisplay("100x100,200x200");
708 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 710 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
709 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 50, 50)); 711 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 50, 50));
710 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); 712 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
711 w1->SetBounds(gfx::Rect(150, 10, 50, 50)); 713 w1->SetBounds(gfx::Rect(150, 10, 50, 50));
712 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); 714 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
713 715
714 // The widget stays in the same root if kStayInSameRootWindowKey is set to 716 // The widget stays in the same root if kStayInSameRootWindowKey is set to
715 // true. 717 // true.
716 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true); 718 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true);
717 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); 719 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
718 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); 720 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
(...skipping 21 matching lines...) Expand all
740 window->SetBoundsInScreen(gfx::Rect(150, 10, 50, 50), 742 window->SetBoundsInScreen(gfx::Rect(150, 10, 50, 50),
741 ScreenAsh::GetSecondaryDisplay()); 743 ScreenAsh::GetSecondaryDisplay());
742 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 744 EXPECT_EQ(root_windows[0], window->GetRootWindow());
743 } 745 }
744 746
745 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { 747 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) {
746 if (!SupportsMultipleDisplays()) 748 if (!SupportsMultipleDisplays())
747 return; 749 return;
748 750
749 UpdateDisplay("100x100,200x200"); 751 UpdateDisplay("100x100,200x200");
750 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 752 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
751 753
752 // Create normal windows on both displays. 754 // Create normal windows on both displays.
753 views::Widget* widget1 = CreateTestWidget( 755 views::Widget* widget1 = CreateTestWidget(
754 Shell::GetScreen()->GetPrimaryDisplay().bounds()); 756 Shell::GetScreen()->GetPrimaryDisplay().bounds());
755 widget1->Show(); 757 widget1->Show();
756 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); 758 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow());
757 views::Widget* widget2 = CreateTestWidget( 759 views::Widget* widget2 = CreateTestWidget(
758 ScreenAsh::GetSecondaryDisplay().bounds()); 760 ScreenAsh::GetSecondaryDisplay().bounds());
759 widget2->Show(); 761 widget2->Show();
760 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow()); 762 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow());
(...skipping 11 matching lines...) Expand all
772 lock_widget->Show(); 774 lock_widget->Show();
773 textfield->RequestFocus(); 775 textfield->RequestFocus();
774 776
775 aura::client::FocusClient* focus_client = 777 aura::client::FocusClient* focus_client =
776 aura::client::GetFocusClient(root_windows[0]); 778 aura::client::GetFocusClient(root_windows[0]);
777 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 779 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
778 780
779 // The lock window should get events on both root windows. 781 // The lock window should get events on both root windows.
780 aura::test::EventGenerator& event_generator(GetEventGenerator()); 782 aura::test::EventGenerator& event_generator(GetEventGenerator());
781 783
782 event_generator.set_current_root_window(root_windows[0]); 784 event_generator.set_current_root_window(root_windows[0]->GetDispatcher());
783 event_generator.PressKey(ui::VKEY_A, 0); 785 event_generator.PressKey(ui::VKEY_A, 0);
784 event_generator.ReleaseKey(ui::VKEY_A, 0); 786 event_generator.ReleaseKey(ui::VKEY_A, 0);
785 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 787 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
786 EXPECT_EQ("a", UTF16ToASCII(textfield->text())); 788 EXPECT_EQ("a", UTF16ToASCII(textfield->text()));
787 789
788 event_generator.set_current_root_window(root_windows[1]); 790 event_generator.set_current_root_window(root_windows[1]->GetDispatcher());
789 event_generator.PressKey(ui::VKEY_B, 0); 791 event_generator.PressKey(ui::VKEY_B, 0);
790 event_generator.ReleaseKey(ui::VKEY_B, 0); 792 event_generator.ReleaseKey(ui::VKEY_B, 0);
791 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 793 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
792 EXPECT_EQ("ab", UTF16ToASCII(textfield->text())); 794 EXPECT_EQ("ab", UTF16ToASCII(textfield->text()));
793 795
794 // Deleting 2nd display. The lock window still should get the events. 796 // Deleting 2nd display. The lock window still should get the events.
795 UpdateDisplay("100x100"); 797 UpdateDisplay("100x100");
796 event_generator.PressKey(ui::VKEY_C, 0); 798 event_generator.PressKey(ui::VKEY_C, 0);
797 event_generator.ReleaseKey(ui::VKEY_C, 0); 799 event_generator.ReleaseKey(ui::VKEY_C, 0);
798 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 800 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
799 EXPECT_EQ("abc", UTF16ToASCII(textfield->text())); 801 EXPECT_EQ("abc", UTF16ToASCII(textfield->text()));
800 802
801 // Creating 2nd display again, and lock window still should get events 803 // Creating 2nd display again, and lock window still should get events
802 // on both root windows. 804 // on both root windows.
803 UpdateDisplay("100x100,200x200"); 805 UpdateDisplay("100x100,200x200");
804 root_windows = Shell::GetAllRootWindows(); 806 root_windows = Shell::GetAllRootWindows();
805 event_generator.set_current_root_window(root_windows[0]); 807 event_generator.set_current_root_window(root_windows[0]->GetDispatcher());
806 event_generator.PressKey(ui::VKEY_D, 0); 808 event_generator.PressKey(ui::VKEY_D, 0);
807 event_generator.ReleaseKey(ui::VKEY_D, 0); 809 event_generator.ReleaseKey(ui::VKEY_D, 0);
808 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 810 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
809 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text())); 811 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text()));
810 812
811 event_generator.set_current_root_window(root_windows[1]); 813 event_generator.set_current_root_window(root_windows[1]->GetDispatcher());
812 event_generator.PressKey(ui::VKEY_E, 0); 814 event_generator.PressKey(ui::VKEY_E, 0);
813 event_generator.ReleaseKey(ui::VKEY_E, 0); 815 event_generator.ReleaseKey(ui::VKEY_E, 0);
814 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 816 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
815 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); 817 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text()));
816 } 818 }
817 819
818 TEST_F(ExtendedDesktopTest, PassiveGrab) { 820 TEST_F(ExtendedDesktopTest, PassiveGrab) {
819 if (!SupportsMultipleDisplays()) 821 if (!SupportsMultipleDisplays())
820 return; 822 return;
821 823
(...skipping 18 matching lines...) Expand all
840 generator.ReleaseLeftButton(); 842 generator.ReleaseLeftButton();
841 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); 843 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset());
842 844
843 generator.MoveMouseTo(400, 150); 845 generator.MoveMouseTo(400, 150);
844 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); 846 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset());
845 847
846 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 848 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
847 } 849 }
848 850
849 } // namespace ash 851 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698