| OLD | NEW |
| 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) { | 366 TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) { |
| 367 #endif | 367 #endif |
| 368 gfx::Transform transform; | 368 gfx::Transform transform; |
| 369 transform.Translate(100.0, 100.0); | 369 transform.Translate(100.0, 100.0); |
| 370 transform.Rotate(90.0); | 370 transform.Rotate(90.0); |
| 371 transform.Scale(2.0, 5.0); | 371 transform.Scale(2.0, 5.0); |
| 372 dispatcher()->SetTransform(transform); | 372 dispatcher()->SetTransform(transform); |
| 373 dispatcher()->MoveCursorTo(gfx::Point(10, 10)); | 373 dispatcher()->MoveCursorTo(gfx::Point(10, 10)); |
| 374 #if !defined(OS_WIN) | 374 #if !defined(OS_WIN) |
| 375 gfx::Point mouse_location; | 375 gfx::Point mouse_location; |
| 376 EXPECT_TRUE(dispatcher()->QueryMouseLocationForTest(&mouse_location)); | 376 EXPECT_TRUE(dispatcher()->host()->QueryMouseLocation(&mouse_location)); |
| 377 // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413.OD | 377 // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413.OD |
| 378 EXPECT_EQ("50,120", mouse_location.ToString()); | 378 EXPECT_EQ("50,120", mouse_location.ToString()); |
| 379 #endif | 379 #endif |
| 380 EXPECT_EQ("10,10", gfx::Screen::GetScreenFor( | 380 EXPECT_EQ("10,10", gfx::Screen::GetScreenFor( |
| 381 root_window())->GetCursorScreenPoint().ToString()); | 381 root_window())->GetCursorScreenPoint().ToString()); |
| 382 } | 382 } |
| 383 | 383 |
| 384 // Tests Window::ConvertPointToWindow() with transform to non-root windows. | 384 // Tests Window::ConvertPointToWindow() with transform to non-root windows. |
| 385 TEST_F(WindowTest, MoveCursorToWithTransformWindow) { | 385 TEST_F(WindowTest, MoveCursorToWithTransformWindow) { |
| 386 scoped_ptr<Window> w1( | 386 scoped_ptr<Window> w1( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 w1->SetTransform(transform); | 454 w1->SetTransform(transform); |
| 455 w11->SetTransform(transform); | 455 w11->SetTransform(transform); |
| 456 w111->SetTransform(transform); | 456 w111->SetTransform(transform); |
| 457 w1111->SetTransform(transform); | 457 w1111->SetTransform(transform); |
| 458 | 458 |
| 459 w1111->MoveCursorTo(gfx::Point(10, 10)); | 459 w1111->MoveCursorTo(gfx::Point(10, 10)); |
| 460 | 460 |
| 461 #if !defined(OS_WIN) | 461 #if !defined(OS_WIN) |
| 462 // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413. | 462 // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413. |
| 463 gfx::Point mouse_location; | 463 gfx::Point mouse_location; |
| 464 EXPECT_TRUE(dispatcher()->QueryMouseLocationForTest(&mouse_location)); | 464 EXPECT_TRUE(dispatcher()->host()->QueryMouseLocation(&mouse_location)); |
| 465 EXPECT_EQ("169,80", mouse_location.ToString()); | 465 EXPECT_EQ("169,80", mouse_location.ToString()); |
| 466 #endif | 466 #endif |
| 467 EXPECT_EQ("20,53", | 467 EXPECT_EQ("20,53", |
| 468 gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); | 468 gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); |
| 469 } | 469 } |
| 470 | 470 |
| 471 TEST_F(WindowTest, HitTest) { | 471 TEST_F(WindowTest, HitTest) { |
| 472 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); | 472 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); |
| 473 w1.set_id(1); | 473 w1.set_id(1); |
| 474 w1.Init(ui::LAYER_TEXTURED); | 474 w1.Init(ui::LAYER_TEXTURED); |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 w121->set_ignore_events(true); | 1528 w121->set_ignore_events(true); |
| 1529 EXPECT_EQ(w12.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); | 1529 EXPECT_EQ(w12.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); |
| 1530 w12->set_ignore_events(true); | 1530 w12->set_ignore_events(true); |
| 1531 EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); | 1531 EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); |
| 1532 w111->set_ignore_events(true); | 1532 w111->set_ignore_events(true); |
| 1533 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); | 1533 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 // Tests transformation on the root window. | 1536 // Tests transformation on the root window. |
| 1537 TEST_F(WindowTest, Transform) { | 1537 TEST_F(WindowTest, Transform) { |
| 1538 gfx::Size size = dispatcher()->GetHostSize(); | 1538 gfx::Size size = dispatcher()->host()->GetBounds().size(); |
| 1539 EXPECT_EQ(gfx::Rect(size), | 1539 EXPECT_EQ(gfx::Rect(size), |
| 1540 gfx::Screen::GetScreenFor(root_window())->GetDisplayNearestPoint( | 1540 gfx::Screen::GetScreenFor(root_window())->GetDisplayNearestPoint( |
| 1541 gfx::Point()).bounds()); | 1541 gfx::Point()).bounds()); |
| 1542 | 1542 |
| 1543 // Rotate it clock-wise 90 degrees. | 1543 // Rotate it clock-wise 90 degrees. |
| 1544 gfx::Transform transform; | 1544 gfx::Transform transform; |
| 1545 transform.Translate(size.height(), 0); | 1545 transform.Translate(size.height(), 0); |
| 1546 transform.Rotate(90.0); | 1546 transform.Rotate(90.0); |
| 1547 dispatcher()->SetTransform(transform); | 1547 dispatcher()->SetTransform(transform); |
| 1548 | 1548 |
| 1549 // The size should be the transformed size. | 1549 // The size should be the transformed size. |
| 1550 gfx::Size transformed_size(size.height(), size.width()); | 1550 gfx::Size transformed_size(size.height(), size.width()); |
| 1551 EXPECT_EQ(transformed_size.ToString(), | 1551 EXPECT_EQ(transformed_size.ToString(), |
| 1552 root_window()->bounds().size().ToString()); | 1552 root_window()->bounds().size().ToString()); |
| 1553 EXPECT_EQ( | 1553 EXPECT_EQ( |
| 1554 gfx::Rect(transformed_size).ToString(), | 1554 gfx::Rect(transformed_size).ToString(), |
| 1555 gfx::Screen::GetScreenFor(root_window())->GetDisplayNearestPoint( | 1555 gfx::Screen::GetScreenFor(root_window())->GetDisplayNearestPoint( |
| 1556 gfx::Point()).bounds().ToString()); | 1556 gfx::Point()).bounds().ToString()); |
| 1557 | 1557 |
| 1558 // Host size shouldn't change. | 1558 // Host size shouldn't change. |
| 1559 EXPECT_EQ(size.ToString(), | 1559 EXPECT_EQ(size.ToString(), |
| 1560 dispatcher()->GetHostSize().ToString()); | 1560 dispatcher()->host()->GetBounds().size().ToString()); |
| 1561 } | 1561 } |
| 1562 | 1562 |
| 1563 TEST_F(WindowTest, TransformGesture) { | 1563 TEST_F(WindowTest, TransformGesture) { |
| 1564 gfx::Size size = dispatcher()->GetHostSize(); | 1564 gfx::Size size = dispatcher()->host()->GetBounds().size(); |
| 1565 | 1565 |
| 1566 scoped_ptr<GestureTrackPositionDelegate> delegate( | 1566 scoped_ptr<GestureTrackPositionDelegate> delegate( |
| 1567 new GestureTrackPositionDelegate); | 1567 new GestureTrackPositionDelegate); |
| 1568 scoped_ptr<Window> window(CreateTestWindowWithDelegate(delegate.get(), -1234, | 1568 scoped_ptr<Window> window(CreateTestWindowWithDelegate(delegate.get(), -1234, |
| 1569 gfx::Rect(0, 0, 20, 20), root_window())); | 1569 gfx::Rect(0, 0, 20, 20), root_window())); |
| 1570 | 1570 |
| 1571 // Rotate the root-window clock-wise 90 degrees. | 1571 // Rotate the root-window clock-wise 90 degrees. |
| 1572 gfx::Transform transform; | 1572 gfx::Transform transform; |
| 1573 transform.Translate(size.height(), 0.0); | 1573 transform.Translate(size.height(), 0.0); |
| 1574 transform.Rotate(90.0); | 1574 transform.Rotate(90.0); |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2288 window->Show(); | 2288 window->Show(); |
| 2289 | 2289 |
| 2290 client.set_ignore_visibility_changes(true); | 2290 client.set_ignore_visibility_changes(true); |
| 2291 window->Hide(); | 2291 window->Hide(); |
| 2292 EXPECT_FALSE(window->IsVisible()); | 2292 EXPECT_FALSE(window->IsVisible()); |
| 2293 EXPECT_TRUE(window->layer()->visible()); | 2293 EXPECT_TRUE(window->layer()->visible()); |
| 2294 } | 2294 } |
| 2295 | 2295 |
| 2296 // Tests mouse events on window change. | 2296 // Tests mouse events on window change. |
| 2297 TEST_F(WindowTest, MouseEventsOnWindowChange) { | 2297 TEST_F(WindowTest, MouseEventsOnWindowChange) { |
| 2298 gfx::Size size = dispatcher()->GetHostSize(); | 2298 gfx::Size size = dispatcher()->host()->GetBounds().size(); |
| 2299 | 2299 |
| 2300 EventGenerator generator(root_window()); | 2300 EventGenerator generator(root_window()); |
| 2301 generator.MoveMouseTo(50, 50); | 2301 generator.MoveMouseTo(50, 50); |
| 2302 | 2302 |
| 2303 EventCountDelegate d1; | 2303 EventCountDelegate d1; |
| 2304 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d1, 1, | 2304 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d1, 1, |
| 2305 gfx::Rect(0, 0, 100, 100), root_window())); | 2305 gfx::Rect(0, 0, 100, 100), root_window())); |
| 2306 RunAllPendingInMessageLoop(); | 2306 RunAllPendingInMessageLoop(); |
| 2307 // The format of result is "Enter/Mouse/Leave". | 2307 // The format of result is "Enter/Mouse/Leave". |
| 2308 EXPECT_EQ("1 1 0", d1.GetMouseMotionCountsAndReset()); | 2308 EXPECT_EQ("1 1 0", d1.GetMouseMotionCountsAndReset()); |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3180 parent->AddTransientChild(transient); | 3180 parent->AddTransientChild(transient); |
| 3181 parent.reset(); | 3181 parent.reset(); |
| 3182 | 3182 |
| 3183 ASSERT_EQ(2u, destruction_order.size()); | 3183 ASSERT_EQ(2u, destruction_order.size()); |
| 3184 EXPECT_EQ("transient", destruction_order[0]); | 3184 EXPECT_EQ("transient", destruction_order[0]); |
| 3185 EXPECT_EQ("parent", destruction_order[1]); | 3185 EXPECT_EQ("parent", destruction_order[1]); |
| 3186 } | 3186 } |
| 3187 | 3187 |
| 3188 } // namespace test | 3188 } // namespace test |
| 3189 } // namespace aura | 3189 } // namespace aura |
| OLD | NEW |