FileDocCategorySizeDatePackage
SearchManagerTest.javaAPI DocAndroid 5.1 API6030Thu Mar 12 22:22:12 GMT 2015android.app

SearchManagerTest

public class SearchManagerTest extends android.test.ActivityInstrumentationTestCase2
To launch this test from the command line: adb shell am instrument -w \ -e class com.android.unit_tests.SearchManagerTest \ com.android.unit_tests/android.test.InstrumentationTestRunner

Fields Summary
private android.content.ComponentName
SEARCHABLE_ACTIVITY
android.content.Context
mContext
Local copy of activity context
Constructors Summary
public SearchManagerTest()


      
        super("com.android.frameworks.coretests", LocalActivity.class);
    
Methods Summary
private android.app.ISearchManagergetSearchManagerService()

        return ISearchManager.Stub.asInterface(
                ServiceManager.getService(Context.SEARCH_SERVICE));
    
public voidsetUp()
Setup any common data for the upcoming tests.

        super.setUp();
        
        Activity testActivity = getActivity();
        mContext = testActivity;
    
public voidtestSearchManagerAvailable()
The goal of this test is to confirm that we can obtain a search manager at any time, and that for any given context, it is a singleton.

        SearchManager searchManager1 = (SearchManager)
                mContext.getSystemService(Context.SEARCH_SERVICE);
        assertNotNull(searchManager1);
        SearchManager searchManager2 = (SearchManager)
                mContext.getSystemService(Context.SEARCH_SERVICE);
        assertNotNull(searchManager2);
        assertSame(searchManager1, searchManager2 );
    
public voidtestSearchManagerInterfaceAvailable()
The goal of this test is to confirm that we can obtain a search manager interface.

        assertNotNull(getSearchManagerService());
    
public voidtestSearchManagerInvocations()
The goal of this test is to confirm that we can start and then stop a simple search.

        SearchManager searchManager = (SearchManager)
                mContext.getSystemService(Context.SEARCH_SERVICE);
        assertNotNull(searchManager);

        // These tests should simply run to completion w/o exceptions
        searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
        searchManager.stopSearch();

        searchManager.startSearch("", false, SEARCHABLE_ACTIVITY, null, false);
        searchManager.stopSearch();

        searchManager.startSearch("test search string", false, SEARCHABLE_ACTIVITY, null, false);
        searchManager.stopSearch();

        searchManager.startSearch("test search string", true, SEARCHABLE_ACTIVITY, null, false);
        searchManager.stopSearch();
    
public voidtestStartSearchIdempotent()
Tests that startSearch() can be called multiple times without stopSearch() in between.

         SearchManager searchManager = (SearchManager)
                 mContext.getSystemService(Context.SEARCH_SERVICE);
         assertNotNull(searchManager);

         searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
         searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
         searchManager.stopSearch();
    
public voidtestStopSearchIdempotent()
Tests that stopSearch() can be called when the search UI is not visible and can be called multiple times without startSearch() in between.

         SearchManager searchManager = (SearchManager)
                 mContext.getSystemService(Context.SEARCH_SERVICE);
         assertNotNull(searchManager);
         searchManager.stopSearch();

         searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
         searchManager.stopSearch();
         searchManager.stopSearch();