Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "cc/proto/skia_conversions.h" | 5 #include "cc/proto/skia_conversions.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/proto/skregion.pb.h" | 9 #include "cc/proto/skregion.pb.h" |
| 10 #include "cc/proto/skrrect.pb.h" | 10 #include "cc/proto/skrrect.pb.h" |
| 11 #include "cc/proto/skxfermode.pb.h" | 11 #include "cc/proto/skxfermode.pb.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/skia/include/core/SkBlendMode.h" | |
| 13 #include "third_party/skia/include/core/SkRRect.h" | 14 #include "third_party/skia/include/core/SkRRect.h" |
| 14 #include "third_party/skia/include/core/SkRegion.h" | 15 #include "third_party/skia/include/core/SkRegion.h" |
| 15 #include "third_party/skia/include/core/SkXfermode.h" | |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkRegionOp) { | 20 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkRegionOp) { |
| 21 for (size_t i = 0; i < SkRegion::Op::kLastOp; i++) { | 21 for (size_t i = 0; i < SkRegion::Op::kLastOp; i++) { |
| 22 SkRegion::Op op = static_cast<SkRegion::Op>(i); | 22 SkRegion::Op op = static_cast<SkRegion::Op>(i); |
| 23 EXPECT_EQ(op, SkRegionOpFromProto(SkRegionOpToProto(op))); | 23 EXPECT_EQ(op, SkRegionOpFromProto(SkRegionOpToProto(op))); |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkXfermodeMode) { | 27 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkXfermodeMode) { |
| 28 for (size_t i = 0; i < SkXfermode::Mode::kLastMode; i++) { | 28 for (size_t i = 0; i < (size_t)SkBlendMode::kLastMode; i++) { |
|
f(malita)
2016/11/16 21:10:58
nit: static_cast
reed1
2016/11/16 21:31:17
Done.
| |
| 29 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(i); | 29 SkBlendMode mode = static_cast<SkBlendMode>(i); |
| 30 EXPECT_EQ(mode, SkXfermodeModeFromProto(SkXfermodeModeToProto(mode))); | 30 EXPECT_EQ(mode, SkXfermodeModeFromProto(SkXfermodeModeToProto(mode))); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkRRect) { | 34 TEST(SkiaProtoConversionsTest, SerializeDeserializeSkRRect) { |
| 35 SkRect rect = SkRect::MakeXYWH(0, 10, 15, 20); | 35 SkRect rect = SkRect::MakeXYWH(0, 10, 15, 20); |
| 36 SkVector radii[4]; | 36 SkVector radii[4]; |
| 37 radii[0] = SkVector::Make(0.1f, 0.2f); | 37 radii[0] = SkVector::Make(0.1f, 0.2f); |
| 38 radii[1] = SkVector::Make(0.3f, 0.4f); | 38 radii[1] = SkVector::Make(0.3f, 0.4f); |
| 39 radii[2] = SkVector::Make(0.5f, 0.6f); | 39 radii[2] = SkVector::Make(0.5f, 0.6f); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 66 proto.radii_lower_left().x()); | 66 proto.radii_lower_left().x()); |
| 67 EXPECT_EQ(rrect.radii(SkRRect::kLowerLeft_Corner).y(), | 67 EXPECT_EQ(rrect.radii(SkRRect::kLowerLeft_Corner).y(), |
| 68 proto.radii_lower_left().y()); | 68 proto.radii_lower_left().y()); |
| 69 | 69 |
| 70 // Test ProtoToRRect | 70 // Test ProtoToRRect |
| 71 EXPECT_EQ(rrect, ProtoToSkRRect(proto)); | 71 EXPECT_EQ(rrect, ProtoToSkRRect(proto)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 } // namespace cc | 75 } // namespace cc |
| OLD | NEW |