1package com.xtremelabs.robolectric.shadows; 2 3import android.content.pm.ActivityInfo; 4import android.content.pm.PackageManager; 5import android.content.pm.ResolveInfo; 6 7import com.xtremelabs.robolectric.Robolectric; 8import com.xtremelabs.robolectric.internal.Implementation; 9import com.xtremelabs.robolectric.internal.Implements; 10 11@Implements( ResolveInfo.class ) 12public class ShadowResolveInfo { 13 14 private String label; 15 16 @Implementation 17 public String loadLabel( PackageManager mgr ) { return label; } 18 19 /** 20 * Non-Android accessor used to set the value returned by {@link loadLabel} 21 */ 22 public void setLabel( String l ) { label = l; } 23 24 /** 25 * Non-Android accessor used for creating ResolveInfo objects 26 * @param displayName 27 * @param packageName 28 * @return 29 */ 30 public static ResolveInfo newResolveInfo( String displayName, String packageName ) { 31 return newResolveInfo( displayName, packageName, null); 32 } 33 34 /** 35 * Non-Android accessor used for creating ResolveInfo objects 36 * @param displayName 37 * @param packageName 38 * @return 39 */ 40 public static ResolveInfo newResolveInfo( String displayName, String packageName, String activityName ) { 41 42 ResolveInfo resInfo = new ResolveInfo(); 43 ActivityInfo actInfo = new ActivityInfo(); 44 actInfo.packageName = packageName; 45 actInfo.name = activityName; 46 resInfo.activityInfo = actInfo; 47 48 ShadowResolveInfo shResolve = Robolectric.shadowOf(resInfo ); 49 shResolve.setLabel( displayName ); 50 return resInfo; 51 } 52} 53