Fix broken Searchables unit tests.
The newly added code was using methods which were not overridden by the unit test, fixed now.
This commit is contained in:
@@ -20,6 +20,7 @@ import android.app.SearchManager;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ProviderInfo;
|
import android.content.pm.ProviderInfo;
|
||||||
@@ -306,6 +307,14 @@ public class SearchablesTest extends AndroidTestCase {
|
|||||||
throws PackageManager.NameNotFoundException {
|
throws PackageManager.NameNotFoundException {
|
||||||
return mRealContext.createPackageContext(packageName, flags);
|
return mRealContext.createPackageContext(packageName, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message broadcast. Pass through for now.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendBroadcast(Intent intent) {
|
||||||
|
mRealContext.sendBroadcast(intent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -376,7 +385,8 @@ public class SearchablesTest extends AndroidTestCase {
|
|||||||
@Override
|
@Override
|
||||||
public ResolveInfo resolveActivity(Intent intent, int flags) {
|
public ResolveInfo resolveActivity(Intent intent, int flags) {
|
||||||
assertNotNull(intent);
|
assertNotNull(intent);
|
||||||
assertEquals(intent.getAction(), SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
|
assertTrue(intent.getAction().equals(Intent.ACTION_WEB_SEARCH)
|
||||||
|
|| intent.getAction().equals(SearchManager.INTENT_ACTION_GLOBAL_SEARCH));
|
||||||
switch (mSearchablesMode) {
|
switch (mSearchablesMode) {
|
||||||
case SEARCHABLES_PASSTHROUGH:
|
case SEARCHABLES_PASSTHROUGH:
|
||||||
return mRealPackageManager.resolveActivity(intent, flags);
|
return mRealPackageManager.resolveActivity(intent, flags);
|
||||||
@@ -439,6 +449,29 @@ public class SearchablesTest extends AndroidTestCase {
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the activity information for a particular activity.
|
||||||
|
*
|
||||||
|
* @param name The name of the activity to find.
|
||||||
|
* @param flags Additional option flags.
|
||||||
|
*
|
||||||
|
* @return ActivityInfo Information about the activity, if found, else null.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ActivityInfo getActivityInfo(ComponentName name, int flags)
|
||||||
|
throws NameNotFoundException {
|
||||||
|
assertNotNull(name);
|
||||||
|
MoreAsserts.assertNotEqual(name, "");
|
||||||
|
switch (mSearchablesMode) {
|
||||||
|
case SEARCHABLES_PASSTHROUGH:
|
||||||
|
return mRealPackageManager.getActivityInfo(name, flags);
|
||||||
|
case SEARCHABLES_MOCK_ZERO:
|
||||||
|
throw new NameNotFoundException();
|
||||||
|
default:
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user