Search in sources :

Example 1 with ArgumentMatcher

use of org.mockito.compat.ArgumentMatcher in project platform_frameworks_base by android.

the class NetworkScorerAppManagerTest method mockRecommendationServiceAvailable.

private void mockRecommendationServiceAvailable(final String packageName, int packageUid) {
    final ResolveInfo serviceInfo = new ResolveInfo();
    serviceInfo.serviceInfo = new ServiceInfo();
    serviceInfo.serviceInfo.name = ".RecommendationService";
    serviceInfo.serviceInfo.packageName = packageName;
    serviceInfo.serviceInfo.applicationInfo = new ApplicationInfo();
    serviceInfo.serviceInfo.applicationInfo.uid = packageUid;
    final int flags = 0;
    when(mMockPm.resolveService(Mockito.argThat(new ArgumentMatcher<Intent>() {

        @Override
        public boolean matchesObject(Object object) {
            Intent intent = (Intent) object;
            return NetworkScoreManager.ACTION_RECOMMEND_NETWORKS.equals(intent.getAction()) && packageName.equals(intent.getPackage());
        }
    }), Mockito.eq(flags))).thenReturn(serviceInfo);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ArgumentMatcher(org.mockito.compat.ArgumentMatcher) ApplicationInfo(android.content.pm.ApplicationInfo) Intent(android.content.Intent)

Aggregations

Intent (android.content.Intent)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 ResolveInfo (android.content.pm.ResolveInfo)1 ServiceInfo (android.content.pm.ServiceInfo)1 ArgumentMatcher (org.mockito.compat.ArgumentMatcher)1