Search in sources :

Example 1 with JsonReader

use of com.airbnb.lottie.parser.moshi.JsonReader in project lottie-android by airbnb.

the class LottieCompositionFactoryTest method testZeroCacheWorks.

@Test
public void testZeroCacheWorks() {
    JsonReader reader = JsonReader.of(buffer(source(getNeverCompletingInputStream())));
    LottieCompositionFactory.setMaxCacheSize(1);
    LottieResult<LottieComposition> taskFoo1 = LottieCompositionFactory.fromJsonReaderSync(reader, "foo");
    LottieResult<LottieComposition> taskFoo2 = LottieCompositionFactory.fromJsonReaderSync(reader, "foo");
    assertNotSame(taskFoo1, taskFoo2);
}
Also used : JsonReader(com.airbnb.lottie.parser.moshi.JsonReader) Test(org.junit.Test)

Example 2 with JsonReader

use of com.airbnb.lottie.parser.moshi.JsonReader in project lottie-android by airbnb.

the class LottieCompositionFactoryTest method testLoadJsonReader.

@Test
public void testLoadJsonReader() {
    JsonReader reader = JsonReader.of(buffer(source(new ByteArrayInputStream(JSON.getBytes()))));
    LottieResult<LottieComposition> result = LottieCompositionFactory.fromJsonReaderSync(reader, "json");
    assertNull(result.getException());
    assertNotNull(result.getValue());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) JsonReader(com.airbnb.lottie.parser.moshi.JsonReader) Test(org.junit.Test)

Example 3 with JsonReader

use of com.airbnb.lottie.parser.moshi.JsonReader in project lottie-android by airbnb.

the class LottieCompositionFactoryTest method testNullMultipleTimesAsync.

@Test
public void testNullMultipleTimesAsync() {
    JsonReader reader = JsonReader.of(buffer(source(getNeverCompletingInputStream())));
    LottieTask<LottieComposition> task1 = LottieCompositionFactory.fromJsonReader(reader, null);
    LottieTask<LottieComposition> task2 = LottieCompositionFactory.fromJsonReader(reader, null);
    assertNotSame(task1, task2);
}
Also used : JsonReader(com.airbnb.lottie.parser.moshi.JsonReader) Test(org.junit.Test)

Example 4 with JsonReader

use of com.airbnb.lottie.parser.moshi.JsonReader in project lottie-android by airbnb.

the class LottieCompositionFactoryTest method testLoadInvalidJsonReader.

@Test
public void testLoadInvalidJsonReader() {
    JsonReader reader = JsonReader.of(buffer(source(new ByteArrayInputStream(NOT_JSON.getBytes()))));
    LottieResult<LottieComposition> result = LottieCompositionFactory.fromJsonReaderSync(reader, "json");
    assertNotNull(result.getException());
    assertNull(result.getValue());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) JsonReader(com.airbnb.lottie.parser.moshi.JsonReader) Test(org.junit.Test)

Example 5 with JsonReader

use of com.airbnb.lottie.parser.moshi.JsonReader in project lottie-android by airbnb.

the class LottieCompositionFactoryTest method testNullMultipleTimesSync.

@Test
public void testNullMultipleTimesSync() {
    JsonReader reader = JsonReader.of(buffer(source(getNeverCompletingInputStream())));
    LottieResult<LottieComposition> task1 = LottieCompositionFactory.fromJsonReaderSync(reader, null);
    LottieResult<LottieComposition> task2 = LottieCompositionFactory.fromJsonReaderSync(reader, null);
    assertNotSame(task1, task2);
}
Also used : JsonReader(com.airbnb.lottie.parser.moshi.JsonReader) Test(org.junit.Test)

Aggregations

JsonReader (com.airbnb.lottie.parser.moshi.JsonReader)5 Test (org.junit.Test)5 ByteArrayInputStream (java.io.ByteArrayInputStream)2