| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #include "core/animation/animatable/AnimatableColor.h" | |
| 32 | |
| 33 #include "testing/gtest/include/gtest/gtest.h" | |
| 34 | |
| 35 namespace blink { | |
| 36 | |
| 37 TEST(AnimationAnimatableColorTest, ToColor) { | |
| 38 Color transparent = AnimatableColorImpl(Color::transparent).toColor(); | |
| 39 EXPECT_EQ(transparent.rgb(), Color::transparent); | |
| 40 Color red = AnimatableColorImpl(Color(0xFFFF0000)).toColor(); | |
| 41 EXPECT_EQ(red.rgb(), 0xFFFF0000); | |
| 42 } | |
| 43 | |
| 44 TEST(AnimationAnimatableColorTest, Interpolate) { | |
| 45 EXPECT_EQ(AnimatableColorImpl(Color(0xFF00FF00)) | |
| 46 .interpolateTo(Color(0xFF00FF00), -10) | |
| 47 .toColor() | |
| 48 .rgb(), | |
| 49 0xFF00FF00); | |
| 50 EXPECT_EQ(AnimatableColorImpl(Color(0xFF00FF00)) | |
| 51 .interpolateTo(Color(0xFFFF00FF), -10) | |
| 52 .toColor() | |
| 53 .rgb(), | |
| 54 0xFF00FF00); | |
| 55 EXPECT_EQ(AnimatableColorImpl(Color(0xFF00FF00)) | |
| 56 .interpolateTo(Color(0xFFFF00FF), 0) | |
| 57 .toColor() | |
| 58 .rgb(), | |
| 59 0xFF00FF00); | |
| 60 EXPECT_EQ(AnimatableColorImpl(Color(0xFF00FF00)) | |
| 61 .interpolateTo(Color(0xFFFF00FF), 1. / 255) | |
| 62 .toColor() | |
| 63 .rgb(), | |
| 64 0xFF01FE01); | |
| 65 EXPECT_EQ(AnimatableColorImpl(Color(0xFF00FF00)) | |
| 66 .interpolateTo(Color(0xFFFF00FF), 0.5) | |
| 67 .toColor() | |
| 68 .rgb(), | |
| 69 0xFF808080); | |
| 70 EXPECT_EQ(AnimatableColorImpl(Color(0xFF00FF00)) | |
| 71 .interpolateTo(Color(0xFFFF00FF), 254. / 255) | |
| 72 .toColor() | |
| 73 .rgb(), | |
| 74 0xFFFE01FE); | |
| 75 EXPECT_EQ(AnimatableColorImpl(Color(0xFF00FF00)) | |
| 76 .interpolateTo(Color(0xFFFF00FF), 1) | |
| 77 .toColor() | |
| 78 .rgb(), | |
| 79 0xFFFF00FF); | |
| 80 EXPECT_EQ(AnimatableColorImpl(Color(0xFF00FF00)) | |
| 81 .interpolateTo(Color(0xFFFF00FF), 10) | |
| 82 .toColor() | |
| 83 .rgb(), | |
| 84 0xFFFF00FF); | |
| 85 | |
| 86 EXPECT_EQ(AnimatableColorImpl(Color(0xFF001020)) | |
| 87 .interpolateTo(Color(0xFF4080C0), 3. / 16) | |
| 88 .toColor() | |
| 89 .rgb(), | |
| 90 0xFF0C253E); | |
| 91 | |
| 92 EXPECT_EQ(AnimatableColorImpl(Color(0x0000FF00)) | |
| 93 .interpolateTo(Color(0xFFFF00FF), 0.5) | |
| 94 .toColor() | |
| 95 .rgb(), | |
| 96 0x80FF00FF); | |
| 97 EXPECT_EQ(AnimatableColorImpl(Color(0x4000FF00)) | |
| 98 .interpolateTo(Color(0x80FF00FF), 0.5) | |
| 99 .toColor() | |
| 100 .rgb(), | |
| 101 0x60AA55AAu); | |
| 102 EXPECT_EQ(AnimatableColorImpl(Color(0x40FF00FF)) | |
| 103 .interpolateTo(Color(0x80FFFFFF), 0.5) | |
| 104 .toColor() | |
| 105 .rgb(), | |
| 106 0x60FFAAFFu); | |
| 107 | |
| 108 EXPECT_EQ(AnimatableColorImpl(Color(0x10204080)) | |
| 109 .interpolateTo(Color(0x104080C0), 0.5) | |
| 110 .toColor() | |
| 111 .rgb(), | |
| 112 0x103060A0u); | |
| 113 } | |
| 114 | |
| 115 } // namespace blink | |
| OLD | NEW |