| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "ui/gfx/geometry/insets.h" | 7 #include "ui/gfx/geometry/insets.h" |
| 8 #include "ui/gfx/geometry/vector2d.h" |
| 8 #include "ui/gfx/shadow_value.h" | 9 #include "ui/gfx/shadow_value.h" |
| 9 | 10 |
| 10 namespace gfx { | 11 namespace gfx { |
| 11 | 12 |
| 12 TEST(ShadowValueTest, GetMargin) { | 13 TEST(ShadowValueTest, GetMargin) { |
| 13 const struct TestCase { | 14 const struct TestCase { |
| 14 Insets expected_margin; | 15 Insets expected_margin; |
| 15 size_t shadow_count; | 16 size_t shadow_count; |
| 16 ShadowValue shadows[2]; | 17 ShadowValue shadows[2]; |
| 17 } kTestCases[] = { | 18 } kTestCases[] = { |
| 18 { | 19 { |
| 19 Insets(), 0, {}, | 20 Insets(), 0, {}, |
| 20 }, | 21 }, |
| 21 { | 22 { |
| 22 Insets(-2, -2, -2, -2), | 23 Insets(-2, -2, -2, -2), |
| 23 1, | 24 1, |
| 24 { ShadowValue(gfx::Point(0, 0), 4, 0), }, | 25 { ShadowValue(gfx::Vector2d(0, 0), 4, 0), }, |
| 25 }, | 26 }, |
| 26 { | 27 { |
| 27 Insets(0, -1, -4, -3), | 28 Insets(0, -1, -4, -3), |
| 28 1, | 29 1, |
| 29 { ShadowValue(gfx::Point(1, 2), 4, 0), }, | 30 { ShadowValue(gfx::Vector2d(1, 2), 4, 0), }, |
| 30 }, | 31 }, |
| 31 { | 32 { |
| 32 Insets(-4, -3, 0, -1), | 33 Insets(-4, -3, 0, -1), |
| 33 1, | 34 1, |
| 34 { ShadowValue(gfx::Point(-1, -2), 4, 0), }, | 35 { ShadowValue(gfx::Vector2d(-1, -2), 4, 0), }, |
| 35 }, | 36 }, |
| 36 { | 37 { |
| 37 Insets(0, -1, -5, -4), | 38 Insets(0, -1, -5, -4), |
| 38 2, | 39 2, |
| 39 { | 40 { |
| 40 ShadowValue(gfx::Point(1, 2), 4, 0), | 41 ShadowValue(gfx::Vector2d(1, 2), 4, 0), |
| 41 ShadowValue(gfx::Point(2, 3), 4, 0), | 42 ShadowValue(gfx::Vector2d(2, 3), 4, 0), |
| 42 }, | 43 }, |
| 43 }, | 44 }, |
| 44 { | 45 { |
| 45 Insets(-4, -3, -5, -4), | 46 Insets(-4, -3, -5, -4), |
| 46 2, | 47 2, |
| 47 { | 48 { |
| 48 ShadowValue(gfx::Point(-1, -2), 4, 0), | 49 ShadowValue(gfx::Vector2d(-1, -2), 4, 0), |
| 49 ShadowValue(gfx::Point(2, 3), 4, 0), | 50 ShadowValue(gfx::Vector2d(2, 3), 4, 0), |
| 50 }, | 51 }, |
| 51 }, | 52 }, |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 for (size_t i = 0; i < arraysize(kTestCases); ++i) { | 55 for (size_t i = 0; i < arraysize(kTestCases); ++i) { |
| 55 Insets margin = ShadowValue::GetMargin( | 56 Insets margin = ShadowValue::GetMargin( |
| 56 ShadowValues(kTestCases[i].shadows, | 57 ShadowValues(kTestCases[i].shadows, |
| 57 kTestCases[i].shadows + kTestCases[i].shadow_count)); | 58 kTestCases[i].shadows + kTestCases[i].shadow_count)); |
| 58 | 59 |
| 59 EXPECT_EQ(kTestCases[i].expected_margin, margin) << " i=" << i; | 60 EXPECT_EQ(kTestCases[i].expected_margin, margin) << " i=" << i; |
| 60 } | 61 } |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace gfx | 64 } // namespace gfx |
| OLD | NEW |