@Override public int isBillingSupported(@Nonnull String product, int apiVersion, @Nonnull Bundle extraParams, @Nonnull RequestListener<Object> listener) { Check.isNotEmpty(product); return runWhenConnected(new BillingSupportedRequest(product, apiVersion, extraParams), wrapListener(listener), mTag); }
@Override public void start(@Nonnull IInAppBillingService service, @Nonnull String packageName) throws RemoteException { final int response = mExtraParams != null ? service.isBillingSupportedExtraParams(mApiVersion, packageName, mProduct, mExtraParams) : service.isBillingSupported(mApiVersion, packageName, mProduct); if (!handleError(response)) { onSuccess(new Object()); } }
@Test public void testShouldUseExtraParams() throws Exception { final Bundle extraParams = new Bundle(); extraParams.putString("extra", "test"); final BillingSupportedRequest request = new BillingSupportedRequest("product", Billing.V7, extraParams); final IInAppBillingService service = mock(IInAppBillingService.class); request.start(service, "package"); verify(service).isBillingSupportedExtraParams(eq(Billing.V7), eq("package"), eq("product"), eq(extraParams)); } }
@Test public void testShouldNotBeCachedWithExtraParams() throws Exception { final BillingSupportedRequest request = new BillingSupportedRequest("test", Billing.V7, new Bundle()); assertNull(request.getCacheKey()); }
@Test public void testShouldHaveDifferentCacheKeys() throws Exception { final BillingSupportedRequest r1 = newRequest("test1"); final BillingSupportedRequest r2 = newRequest("test2"); assertNotEquals(r1.getCacheKey(), r2.getCacheKey()); }
@Override public int isBillingSupported(@Nonnull String product, int apiVersion, @Nonnull RequestListener<Object> listener) { Check.isNotEmpty(product); return runWhenConnected(new BillingSupportedRequest(product, apiVersion, null), wrapListener(listener), mTag); }
@Nonnull private BillingSupportedRequest newRequest(@Nonnull String product) { return new BillingSupportedRequest(product); }