public void testSwipingListView() {
        // Given a SwipeRefreshLayout which is displaying a populated list
        populateList();

        // When the swipe refresh layout is dragged
        TouchUtils.dragViewBy(this,
                mSwipeRefreshLayout,
                Gravity.CENTER,
                0,
                Math.round(mSwipeRefreshLayout.getHeight() * 0.4f));

        // Then the SwipeRefreshLayout should be refreshing
        // We need to use runOnMainSync here as fake dragging uses waitForIdleSync()
        getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                assertTrue(mSwipeRefreshLayout.isRefreshing());
            }
        });
    }
Test that swiping on the populated list triggers a refresh.
SwipeRefreshMultipleViews/Application/tests/src/com/example/android/swiperefreshmultipleviews/tests/SampleTests.java