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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/aura/client/capture_client.h" | 11 #include "ui/aura/client/capture_client.h" |
12 #include "ui/aura/client/stacking_client.h" | 12 #include "ui/aura/client/stacking_client.h" |
13 #include "ui/aura/client/visibility_client.h" | 13 #include "ui/aura/client/visibility_client.h" |
14 #include "ui/aura/event.h" | 14 #include "ui/aura/event.h" |
15 #include "ui/aura/layout_manager.h" | 15 #include "ui/aura/layout_manager.h" |
16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
17 #include "ui/aura/root_window_host.h" | |
17 #include "ui/aura/root_window_observer.h" | 18 #include "ui/aura/root_window_observer.h" |
18 #include "ui/aura/test/aura_test_base.h" | 19 #include "ui/aura/test/aura_test_base.h" |
19 #include "ui/aura/test/event_generator.h" | 20 #include "ui/aura/test/event_generator.h" |
20 #include "ui/aura/test/test_window_delegate.h" | 21 #include "ui/aura/test/test_window_delegate.h" |
21 #include "ui/aura/test/test_windows.h" | 22 #include "ui/aura/test/test_windows.h" |
22 #include "ui/aura/window_delegate.h" | 23 #include "ui/aura/window_delegate.h" |
23 #include "ui/aura/window_observer.h" | 24 #include "ui/aura/window_observer.h" |
24 #include "ui/aura/window_property.h" | 25 #include "ui/aura/window_property.h" |
25 #include "ui/base/gestures/gesture_configuration.h" | 26 #include "ui/base/gestures/gesture_configuration.h" |
26 #include "ui/base/hit_test.h" | 27 #include "ui/base/hit_test.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 // Window::ConvertPointToWindow is mostly identical to | 296 // Window::ConvertPointToWindow is mostly identical to |
296 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted, | 297 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted, |
297 // in which case the function just returns. | 298 // in which case the function just returns. |
298 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); | 299 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); |
299 gfx::Point reference_point(100, 100); | 300 gfx::Point reference_point(100, 100); |
300 gfx::Point test_point = reference_point; | 301 gfx::Point test_point = reference_point; |
301 Window::ConvertPointToWindow(NULL, w1.get(), &test_point); | 302 Window::ConvertPointToWindow(NULL, w1.get(), &test_point); |
302 EXPECT_EQ(reference_point, test_point); | 303 EXPECT_EQ(reference_point, test_point); |
303 } | 304 } |
304 | 305 |
306 TEST_F(WindowTest, MoveCursorTo) { | |
307 scoped_ptr<Window> w1( | |
308 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL)); | |
309 scoped_ptr<Window> w11( | |
310 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); | |
311 scoped_ptr<Window> w111( | |
312 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); | |
313 scoped_ptr<Window> w1111( | |
314 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); | |
315 | |
316 RootWindow* root = root_window(); | |
317 root->MoveCursorTo(gfx::Point(10, 10)); | |
318 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.
| |
319 w1->MoveCursorTo(gfx::Point(10, 10)); | |
320 EXPECT_EQ(gfx::Point(20, 20), root->last_mouse_location()); | |
321 w11->MoveCursorTo(gfx::Point(10, 10)); | |
322 EXPECT_EQ(gfx::Point(25, 25), root->last_mouse_location()); | |
323 w111->MoveCursorTo(gfx::Point(10, 10)); | |
324 EXPECT_EQ(gfx::Point(30, 30), root->last_mouse_location()); | |
325 w1111->MoveCursorTo(gfx::Point(10, 10)); | |
326 EXPECT_EQ(gfx::Point(35, 35), root->last_mouse_location()); | |
327 | |
328 // Test with transform to root_window. | |
329 ui::Transform transform0; | |
330 transform0.ConcatScale(2, 5); | |
331 transform0.ConcatTranslate(10, -20); | |
332 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.
| |
333 root->SetTransform(transform0); | |
334 root->MoveCursorTo(gfx::Point(10, 10)); | |
335 EXPECT_EQ(gfx::Point(42, 0), root->host()->QueryMouseLocation()); | |
336 EXPECT_EQ(gfx::Point(10, 10), root->last_mouse_location()); | |
337 | |
338 // Tests with transform to windows. | |
339 ui::Transform transform1; | |
340 transform1.ConcatScale(2, 2); | |
341 w1->SetTransform(transform1); | |
342 w1->MoveCursorTo(gfx::Point(10, 10)); | |
343 EXPECT_EQ(gfx::Point(30, 30), root->last_mouse_location()); | |
344 | |
345 ui::Transform transform2; | |
346 transform2.ConcatTranslate(-10, 20); | |
347 w11->SetTransform(transform2); | |
348 w11->MoveCursorTo(gfx::Point(10, 10)); | |
349 EXPECT_EQ(gfx::Point(20, 80), root->last_mouse_location()); | |
350 | |
351 ui::Transform transform3; | |
352 transform3.ConcatRotate(45.0f); | |
353 w111->SetTransform(transform3); | |
354 w111->MoveCursorTo(gfx::Point(10, 10)); | |
355 EXPECT_EQ(gfx::Point(10, 98), root->last_mouse_location()); | |
356 | |
357 ui::Transform transform4; | |
358 transform4.ConcatScale(0.3f, 0.5f); | |
359 transform4.ConcatRotate(120.0f); | |
360 transform4.ConcatTranslate(-10, -20); | |
361 w1111->SetTransform(transform4); | |
362 w1111->MoveCursorTo(gfx::Point(10, 10)); | |
363 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.
| |
364 } | |
365 | |
305 TEST_F(WindowTest, HitTest) { | 366 TEST_F(WindowTest, HitTest) { |
306 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); | 367 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); |
307 w1.set_id(1); | 368 w1.set_id(1); |
308 w1.Init(ui::LAYER_TEXTURED); | 369 w1.Init(ui::LAYER_TEXTURED); |
309 w1.SetBounds(gfx::Rect(10, 20, 50, 60)); | 370 w1.SetBounds(gfx::Rect(10, 20, 50, 60)); |
310 w1.Show(); | 371 w1.Show(); |
311 w1.SetParent(NULL); | 372 w1.SetParent(NULL); |
312 | 373 |
313 // Points are in the Window's coordinates. | 374 // Points are in the Window's coordinates. |
314 EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1))); | 375 EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1))); |
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2289 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); | 2350 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
2290 | 2351 |
2291 // No bounds changed notification at the end of animation since layer | 2352 // No bounds changed notification at the end of animation since layer |
2292 // delegate is NULL. | 2353 // delegate is NULL. |
2293 EXPECT_FALSE(delegate.bounds_changed()); | 2354 EXPECT_FALSE(delegate.bounds_changed()); |
2294 EXPECT_NE("0,0 100x100", window->bounds().ToString()); | 2355 EXPECT_NE("0,0 100x100", window->bounds().ToString()); |
2295 } | 2356 } |
2296 | 2357 |
2297 } // namespace test | 2358 } // namespace test |
2298 } // namespace aura | 2359 } // namespace aura |
OLD | NEW |