@Test public void checkGetHeroIndexOnEvenNumber() { mContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { mBar = Mockito.spy(new ThumbsBar(mContext, null)); } }); int childCountForTest = 4; int expectedHeroIndex = 2; when(mBar.getChildCount()).thenReturn(childCountForTest); assertEquals(mBar.getHeroIndex(), expectedHeroIndex); }
public int getHeroIndex() { return getChildCount() / 2; }
ThumbsBar extends LinearLayout { public int getHeroIndex() { return getChildCount() / 2; } }
ThumbsBar extends LinearLayout { public int getHeroIndex() { return getChildCount() / 2; } ThumbsBar(Context context, AttributeSet attrs);  ThumbsBar(Context context, AttributeSet attrs, int defStyle); }
ThumbsBar extends LinearLayout { public int getHeroIndex() { return getChildCount() / 2; } ThumbsBar(Context context, AttributeSet attrs);  ThumbsBar(Context context, AttributeSet attrs, int defStyle); int getHeroIndex(); void setThumbSize(int width, int height); void setHeroThumbSize(int width, int height); void setThumbSpace(int spaceInPixel); void setNumberOfThumbs(int numOfThumbs); void clearThumbBitmaps(); Bitmap getThumbBitmap(int index); void setThumbBitmap(int index, Bitmap bitmap); }
ThumbsBar extends LinearLayout { public int getHeroIndex() { return getChildCount() / 2; } ThumbsBar(Context context, AttributeSet attrs);  ThumbsBar(Context context, AttributeSet attrs, int defStyle); int getHeroIndex(); void setThumbSize(int width, int height); void setHeroThumbSize(int width, int height); void setThumbSpace(int spaceInPixel); void setNumberOfThumbs(int numOfThumbs); void clearThumbBitmaps(); Bitmap getThumbBitmap(int index); void setThumbBitmap(int index, Bitmap bitmap);  }