blob: ba451e1e10dc469f13491a4f68818a5cfb538a0f [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
18import android.content.res.ColorStateList;
19import android.service.quicksettings.Tile;
20import android.support.test.runner.AndroidJUnit4;
21import android.test.suitebuilder.annotation.SmallTest;
22import com.android.systemui.SysuiTestCase;
23import org.junit.Before;
24import org.junit.Test;
25import org.junit.runner.RunWith;
26import com.android.systemui.R;
27
28import static junit.framework.Assert.assertEquals;
29
30@SmallTest
31@RunWith(AndroidJUnit4.class)
32public class TileColorPickerTest extends SysuiTestCase {
33 private static final int DEFAULT_COLOR = 0;
34
35 private TileColorPicker mTileColorPicker;
36 private ColorStateList mTintColorStateList;
37
38 @Before
39 public void setUp() {
40 mTileColorPicker = TileColorPicker.getInstance(mContext);
41 mTintColorStateList = mContext.getResources().
42 getColorStateList(R.color.tint_color_selector, mContext.getTheme());
43 }
44
45 @Test
46 public void testGetColor_StateUnavailable_ReturnUnavailableColor() {
47 final int color = mTileColorPicker.getColor(Tile.STATE_UNAVAILABLE);
48 final int expectedColor = mTintColorStateList.getColorForState(
49 TileColorPicker.DISABLE_STATE_SET, DEFAULT_COLOR);
50
51 assertEquals(expectedColor, color);
52 }
53
54 @Test
55 public void testGetColor_StateInactive_ReturnInactiveColor() {
56 final int color = mTileColorPicker.getColor(Tile.STATE_INACTIVE);
57 final int expectedColor = mTintColorStateList.getColorForState(
58 TileColorPicker.INACTIVE_STATE_SET, DEFAULT_COLOR);
59
60 assertEquals(expectedColor, color);
61 }
62
63 @Test
64 public void testGetColor_StateActive_ReturnActiveColor() {
65 final int color = mTileColorPicker.getColor(Tile.STATE_ACTIVE);
66 final int expectedColor = mTintColorStateList.getColorForState(
67 TileColorPicker.ENABLE_STATE_SET, DEFAULT_COLOR);
68
69 assertEquals(expectedColor, color);
70 }
71}