Skip to content

Commit

Permalink
Update to Truth 0.45, and address deprecations.
Browse files Browse the repository at this point in the history
Renames may include:
- containsAllOf => containsAtLeast
- containsAllIn => containsAtLeastElementsIn
- isSameAs => isSameInstanceAs
- isOrdered => isInOrder
- isStrictlyOrdered => isInStrictOrder

The other major change is to change custom subjects to extend raw Subject instead of supplying type parameters. The type parameters are being removed from Subject. This CL will temporarily produce rawtypes warnings, which will go away when I remove the type parameters (as soon as this batch of CLs is submitted).

Some CLs in this batch also migrate calls away from actualAsString(). Its literal replacement is `"<" + actual + ">"` (unless an object overrides actualCustomStringRepresentation()), but usually I've made a larger change, such as switching from an old-style "Not true that..." failure message to one generated with the Fact API. In that case, the new code usually contains a direct reference to this.actual (a field that I occasionally had to create). Another larger change I sometimes made is to switch from a manual check-and-fail approach to instead use check(...). And sometimes I just remove a withMessage() call that's no longer necessary now that the code uses check(...), or I introduce a check(...) call. (An assertion made with check(...) automatically includes the actual value from the original subject, so there's no need to set it again with withMessage().)

Finally, there's one CL in this batch in which I migrate a Correspondence subclass to instead use Correspondence.from.

PiperOrigin-RevId: 251729082
  • Loading branch information
cpovirk authored and glide-copybara-robot committed Jun 5, 2019
1 parent c3ff2e5 commit 5bb4691
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MOCKITO_VERSION=1.9.5
MOCKITO_ANDROID_VERSION=2.24.0
ROBOLECTRIC_VERSION=4.3-beta-1
MOCKWEBSERVER_VERSION=3.0.0-RC1
TRUTH_VERSION=0.44
TRUTH_VERSION=0.45
JSR_305_VERSION=3.0.2
AUTO_SERVICE_VERSION=1.0-rc3
JAVAPOET_VERSION=1.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void load_withWideGamutImage_bitmapInPoolWithSizeAndConfig_usesBitmapFrom
Bitmap bitmap =
concurrency.get(
Glide.with(context).asBitmap().load(ResourceIds.raw.webkit_logo_p3).submit());
assertThat(bitmap).isSameAs(expected);
assertThat(bitmap).isSameInstanceAs(expected);
}

// TODO: Even with hardware allowed, we get a wide F16. Attempting to decode the resource with
Expand Down Expand Up @@ -172,7 +172,7 @@ public void loadWideGamutImage_withArgb888OfSufficientSizeInPool_usesArgb8888Bit

Bitmap result = concurrency.get(Glide.with(context).asBitmap().load(data).submit());

assertThat(result).isSameAs(argb8888);
assertThat(result).isSameInstanceAs(argb8888);
}

private static byte[] asJpeg(Bitmap bitmap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

/** Truth assertions for comparing {@link Bitmap}s. */
// Test APIs.
@SuppressWarnings({"WeakerAccess", "unused"})
public final class BitmapSubject extends Subject<BitmapSubject, Bitmap> {
@SuppressWarnings({"WeakerAccess", "unused", "rawtypes", "unchecked"})
public final class BitmapSubject extends Subject {

private static final Subject.Factory<BitmapSubject, Bitmap> FACTORY =
new Subject.Factory<BitmapSubject, Bitmap>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public static void setUpClass() {
@Test public void readingTheSameFileMultipleTimes() throws Exception {
set("a", "a", "b");
DiskLruCache.Value value = cache.get("a");
assertThat(value.getFile(0)).isSameAs(value.getFile(0));
assertThat(value.getFile(0)).isSameInstanceAs(value.getFile(0));
}

@Test public void rebuildJournalOnRepeatedReads() throws Exception {
Expand Down

0 comments on commit 5bb4691

Please sign in to comment.