aboutsummaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorSam Judd <judds@google.com>2014-11-03 07:56:12 -0800
committerSam Judd <judds@google.com>2014-11-03 07:56:12 -0800
commit8588abe9e8967252c789d239e23ff1bfc3c26b21 (patch)
treecb522ade838f1d19b199efd122f6ef91a49cc869 /library
parentf4d511ebf70c55d9224b57e6ff390373c0e2b12e (diff)
downloadglide-8588abe9e8967252c789d239e23ff1bfc3c26b21.tar.gz
Replace Hamcrest with Truth.
Fewer static imports, better wrangling of generics (particularly when asserting contains), and, least of all, better internal support.
Diffstat (limited to 'library')
-rw-r--r--library/build.gradle3
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/ListPreloaderTest.java5
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/data/HttpUrlFetcherServerTest.java22
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/data/MediaStoreThumbFetcherTest.java5
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/engine/EngineTest.java20
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPoolTest.java5
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/engine/cache/MemorySizeCalculatorTest.java19
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/engine/executor/FifoPriorityThreadPoolExecutorTest.java12
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillRunnerTest.java18
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillerTest.java20
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/model/ImageVideoWrapperEncoderTest.java7
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/model/stream/HttpUrlGlideUrlLoaderTest.java5
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoderTest.java5
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/GlideBitmapDrawableTest.java14
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/StreamBitmapDecoderTest.java9
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/TransformationUtilsTest.java18
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/resource/gif/GifFrameModelLoaderTest.java5
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapResourceEncoderTest.java7
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceDecoderTest.java7
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceEncoderTest.java7
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/load/resource/transcode/BitmapBytesTranscoderTest.java10
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/manager/ConnectivityMonitorFactoryTest.java7
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/manager/DefaultConnectivityMonitorTest.java12
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java7
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/request/target/GlideDrawableImageViewTargetTest.java12
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/request/target/ImageViewTargetFactoryTest.java15
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/request/target/ViewTargetTest.java9
-rw-r--r--library/src/androidTest/java/com/bumptech/glide/tests/KeyAssertions.java8
28 files changed, 126 insertions, 167 deletions
diff --git a/library/build.gradle b/library/build.gradle
index 35205660..b9706b50 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -24,8 +24,7 @@ dependencies {
androidTestCompile 'com.google.guava:guava-testlib:18.0'
androidTestCompile "com.android.support:support-v4:${SUPPORT_V4_VERSION}"
- androidTestCompile "org.hamcrest:hamcrest-core:${HAMCREST_VERSION}"
- androidTestCompile "org.hamcrest:hamcrest-library:${HAMCREST_VERSION}"
+ androidTestCompile "com.google.truth:truth:${TRUTH_VERSION}"
androidTestCompile "junit:junit:${JUNIT_VERSION}"
androidTestCompile "org.mockito:mockito-all:${MOCKITO_VERSION}"
androidTestCompile "org.robolectric:robolectric:${ROBOLECTRIC_VERSION}"
diff --git a/library/src/androidTest/java/com/bumptech/glide/ListPreloaderTest.java b/library/src/androidTest/java/com/bumptech/glide/ListPreloaderTest.java
index 2bfdf18c..3e525cfa 100644
--- a/library/src/androidTest/java/com/bumptech/glide/ListPreloaderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/ListPreloaderTest.java
@@ -12,9 +12,8 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.hamcrest.Matchers.containsInAnyOrder;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -233,7 +232,7 @@ public class ListPreloaderTest {
preloader.onScroll(null, 1, 10, 30);
- assertThat(loadedObjects, containsInAnyOrder(objects.toArray()));
+ assertThat(loadedObjects).containsAllIn(objects);
}
private static class ListPreloaderAdapter extends ListPreloader<Object> {
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/data/HttpUrlFetcherServerTest.java b/library/src/androidTest/java/com/bumptech/glide/load/data/HttpUrlFetcherServerTest.java
index 0440dfd7..f7265b4b 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/data/HttpUrlFetcherServerTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/data/HttpUrlFetcherServerTest.java
@@ -20,10 +20,8 @@ import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.endsWith;
-import static org.hamcrest.Matchers.equalTo;
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
@@ -61,7 +59,7 @@ public class HttpUrlFetcherServerTest {
.setResponseCode(200));
HttpUrlFetcher fetcher = getFetcher();
InputStream is = fetcher.loadData(Priority.HIGH);
- assertThat(isToString(is), equalTo(expected));
+ assertEquals(expected, isToString(is));
}
@Test
@@ -74,7 +72,7 @@ public class HttpUrlFetcherServerTest {
.setResponseCode(200)
.setBody(expected));
InputStream is = getFetcher().loadData(Priority.LOW);
- assertThat(isToString(is), equalTo(expected));
+ assertEquals(expected, isToString(is));
}
@Test
@@ -87,7 +85,7 @@ public class HttpUrlFetcherServerTest {
.setResponseCode(200)
.setBody(expected));
InputStream is = getFetcher().loadData(Priority.LOW);
- assertThat(isToString(is), equalTo(expected));
+ assertEquals(expected, isToString(is));
}
@Test
@@ -100,11 +98,11 @@ public class HttpUrlFetcherServerTest {
.setResponseCode(200)
.setBody(expected));
InputStream is = getFetcher().loadData(Priority.NORMAL);
- assertThat(isToString(is), equalTo(expected));
+ assertEquals(expected, isToString(is));
mockWebServer.takeRequest();
RecordedRequest second = mockWebServer.takeRequest();
- assertThat(second.getPath(), endsWith("/redirect"));
+ assertThat(second.getPath()).endsWith("/redirect");
}
@Test
@@ -121,11 +119,11 @@ public class HttpUrlFetcherServerTest {
.setResponseCode(200).setBody(expected));
InputStream is = getFetcher().loadData(Priority.NORMAL);
- assertThat(isToString(is), equalTo(expected));
+ assertEquals(expected, isToString(is));
- assertThat(mockWebServer.takeRequest().getPath(), containsString(DEFAULT_PATH));
+ assertThat(mockWebServer.takeRequest().getPath()).contains(DEFAULT_PATH);
for (int i = 0; i < numRedirects; i++) {
- assertThat(mockWebServer.takeRequest().getPath(), containsString(redirectBase + i));
+ assertThat(mockWebServer.takeRequest().getPath()).contains(redirectBase + i);
}
}
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/data/MediaStoreThumbFetcherTest.java b/library/src/androidTest/java/com/bumptech/glide/load/data/MediaStoreThumbFetcherTest.java
index c62661a9..c29b12fc 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/data/MediaStoreThumbFetcherTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/data/MediaStoreThumbFetcherTest.java
@@ -13,9 +13,8 @@ import org.robolectric.annotation.Config;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import static org.hamcrest.Matchers.containsString;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
@@ -90,7 +89,7 @@ public class MediaStoreThumbFetcherTest {
@Test
public void testContainsAllRelevantPartsInId() {
String id = harness.get().getId();
- assertThat(id, containsString(harness.uri.toString()));
+ assertThat(id).contains(harness.uri.toString());
}
@SuppressWarnings("unchecked")
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/engine/EngineTest.java b/library/src/androidTest/java/com/bumptech/glide/load/engine/EngineTest.java
index 1bef918a..1edd877b 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/engine/EngineTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/engine/EngineTest.java
@@ -28,14 +28,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasEntry;
-import static org.hamcrest.Matchers.hasKey;
-import static org.hamcrest.Matchers.not;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
@@ -90,7 +86,7 @@ public class EngineTest {
public void testNewRunnerIsAddedToRunnersMap() {
harness.doLoad();
- assertThat(harness.jobs, hasKey((Key) harness.cacheKey));
+ assertThat(harness.jobs).containsKey(harness.cacheKey);
}
@Test
@@ -145,7 +141,7 @@ public class EngineTest {
harness.doLoad();
- assertThat(harness.activeResources, not(hasKey((Key) harness.cacheKey)));
+ assertThat(harness.activeResources).doesNotContainKey(harness.cacheKey);
}
@Test
@@ -267,7 +263,7 @@ public class EngineTest {
harness.engine.onEngineJobComplete(harness.cacheKey, harness.resource);
- assertThat(harness.jobs, not(hasKey((Key) harness.cacheKey)));
+ assertThat(harness.jobs).doesNotContainKey(harness.cacheKey);
}
@Test
@@ -297,7 +293,7 @@ public class EngineTest {
@Test
public void testDoesNotPutNullResourceInActiveResourcesOnEngineComplete() {
harness.engine.onEngineJobComplete(harness.cacheKey, null);
- assertThat(harness.activeResources, not(hasKey((Key) harness.cacheKey)));
+ assertThat(harness.activeResources).doesNotContainKey(harness.cacheKey);
}
@Test
@@ -306,7 +302,7 @@ public class EngineTest {
harness.engine.onEngineJobCancelled(harness.job, harness.cacheKey);
- assertThat(harness.jobs, not(hasKey((Key) harness.cacheKey)));
+ assertThat(harness.jobs).doesNotContainKey(harness.cacheKey);
}
@@ -360,7 +356,7 @@ public class EngineTest {
harness.engine.onResourceReleased(harness.cacheKey, harness.resource);
- assertThat(harness.activeResources, not(hasKey((Key) harness.cacheKey)));
+ assertThat(harness.activeResources).doesNotContainKey(harness.cacheKey);
}
@Test
@@ -378,7 +374,7 @@ public class EngineTest {
public void testJobIsPutInJobWithCacheKeyWithRelevantIds() {
harness.doLoad();
- assertThat(harness.jobs, hasEntry(equalTo((Key) harness.cacheKey), equalTo(harness.job)));
+ assertThat(harness.jobs).containsEntry(harness.cacheKey, harness.job);
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPoolTest.java b/library/src/androidTest/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPoolTest.java
index e63eb84b..4a648da9 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPoolTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPoolTest.java
@@ -16,10 +16,9 @@ import java.util.List;
import static android.content.ComponentCallbacks2.TRIM_MEMORY_BACKGROUND;
import static android.content.ComponentCallbacks2.TRIM_MEMORY_COMPLETE;
import static android.content.ComponentCallbacks2.TRIM_MEMORY_MODERATE;
-import static org.hamcrest.Matchers.empty;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
@@ -51,7 +50,7 @@ public class LruBitmapPoolTest {
Bitmap bitmap = createMutableBitmap();
Robolectric.shadowOf(bitmap).setMutable(false);
pool.put(bitmap);
- assertThat(strategy.bitmaps, empty());
+ assertThat(strategy.bitmaps).isEmpty();
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/engine/cache/MemorySizeCalculatorTest.java b/library/src/androidTest/java/com/bumptech/glide/load/engine/cache/MemorySizeCalculatorTest.java
index e8d36feb..8c301fe5 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/engine/cache/MemorySizeCalculatorTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/engine/cache/MemorySizeCalculatorTest.java
@@ -4,6 +4,7 @@ import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import com.bumptech.glide.tests.Util;
+import com.google.common.collect.Range;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -12,10 +13,8 @@ import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-import static org.hamcrest.Matchers.lessThan;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -55,7 +54,7 @@ public class MemorySizeCalculatorTest {
int memoryCacheSize = harness.getCalculator().getMemoryCacheSize();
- assertThat(memoryCacheSize, lessThanOrEqualTo(Math.round(memoryClassBytes * harness.sizeMultiplier)));
+ assertThat((float) memoryCacheSize).isIn(Range.atMost(memoryClassBytes * harness.sizeMultiplier));
}
@Test
@@ -76,7 +75,7 @@ public class MemorySizeCalculatorTest {
int bitmapPoolSize = harness.getCalculator().getBitmapPoolSize();
- assertThat(bitmapPoolSize, lessThanOrEqualTo(Math.round(memoryClassBytes * harness.sizeMultiplier)));
+ assertThat((float) bitmapPoolSize).isIn(Range.atMost(memoryClassBytes * harness.sizeMultiplier));
}
@Test
@@ -93,8 +92,10 @@ public class MemorySizeCalculatorTest {
+ " bitmapPoolSize: " + bitmapPoolSize
+ " memoryClass: " + memoryCacheSize
+ " sizeMultiplier: " + harness.sizeMultiplier;
- assertThat(failHelpMessage, memoryCacheSize + bitmapPoolSize,
- lessThanOrEqualTo(Math.round(memoryClassBytes * harness.sizeMultiplier)));
+ assertThat((float) memoryCacheSize + bitmapPoolSize).isIn(
+ Range.atMost(memoryClassBytes * harness.sizeMultiplier));
+// assertThat(failHelpMessage, memoryCacheSize + bitmapPoolSize,
+// lessThanOrEqualTo(Math.round());
}
@Test
@@ -108,8 +109,8 @@ public class MemorySizeCalculatorTest {
final int smallMemoryCacheSize = harness.getCalculator().getMemoryCacheSize();
final int smallBitmapPoolSize = harness.getCalculator().getBitmapPoolSize();
- assertThat(smallMemoryCacheSize, lessThan(normalMemoryCacheSize));
- assertThat(smallBitmapPoolSize, lessThan(normalBitmapPoolSize));
+ assertThat(smallMemoryCacheSize).isLessThan(normalMemoryCacheSize);
+ assertThat(smallBitmapPoolSize).isLessThan(normalBitmapPoolSize);
}
private int getLargeEnoughMemoryClass() {
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/engine/executor/FifoPriorityThreadPoolExecutorTest.java b/library/src/androidTest/java/com/bumptech/glide/load/engine/executor/FifoPriorityThreadPoolExecutorTest.java
index 0dbd5108..ca459335 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/engine/executor/FifoPriorityThreadPoolExecutorTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/engine/executor/FifoPriorityThreadPoolExecutorTest.java
@@ -12,10 +12,8 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.hasSize;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -39,7 +37,7 @@ public class FifoPriorityThreadPoolExecutorTest {
executor.awaitTermination(200, TimeUnit.MILLISECONDS);
- assertThat(resultPriorities, hasSize(numPrioritiesToTest));
+ assertThat(resultPriorities).hasSize(numPrioritiesToTest);
// Since no jobs are queued, the first item added will be run immediately, regardless of priority.
assertEquals(numPrioritiesToTest, resultPriorities.get(0).intValue());
@@ -52,11 +50,11 @@ public class FifoPriorityThreadPoolExecutorTest {
@Test
public void testLoadsWithSamePriorityAreExecutedInSubmitOrder() throws InterruptedException {
final int numItemsToTest = 10;
- final Integer[] executionOrder = new Integer[numItemsToTest];
+ final List<Integer> executionOrder = new ArrayList<Integer>();
final List<Integer> executedOrder = Collections.synchronizedList(new ArrayList<Integer>());
FifoPriorityThreadPoolExecutor executor = new FifoPriorityThreadPoolExecutor(1);
for (int i = 0; i < numItemsToTest; i++) {
- executionOrder[i] = i;
+ executionOrder.add(i);
}
for (int i = 0; i < numItemsToTest; i++) {
final int finalI = i;
@@ -70,7 +68,7 @@ public class FifoPriorityThreadPoolExecutorTest {
}
executor.awaitTermination(200, TimeUnit.MILLISECONDS);
- assertThat(executedOrder, contains(executionOrder));
+ assertThat(executedOrder).containsAllIn(executionOrder).inOrder();
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillRunnerTest.java b/library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillRunnerTest.java
index 1007cf4b..73bbac84 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillRunnerTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillRunnerTest.java
@@ -22,9 +22,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.hasSize;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertNotEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
@@ -74,7 +72,7 @@ public class BitmapPreFillRunnerTest {
handler.run();
Bitmap expected = Bitmap.createBitmap(size.getWidth(), size.getHeight(), size.getConfig());
- assertThat(addedBitmaps, contains(expected, expected, expected));
+ assertThat(addedBitmaps).containsExactly(expected, expected, expected);
}
@Test
@@ -111,7 +109,7 @@ public class BitmapPreFillRunnerTest {
current = addedBitmaps.get(i);
}
- assertThat(addedBitmaps, hasSize(4));
+ assertThat(addedBitmaps).hasSize(4);
}
@Test
@@ -125,11 +123,11 @@ public class BitmapPreFillRunnerTest {
BitmapPreFillRunner handler = getHandler(allocationOrder);
handler.run();
- assertThat(addedBitmaps, hasSize(1));
+ assertThat(addedBitmaps).hasSize(1);
handler.run();
- assertThat(addedBitmaps, hasSize(3));
+ assertThat(addedBitmaps).hasSize(3);
}
@Test
@@ -219,7 +217,7 @@ public class BitmapPreFillRunnerTest {
verify(cache).put(any(Key.class), any(Resource.class));
verify(pool, never()).put(any(Bitmap.class));
- assertThat(addedBitmaps, contains(bitmap));
+ assertThat(addedBitmaps).containsExactly(bitmap);
}
@Test
@@ -237,7 +235,7 @@ public class BitmapPreFillRunnerTest {
verify(cache, never()).put(any(Key.class), any(Resource.class));
verify(pool).put(eq(bitmap));
- assertThat(addedBitmaps, contains(bitmap));
+ assertThat(addedBitmaps).containsExactly(bitmap);
}
@Test
@@ -255,7 +253,7 @@ public class BitmapPreFillRunnerTest {
verify(cache, never()).put(any(Key.class), any(Resource.class));
verify(pool).put(eq(bitmap));
- assertThat(addedBitmaps, contains(bitmap));
+ assertThat(addedBitmaps).containsExactly(bitmap);
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillerTest.java b/library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillerTest.java
index 8cbc0ab2..8e789d0f 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillerTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillerTest.java
@@ -5,7 +5,7 @@ import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.engine.cache.MemoryCache;
import com.bumptech.glide.util.Util;
-import org.hamcrest.core.CombinableMatcher;
+import com.google.common.collect.Range;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -16,10 +16,7 @@ import org.robolectric.annotation.Config;
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.either;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
@@ -124,7 +121,7 @@ public class BitmapPreFillerTest {
byteSize += Util.getBitmapByteSize(current.getWidth(), current.getHeight(), current.getConfig());
}
- assertThat(byteSize, lessThanOrEqualTo(POOL_SIZE + CACHE_SIZE));
+ assertThat(byteSize).isIn(Range.atMost(POOL_SIZE + CACHE_SIZE));
}
@Test
@@ -151,7 +148,7 @@ public class BitmapPreFillerTest {
byteSize += Util.getBitmapByteSize(current.getWidth(), current.getHeight(), current.getConfig());
}
- assertThat(byteSize, lessThanOrEqualTo(POOL_SIZE + CACHE_SIZE));
+ assertThat(byteSize).isIn(Range.atMost(POOL_SIZE + CACHE_SIZE));
}
@Test
@@ -280,9 +277,12 @@ public class BitmapPreFillerTest {
attributes.add(allocationOrder.remove());
}
- CombinableMatcher.CombinableEitherMatcher<Iterable<? extends PreFillType>> either =
- either(contains(smallWidth, smallHeight, smallWidth, smallHeight));
- assertThat(attributes, either.or(contains(smallHeight, smallWidth, smallHeight, smallWidth)));
+ // Either width, height, width, height or height, width, height, width.
+ try {
+ assertThat(attributes).containsExactly(smallWidth, smallHeight, smallWidth, smallHeight).inOrder();
+ } catch (AssertionError e) {
+ assertThat(attributes).containsExactly(smallHeight, smallWidth, smallHeight, smallWidth).inOrder();
+ }
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/model/ImageVideoWrapperEncoderTest.java b/library/src/androidTest/java/com/bumptech/glide/load/model/ImageVideoWrapperEncoderTest.java
index c754d3c1..ca61cc6a 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/model/ImageVideoWrapperEncoderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/model/ImageVideoWrapperEncoderTest.java
@@ -15,8 +15,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -47,8 +46,8 @@ public class ImageVideoWrapperEncoderTest {
String id = encoder.getId();
- assertThat(id, containsString(streamId));
- assertThat(id, containsString(fileId));
+ assertThat(id).contains(streamId);
+ assertThat(id).contains(fileId);
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/model/stream/HttpUrlGlideUrlLoaderTest.java b/library/src/androidTest/java/com/bumptech/glide/load/model/stream/HttpUrlGlideUrlLoaderTest.java
index 7ae3cd4b..e1abdc08 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/model/stream/HttpUrlGlideUrlLoaderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/model/stream/HttpUrlGlideUrlLoaderTest.java
@@ -10,8 +10,7 @@ import org.junit.runners.JUnit4;
import java.io.InputStream;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.assertThat;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
@RunWith(JUnit4.class)
@@ -28,6 +27,6 @@ public class HttpUrlGlideUrlLoaderTest {
@Test
public void testReturnsValidFetcher() {
DataFetcher<InputStream> result = loader.getResourceFetcher(model, 100, 100);
- assertThat(result, instanceOf(HttpUrlFetcher.class));
+ assertThat(result).isInstanceOf(HttpUrlFetcher.class);
}
}
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoderTest.java b/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoderTest.java
index 238167e7..185932ab 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoderTest.java
@@ -15,8 +15,7 @@ import org.robolectric.shadows.ShadowBitmap;
import java.io.ByteArrayOutputStream;
import static com.bumptech.glide.tests.Util.assertClassHasValidId;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -90,7 +89,7 @@ public class BitmapEncoderTest {
}
private static void assertContains(String string, String expected) {
- assertThat(string, containsString(expected));
+ assertThat(string).contains(expected);
}
@SuppressWarnings("unchecked")
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/GlideBitmapDrawableTest.java b/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/GlideBitmapDrawableTest.java
index 8d4a263d..c62393cf 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/GlideBitmapDrawableTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/GlideBitmapDrawableTest.java
@@ -17,12 +17,10 @@ import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.instanceOf;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
@@ -86,7 +84,7 @@ public class GlideBitmapDrawableTest {
@Test
public void testConstantStateReturnsNewGlideBitmapDrawable() {
Drawable newDrawable = drawable.getConstantState().newDrawable();
- assertThat(newDrawable, instanceOf(GlideBitmapDrawable.class));
+ assertThat(newDrawable).isInstanceOf(GlideBitmapDrawable.class);
}
@Test
@@ -98,7 +96,7 @@ public class GlideBitmapDrawableTest {
@Test
public void testMutatedDrawableIsGlideBitmapDrawable() {
Drawable newDrawable = drawable.mutate();
- assertThat(newDrawable, instanceOf(GlideBitmapDrawable.class));
+ assertThat(newDrawable).isInstanceOf(GlideBitmapDrawable.class);
}
@Test
@@ -118,7 +116,7 @@ public class GlideBitmapDrawableTest {
Drawable mutated = drawable.mutate();
mutated.draw(canvas);
- assertThat(mutated.getBounds(), equalTo(bounds));
+ assertEquals(bounds, mutated.getBounds());
verify(canvas, times(2)).drawBitmap(eq(bitmap), isNull(Rect.class), eq(bounds), any(Paint.class));
}
@@ -134,7 +132,7 @@ public class GlideBitmapDrawableTest {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Paint paint = (Paint) invocation.getArguments()[3];
- assertThat(paint.getAlpha(), equalTo(1));
+ assertEquals(1, paint.getAlpha());
return null;
}
}).when(canvas).drawBitmap(any(Bitmap.class), any(Rect.class), any(Rect.class), any(Paint.class));
@@ -156,7 +154,7 @@ public class GlideBitmapDrawableTest {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Paint paint = (Paint) invocation.getArguments()[3];
- assertThat(paint.getColorFilter(), equalTo(originalColorFilter));
+ assertEquals(originalColorFilter, paint.getColorFilter());
return null;
}
}).when(canvas).drawBitmap(any(Bitmap.class), any(Rect.class), any(Rect.class), any(Paint.class));
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/StreamBitmapDecoderTest.java b/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/StreamBitmapDecoderTest.java
index 843ef7a2..3e38e29b 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/StreamBitmapDecoderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/StreamBitmapDecoderTest.java
@@ -14,10 +14,9 @@ import org.robolectric.annotation.Config;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import static org.hamcrest.Matchers.containsString;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -52,9 +51,9 @@ public class StreamBitmapDecoderTest {
when(harness.downsampler.getId()).thenReturn(downsamplerId);
String actualId = harness.decoder.getId();
- assertThat(actualId, containsString(downsamplerId));
- assertThat(actualId, containsString(harness.decodeFormat.toString()));
- assertThat(actualId, containsString(Util.getExpectedClassId(StreamBitmapDecoder.class)));
+ assertThat(actualId).contains(downsamplerId);
+ assertThat(actualId).contains(harness.decodeFormat.toString());
+ assertThat(actualId).contains(Util.getExpectedClassId(StreamBitmapDecoder.class));
}
private static class DecoderHarness {
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/TransformationUtilsTest.java b/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/TransformationUtilsTest.java
index 57ec110f..3bccf17d 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/TransformationUtilsTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/resource/bitmap/TransformationUtilsTest.java
@@ -4,7 +4,7 @@ import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.media.ExifInterface;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
-import org.hamcrest.core.CombinableMatcher;
+import com.google.common.collect.Range;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -14,14 +14,10 @@ import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowBitmap;
-import static org.hamcrest.Matchers.closeTo;
-import static org.hamcrest.Matchers.either;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -257,19 +253,17 @@ public class TransformationUtilsTest {
double originalAspectRatio = (double) original.getWidth() / (double) original.getHeight();
double transformedAspectRatio = (double) transformed.getWidth() / (double) transformed.getHeight();
- assertThat("nearly identical aspect ratios", transformedAspectRatio, closeTo(originalAspectRatio, 0.05));
+ assertThat(transformedAspectRatio).isIn(Range.open(originalAspectRatio - 0.05f, originalAspectRatio + 0.05f));
}
private static void assertBitmapFitsExactlyWithinBounds(int maxSide, Bitmap bitmap) {
final int width = bitmap.getWidth();
final int height = bitmap.getHeight();
- assertThat("width", width, lessThanOrEqualTo(maxSide));
- assertThat("height", height, lessThanOrEqualTo(maxSide));
+ assertThat(width).isIn(Range.atMost(maxSide));
+ assertThat(height).isIn(Range.atMost(maxSide));
- // See https://code.google.com/p/hamcrest/issues/detail?id=82.
- CombinableMatcher.CombinableEitherMatcher<Integer> eitherMatcher = either(equalTo(width));
- assertThat("one side must match maxSide", maxSide, eitherMatcher.or(equalTo(height)));
+ assertTrue("one side must match maxSide", width == maxSide || height == maxSide);
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/resource/gif/GifFrameModelLoaderTest.java b/library/src/androidTest/java/com/bumptech/glide/load/resource/gif/GifFrameModelLoaderTest.java
index 272c7603..4f9b054a 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/resource/gif/GifFrameModelLoaderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/resource/gif/GifFrameModelLoaderTest.java
@@ -7,9 +7,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import static org.hamcrest.Matchers.containsString;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -32,7 +31,7 @@ public class GifFrameModelLoaderTest {
String fetcherId = loader.getResourceFetcher(decoder, 1, 2).getId();
- assertThat(fetcherId, containsString(String.valueOf(frameIndex)));
+ assertThat(fetcherId).contains(String.valueOf(frameIndex));
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapResourceEncoderTest.java b/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapResourceEncoderTest.java
index d2139d12..80245e2c 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapResourceEncoderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapResourceEncoderTest.java
@@ -13,9 +13,8 @@ import org.robolectric.annotation.Config;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
-import static org.hamcrest.Matchers.containsString;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
@@ -96,7 +95,7 @@ public class GifBitmapResourceEncoderTest {
String bitmapId = "bitmapId";
when(bitmapEncoder.getId()).thenReturn(bitmapId);
String id = encoder.getId();
- assertThat(id, containsString(gifId));
- assertThat(id, containsString(bitmapId));
+ assertThat(id).contains(gifId);
+ assertThat(id).contains(bitmapId);
}
}
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceDecoderTest.java b/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceDecoderTest.java
index 0b6666f1..841854f4 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceDecoderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceDecoderTest.java
@@ -21,10 +21,9 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import static org.hamcrest.Matchers.containsString;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
@@ -217,8 +216,8 @@ public class GifBitmapWrapperResourceDecoderTest {
when(gifDecoder.getId()).thenReturn(gifId);
String id = decoder.getId();
- assertThat(id, containsString(bitmapId));
- assertThat(id, containsString(gifId));
+ assertThat(id).contains(bitmapId);
+ assertThat(id).contains(gifId);
}
@SuppressWarnings("unchecked")
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceEncoderTest.java b/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceEncoderTest.java
index 4b54bfe4..c674caf2 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceEncoderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResourceEncoderTest.java
@@ -8,8 +8,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -35,7 +34,7 @@ public class GifBitmapWrapperResourceEncoderTest {
when(gifEncoder.getId()).thenReturn(gifId);
String id = encoder.getId();
- assertThat(id, containsString(bitmapId));
- assertThat(id, containsString(gifId));
+ assertThat(id).contains(bitmapId);
+ assertThat(id).contains(gifId);
}
}
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/resource/transcode/BitmapBytesTranscoderTest.java b/library/src/androidTest/java/com/bumptech/glide/load/resource/transcode/BitmapBytesTranscoderTest.java
index d9b61b8f..95a393b3 100644
--- a/library/src/androidTest/java/com/bumptech/glide/load/resource/transcode/BitmapBytesTranscoderTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/load/resource/transcode/BitmapBytesTranscoderTest.java
@@ -10,9 +10,7 @@ import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertThat;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -30,14 +28,14 @@ public class BitmapBytesTranscoderTest {
@Test
public void testReturnsBytesOfGivenBitmap() {
String transcodedDescription = harness.getTranscodedDescription();
- assertThat(transcodedDescription, startsWith(harness.description));
+ assertThat(transcodedDescription).startsWith(harness.description);
}
@Test
public void testUsesGivenQuality() {
harness.quality = 66;
String transcodedDescription = harness.getTranscodedDescription();
- assertThat(transcodedDescription, containsString(String.valueOf(harness.quality)));
+ assertThat(transcodedDescription).contains(String.valueOf(harness.quality));
}
@Test
@@ -45,7 +43,7 @@ public class BitmapBytesTranscoderTest {
for (Bitmap.CompressFormat format : Bitmap.CompressFormat.values()) {
harness.compressFormat = format;
String transcodedDescription = harness.getTranscodedDescription();
- assertThat(transcodedDescription, containsString(format.name()));
+ assertThat(transcodedDescription).contains(format.name());
}
}
diff --git a/library/src/androidTest/java/com/bumptech/glide/manager/ConnectivityMonitorFactoryTest.java b/library/src/androidTest/java/com/bumptech/glide/manager/ConnectivityMonitorFactoryTest.java
index f58ef054..3a4fc361 100644
--- a/library/src/androidTest/java/com/bumptech/glide/manager/ConnectivityMonitorFactoryTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/manager/ConnectivityMonitorFactoryTest.java
@@ -7,8 +7,7 @@ import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.assertThat;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
@RunWith(RobolectricTestRunner.class)
@@ -26,13 +25,13 @@ public class ConnectivityMonitorFactoryTest {
Robolectric.getShadowApplication().grantPermissions("android.permission.ACCESS_NETWORK_STATE");
ConnectivityMonitor connectivityMonitor =
factory.build(Robolectric.application, mock(ConnectivityMonitor.ConnectivityListener.class));
- assertThat(connectivityMonitor, instanceOf(DefaultConnectivityMonitor.class));
+ assertThat(connectivityMonitor).isInstanceOf(DefaultConnectivityMonitor.class);
}
@Test
public void testReturnsNullConnectivityMonitorWhenDoesNotHavePermission() {
ConnectivityMonitor connectivityMonitor =
factory.build(Robolectric.application, mock(ConnectivityMonitor.ConnectivityListener.class));
- assertThat(connectivityMonitor, instanceOf(NullConnectivityMonitor.class));
+ assertThat(connectivityMonitor).isInstanceOf(NullConnectivityMonitor.class);
}
}
diff --git a/library/src/androidTest/java/com/bumptech/glide/manager/DefaultConnectivityMonitorTest.java b/library/src/androidTest/java/com/bumptech/glide/manager/DefaultConnectivityMonitorTest.java
index 2020b65d..7c3d681f 100644
--- a/library/src/androidTest/java/com/bumptech/glide/manager/DefaultConnectivityMonitorTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/manager/DefaultConnectivityMonitorTest.java
@@ -16,9 +16,7 @@ import org.robolectric.shadows.ShadowNetworkInfo;
import java.util.List;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.assertThat;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -41,7 +39,7 @@ public class DefaultConnectivityMonitorTest {
public void testRegistersReceiverOnStart() {
monitor.onStart();
- assertThat(getConnectivityReceivers(), hasSize(1));
+ assertThat(getConnectivityReceivers()).hasSize(1);
}
@Test
@@ -49,7 +47,7 @@ public class DefaultConnectivityMonitorTest {
monitor.onStart();
monitor.onStart();
- assertThat(getConnectivityReceivers(), hasSize(1));
+ assertThat(getConnectivityReceivers()).hasSize(1);
}
@Test
@@ -57,7 +55,7 @@ public class DefaultConnectivityMonitorTest {
monitor.onStart();
monitor.onStop();
- assertThat(getConnectivityReceivers(), empty());
+ assertThat(getConnectivityReceivers()).isEmpty();
}
@Test
@@ -65,7 +63,7 @@ public class DefaultConnectivityMonitorTest {
monitor.onStop();
monitor.onStop();
- assertThat(getConnectivityReceivers(), empty());
+ assertThat(getConnectivityReceivers()).isEmpty();
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java b/library/src/androidTest/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java
index 4a12de50..7855a4e2 100644
--- a/library/src/androidTest/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java
@@ -22,8 +22,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.util.ActivityController;
import static com.bumptech.glide.tests.BackgroundUtil.testInBackground;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.empty;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -54,8 +53,8 @@ public class RequestManagerRetrieverTest {
Util.setSdkVersionInt(initialSdkVersion);
Robolectric.shadowOf(Looper.getMainLooper()).runToEndOfTasks();
- assertThat(retriever.pendingRequestManagerFragments.entrySet(), empty());
- assertThat(retriever.pendingSupportRequestManagerFragments.entrySet(), empty());
+ assertThat(retriever.pendingRequestManagerFragments).isEmpty();
+ assertThat(retriever.pendingSupportRequestManagerFragments).isEmpty();
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/request/target/GlideDrawableImageViewTargetTest.java b/library/src/androidTest/java/com/bumptech/glide/request/target/GlideDrawableImageViewTargetTest.java
index 67bdaaa5..cc961c80 100644
--- a/library/src/androidTest/java/com/bumptech/glide/request/target/GlideDrawableImageViewTargetTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/request/target/GlideDrawableImageViewTargetTest.java
@@ -14,11 +14,9 @@ import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.not;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
@@ -66,7 +64,7 @@ public class GlideDrawableImageViewTargetTest {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Drawable drawable = (Drawable) invocation.getArguments()[0];
- assertThat(drawable, instanceOf(SquaringDrawable.class));
+ assertThat(drawable).isInstanceOf(SquaringDrawable.class);
return null;
}
}).when(mockView).setImageDrawable(any(Drawable.class));
@@ -96,7 +94,7 @@ public class GlideDrawableImageViewTargetTest {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Drawable drawable = (Drawable) invocation.getArguments()[0];
- assertThat(drawable, not(instanceOf(SquaringDrawable.class)));
+ assertThat(drawable).isNotInstanceOf(SquaringDrawable.class);
return null;
}
}).when(mockView).setImageDrawable(any(Drawable.class));
@@ -126,7 +124,7 @@ public class GlideDrawableImageViewTargetTest {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Drawable drawable = (Drawable) invocation.getArguments()[0];
- assertThat(drawable, not(instanceOf(SquaringDrawable.class)));
+ assertThat(drawable).isNotInstanceOf(SquaringDrawable.class);
return null;
}
}).when(mockView).setImageDrawable(any(Drawable.class));
@@ -156,7 +154,7 @@ public class GlideDrawableImageViewTargetTest {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Drawable drawable = (Drawable) invocation.getArguments()[0];
- assertThat(drawable, not(instanceOf(SquaringDrawable.class)));
+ assertThat(drawable).isNotInstanceOf(SquaringDrawable.class);
return null;
}
}).when(mockView).setImageDrawable(any(Drawable.class));
diff --git a/library/src/androidTest/java/com/bumptech/glide/request/target/ImageViewTargetFactoryTest.java b/library/src/androidTest/java/com/bumptech/glide/request/target/ImageViewTargetFactoryTest.java
index 61916f6f..ecccbfc3 100644
--- a/library/src/androidTest/java/com/bumptech/glide/request/target/ImageViewTargetFactoryTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/request/target/ImageViewTargetFactoryTest.java
@@ -16,8 +16,7 @@ import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.assertThat;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
@RunWith(RobolectricTestRunner.class)
@@ -37,7 +36,7 @@ public class ImageViewTargetFactoryTest {
Bitmap bitmap = Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
Target<Bitmap> target = factory.buildTarget(view, Bitmap.class);
target.onResourceReady(bitmap, null);
- assertThat(target, instanceOf(BitmapImageViewTarget.class));
+ assertThat(target).isInstanceOf(BitmapImageViewTarget.class);
}
@Test
@@ -45,7 +44,7 @@ public class ImageViewTargetFactoryTest {
GlideDrawable glideDrawable = mock(GlideDrawable.class);
Target<GlideDrawable> target = factory.buildTarget(view, GlideDrawable.class);
target.onResourceReady(glideDrawable, null);
- assertThat(target, instanceOf(GlideDrawableImageViewTarget.class));
+ assertThat(target).isInstanceOf(GlideDrawableImageViewTarget.class);
}
@Test
@@ -53,7 +52,7 @@ public class ImageViewTargetFactoryTest {
GifDrawable gifDrawable = mock(GifDrawable.class);
Target target = factory.buildTarget(view, GifDrawable.class);
target.onResourceReady(gifDrawable, null);
- assertThat(target, instanceOf(GlideDrawableImageViewTarget.class));
+ assertThat(target).isInstanceOf(GlideDrawableImageViewTarget.class);
}
@Test
@@ -61,7 +60,7 @@ public class ImageViewTargetFactoryTest {
GlideBitmapDrawable drawable = mock(GlideBitmapDrawable.class);
Target target = factory.buildTarget(view, GlideBitmapDrawable.class);
target.onResourceReady(drawable, null);
- assertThat(target, instanceOf(GlideDrawableImageViewTarget.class));
+ assertThat(target).isInstanceOf(GlideDrawableImageViewTarget.class);
}
@Test
@@ -71,14 +70,14 @@ public class ImageViewTargetFactoryTest {
Target target = factory.buildTarget(view, BitmapDrawable.class);
target.onResourceReady(drawable, null);
- assertThat(target, instanceOf(DrawableImageViewTarget.class));
+ assertThat(target).isInstanceOf(DrawableImageViewTarget.class);
}
@Test
public void testReturnsTargetForDrawables() {
Target<Drawable> target = factory.buildTarget(view, Drawable.class);
target.onResourceReady(new ColorDrawable(Color.RED), null);
- assertThat(target, instanceOf(DrawableImageViewTarget.class));
+ assertThat(target).isInstanceOf(DrawableImageViewTarget.class);
}
@Test(expected = IllegalArgumentException.class)
diff --git a/library/src/androidTest/java/com/bumptech/glide/request/target/ViewTargetTest.java b/library/src/androidTest/java/com/bumptech/glide/request/target/ViewTargetTest.java
index caa2aba6..e77c7408 100644
--- a/library/src/androidTest/java/com/bumptech/glide/request/target/ViewTargetTest.java
+++ b/library/src/androidTest/java/com/bumptech/glide/request/target/ViewTargetTest.java
@@ -25,8 +25,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import static android.view.ViewGroup.LayoutParams;
import static android.view.ViewTreeObserver.OnPreDrawListener;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Matchers.anyInt;
@@ -191,7 +190,7 @@ public class ViewTargetTest {
target.getSize(cb2);
PreDrawShadowViewTreeObserver shadowObserver = Robolectric.shadowOf_(view.getViewTreeObserver());
- assertThat(shadowObserver.getPreDrawListeners(), hasSize(1));
+ assertThat(shadowObserver.getPreDrawListeners()).hasSize(1);
}
@Test
@@ -204,7 +203,7 @@ public class ViewTargetTest {
PreDrawShadowViewTreeObserver shadowObserver = Robolectric.shadowOf_(view.getViewTreeObserver());
shadowObserver.fireOnPreDrawListeners();
- assertThat(shadowObserver.getPreDrawListeners(), hasSize(0));
+ assertThat(shadowObserver.getPreDrawListeners()).hasSize(0);
SizeReadyCallback cb2 = mock(SizeReadyCallback.class);
view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
@@ -225,7 +224,7 @@ public class ViewTargetTest {
shadowObserver.fireOnPreDrawListeners();
verify(cb, never()).onSizeReady(anyInt(), anyInt());
- assertThat(shadowObserver.getPreDrawListeners(), hasSize(1));
+ assertThat(shadowObserver.getPreDrawListeners()).hasSize(1);
}
@Test
diff --git a/library/src/androidTest/java/com/bumptech/glide/tests/KeyAssertions.java b/library/src/androidTest/java/com/bumptech/glide/tests/KeyAssertions.java
index d3effec6..7b27d707 100644
--- a/library/src/androidTest/java/com/bumptech/glide/tests/KeyAssertions.java
+++ b/library/src/androidTest/java/com/bumptech/glide/tests/KeyAssertions.java
@@ -6,9 +6,7 @@ import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -24,7 +22,7 @@ public class KeyAssertions {
assertEquals(first, second);
assertEquals(first.hashCode(), second.hashCode());
- assertThat(getDigest(first), equalTo(getDigest(second)));
+ assertThat(getDigest(first)).isEqualTo(getDigest(second));
}
public static void assertDifferent(Key first, Key second)
@@ -44,7 +42,7 @@ public class KeyAssertions {
MessageDigest secondDigest = MessageDigest.getInstance("SHA-1");
second.updateDiskCacheKey(secondDigest);
- assertThat(getDigest(first), not(equalTo(getDigest(second))));
+ assertNotEquals(getDigest(first), getDigest(second));
}
}