SearchManagerTestpublic 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 | mContextLocal copy of activity context |
Constructors Summary |
---|
public SearchManagerTest()
super("com.android.frameworks.coretests", LocalActivity.class);
|
Methods Summary |
---|
private android.app.ISearchManager | getSearchManagerService()
return ISearchManager.Stub.asInterface(
ServiceManager.getService(Context.SEARCH_SERVICE));
| public void | setUp()Setup any common data for the upcoming tests.
super.setUp();
Activity testActivity = getActivity();
mContext = testActivity;
| public void | testSearchManagerAvailable()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 void | testSearchManagerInterfaceAvailable()The goal of this test is to confirm that we can obtain
a search manager interface.
assertNotNull(getSearchManagerService());
| public void | testSearchManagerInvocations()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 void | testStartSearchIdempotent()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 void | testStopSearchIdempotent()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();
|
|