• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.content.pm.ActivityInfo;
4 import android.content.pm.PackageManager;
5 import android.content.pm.ResolveInfo;
6 
7 import com.xtremelabs.robolectric.Robolectric;
8 import com.xtremelabs.robolectric.internal.Implementation;
9 import com.xtremelabs.robolectric.internal.Implements;
10 
11 @Implements( ResolveInfo.class )
12 public class ShadowResolveInfo {
13 
14 	private String label;
15 
16 	@Implementation
loadLabel( PackageManager mgr )17 	public String loadLabel( PackageManager mgr ) { return label; }
18 
19 	/**
20 	 * Non-Android accessor used to set the value returned by {@link loadLabel}
21 	 */
setLabel( String l )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 	 */
newResolveInfo( String displayName, String packageName )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 	 */
newResolveInfo( String displayName, String packageName, String activityName )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