package com.bumptech.glide.load.resource;
import static com.bumptech.glide.tests.Util.mockResource;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import android.app.Application;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.tests.KeyAssertions;
import com.bumptech.glide.tests.Util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.robolectric.RuntimeEnvironment;
@RunWith(JUnit4.class)
public class UnitTransformationTest {
private Application app;
@Before
public void setUp() {
app = RuntimeEnvironment.application;
}
@Test
public void testReturnsGivenResource() {
Resource<Object> resource = mockResource();
UnitTransformation<Object> transformation = UnitTransformation.get();
assertEquals(resource, transformation.transform(app, resource, 10, 10));
}
@Test
public void testEquals() throws NoSuchAlgorithmException {
KeyAssertions.assertSame(UnitTransformation.get(), UnitTransformation.get());
@SuppressWarnings("unchecked") Transformation<Object> other = mock(Transformation.class);
doAnswer(new Util.WriteDigest("other")).when(other)
.updateDiskCacheKey(any(MessageDigest.class));
KeyAssertions.assertDifferent(UnitTransformation.get(), other);
}
}