Index: ui/aura/window_unittest.cc |
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc |
index 5932a4cc74acd96a075b08a5a0587d3d82e03f5b..d016067444a624933d139e0de646fa42999ff7e3 100644 |
--- a/ui/aura/window_unittest.cc |
+++ b/ui/aura/window_unittest.cc |
@@ -14,6 +14,7 @@ |
#include "ui/aura/event.h" |
#include "ui/aura/layout_manager.h" |
#include "ui/aura/root_window.h" |
+#include "ui/aura/root_window_host.h" |
#include "ui/aura/root_window_observer.h" |
#include "ui/aura/test/aura_test_base.h" |
#include "ui/aura/test/event_generator.h" |
@@ -302,6 +303,66 @@ TEST_F(WindowTest, ConvertPointToWindow) { |
EXPECT_EQ(reference_point, test_point); |
} |
+TEST_F(WindowTest, MoveCursorTo) { |
+ scoped_ptr<Window> w1( |
+ CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL)); |
+ scoped_ptr<Window> w11( |
+ CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); |
+ scoped_ptr<Window> w111( |
+ CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); |
+ scoped_ptr<Window> w1111( |
+ CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); |
+ |
+ RootWindow* root = root_window(); |
+ root->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(10, 10), root->last_mouse_location()); |
oshima
2012/06/15 16:57:01
could you please use the style
EXPECT_EQ("10,10",
yoshiki
2012/06/18 06:55:36
Done.
|
+ w1->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(20, 20), root->last_mouse_location()); |
+ w11->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(25, 25), root->last_mouse_location()); |
+ w111->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(30, 30), root->last_mouse_location()); |
+ w1111->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(35, 35), root->last_mouse_location()); |
+ |
+ // Test with transform to root_window. |
+ ui::Transform transform0; |
+ transform0.ConcatScale(2, 5); |
+ transform0.ConcatTranslate(10, -20); |
+ transform0.ConcatRotate(-45.0f); |
oshima
2012/06/15 16:57:01
non orthogonal angles makes it difficult to verify
yoshiki
2012/06/18 06:55:36
Done.
|
+ root->SetTransform(transform0); |
+ root->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(42, 0), root->host()->QueryMouseLocation()); |
+ EXPECT_EQ(gfx::Point(10, 10), root->last_mouse_location()); |
+ |
+ // Tests with transform to windows. |
+ ui::Transform transform1; |
+ transform1.ConcatScale(2, 2); |
+ w1->SetTransform(transform1); |
+ w1->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(30, 30), root->last_mouse_location()); |
+ |
+ ui::Transform transform2; |
+ transform2.ConcatTranslate(-10, 20); |
+ w11->SetTransform(transform2); |
+ w11->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(20, 80), root->last_mouse_location()); |
+ |
+ ui::Transform transform3; |
+ transform3.ConcatRotate(45.0f); |
+ w111->SetTransform(transform3); |
+ w111->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(10, 98), root->last_mouse_location()); |
+ |
+ ui::Transform transform4; |
+ transform4.ConcatScale(0.3f, 0.5f); |
+ transform4.ConcatRotate(120.0f); |
+ transform4.ConcatTranslate(-10, -20); |
+ w1111->SetTransform(transform4); |
+ w1111->MoveCursorTo(gfx::Point(10, 10)); |
+ EXPECT_EQ(gfx::Point(15, 33), root->last_mouse_location()); |
oshima
2012/06/15 16:57:01
It's hard to tell these tests are correct. It'd be
yoshiki
2012/06/18 06:55:36
Done.
|
+} |
+ |
TEST_F(WindowTest, HitTest) { |
Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); |
w1.set_id(1); |