Example usage for android.test TouchUtils dragViewBy

List of usage examples for android.test TouchUtils dragViewBy

Introduction

In this page you can find the example usage for android.test TouchUtils dragViewBy.

Prototype

@Deprecated
public static int dragViewBy(InstrumentationTestCase test, View v, int gravity, int deltaX, int deltaY) 

Source Link

Document

Simulate touching a view and dragging it by the specified amount.

Usage

From source file:com.example.android.swiperefreshlayoutbasic.tests.SampleTests.java

/**
 * Test that swiping on the populated list triggers a refresh.
 *///from w ww  .j a v a 2s . c  om
public void testSwipingListView() {
    // Given a SwipeRefreshLayout which is displaying a populated list

    // 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());
        }
    });
}

From source file:com.example.android.swiperefreshlistfragment.tests.SampleTests.java

/**
 * Test that swiping on the populated list triggers a refresh.
 */// w  ww. java  2 s.c  om
public void testSwipingListView() {
    // Given a SwipeRefreshLayout which is displaying a populated list

    // When the swipe refresh layout is dragged
    TouchUtils.dragViewBy(this, mSwipeRefreshLayout, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 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());
        }
    });
}

From source file:com.example.android.swiperefreshmultipleviews.tests.SampleTests.java

/**
 * Test that swiping on the empty view triggers a refresh.
 *///from  w  w w .j  a v  a2s .c o  m
public void testSwipingEmptyView() {
    // Given a SwipeRefreshLayout which is displaying the empty view

    // 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
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            assertTrue(mSwipeRefreshLayout.isRefreshing());
        }
    });
}

From source file:com.example.android.swiperefreshmultipleviews.tests.SampleTests.java

/**
 * Test that swiping on the populated list triggers a refresh.
 *//*from   www . ja  v a 2s . c om*/
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());
        }
    });
}