protected void setUp() throws Exception { super.setUp(); // Tests that need this set should explicitly set it. GraphRequest.setDefaultBatchApplicationId(null); }
protected void setBatchApplicationIdForTestApp() { readApplicationIdAndSecret(); GraphRequest.setDefaultBatchApplicationId(applicationId); }
GraphRequest.setDefaultBatchApplicationId(testApplicationId);
GraphRequest.setDefaultBatchApplicationId(appId);
@LargeTest public void testBatchOnProgressCallbackIsCalled() { final AtomicInteger count = new AtomicInteger(); final AccessToken accessToken = getAccessTokenForSharedUser(); String appId = getApplicationId(); GraphRequest.setDefaultBatchApplicationId(appId); GraphRequest request1 = GraphRequest.newGraphPathRequest(accessToken, "4", null); assertNotNull(request1); GraphRequest request2 = GraphRequest.newGraphPathRequest(accessToken, "4", null); assertNotNull(request2); GraphRequestBatch batch = new GraphRequestBatch(request1, request2); batch.addCallback(new GraphRequestBatch.OnProgressCallback() { @Override public void onBatchCompleted(GraphRequestBatch batch) { } @Override public void onBatchProgress(GraphRequestBatch batch, long current, long max) { count.incrementAndGet(); } }); batch.executeAndWait(); assertEquals(1, count.get()); }
@LargeTest public void testBatchLastOnProgressCallbackIsCalledOnce() { final AtomicInteger count = new AtomicInteger(); final AccessToken accessToken = getAccessTokenForSharedUser(); String appId = getApplicationId(); GraphRequest.setDefaultBatchApplicationId(appId); GraphRequest request1 = GraphRequest.newGraphPathRequest(accessToken, "4", null); assertNotNull(request1); GraphRequest request2 = GraphRequest.newGraphPathRequest(accessToken, "4", null); assertNotNull(request2); GraphRequestBatch batch = new GraphRequestBatch(request1, request2); batch.addCallback(new GraphRequestBatch.OnProgressCallback() { @Override public void onBatchCompleted(GraphRequestBatch batch) { } @Override public void onBatchProgress(GraphRequestBatch batch, long current, long max) { if (current == max) { count.incrementAndGet(); } else if (current > max) { count.set(0); } } }); batch.executeAndWait(); assertEquals(1, count.get()); }