FileDocCategorySizeDatePackage
AutoCompleteTextViewCallbacks.javaAPI DocAndroid 1.5 API4723Wed May 06 22:42:02 BST 2009android.widget

AutoCompleteTextViewCallbacks

public class AutoCompleteTextViewCallbacks extends android.test.ActivityInstrumentationTestCase2

Fields Summary
Constructors Summary
public AutoCompleteTextViewCallbacks()

        super("com.android.frameworktest", AutoCompleteTextViewSimple.class);
    
Methods Summary
public voidtestPopupEnterSelection()
Test that arrow-down into the popup calls the onSelected callback

        AutoCompleteTextViewSimple theActivity = getActivity();
        AutoCompleteTextView textView = theActivity.getTextView();
        final Instrumentation instrumentation = getInstrumentation();
        
        // focus and type
        textView.requestFocus();
        instrumentation.waitForIdleSync();
        sendKeys("A");
        
        // prepare to move down into the popup
        theActivity.resetItemListeners();
        sendKeys("DPAD_DOWN");
        
        // now check for selection callbacks.
        assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
        assertTrue("onItemSelected should be called", theActivity.mItemSelectedCalled);
        assertEquals("onItemSelected position", 0, theActivity.mItemSelectedPosition);
        assertFalse("onNothingSelected should not be called", theActivity.mNothingSelectedCalled);
        
        // try one more time - should move from 0 to 1
        theActivity.resetItemListeners();
        sendKeys("DPAD_DOWN");
        
        // now check for selection callbacks.
        assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
        assertTrue("onItemSelected should be called", theActivity.mItemSelectedCalled);
        assertEquals("onItemSelected position", 1, theActivity.mItemSelectedPosition);
        assertFalse("onNothingSelected should not be called", theActivity.mNothingSelectedCalled);
    
public voidtestPopupLeaveSelection()
Test that arrow-up out of the popup calls the onNothingSelected callback

        AutoCompleteTextViewSimple theActivity = getActivity();
        AutoCompleteTextView textView = theActivity.getTextView();
        final Instrumentation instrumentation = getInstrumentation();
        
        // focus and type
        textView.requestFocus();
        instrumentation.waitForIdleSync();
        sendKeys("A");
        
        // move down into the popup
        sendKeys("DPAD_DOWN");
        
        // now move back up out of the popup
        theActivity.resetItemListeners();
        sendKeys("DPAD_UP");

        // now check for selection callbacks.
        assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
        assertFalse("onItemSelected should not be called", theActivity.mItemSelectedCalled);
        assertTrue("onNothingSelected should be called", theActivity.mNothingSelectedCalled);
    
public voidtestPopupNoSelection()
Test that the initial popup of the suggestions does not select anything

        AutoCompleteTextViewSimple theActivity = getActivity();
        AutoCompleteTextView textView = theActivity.getTextView();
        final Instrumentation instrumentation = getInstrumentation();
        
        // focus and type
        textView.requestFocus();
        instrumentation.waitForIdleSync();
        sendKeys("A");
        
        // now check for selection callbacks.  Nothing should be clicked or selected.
        assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
        assertFalse("onItemSelected should not be called", theActivity.mItemSelectedCalled);
        
        // arguably, this should be "false", because we aren't deselecting - we shouldn't
        // really be calling it.  But it's not the end of the world, and we might wind up
        // breaking something if we change this.
        assertTrue("onNothingSelected should be called", theActivity.mNothingSelectedCalled);