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/compositor/test/test_utils.h" | 5 #include "ui/compositor/test/test_utils.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gfx/rect.h" | 8 #include "ui/gfx/rect.h" |
9 #include "ui/gfx/transform.h" | 9 #include "ui/gfx/transform.h" |
10 | 10 |
11 namespace ui { | 11 namespace ui { |
12 | 12 |
13 //TODO(avallee): Make this into a predicate and add some matrix pretty printing. | |
14 void CheckApproximatelyEqual(const gfx::Transform& lhs, | 13 void CheckApproximatelyEqual(const gfx::Transform& lhs, |
15 const gfx::Transform& rhs) { | 14 const gfx::Transform& rhs) { |
16 for (int i = 0; i < 4; ++i) { | 15 for (int i = 0; i < 4; ++i) { |
17 for (int j = 0; j < 4; ++j) { | 16 for (int j = 0; j < 4; ++j) { |
18 EXPECT_FLOAT_EQ(lhs.matrix().get(i, j), rhs.matrix().get(i, j)) | 17 EXPECT_FLOAT_EQ(lhs.matrix().get(i, j), rhs.matrix().get(i, j)); |
19 << "(i, j) = (" << i << ", " << j <<")"; | |
20 } | 18 } |
21 } | 19 } |
22 | |
23 if (::testing::Test::HasFailure()) { | |
24 ADD_FAILURE() << "Expected matrix:\n" | |
25 << lhs.ToString() << "\n" | |
26 << "Actual matrix:\n" | |
27 << rhs.ToString(); | |
28 } | |
29 } | 20 } |
30 | 21 |
31 void CheckApproximatelyEqual(const gfx::Rect& lhs, const gfx::Rect& rhs) { | 22 void CheckApproximatelyEqual(const gfx::Rect& lhs, const gfx::Rect& rhs) { |
32 EXPECT_FLOAT_EQ(lhs.x(), rhs.x()); | 23 EXPECT_FLOAT_EQ(lhs.x(), rhs.x()); |
33 EXPECT_FLOAT_EQ(lhs.y(), rhs.y()); | 24 EXPECT_FLOAT_EQ(lhs.y(), rhs.y()); |
34 EXPECT_FLOAT_EQ(lhs.width(), rhs.width()); | 25 EXPECT_FLOAT_EQ(lhs.width(), rhs.width()); |
35 EXPECT_FLOAT_EQ(lhs.height(), rhs.height()); | 26 EXPECT_FLOAT_EQ(lhs.height(), rhs.height()); |
36 } | 27 } |
37 | 28 |
38 } // namespace ui | 29 } // namespace ui |
OLD | NEW |