| 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 #if !defined(OS_WIN) | 463 #if !defined(OS_WIN) |
| 464 // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413. | 464 // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413. |
| 465 gfx::Point mouse_location; | 465 gfx::Point mouse_location; |
| 466 EXPECT_TRUE(dispatcher()->host()->QueryMouseLocation(&mouse_location)); | 466 EXPECT_TRUE(dispatcher()->host()->QueryMouseLocation(&mouse_location)); |
| 467 EXPECT_EQ("169,80", mouse_location.ToString()); | 467 EXPECT_EQ("169,80", mouse_location.ToString()); |
| 468 #endif | 468 #endif |
| 469 EXPECT_EQ("20,53", | 469 EXPECT_EQ("20,53", |
| 470 gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); | 470 gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); |
| 471 } | 471 } |
| 472 | 472 |
| 473 TEST_F(WindowTest, HitTest) { | |
| 474 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); | |
| 475 w1.set_id(1); | |
| 476 w1.Init(aura::WINDOW_LAYER_TEXTURED); | |
| 477 w1.SetBounds(gfx::Rect(10, 20, 50, 60)); | |
| 478 w1.Show(); | |
| 479 ParentWindow(&w1); | |
| 480 | |
| 481 // Points are in the Window's coordinates. | |
| 482 EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1))); | |
| 483 EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1))); | |
| 484 | |
| 485 // TODO(beng): clip Window to parent. | |
| 486 } | |
| 487 | |
| 488 TEST_F(WindowTest, HitTestMask) { | |
| 489 MaskedWindowDelegate d1(gfx::Rect(5, 6, 20, 30)); | |
| 490 Window w1(&d1); | |
| 491 w1.Init(aura::WINDOW_LAYER_NOT_DRAWN); | |
| 492 w1.SetBounds(gfx::Rect(10, 20, 50, 60)); | |
| 493 w1.Show(); | |
| 494 ParentWindow(&w1); | |
| 495 | |
| 496 // Points inside the mask. | |
| 497 EXPECT_TRUE(w1.HitTest(gfx::Point(5, 6))); // top-left | |
| 498 EXPECT_TRUE(w1.HitTest(gfx::Point(15, 21))); // center | |
| 499 EXPECT_TRUE(w1.HitTest(gfx::Point(24, 35))); // bottom-right | |
| 500 | |
| 501 // Points outside the mask. | |
| 502 EXPECT_FALSE(w1.HitTest(gfx::Point(0, 0))); | |
| 503 EXPECT_FALSE(w1.HitTest(gfx::Point(60, 80))); | |
| 504 EXPECT_FALSE(w1.HitTest(gfx::Point(4, 6))); | |
| 505 EXPECT_FALSE(w1.HitTest(gfx::Point(5, 5))); | |
| 506 EXPECT_FALSE(w1.HitTest(gfx::Point(25, 36))); | |
| 507 } | |
| 508 | |
| 509 TEST_F(WindowTest, GetEventHandlerForPoint) { | 473 TEST_F(WindowTest, GetEventHandlerForPoint) { |
| 510 scoped_ptr<Window> w1( | 474 scoped_ptr<Window> w1( |
| 511 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), | 475 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), |
| 512 root_window())); | 476 root_window())); |
| 513 scoped_ptr<Window> w11( | 477 scoped_ptr<Window> w11( |
| 514 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); | 478 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); |
| 515 scoped_ptr<Window> w111( | 479 scoped_ptr<Window> w111( |
| 516 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); | 480 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); |
| 517 scoped_ptr<Window> w1111( | 481 scoped_ptr<Window> w1111( |
| 518 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); | 482 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); |
| (...skipping 2804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3323 BuildRootLayerTreeDescription(*root.layer())) | 3287 BuildRootLayerTreeDescription(*root.layer())) |
| 3324 << "layer tree doesn't match at " << i; | 3288 << "layer tree doesn't match at " << i; |
| 3325 EXPECT_EQ(data[i].expected_description, | 3289 EXPECT_EQ(data[i].expected_description, |
| 3326 BuildRootWindowTreeDescription(root)) | 3290 BuildRootWindowTreeDescription(root)) |
| 3327 << "window tree doesn't match at " << i; | 3291 << "window tree doesn't match at " << i; |
| 3328 } | 3292 } |
| 3329 } | 3293 } |
| 3330 | 3294 |
| 3331 } // namespace test | 3295 } // namespace test |
| 3332 } // namespace aura | 3296 } // namespace aura |
| OLD | NEW |