public void testGetConstantState() {
    assertNotNull(mNinePatchDrawable.getConstantState());

    ConstantState constantState = mNinePatchDrawable.getConstantState();
    // change the drawable's configuration does not affect the state's configuration
    mNinePatchDrawable.setChangingConfigurations(0xff);
    assertEquals(0, constantState.getChangingConfigurations());
    // the state's configuration refreshed when getConstantState is called.
    constantState = mNinePatchDrawable.getConstantState();
    assertEquals(0xff, constantState.getChangingConfigurations());
  }
 public Drawable loadIcon(Context context, RunningState state) {
   if (mUser == null) {
     return super.loadIcon(context, state);
   }
   if (mUser.mIcon != null) {
     ConstantState constState = mUser.mIcon.getConstantState();
     if (constState == null) {
       return mUser.mIcon;
     } else {
       return constState.newDrawable();
     }
   }
   return context.getDrawable(com.android.internal.R.drawable.ic_menu_cc);
 }
  public void testGetChangingConfigurations() {
    ConstantState constantState = mNinePatchDrawable.getConstantState();

    // default
    assertEquals(0, constantState.getChangingConfigurations());
    assertEquals(0, mNinePatchDrawable.getChangingConfigurations());

    // change the drawable's configuration does not affect the state's configuration
    mNinePatchDrawable.setChangingConfigurations(0xff);
    assertEquals(0xff, mNinePatchDrawable.getChangingConfigurations());
    assertEquals(0, constantState.getChangingConfigurations());

    // the state's configuration get refreshed
    constantState = mNinePatchDrawable.getConstantState();
    assertEquals(0xff, constantState.getChangingConfigurations());

    // set a new configuration to drawable
    mNinePatchDrawable.setChangingConfigurations(0xff00);
    assertEquals(0xff, constantState.getChangingConfigurations());
    assertEquals(0xffff, mNinePatchDrawable.getChangingConfigurations());
  }