com.facebook.imagepipeline.producers.Consumer Java Examples

The following examples show how to use com.facebook.imagepipeline.producers.Consumer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testGetFullFetchSupplier() {
  Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier =
      mImagePipeline.getDataSourceSupplier(
          mImageRequest, mCallerContext, ImageRequest.RequestLevel.FULL_FETCH);
  Producer<CloseableReference<CloseableImage>> decodedSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(decodedSequence);
  DataSource<CloseableReference<CloseableImage>> dataSource = dataSourceSupplier.get();
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(decodedSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
}
 
Example #2
Source File: CloseableProducerToDataSourceAdapterTest.java    From fresco with MIT License 6 votes vote down vote up
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mResourceReleaser = mock(ResourceReleaser.class);
  mResultRef1 = CloseableReference.of(new Object(), mResourceReleaser);
  mResultRef2 = CloseableReference.of(new Object(), mResourceReleaser);
  mResultRef3 = CloseableReference.of(new Object(), mResourceReleaser);
  mException = mock(Exception.class);

  mDataSubscriber1 = mock(DataSubscriber.class);
  mDataSubscriber2 = mock(DataSubscriber.class);

  mSettableProducerContext = mock(SettableProducerContext.class);
  mProducer = mock(Producer.class);
  mDataSource =
      CloseableProducerToDataSourceAdapter.create(
          mProducer, mSettableProducerContext, mRequestListener);
  ArgumentCaptor<Consumer> captor = ArgumentCaptor.forClass(Consumer.class);
  verify(mRequestListener).onRequestStart(mSettableProducerContext);
  verify(mProducer).produceResults(captor.capture(), any(SettableProducerContext.class));
  mInternalConsumer = captor.getValue();

  mDataSource.subscribe(mDataSubscriber1, CallerThreadExecutor.getInstance());
}
 
Example #3
Source File: CloseableProducerToDataSourceAdapterTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void test_NI_a_NL_C() {
  mInternalConsumer.onNewResult(null, Consumer.NO_FLAGS);
  verify(mDataSubscriber1).onNewResult(mDataSource);
  verifyWithResult(null, INTERMEDIATE);

  testSubscribe(NO_INTERACTIONS);

  mInternalConsumer.onNewResult(null, Consumer.IS_LAST);
  verify(mRequestListener).onRequestSuccess(mSettableProducerContext);
  verify(mDataSubscriber1).onNewResult(mDataSource);
  verify(mDataSubscriber2).onNewResult(mDataSource);
  verifyWithResult(null, LAST);

  testClose(FINISHED, 2);
}
 
Example #4
Source File: ProducerToDataSourceAdapterTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void test_NI_a_NL_C() {
  mInternalConsumer.onNewResult(null, Consumer.NO_FLAGS);
  verify(mDataSubscriber1).onNewResult(mDataSource);
  verifyWithResult(null, INTERMEDIATE);

  testSubscribe(NO_INTERACTIONS);

  mInternalConsumer.onNewResult(null, Consumer.IS_LAST);
  verify(mRequestListener).onRequestSuccess(mSettableProducerContext);
  verify(mDataSubscriber1).onNewResult(mDataSource);
  verify(mDataSubscriber2).onNewResult(mDataSource);
  verifyWithResult(null, LAST);

  testClose(FINISHED, 2);
}
 
Example #5
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testPrefetchToEncodedCacheDefaultPriority() {
  Producer<Void> prefetchProducerSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(mImageRequest))
      .thenReturn(prefetchProducerSequence);
  DataSource<Void> dataSource =
      mImagePipeline.prefetchToEncodedCache(mImageRequest, mCallerContext);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(prefetchProducerSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.MEDIUM);
}
 
Example #6
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testPrefetchToEncodedCacheCustomPriority() {
  Producer<Void> prefetchProducerSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(mImageRequest))
      .thenReturn(prefetchProducerSequence);
  DataSource<Void> dataSource =
      mImagePipeline.prefetchToEncodedCache(mImageRequest, mCallerContext, Priority.MEDIUM);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(prefetchProducerSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.MEDIUM);
}
 
Example #7
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testPrefetchToBitmapCache() {
  Producer<Void> prefetchProducerSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImagePrefetchProducerSequence(mImageRequest))
      .thenReturn(prefetchProducerSequence);
  DataSource<Void> dataSource =
      mImagePipeline.prefetchToBitmapCache(mImageRequest, mCallerContext);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(prefetchProducerSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.MEDIUM);
}
 
Example #8
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testFetchLocalEncodedImage() {
  Producer<CloseableReference<PooledByteBuffer>> encodedSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getEncodedImageProducerSequence(mImageRequest))
      .thenReturn(encodedSequence);
  when(mImageRequest.getSourceUri()).thenReturn(Uri.parse("file:///local/file"));
  DataSource<CloseableReference<PooledByteBuffer>> dataSource =
      mImagePipeline.fetchEncodedImage(mImageRequest, mCallerContext);
  assertFalse(dataSource.isFinished());
  ArgumentCaptor<ImageRequest> argumentCaptor = ArgumentCaptor.forClass(ImageRequest.class);
  verify(mRequestListener1)
      .onRequestStart(argumentCaptor.capture(), eq(mCallerContext), eq("0"), eq(false));
  ImageRequest capturedImageRequest = argumentCaptor.getValue();
  assertSame(mImageRequest.getSourceUri(), capturedImageRequest.getSourceUri());
  verify(mRequestListener2)
      .onRequestStart(argumentCaptor.capture(), eq(mCallerContext), eq("0"), eq(false));
  capturedImageRequest = argumentCaptor.getValue();
  assertSame(mImageRequest.getSourceUri(), capturedImageRequest.getSourceUri());
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(encodedSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
}
 
Example #9
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testFetchNetworkEncodedImage() {
  Producer<CloseableReference<PooledByteBuffer>> encodedSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getEncodedImageProducerSequence(mImageRequest))
      .thenReturn(encodedSequence);
  when(mImageRequest.getSourceUri()).thenReturn(Uri.parse("http://test"));
  DataSource<CloseableReference<PooledByteBuffer>> dataSource =
      mImagePipeline.fetchEncodedImage(mImageRequest, mCallerContext);
  assertFalse(dataSource.isFinished());
  ArgumentCaptor<ImageRequest> argumentCaptor = ArgumentCaptor.forClass(ImageRequest.class);
  verify(mRequestListener1)
      .onRequestStart(argumentCaptor.capture(), eq(mCallerContext), eq("0"), eq(false));
  ImageRequest capturedImageRequest = argumentCaptor.getValue();
  assertSame(mImageRequest.getSourceUri(), capturedImageRequest.getSourceUri());
  verify(mRequestListener2)
      .onRequestStart(argumentCaptor.capture(), eq(mCallerContext), eq("0"), eq(false));
  capturedImageRequest = argumentCaptor.getValue();
  assertSame(mImageRequest.getSourceUri(), capturedImageRequest.getSourceUri());
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(encodedSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
}
 
Example #10
Source File: ProducerToDataSourceAdapterTest.java    From fresco with MIT License 6 votes vote down vote up
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mResult1 = new Object();
  mResult2 = new Object();
  mResult3 = new Object();
  mException = mock(Exception.class);

  mDataSubscriber1 = mock(DataSubscriber.class);
  mDataSubscriber2 = mock(DataSubscriber.class);

  mSettableProducerContext = mock(SettableProducerContext.class);
  when(mSettableProducerContext.getId()).thenReturn(mRequestId);
  when(mSettableProducerContext.isPrefetch()).thenReturn(true);
  mProducer = mock(Producer.class);
  mDataSource =
      ProducerToDataSourceAdapter.create(mProducer, mSettableProducerContext, mRequestListener);
  ArgumentCaptor<Consumer> captor = ArgumentCaptor.forClass(Consumer.class);
  verify(mRequestListener).onRequestStart(mSettableProducerContext);
  verify(mProducer).produceResults(captor.capture(), any(SettableProducerContext.class));
  mInternalConsumer = captor.getValue();

  mDataSource.subscribe(mDataSubscriber1, CallerThreadExecutor.getInstance());
}
 
Example #11
Source File: AbstractProducerToDataSourceAdapter.java    From fresco with MIT License 6 votes vote down vote up
private Consumer<T> createConsumer() {
  return new BaseConsumer<T>() {
    @Override
    protected void onNewResultImpl(@Nullable T newResult, @Status int status) {
      AbstractProducerToDataSourceAdapter.this.onNewResultImpl(
          newResult, status, mSettableProducerContext);
    }

    @Override
    protected void onFailureImpl(Throwable throwable) {
      AbstractProducerToDataSourceAdapter.this.onFailureImpl(throwable);
    }

    @Override
    protected void onCancellationImpl() {
      AbstractProducerToDataSourceAdapter.this.onCancellationImpl();
    }

    @Override
    protected void onProgressUpdateImpl(float progress) {
      AbstractProducerToDataSourceAdapter.this.setProgress(progress);
    }
  };
}
 
Example #12
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testFetchDecodedImage() {
  Producer<CloseableReference<CloseableImage>> decodedSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(decodedSequence);
  DataSource<CloseableReference<CloseableImage>> dataSource =
      mImagePipeline.fetchDecodedImage(mImageRequest, mCallerContext);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(decodedSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
}
 
Example #13
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testFetchDecodedImageWithRequestLevel() {
  Producer<CloseableReference<CloseableImage>> decodedSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(decodedSequence);
  DataSource<CloseableReference<CloseableImage>> dataSource =
      mImagePipeline.fetchDecodedImage(
          mImageRequest, mCallerContext, ImageRequest.RequestLevel.DISK_CACHE);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(decodedSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
  assertEquals(
      producerContextArgumentCaptor.getValue().getLowestPermittedRequestLevel(),
      ImageRequest.RequestLevel.DISK_CACHE);
}
 
Example #14
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testFetchFromBitmapCacheDueToMethodCall() {
  Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(bitmapCacheSequence);
  mImagePipeline.fetchImageFromBitmapCache(mImageRequest, mCallerContext);
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(bitmapCacheSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
  assertEquals(
      producerContextArgumentCaptor.getValue().getLowestPermittedRequestLevel(),
      ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE);
}
 
Example #15
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testFetchFromBitmapCacheDueToImageRequest() {
  Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class);
  when(mImageRequest.getLowestPermittedRequestLevel())
      .thenReturn(ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(bitmapCacheSequence);
  mImagePipeline.fetchDecodedImage(mImageRequest, mCallerContext);
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(bitmapCacheSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
  assertEquals(
      producerContextArgumentCaptor.getValue().getLowestPermittedRequestLevel(),
      ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE);
}
 
Example #16
Source File: ImagePipelineTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testGetBitmapCacheGetSupplier() {
  Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier =
      mImagePipeline.getDataSourceSupplier(
          mImageRequest, mCallerContext, ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE);
  Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(bitmapCacheSequence);
  dataSourceSupplier.get();
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(bitmapCacheSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
}
 
Example #17
Source File: AbstractProducerToDataSourceAdapter.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
private Consumer<T> createConsumer() {
  return new BaseConsumer<T>() {
    @Override
    protected void onNewResultImpl(@Nullable T newResult, boolean isLast) {
      AbstractProducerToDataSourceAdapter.this.onNewResultImpl(newResult, isLast);
    }

    @Override
    protected void onFailureImpl(Throwable throwable) {
      AbstractProducerToDataSourceAdapter.this.onFailureImpl(throwable);
    }

    @Override
    protected void onCancellationImpl() {
      AbstractProducerToDataSourceAdapter.this.onCancellationImpl();
    }
  };
}
 
Example #18
Source File: ImagePipelineTest.java    From fresco with MIT License 5 votes vote down vote up
private void verifyPrefetchToDiskCache(
    DataSource<Void> dataSource, Producer<Void> prefetchProducerSequence, Priority priority) {
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(prefetchProducerSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(priority, producerContextArgumentCaptor.getValue().getPriority());
}
 
Example #19
Source File: CloseableProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_I_NL_a_C() {
  testNewResult(mResultRef1, INTERMEDIATE, 1);

  mInternalConsumer.onNewResult(null, Consumer.IS_LAST);
  verify(mRequestListener).onRequestSuccess(mSettableProducerContext);
  verify(mDataSubscriber1).onNewResult(mDataSource);
  verifyWithResult(null, LAST);

  testSubscribe(ON_NEW_RESULT);
  testClose(FINISHED, 2);
}
 
Example #20
Source File: CloseableProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_C_I_a() {
  testClose(NOT_FINISHED, 1);
  mInternalConsumer.onNewResult(mResultRef2, Consumer.NO_FLAGS);
  verifyClosed(NOT_FINISHED, null);
  testSubscribe(NO_INTERACTIONS);
}
 
Example #21
Source File: CloseableProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_NI_S_a_C() {
  mInternalConsumer.onNewResult(null, Consumer.NO_FLAGS);
  verify(mDataSubscriber1).onNewResult(mDataSource);
  verifyWithResult(null, INTERMEDIATE);

  testNewResult(mResultRef1, LAST, 1);
  testSubscribe(ON_NEW_RESULT);
  testClose(FINISHED, 2);
}
 
Example #22
Source File: CloseableProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_F_L_a_C() {
  testFailure(null, 1);
  mInternalConsumer.onNewResult(mResultRef1, Consumer.IS_LAST);
  verifyFailed(null, mException);
  testSubscribe(ON_FAILURE);
  testClose(mException);
}
 
Example #23
Source File: CloseableProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_F_I_a_C() {
  testFailure(null, 1);
  mInternalConsumer.onNewResult(mResultRef1, Consumer.NO_FLAGS);
  verifyFailed(null, mException);
  testSubscribe(ON_FAILURE);
  testClose(mException);
}
 
Example #24
Source File: CloseableProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_L_I_a_C() {
  testNewResult(mResultRef1, LAST, 1);
  mInternalConsumer.onNewResult(mResultRef2, Consumer.NO_FLAGS);
  verifyWithResult(mResultRef1, LAST);
  testSubscribe(ON_NEW_RESULT);
  testClose(FINISHED, 2);
}
 
Example #25
Source File: ProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_C_I_a() {
  testClose(NOT_FINISHED, 1);
  mInternalConsumer.onNewResult(mResult2, Consumer.NO_FLAGS);
  verifyClosed(NOT_FINISHED, null);
  testSubscribe(NO_INTERACTIONS);
}
 
Example #26
Source File: ProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_C_L_a() {
  testClose(NOT_FINISHED, 1);
  mInternalConsumer.onNewResult(mResult2, Consumer.IS_LAST);
  verifyClosed(NOT_FINISHED, null);
  testSubscribe(NO_INTERACTIONS);
}
 
Example #27
Source File: ProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_L_I_a_C() {
  testNewResult(mResult1, LAST, 1);
  mInternalConsumer.onNewResult(mResult2, Consumer.NO_FLAGS);
  verifyWithResult(mResult1, LAST);
  testSubscribe(ON_NEW_RESULT);
  testClose(FINISHED, 2);
}
 
Example #28
Source File: ProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_L_L_a_C() {
  testNewResult(mResult1, LAST, 1);
  mInternalConsumer.onNewResult(mResult2, Consumer.IS_LAST);
  verifyWithResult(mResult1, LAST);
  testSubscribe(ON_NEW_RESULT);
  testClose(FINISHED, 2);
}
 
Example #29
Source File: ProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_F_I_a_C() {
  testFailure(null, 1);
  mInternalConsumer.onNewResult(mResult1, Consumer.NO_FLAGS);
  verifyFailed(null, mException);
  testSubscribe(ON_FAILURE);
  testClose(mException);
}
 
Example #30
Source File: ProducerToDataSourceAdapterTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void test_F_L_a_C() {
  testFailure(null, 1);
  mInternalConsumer.onNewResult(mResult1, Consumer.IS_LAST);
  verifyFailed(null, mException);
  testSubscribe(ON_FAILURE);
  testClose(mException);
}