FileDocCategorySizeDatePackage
AutoCompleteTextViewPopup.javaAPI DocAndroid 1.5 API5553Wed May 06 22:42:02 BST 2009android.widget

AutoCompleteTextViewPopup

public class AutoCompleteTextViewPopup extends android.test.ActivityInstrumentationTestCase2
A collection of tests on aspects of the AutoCompleteTextView's popup

Fields Summary
Constructors Summary
public AutoCompleteTextViewPopup()

        super("com.android.frameworktest", AutoCompleteTextViewSimple.class);
    
Methods Summary
public voidtestPopupClearListSelection()
Test that we can clear the selection

        AutoCompleteTextViewSimple theActivity = getActivity();
        final AutoCompleteTextView textView = theActivity.getTextView();
        final Instrumentation instrumentation = getInstrumentation();
        
        // focus and type
        textView.requestFocus();
        instrumentation.waitForIdleSync();
        sendKeys("A");
        
        // No initial selection
        assertEquals("getListSelection(-1)", 
                ListView.INVALID_POSITION, textView.getListSelection());
        
        // check for selection position as expected
        sendKeys("DPAD_DOWN");
        assertEquals("getListSelection(0)", 0, textView.getListSelection());
        
        // clear it
        runTestOnUiThread(new Runnable() {
            public void run() {
                textView.clearListSelection();
            }
        });
        instrumentation.waitForIdleSync();
        assertEquals("setListSelection(ListView.INVALID_POSITION)", 
                ListView.INVALID_POSITION, textView.getListSelection());
    
public voidtestPopupGetListSelection()
Test that we can look at the selection as we move around

        AutoCompleteTextViewSimple theActivity = getActivity();
        AutoCompleteTextView textView = theActivity.getTextView();
        final Instrumentation instrumentation = getInstrumentation();
        
        // focus and type
        textView.requestFocus();
        instrumentation.waitForIdleSync();
        sendKeys("A");
        
        // No initial selection
        assertEquals("getListSelection(-1)", 
                ListView.INVALID_POSITION, textView.getListSelection());
        
        // check for selection position as expected
        sendKeys("DPAD_DOWN");
        assertEquals("move selection to (0)", 0, textView.getListSelection());
        
        // Repeat for one more movement
        sendKeys("DPAD_DOWN");
        assertEquals("move selection to (1)", 1, textView.getListSelection());
    
public voidtestPopupNavigateNoAdapter()
Make sure we handle an empty adapter properly

        AutoCompleteTextViewSimple theActivity = getActivity();
        final AutoCompleteTextView textView = theActivity.getTextView();
        final Instrumentation instrumentation = getInstrumentation();

        // focus and type
        textView.requestFocus();
        instrumentation.waitForIdleSync();
        sendKeys("A");

        // No initial selection
        assertEquals("getListSelection(-1)",
                ListView.INVALID_POSITION, textView.getListSelection());

        // check for selection position as expected
        sendKeys("DPAD_DOWN");
        assertEquals("getListSelection(0)", 0, textView.getListSelection());

        // Now get rid of the adapter
        runTestOnUiThread(new Runnable() {
            public void run() {
                textView.setAdapter((ArrayAdapter<?>) null);
            }
        });
        instrumentation.waitForIdleSync();

        // now try moving "down" - nothing should happen since there's no longer an adapter
        sendKeys("DPAD_DOWN");
    
public voidtestPopupSetListSelection()
Test that we can move the selection and it responds as expected

        AutoCompleteTextViewSimple theActivity = getActivity();
        final AutoCompleteTextView textView = theActivity.getTextView();
        final Instrumentation instrumentation = getInstrumentation();
        
        // focus and type
        textView.requestFocus();
        instrumentation.waitForIdleSync();
        sendKeys("A");
        
        // No initial selection
        assertEquals("getListSelection(-1)", 
                ListView.INVALID_POSITION, textView.getListSelection());
        
        // set and check
        runTestOnUiThread(new Runnable() {
            public void run() {
                textView.setListSelection(0);
            }
        });
        instrumentation.waitForIdleSync();
        assertEquals("set selection to (0)", 0, textView.getListSelection());
        
        // Use movement to cross-check the movement
        sendKeys("DPAD_DOWN");
        assertEquals("move selection to (1)", 1, textView.getListSelection());