public void setActiveState(boolean active) {
    if (mLogicalState == LOCKED) return;
    mLogicalState = active ? ACTIVE : INACTIVE;

    if (mLogicalState == ACTIVE) {
      // setting the start time to zero, so LOCKED state will not
      // be activated without actual user's double-clicking
      mActiveStateStartTime = 0;
      mConsumed = false;
    }
  }
@Test
  public void testSetActiveState() throws Exception {
    long millis = 1000;
    setCurrentTimeMillis(++millis);

    ModifierKeyState state = new ModifierKeyState(true);
    Assert.assertFalse(state.isActive());
    Assert.assertFalse(state.isLocked());
    Assert.assertFalse(state.isPressed());

    state.setActiveState(true);

    Assert.assertTrue(state.isActive());
    Assert.assertFalse(state.isLocked());
    Assert.assertFalse(state.isPressed());

    state.onPress();

    Assert.assertTrue(state.isActive());
    Assert.assertFalse(state.isLocked());
    Assert.assertTrue(state.isPressed());

    setCurrentTimeMillis(++millis);
    state.onRelease(DOUBLE_TAP_TIMEOUT, LONG_PRESS_TIMEOUT);
    // although the state is ACTIVE before the press-release
    // sequence, we will not move to LOCKED state.
    // we can only move to LOCKED state if the user has double-clicked.
    Assert.assertFalse(state.isActive());
    Assert.assertFalse(state.isLocked());
    Assert.assertFalse(state.isPressed());

    state.onPress();

    Assert.assertTrue(state.isActive());
    Assert.assertFalse(state.isLocked());
    Assert.assertTrue(state.isPressed());

    setCurrentTimeMillis(++millis);
    state.onRelease(DOUBLE_TAP_TIMEOUT, LONG_PRESS_TIMEOUT);

    Assert.assertTrue(state.isActive());
    Assert.assertFalse(state.isLocked());
    Assert.assertFalse(state.isPressed());
  }