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
3 // found in the LICENSE file.
7 #include "extensions/common/image_util.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/skia/include/core/SkColor.h"
11 namespace extensions
{
13 void RunPassTest(const std::string
& css_string
, SkColor expected_result
) {
15 EXPECT_TRUE(image_util::ParseCSSColorString(css_string
, &color
));
16 EXPECT_EQ(color
, expected_result
);
19 void RunFailTest(const std::string
& css_string
) {
21 EXPECT_FALSE(image_util::ParseCSSColorString(css_string
, &color
));
24 TEST(ImageUtilTest
, ChangeBadgeBackgroundNormalCSS
) {
25 RunPassTest("#34006A", SkColorSetARGB(0xFF, 0x34, 0, 0x6A));
28 TEST(ImageUtilTest
, ChangeBadgeBackgroundShortCSS
) {
29 RunPassTest("#A1E", SkColorSetARGB(0xFF, 0xAA, 0x11, 0xEE));
32 TEST(ImageUtilTest
, ChangeBadgeBackgroundCSSNoHash
) {
33 RunFailTest("11FF22");
36 TEST(ImageUtilTest
, ChangeBadgeBackgroundCSSTooShort
) {
40 TEST(ImageUtilTest
, ChangeBadgeBackgroundCSSTooLong
) {
41 RunFailTest("#FF22128");
44 TEST(ImageUtilTest
, ChangeBadgeBackgroundCSSInvalid
) {
45 RunFailTest("#-22128");
48 TEST(ImageUtilTest
, ChangeBadgeBackgroundCSSInvalidWithPlus
) {
49 RunFailTest("#+22128");
52 } // namespace extensions