當前位置: 首頁>>代碼示例>>Java>>正文


Java UploadTask.TaskSnapshot方法代碼示例

本文整理匯總了Java中com.google.firebase.storage.UploadTask.TaskSnapshot方法的典型用法代碼示例。如果您正苦於以下問題:Java UploadTask.TaskSnapshot方法的具體用法?Java UploadTask.TaskSnapshot怎麽用?Java UploadTask.TaskSnapshot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.firebase.storage.UploadTask的用法示例。


在下文中一共展示了UploadTask.TaskSnapshot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testPutStream_notSuccessful

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test public void testPutStream_notSuccessful() {
  mockNotSuccessfulResultForTask(mockUploadTask, new IllegalStateException());
  when(mockStorageReference.putStream(mockInputStream)).thenReturn(mockUploadTask);

  TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();

  RxFirebaseStorage.putStream(mockStorageReference, mockInputStream).subscribe(obs);
  verifyAddOnCompleteListenerForTask(mockUploadTask);

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertError(IllegalStateException.class);
  obs.assertNoValues();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例2: testPutFileWithMetadata

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test public void testPutFileWithMetadata() {
  mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot);
  when(mockStorageReference.putFile(mockUri, mockStorageMetadata)).thenReturn(mockUploadTask);
  when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
  when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);

  TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();

  RxFirebaseStorage.putFile(mockStorageReference, mockUri, mockStorageMetadata).subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockUploadTask);

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() {
    @Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception {
      return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
          && taskSnapshot.getTotalByteCount() == 1000L;
    }
  });
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:27,代碼來源:RxFirebaseStorageTest.java

示例3: testPutStream

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test public void testPutStream() {
  mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot);
  when(mockStorageReference.putStream(mockInputStream)).thenReturn(mockUploadTask);
  when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
  when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);

  TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();

  RxFirebaseStorage.putStream(mockStorageReference, mockInputStream).subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockUploadTask);

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() {
    @Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception {
      return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
          && taskSnapshot.getTotalByteCount() == 1000L;
    }
  });
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:27,代碼來源:RxFirebaseStorageTest.java

示例4: testPutFile

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test public void testPutFile() {
  mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot);
  when(mockStorageReference.putFile(mockUri)).thenReturn(mockUploadTask);
  when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
  when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);

  TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();

  RxFirebaseStorage.putFile(mockStorageReference, mockUri).subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockUploadTask);

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() {
    @Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception {
      return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
          && taskSnapshot.getTotalByteCount() == 1000L;
    }
  });
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:27,代碼來源:RxFirebaseStorageTest.java

示例5: testPutFileWithMetadata_notSuccessful

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test public void testPutFileWithMetadata_notSuccessful() {
  mockNotSuccessfulResultForTask(mockUploadTask, new IllegalStateException());
  when(mockStorageReference.putFile(mockUri, mockStorageMetadata)).thenReturn(mockUploadTask);

  TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();

  RxFirebaseStorage.putFile(mockStorageReference, mockUri, mockStorageMetadata).subscribe(obs);
  verifyAddOnCompleteListenerForTask(mockUploadTask);

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertError(IllegalStateException.class);
  obs.assertNoValues();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例6: testPutBytes

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test public void testPutBytes() {
  mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot);
  when(mockStorageReference.putBytes(new byte[] { 1, 2, 3 })).thenReturn(mockUploadTask);
  when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
  when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);

  TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();

  RxFirebaseStorage.putBytes(mockStorageReference, new byte[] { 1, 2, 3 }).subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockUploadTask);

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() {
    @Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception {
      return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
          && taskSnapshot.getTotalByteCount() == 1000L;
    }
  });
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:27,代碼來源:RxFirebaseStorageTest.java

示例7: putStream

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test
public void putStream() throws InterruptedException {

   TestObserver<UploadTask.TaskSnapshot> storageTestObserver =
      RxFirebaseStorage.putStream(mockStorageRef, stream)
         .test();

   testOnSuccessListener.getValue().onSuccess(uploadSnapshot);

   verify(mockStorageRef).putStream(stream);

   storageTestObserver.assertNoErrors()
      .assertValueCount(1)
      .assertValueSet(Collections.singletonList(uploadSnapshot))
      .assertComplete()
      .dispose();
}
 
開發者ID:FrangSierra,項目名稱:Rx2Firebase,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例8: putFileMetadata

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test
public void putFileMetadata() throws InterruptedException {

   TestObserver<UploadTask.TaskSnapshot> storageTestObserver =
      RxFirebaseStorage.putFile(mockStorageRef, uri, metadata)
         .test();

   testOnSuccessListener.getValue().onSuccess(uploadSnapshot);

   verify(mockStorageRef).putFile(uri, metadata);

   storageTestObserver.assertNoErrors()
      .assertValueCount(1)
      .assertValueSet(Collections.singletonList(uploadSnapshot))
      .assertComplete()
      .dispose();
}
 
開發者ID:FrangSierra,項目名稱:Rx2Firebase,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例9: putBytesMetadata

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test
public void putBytesMetadata() throws InterruptedException {

   TestObserver<UploadTask.TaskSnapshot> storageTestObserver =
      RxFirebaseStorage.putBytes(mockStorageRef, notNullbytes, metadata)
         .test();

   testOnSuccessListener.getValue().onSuccess(uploadSnapshot);

   verify(mockStorageRef).putBytes(notNullbytes, metadata);

   storageTestObserver.assertNoErrors()
      .assertValueCount(1)
      .assertValueSet(Collections.singletonList(uploadSnapshot))
      .assertComplete()
      .dispose();
}
 
開發者ID:FrangSierra,項目名稱:Rx2Firebase,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例10: putBytes

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test
public void putBytes() throws InterruptedException {

   TestObserver<UploadTask.TaskSnapshot> storageTestObserver =
      RxFirebaseStorage.putBytes(mockStorageRef, notNullbytes)
         .test();

   testOnSuccessListener.getValue().onSuccess(uploadSnapshot);

   verify(mockStorageRef).putBytes(notNullbytes);

   storageTestObserver.assertNoErrors()
      .assertValueCount(1)
      .assertValueSet(Collections.singletonList(uploadSnapshot))
      .assertComplete()
      .dispose();
}
 
開發者ID:FrangSierra,項目名稱:Rx2Firebase,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例11: putStreamMetadata

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test
public void putStreamMetadata() throws InterruptedException {

   TestObserver<UploadTask.TaskSnapshot> storageTestObserver =
      RxFirebaseStorage.putStream(mockStorageRef, stream, metadata)
         .test();

   testOnSuccessListener.getValue().onSuccess(uploadSnapshot);

   verify(mockStorageRef).putStream(stream, metadata);

   storageTestObserver.assertNoErrors()
      .assertValueCount(1)
      .assertValueSet(Collections.singletonList(uploadSnapshot))
      .assertComplete()
      .dispose();
}
 
開發者ID:FrangSierra,項目名稱:Rx2Firebase,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例12: putFileMetadata

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test
public void putFileMetadata() throws InterruptedException {

    TestSubscriber<UploadTask.TaskSnapshot> testSubscriber = new TestSubscriber<>();
    RxFirebaseStorage.putFile(mockStorageRef, uri, metadata)
            .subscribeOn(Schedulers.immediate())
            .subscribe(testSubscriber);

    testOnSuccessListener.getValue().onSuccess(uploadSnapshot);

    verify(mockStorageRef).putFile(uri, metadata);

    testSubscriber.assertNoErrors();
    testSubscriber.assertValueCount(1);
    testSubscriber.assertReceivedOnNext(Collections.singletonList(uploadSnapshot));
    testSubscriber.assertNotCompleted();
    testSubscriber.unsubscribe();
}
 
開發者ID:nmoskalenko,項目名稱:RxFirebase,代碼行數:19,代碼來源:RxFirebaseStorageTests.java

示例13: putFileMetadataAndUri

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test
public void putFileMetadataAndUri() throws InterruptedException {

    TestSubscriber<UploadTask.TaskSnapshot> testSubscriber = new TestSubscriber<>();
    RxFirebaseStorage.putFile(mockStorageRef, uri, metadata, uri)
            .subscribeOn(Schedulers.immediate())
            .subscribe(testSubscriber);

    testOnSuccessListener.getValue().onSuccess(uploadSnapshot);

    verify(mockStorageRef).putFile(uri, metadata, uri);

    testSubscriber.assertNoErrors();
    testSubscriber.assertValueCount(1);
    testSubscriber.assertReceivedOnNext(Collections.singletonList(uploadSnapshot));
    testSubscriber.assertNotCompleted();
    testSubscriber.unsubscribe();
}
 
開發者ID:nmoskalenko,項目名稱:RxFirebase,代碼行數:19,代碼來源:RxFirebaseStorageTests.java

示例14: putStream

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test
public void putStream() throws InterruptedException {

    TestSubscriber<UploadTask.TaskSnapshot> testSubscriber = new TestSubscriber<>();
    RxFirebaseStorage.putStream(mockStorageRef, stream)
            .subscribeOn(Schedulers.immediate())
            .subscribe(testSubscriber);

    testOnSuccessListener.getValue().onSuccess(uploadSnapshot);

    verify(mockStorageRef).putStream(stream);

    testSubscriber.assertNoErrors();
    testSubscriber.assertValueCount(1);
    testSubscriber.assertReceivedOnNext(Collections.singletonList(uploadSnapshot));
    testSubscriber.assertNotCompleted();
    testSubscriber.unsubscribe();
}
 
開發者ID:nmoskalenko,項目名稱:RxFirebase,代碼行數:19,代碼來源:RxFirebaseStorageTests.java

示例15: putBytesNoData

import com.google.firebase.storage.UploadTask; //導入方法依賴的package包/類
@Test
public void putBytesNoData() throws InterruptedException {

   TestObserver<UploadTask.TaskSnapshot> storageTestObserver =
      RxFirebaseStorage.putBytes(mockStorageRef, nullBytes)
         .test();

   testOnFailureListener.getValue().onFailure(NULL_FIREBASE_EXCEPTION);

   verify(mockStorageRef).putBytes(nullBytes);

   storageTestObserver.assertError(NULL_FIREBASE_EXCEPTION)
      .assertValueSet(Collections.singletonList(uploadSnapshot))
      .assertNotComplete()
      .dispose();
}
 
開發者ID:FrangSierra,項目名稱:Rx2Firebase,代碼行數:17,代碼來源:RxFirebaseStorageTest.java


注:本文中的com.google.firebase.storage.UploadTask.TaskSnapshot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。