1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.graphics;
18
19import static org.junit.Assert.assertEquals;
20import static org.junit.Assert.assertNotNull;
21
22import android.support.test.filters.SmallTest;
23import android.support.test.runner.AndroidJUnit4;
24
25import org.junit.Test;
26import org.junit.runner.RunWith;
27
28@SmallTest
29@RunWith(AndroidJUnit4.class)
30public class ColorSpaceRendererTest {
31
32    @Test
33    public void testRendererSize() {
34        Bitmap b = ColorSpace.createRenderer()
35                .size(0)
36                .render();
37        assertEquals(128, b.getWidth());
38        assertEquals(128, b.getHeight());
39
40        b = ColorSpace.createRenderer()
41                .size(768)
42                .render();
43        assertEquals(768, b.getWidth());
44        assertEquals(768, b.getHeight());
45    }
46
47    @Test
48    public void testRenderer() {
49        Bitmap b = ColorSpace.createRenderer()
50                .size(1024)
51                .clip(true)
52                .showWhitePoint(false)
53                .add(ColorSpace.get(ColorSpace.Named.SRGB), 0xffffffff)
54                .add(ColorSpace.get(ColorSpace.Named.DCI_P3), 0xffffffff)
55                .add(ColorSpace.get(ColorSpace.Named.PRO_PHOTO_RGB), 0.1f, 0.5f, 0.1f, 0xff000000)
56                .add(ColorSpace.get(ColorSpace.Named.ADOBE_RGB), 0.1f, 0.5f, 0.1f, 0xff000000)
57                .render();
58        assertNotNull(b);
59    }
60
61    @Test
62    public void testUcsRenderer() {
63        Bitmap b = ColorSpace.createRenderer()
64                .size(1024)
65                .clip(true)
66                .showWhitePoint(false)
67                .uniformChromaticityScale(true)
68                .add(ColorSpace.get(ColorSpace.Named.SRGB), 0xffffffff)
69                .add(ColorSpace.get(ColorSpace.Named.DCI_P3), 0xffffffff)
70                .add(ColorSpace.get(ColorSpace.Named.PRO_PHOTO_RGB), 0.1f, 0.5f, 0.1f, 0xff000000)
71                .add(ColorSpace.get(ColorSpace.Named.ADOBE_RGB), 0.1f, 0.5f, 0.1f, 0xff000000)
72                .render();
73        assertNotNull(b);
74    }
75}
76