RealPosClient implements PosClient { @Override public boolean isPointOfSaleInstalled() { List<ResolveInfo> activities = queryChargeActivities(); for (ResolveInfo activity : activities) { String packageName = activity.activityInfo.packageName; if (isPointOfSale(packageName)) { return true; } } return false; } RealPosClient(Context context, String clientId); @NonNull @Override Intent createChargeIntent(@NonNull ChargeRequest chargeRequest); @Override boolean isPointOfSaleInstalled(); @Override void launchPointOfSale(); @Override void openPointOfSalePlayStoreListing(); @NonNull @Override ChargeRequest.Success parseChargeSuccess(@NonNull Intent data); @NonNull @Override ChargeRequest.Error parseChargeError(@NonNull Intent data);  }
@Test public void pointOfSaleInstalled() { assertThat(client.isPointOfSaleInstalled()).isTrue(); }
@Test public void pointOfSaleNotInstalled() { chargeActivities.clear(); assertThat(client.isPointOfSaleInstalled()).isFalse(); }
@Test public void betaFlavorInstalled() { chargeActivities.clear(); installApp("com.squareup.beta", 2, POINT_OF_SALE_SIGNATURE); assertThat(client.isPointOfSaleInstalled()).isTrue(); }
@Test public void invalidPackagePrefix() { chargeActivities.clear(); installApp("com.triangleup", 2, POINT_OF_SALE_SIGNATURE); assertThat(client.isPointOfSaleInstalled()).isFalse(); }
@Test public void invalidSignature() { chargeActivities.clear(); installApp("com.squareup", 2, INVALID_SIGNATURE); assertThat(client.isPointOfSaleInstalled()).isFalse(); }
@Test public void multipleFlavorsInstalled() { chargeActivities.clear(); installApp("com.squareup", 2, POINT_OF_SALE_SIGNATURE); installApp("com.squareup.beta", 3, POINT_OF_SALE_SIGNATURE); assertThat(client.isPointOfSaleInstalled()).isTrue(); }