AboutPagerAdapter extends PagerAdapter { @Override public Object instantiateItem(ViewGroup container, int position) { ImageView imageView = new ImageView(container.getContext()); imageView.setScaleType(ImageView.ScaleType.FIT_XY); int imageRes = mEntries.get(position).image; if (imageRes != 0) { imageView.setImageResource(imageRes); } container.addView(imageView, 0); return imageView; } AboutPagerAdapter(); @Override int getCount(); @Override boolean isViewFromObject(View view, Object object); @Override Object instantiateItem(ViewGroup container, int position); @Override void destroyItem(ViewGroup container, int position, Object object);  }
@Test public void should_create_imageview_and_add_it_to_the_container() { FrameLayout container = new FrameLayout(RuntimeEnvironment.application); adapter.instantiateItem(container, 0); assertThat(container.getChildCount()).isEqualTo(1); assertThat(container.getChildAt(0)).isInstanceOf(ImageView.class); }