@Override
  public Point calculatePositionForPreview(
      Keyboard.Key key, PreviewPopupTheme theme, int[] windowOffset) {
    Point point = new Point(key.x + windowOffset[0], key.y + windowOffset[1]);

    Rect padding = new Rect();
    theme.getPreviewKeyBackground().getPadding(padding);

    point.offset((key.width / 2), padding.bottom);

    if (theme.getPreviewAnimationType() == PreviewPopupTheme.ANIMATION_STYLE_EXTEND) {
      // taking it down a bit to the edge of the origin key
      point.offset(0, key.height);
    }

    return point;
  }
@Test
  public void testCalculatePositionForPreviewWithBackgroundPadding() throws Exception {
    mTheme.setPreviewAnimationType(PreviewPopupTheme.ANIMATION_STYLE_APPEAR);
    Mockito.doAnswer(
            new Answer() {
              @Override
              public Object answer(InvocationOnMock invocation) throws Throwable {
                Rect padding = (Rect) invocation.getArguments()[0];
                padding.bottom = 13;
                return true;
              }
            })
        .when(mTheme.getPreviewKeyBackground())
        .getPadding(Mockito.any(Rect.class));

    int[] offsets = new int[] {50, 60};

    Point result = mUnderTest.calculatePositionForPreview(mTestKey, mTheme, offsets);

    Assert.assertEquals(mTestKey.x + mTestKey.width / 2 + offsets[0], result.x);
    Assert.assertEquals(mTestKey.y + offsets[1] + 13 /*padding*/, result.y);
  }