FileDocCategorySizeDatePackage
ColorStateListTest.javaAPI DocAndroid 5.1 API2458Thu Mar 12 22:22:30 GMT 2015android.graphics

ColorStateListTest

public class ColorStateListTest extends android.test.AndroidTestCase
Tests of {@link android.graphics.ColorStateList}

Fields Summary
private android.content.res.Resources
mResources
private int
mFailureColor
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
        mResources = mContext.getResources();
        mFailureColor = mResources.getColor(R.color.failColor);
    
public voidtestEmptyState()

        ColorStateList colorStateList = mResources.getColorStateList(R.color.color1);
        int[] emptyState = {};
        int defaultColor = colorStateList.getColorForState(emptyState, mFailureColor);
        assertEquals(mResources.getColor(R.color.testcolor2), defaultColor);
    
public voidtestGetColor()

        int defaultColor = mResources.getColor(R.color.color1);
        assertEquals(mResources.getColor(R.color.testcolor2), defaultColor);
    
public voidtestGetColorWhenListHasNoDefault()

        int defaultColor = mResources.getColor(R.color.color_no_default);
        assertEquals(mResources.getColor(R.color.testcolor1), defaultColor);
    
public voidtestStateIsInList()

        ColorStateList colorStateList = mResources.getColorStateList(R.color.color1);
        int[] focusedState = {android.R.attr.state_focused};
        int focusColor = colorStateList.getColorForState(focusedState, R.color.failColor);
        assertEquals(mResources.getColor(R.color.testcolor1), focusColor);