| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/ui/ws/window_coordinate_conversions.h" | 5 #include "services/ui/ws/window_coordinate_conversions.h" |
| 6 | 6 |
| 7 #include "services/ui/ws/server_window.h" | 7 #include "services/ui/ws/server_window.h" |
| 8 #include "services/ui/ws/server_window_delegate.h" | 8 #include "services/ui/ws/server_window_delegate.h" |
| 9 #include "services/ui/ws/test_server_window_delegate.h" | 9 #include "services/ui/ws/test_server_window_delegate.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/gfx/geometry/point_f.h" | 11 #include "ui/gfx/geometry/point_f.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 namespace ws { | 16 namespace ws { |
| 17 | 17 |
| 18 using WindowCoordinateConversionsTest = testing::Test; | 18 using WindowCoordinateConversionsTest = testing::Test; |
| 19 | 19 |
| 20 TEST_F(WindowCoordinateConversionsTest, ConvertRectBetweenWindows) { | 20 TEST_F(WindowCoordinateConversionsTest, ConvertRectBetweenWindows) { |
| 21 TestServerWindowDelegate d1, d2, d3; | 21 TestServerWindowDelegate d1, d2, d3; |
| 22 ServerWindow v1(&d1, WindowId()), v2(&d2, WindowId()), v3(&d3, WindowId()); | 22 ServerWindow v1(&d1, WindowId()), v2(&d2, WindowId()), v3(&d3, WindowId()); |
| 23 v1.SetBounds(gfx::Rect(1, 2, 100, 100)); | 23 v1.SetBounds(gfx::Rect(1, 2, 100, 100), cc::LocalFrameId()); |
| 24 v2.SetBounds(gfx::Rect(3, 4, 100, 100)); | 24 v2.SetBounds(gfx::Rect(3, 4, 100, 100), cc::LocalFrameId()); |
| 25 v3.SetBounds(gfx::Rect(5, 6, 100, 100)); | 25 v3.SetBounds(gfx::Rect(5, 6, 100, 100), cc::LocalFrameId()); |
| 26 v1.Add(&v2); | 26 v1.Add(&v2); |
| 27 v2.Add(&v3); | 27 v2.Add(&v3); |
| 28 | 28 |
| 29 EXPECT_EQ(gfx::Rect(2, 1, 8, 9), | 29 EXPECT_EQ(gfx::Rect(2, 1, 8, 9), |
| 30 ConvertRectBetweenWindows(&v1, &v3, gfx::Rect(10, 11, 8, 9))); | 30 ConvertRectBetweenWindows(&v1, &v3, gfx::Rect(10, 11, 8, 9))); |
| 31 | 31 |
| 32 EXPECT_EQ(gfx::Rect(18, 21, 8, 9), | 32 EXPECT_EQ(gfx::Rect(18, 21, 8, 9), |
| 33 ConvertRectBetweenWindows(&v3, &v1, gfx::Rect(10, 11, 8, 9))); | 33 ConvertRectBetweenWindows(&v3, &v1, gfx::Rect(10, 11, 8, 9))); |
| 34 } | 34 } |
| 35 | 35 |
| 36 TEST_F(WindowCoordinateConversionsTest, ConvertPointFBetweenWindows) { | 36 TEST_F(WindowCoordinateConversionsTest, ConvertPointFBetweenWindows) { |
| 37 TestServerWindowDelegate d1, d2, d3; | 37 TestServerWindowDelegate d1, d2, d3; |
| 38 ServerWindow v1(&d1, WindowId()), v2(&d2, WindowId()), v3(&d3, WindowId()); | 38 ServerWindow v1(&d1, WindowId()), v2(&d2, WindowId()), v3(&d3, WindowId()); |
| 39 v1.SetBounds(gfx::Rect(1, 2, 100, 100)); | 39 v1.SetBounds(gfx::Rect(1, 2, 100, 100), cc::LocalFrameId()); |
| 40 v2.SetBounds(gfx::Rect(3, 4, 100, 100)); | 40 v2.SetBounds(gfx::Rect(3, 4, 100, 100), cc::LocalFrameId()); |
| 41 v3.SetBounds(gfx::Rect(5, 6, 100, 100)); | 41 v3.SetBounds(gfx::Rect(5, 6, 100, 100), cc::LocalFrameId()); |
| 42 v1.Add(&v2); | 42 v1.Add(&v2); |
| 43 v2.Add(&v3); | 43 v2.Add(&v3); |
| 44 | 44 |
| 45 { | 45 { |
| 46 const gfx::PointF result( | 46 const gfx::PointF result( |
| 47 ConvertPointFBetweenWindows(&v1, &v3, gfx::PointF(10.5f, 11.9f))); | 47 ConvertPointFBetweenWindows(&v1, &v3, gfx::PointF(10.5f, 11.9f))); |
| 48 EXPECT_FLOAT_EQ(2.5f, result.x()); | 48 EXPECT_FLOAT_EQ(2.5f, result.x()); |
| 49 EXPECT_FLOAT_EQ(1.9f, result.y()); | 49 EXPECT_FLOAT_EQ(1.9f, result.y()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 { | 52 { |
| 53 const gfx::PointF result( | 53 const gfx::PointF result( |
| 54 ConvertPointFBetweenWindows(&v3, &v1, gfx::PointF(10.2f, 11.4f))); | 54 ConvertPointFBetweenWindows(&v3, &v1, gfx::PointF(10.2f, 11.4f))); |
| 55 EXPECT_FLOAT_EQ(18.2f, result.x()); | 55 EXPECT_FLOAT_EQ(18.2f, result.x()); |
| 56 EXPECT_FLOAT_EQ(21.4f, result.y()); | 56 EXPECT_FLOAT_EQ(21.4f, result.y()); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace ws | 60 } // namespace ws |
| 61 | 61 |
| 62 } // namespace ui | 62 } // namespace ui |
| OLD | NEW |