blob: ec8552b7f3949bb0dd73c5606c4a929c620c177a [file] [log] [blame]
jackqdyulei76471a52016-12-05 15:03:56 -08001/*
2 * Copyright (C) 2016 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 */
16package com.android.systemui.qs.external;
17
Brett Chabot84151d92019-02-27 15:37:59 -080018import static junit.framework.Assert.assertEquals;
19
jackqdyulei76471a52016-12-05 15:03:56 -080020import android.content.res.ColorStateList;
21import android.service.quicksettings.Tile;
jackqdyulei76471a52016-12-05 15:03:56 -080022import android.test.suitebuilder.annotation.SmallTest;
Brett Chabot84151d92019-02-27 15:37:59 -080023
24import androidx.test.runner.AndroidJUnit4;
25
26import com.android.systemui.R;
jackqdyulei76471a52016-12-05 15:03:56 -080027import com.android.systemui.SysuiTestCase;
Brett Chabot84151d92019-02-27 15:37:59 -080028
jackqdyulei76471a52016-12-05 15:03:56 -080029import org.junit.Before;
30import org.junit.Test;
31import org.junit.runner.RunWith;
jackqdyulei76471a52016-12-05 15:03:56 -080032
33@SmallTest
34@RunWith(AndroidJUnit4.class)
35public class TileColorPickerTest extends SysuiTestCase {
36 private static final int DEFAULT_COLOR = 0;
37
38 private TileColorPicker mTileColorPicker;
39 private ColorStateList mTintColorStateList;
40
41 @Before
42 public void setUp() {
43 mTileColorPicker = TileColorPicker.getInstance(mContext);
44 mTintColorStateList = mContext.getResources().
45 getColorStateList(R.color.tint_color_selector, mContext.getTheme());
46 }
47
48 @Test
49 public void testGetColor_StateUnavailable_ReturnUnavailableColor() {
50 final int color = mTileColorPicker.getColor(Tile.STATE_UNAVAILABLE);
51 final int expectedColor = mTintColorStateList.getColorForState(
52 TileColorPicker.DISABLE_STATE_SET, DEFAULT_COLOR);
53
54 assertEquals(expectedColor, color);
55 }
56
57 @Test
58 public void testGetColor_StateInactive_ReturnInactiveColor() {
59 final int color = mTileColorPicker.getColor(Tile.STATE_INACTIVE);
60 final int expectedColor = mTintColorStateList.getColorForState(
61 TileColorPicker.INACTIVE_STATE_SET, DEFAULT_COLOR);
62
63 assertEquals(expectedColor, color);
64 }
65
66 @Test
67 public void testGetColor_StateActive_ReturnActiveColor() {
68 final int color = mTileColorPicker.getColor(Tile.STATE_ACTIVE);
69 final int expectedColor = mTintColorStateList.getColorForState(
70 TileColorPicker.ENABLE_STATE_SET, DEFAULT_COLOR);
71
72 assertEquals(expectedColor, color);
73 }
74}