Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ androidx-fragment = "1.6.1"
okhttp-min-sdk-version = "21"
kotlin-compiler-extension = "1.5.5"
androidx-benchmark = "1.5.0-alpha05"
compile-sdk-version = "36"
compile-sdk-version = "37"
androidx-multidex = "2.0.1"
autoservice = "1.0-rc3"
autoservice-annotations = "1.0.1"
Expand Down Expand Up @@ -55,7 +55,7 @@ mockwebserver = "3.0.0-RC1"
okhttp2 = "2.7.5"
okhttp3 = "3.10.0"
okhttp4 = "4.10.0"
robolectric = "4.11.1"
robolectric = "4.16"
rx-android = "1.2.1"
rx-java = "1.3.8"
svg = "1.2.1"
Expand Down
38 changes: 18 additions & 20 deletions integration/sqljournaldiskcache/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
plugins {
id("com.android.library")
}
plugins { id("com.android.library") }

android {
namespace = "com.bumptech.glide.integration.sqljournaldiskcache"
namespace = "com.bumptech.glide.integration.sqljournaldiskcache"

compileSdk = libs.versions.compile.sdk.version.get().toInt()
compileSdk = libs.versions.compile.sdk.version.get().toInt()

defaultConfig { minSdk = libs.versions.min.sdk.version.get().toInt() }
defaultConfig { minSdk = libs.versions.min.sdk.version.get().toInt() }

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

dependencies {
implementation(project(":library"))
implementation(libs.errorprone.annotations)
implementation(project(":library"))
implementation(libs.errorprone.annotations)

testImplementation(libs.guava.testlib)
testImplementation(libs.truth)
testImplementation(libs.junit)
testImplementation(libs.mockito.core)
testImplementation(libs.robolectric)
testImplementation(libs.androidx.test.core)
testImplementation(libs.androidx.junit)
testImplementation(libs.androidx.test.runner)
testImplementation(libs.guava.testlib)
testImplementation(libs.truth)
testImplementation(libs.junit)
testImplementation(libs.mockito.core)
testImplementation(libs.robolectric)
testImplementation(libs.androidx.test.core)
testImplementation(libs.androidx.junit)
testImplementation(libs.androidx.test.runner)
}

apply(from = "${rootProject.projectDir}/scripts/upload.gradle.kts")
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;

import android.content.Context;
import android.os.Looper;
Expand All @@ -20,6 +19,8 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowLooper;

@RunWith(AndroidJUnit4.class)
public class JournaledLruDiskCacheTest {
Expand Down Expand Up @@ -322,7 +323,7 @@ public void eviction_removesFirstPutFile() {

// Eviction is triggered by posts.
private static void onIdleWorkerThread() {
shadowOf(Looper.getMainLooper()).idle();
((ShadowLooper) Shadow.extract(Looper.getMainLooper())).idle();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bumptech.glide.load.data.mediastore;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.bumptech.glide.testutil.CustomShadows.shadowOf;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
Expand Down Expand Up @@ -32,7 +33,6 @@
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.fakes.RoboCursor;

Expand Down Expand Up @@ -91,7 +91,7 @@ public void testClosesCursor() throws FileNotFoundException {
@Test
public void testReturnsOpenedInputStreamWhenFileFound() throws FileNotFoundException {
InputStream expected = new ByteArrayInputStream(new byte[0]);
Shadows.shadowOf(ApplicationProvider.getApplicationContext().getContentResolver())
shadowOf(ApplicationProvider.getApplicationContext().getContentResolver())
.registerInputStream(harness.uri, expected);
assertEquals(expected, harness.get().open(harness.uri));
}
Expand All @@ -108,7 +108,7 @@ public void testVideoQueryReturnsVideoCursor() {
ThumbFetcher.VideoThumbnailQuery query =
new ThumbFetcher.VideoThumbnailQuery(getContentResolver());
RoboCursor testCursor = new RoboCursor();
Shadows.shadowOf(ApplicationProvider.getApplicationContext().getContentResolver())
shadowOf(ApplicationProvider.getApplicationContext().getContentResolver())
.setCursor(queryUri, testCursor);
assertEquals(testCursor, query.query(harness.uri));
}
Expand All @@ -119,7 +119,7 @@ public void testImageQueryReturnsImageCursor() {
ThumbFetcher.ImageThumbnailQuery query =
new ThumbFetcher.ImageThumbnailQuery(getContentResolver());
RoboCursor testCursor = new RoboCursor();
Shadows.shadowOf(ApplicationProvider.getApplicationContext().getContentResolver())
shadowOf(ApplicationProvider.getApplicationContext().getContentResolver())
.setCursor(queryUri, testCursor);
assertEquals(testCursor, query.query(harness.uri));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.engine;

import static com.bumptech.glide.testutil.CustomShadows.shadowOf;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
Expand All @@ -25,7 +26,6 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;

@RunWith(RobolectricTestRunner.class)
public class ActiveResourcesTest {
Expand Down Expand Up @@ -375,7 +375,7 @@ private void waitForLatch(CountDownLatch latch) {
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Shadows.shadowOf(Looper.getMainLooper()).runToEndOfTasks();
shadowOf(Looper.getMainLooper()).runToEndOfTasks();
}

private CountDownLatch getLatchForClearedRef() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.bumptech.glide.tests.Util.anyResource;
import static com.bumptech.glide.tests.Util.isADataSource;
import static com.bumptech.glide.tests.Util.mockResource;
import static com.bumptech.glide.testutil.CustomShadows.shadowOf;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -37,7 +38,6 @@
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLooper;

Expand Down Expand Up @@ -255,7 +255,7 @@ public void testDoesNotNotifyCancelledIfReceivedException() {
@Test
public void testReleasesResourceIfCancelledOnReady() {
Looper looper = harness.mainHandler.getLooper();
Shadows.shadowOf(looper).pause();
shadowOf(looper).pause();

final EngineJob<Object> job = harness.getJob();
job.start(harness.decodeJob);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.bumptech.glide.tests.Util.mockResource;
import static com.bumptech.glide.testutil.CustomShadows.shadowOf;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
Expand All @@ -13,7 +14,6 @@
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
Expand All @@ -30,18 +30,18 @@ public void setUp() {
@Test
public void recycle_withoutForceNextFrame_recyclesResourceSynchronously() {
Resource<?> resource = mockResource();
Shadows.shadowOf(Looper.getMainLooper()).pause();
shadowOf(Looper.getMainLooper()).pause();
recycler.recycle(resource, /* forceNextFrame= */ false);
verify(resource).recycle();
}

@Test
public void recycle_withForceNextFrame_postsRecycle() {
Resource<?> resource = mockResource();
Shadows.shadowOf(Looper.getMainLooper()).pause();
shadowOf(Looper.getMainLooper()).pause();
recycler.recycle(resource, /* forceNextFrame= */ true);
verify(resource, never()).recycle();
Shadows.shadowOf(Looper.getMainLooper()).runToEndOfTasks();
shadowOf(Looper.getMainLooper()).runToEndOfTasks();
verify(resource).recycle();
}

Expand All @@ -60,14 +60,14 @@ public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
.when(parent)
.recycle();

Shadows.shadowOf(Looper.getMainLooper()).pause();
shadowOf(Looper.getMainLooper()).pause();

recycler.recycle(parent, /* forceNextFrame= */ false);

verify(parent).recycle();
verify(child, never()).recycle();

Shadows.shadowOf(Looper.getMainLooper()).runOneTask();
shadowOf(Looper.getMainLooper()).runOneTask();

verify(child).recycle();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.engine.cache;

import static com.bumptech.glide.testutil.CustomShadows.shadowOf;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand All @@ -16,7 +17,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
Expand All @@ -42,7 +42,7 @@ public void tearDown() {

@Test
public void testDefaultMemoryCacheSizeIsTwiceScreenSize() {
Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass());
shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass());

float memoryCacheSize = harness.getCalculator().getMemoryCacheSize();

Expand All @@ -52,7 +52,7 @@ public void testDefaultMemoryCacheSizeIsTwiceScreenSize() {
@Test
public void testCanSetCustomMemoryCacheSize() {
harness.memoryCacheScreens = 9.5f;
Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass());
shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass());

float memoryCacheSize = harness.getCalculator().getMemoryCacheSize();

Expand All @@ -64,7 +64,7 @@ public void testDefaultMemoryCacheSizeIsLimitedByMemoryClass() {
final int memoryClassBytes =
Math.round(harness.getScreenSize() * harness.memoryCacheScreens * harness.sizeMultiplier);

Shadows.shadowOf(harness.activityManager).setMemoryClass(memoryClassBytes / (1024 * 1024));
shadowOf(harness.activityManager).setMemoryClass(memoryClassBytes / (1024 * 1024));

float memoryCacheSize = harness.getCalculator().getMemoryCacheSize();

Expand All @@ -73,7 +73,7 @@ public void testDefaultMemoryCacheSizeIsLimitedByMemoryClass() {

@Test
public void testDefaultBitmapPoolSize() {
Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass());
shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass());

float bitmapPoolSize = harness.getCalculator().getBitmapPoolSize();

Expand All @@ -83,7 +83,7 @@ public void testDefaultBitmapPoolSize() {
@Test
public void testCanSetCustomBitmapPoolSize() {
harness.bitmapPoolScreens = 2f;
Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass());
shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass());

float bitmapPoolSize = harness.getCalculator().getBitmapPoolSize();

Expand All @@ -95,7 +95,7 @@ public void testDefaultBitmapPoolSizeIsLimitedByMemoryClass() {
final int memoryClassBytes =
Math.round(harness.getScreenSize() * harness.bitmapPoolScreens * harness.sizeMultiplier);

Shadows.shadowOf(harness.activityManager).setMemoryClass(memoryClassBytes / (1024 * 1024));
shadowOf(harness.activityManager).setMemoryClass(memoryClassBytes / (1024 * 1024));

int bitmapPoolSize = harness.getCalculator().getBitmapPoolSize();

Expand All @@ -110,7 +110,7 @@ public void testCumulativePoolAndMemoryCacheSizeAreLimitedByMemoryClass() {
harness.getScreenSize()
* (harness.bitmapPoolScreens + harness.memoryCacheScreens)
* harness.sizeMultiplier);
Shadows.shadowOf(harness.activityManager).setMemoryClass(memoryClassBytes / (1024 * 1024));
shadowOf(harness.activityManager).setMemoryClass(memoryClassBytes / (1024 * 1024));

int memoryCacheSize = harness.getCalculator().getMemoryCacheSize();
int bitmapPoolSize = harness.getCalculator().getBitmapPoolSize();
Expand All @@ -121,7 +121,7 @@ public void testCumulativePoolAndMemoryCacheSizeAreLimitedByMemoryClass() {

@Test
public void testCumulativePoolAndMemoryCacheSizesAreSmallerOnLowMemoryDevices() {
Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass() / 2);
shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass() / 2);
final int normalMemoryCacheSize = harness.getCalculator().getMemoryCacheSize();
final int normalBitmapPoolSize = harness.getCalculator().getBitmapPoolSize();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.resource.bitmap;

import static com.bumptech.glide.testutil.CustomShadows.shadowOf;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -28,7 +29,6 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
Expand Down Expand Up @@ -366,7 +366,7 @@ public void testRotateImage() {
assertThat(ninety.getPixel(1, 0)).isEqualTo(Color.BLUE);
} else {
// Use legacy shadow APIs
assertThat(Shadows.shadowOf(ninety).getDescription()).contains("rotate=90.0");
assertThat(shadowOf(ninety).getDescription()).contains("rotate=90.0");
}
assertEquals(toRotate.getWidth(), toRotate.getHeight());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.bumptech.glide.manager;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.bumptech.glide.testutil.CustomShadows.shadowOf;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import static org.robolectric.Shadows.shadowOf;

import android.app.Application;
import androidx.test.core.app.ApplicationProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.bumptech.glide.manager;

import static com.bumptech.glide.testutil.CustomShadows.shadowOf;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.robolectric.Shadows.shadowOf;
import static org.robolectric.annotation.LooperMode.Mode.LEGACY;

import android.app.Application;
Expand Down
Loading
Loading