Testing Fixed Preload Size Provider Implementation in Glide
This test suite validates the FixedPreloadSizeProvider class in the Glide image loading library. It focuses on verifying the provider’s ability to consistently return predefined width and height dimensions for preloading images.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
bumptech/glide
library/test/src/test/java/com/bumptech/glide/util/FixedPreloadSizeProviderTest.java
package com.bumptech.glide.util;
import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.google.common.truth.Truth.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = ROBOLECTRIC_SDK)
public class FixedPreloadSizeProviderTest {
// containsExactly doesn't need a return value check.
@SuppressWarnings("ResultOfMethodCallIgnored")
@Test
public void testReturnsGivenSize() {
int width = 500;
int height = 1234;
FixedPreloadSizeProvider<Object> provider = new FixedPreloadSizeProvider<>(width, height);
int[] size = provider.getPreloadSize(new Object(), 0, 0);
assertThat(size).asList().containsExactly(width, height);
}
}