FileDocCategorySizeDatePackage
DisabledLongpressTest.javaAPI DocAndroid 5.1 API2773Thu Mar 12 22:22:12 GMT 2015android.view

DisabledLongpressTest

public class DisabledLongpressTest extends android.test.ActivityInstrumentationTestCase
Exercises {@link android.view.View}'s longpress plumbing by testing the disabled case.

Fields Summary
private android.view.View
mSimpleView
private boolean
mLongClicked
Constructors Summary
public DisabledLongpressTest()

        super("com.android.frameworks.coretests", Longpress.class);
    
Methods Summary
public voidsetUp()

        super.setUp();

        final Longpress a = getActivity();
        mSimpleView = a.findViewById(R.id.simple_view);
        mSimpleView.setOnLongClickListener(new OnLongClickListener() {
            public boolean onLongClick(View v) {
                mLongClicked = true;
                return true;
            }
        });
        // The View#setOnLongClickListener will ensure the View is long
        // clickable, we reverse that here
        mSimpleView.setLongClickable(false);
    
protected voidtearDown()

        super.tearDown();

        mLongClicked = false;
    
public voidtestKeypadLongClick()

        mSimpleView.requestFocus();
        getInstrumentation().waitForIdleSync();
        KeyUtils.longClick(this);
        
        getInstrumentation().waitForIdleSync();
        assertFalse(mLongClicked);
    
public voidtestSetUpConditions()

        assertNotNull(mSimpleView);
        assertTrue(mSimpleView.hasFocus());
        assertFalse(mLongClicked);
    
public voidtestTouchLongClick()

        TouchUtils.longClickView(this, mSimpleView);
        getInstrumentation().waitForIdleSync();
        assertFalse(mLongClicked);