1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2017 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#include "tests/Test.h"
9cb93a386Sopenharmony_ci
10cb93a386Sopenharmony_ci#include "include/core/SkColor.h"
11cb93a386Sopenharmony_ci
12cb93a386Sopenharmony_ciDEF_TEST(ColorToHSVRoundTrip, reporter) {
13cb93a386Sopenharmony_ci    SkScalar hsv[3];
14cb93a386Sopenharmony_ci    for (U8CPU r = 0; r <= 255; r++) {
15cb93a386Sopenharmony_ci        for (U8CPU g = 0; g <= 255; g++) {
16cb93a386Sopenharmony_ci            for (U8CPU b = 0; b <= 255; b++) {
17cb93a386Sopenharmony_ci                SkColor color = SkColorSetRGB(r, g, b);
18cb93a386Sopenharmony_ci                SkColorToHSV(color, hsv);
19cb93a386Sopenharmony_ci                SkColor result = SkHSVToColor(0xFF, hsv);
20cb93a386Sopenharmony_ci                if (result != color) {
21cb93a386Sopenharmony_ci                    ERRORF(reporter, "HSV roundtrip mismatch!\n"
22cb93a386Sopenharmony_ci                                     "\toriginal: %X\n"
23cb93a386Sopenharmony_ci                                     "\tHSV: %f, %f, %f\n"
24cb93a386Sopenharmony_ci                                     "\tresult: %X\n",
25cb93a386Sopenharmony_ci                           color, hsv[0], hsv[1], hsv[2], result);
26cb93a386Sopenharmony_ci                }
27cb93a386Sopenharmony_ci            }
28cb93a386Sopenharmony_ci        }
29cb93a386Sopenharmony_ci    }
30cb93a386Sopenharmony_ci}
31