Code example for ViewPager

0
    private ViewPager pager;
    private TestPagerAdapter adapter;
 
    @Before 
    public void setUp() throws Exception { 
        pager = new ViewPager(new Activity());
        adapter = new TestPagerAdapter();
    } 
 
    @Test 
    public void shouldSetAndGetAdapter() throws Exception { 
        assertNull(pager.getAdapter());
 
        pager.setAdapter(adapter);
        assertSame(adapter, pager.getAdapter());
    } 
 
    @Test 
    public void test_getAndSetCurrentItem() throws Exception { 
        pager.setAdapter(adapter);
        pager.setCurrentItem(2);