use of com.paypal.android.sdk.onetouch.core.base.ContextInspector in project braintree_android by braintree.
the class TestSetupHelper method getMockContextInspector.
public static ContextInspector getMockContextInspector() throws NameNotFoundException {
ApplicationInfo applicationInfoMock = mock(ApplicationInfo.class);
when(applicationInfoMock.loadLabel(any(PackageManager.class))).thenReturn("application-name");
ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.packageName = "com.test";
PackageInfo packageInfo = new PackageInfo();
packageInfo.applicationInfo = applicationInfoMock;
ActivityInfo activityInfo = new ActivityInfo();
activityInfo.name = "Browser";
activityInfo.applicationInfo = applicationInfo;
ResolveInfo resolveInfo = new ResolveInfo();
resolveInfo.activityInfo = activityInfo;
PackageManager packageManager = mock(PackageManager.class);
when(packageManager.getPackageInfo(anyString(), anyInt())).thenReturn(packageInfo);
when(packageManager.resolveActivity(any(Intent.class), eq(PackageManager.MATCH_DEFAULT_ONLY))).thenReturn(resolveInfo);
TelephonyManager telephonyManager = mock(TelephonyManager.class);
when(telephonyManager.getSimOperator()).thenReturn("12345");
Context context = spy(RuntimeEnvironment.application);
when(context.getPackageManager()).thenReturn(packageManager);
when(context.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(telephonyManager);
ContextInspector contextInspector = mock(ContextInspector.class);
when(contextInspector.getContext()).thenReturn(context);
RuntimeEnvironment.application.getSharedPreferences("PayPalOTC", Context.MODE_PRIVATE).edit().putString("InstallationGUID", "installation-guid").apply();
return contextInspector;
}
use of com.paypal.android.sdk.onetouch.core.base.ContextInspector in project braintree_android by braintree.
the class FptiManagerUnitTest method setup.
@Before
public void setup() throws NameNotFoundException {
ContextInspector contextInspector = getMockContextInspector();
PayPalHttpClient httpClient = mock(PayPalHttpClient.class);
mFptiManager = spy(new FptiManager(contextInspector, httpClient));
}
Aggregations