Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a constant for Robolectric tests using sdk = 18. #5207

Merged
merged 1 commit into from
Jul 7, 2023
Merged
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
3 changes: 2 additions & 1 deletion library/test/src/test/java/com/bumptech/glide/GlideTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.bumptech.glide.request.RequestOptions.decodeTypeOf;
import static com.bumptech.glide.request.RequestOptions.errorOf;
import static com.bumptech.glide.request.RequestOptions.placeholderOf;
Expand Down Expand Up @@ -94,7 +95,7 @@
@LooperMode(LEGACY)
@RunWith(RobolectricTestRunner.class)
@Config(
sdk = 18,
sdk = ROBOLECTRIC_SDK,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brettchabot Hi Brett, why not using property file for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to introduce a behavior change for tests that currently don't specify a @config(sdk)

However, it's a good suggestion that @sjudd might want to consider as a future change.

shadows = {
GlideTest.ShadowFileDescriptorContentResolver.class,
GlideTest.ShadowMediaMetadataRetriever.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK)
public class ListPreloaderTest {

@Mock private RequestBuilder<Object> request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

@SuppressWarnings("unchecked")
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK)
public class RequestBuilderTest {
@Rule public TearDownGlide tearDownGlide = new TearDownGlide();

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

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.bumptech.glide.tests.BackgroundUtil.testInBackground;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -42,7 +43,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class RequestManagerTest {
@Rule public TearDownGlide tearDownGlide = new TearDownGlide();

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

public class RobolectricConstants {
/** The default SDK used for Robolectric tests */
public static final int ROBOLECTRIC_SDK = 18;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bumptech.glide.load;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;

import androidx.annotation.NonNull;
import com.bumptech.glide.load.Option.CacheKeyUpdater;
import com.bumptech.glide.tests.KeyTester;
Expand All @@ -12,7 +14,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class OptionsTest {
@Rule public final KeyTester keyTester = new KeyTester();

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

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.google.common.truth.Truth.assertThat;

import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
Expand All @@ -15,7 +16,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class ExifOrientationStreamTest {
private ArrayPool byteArrayPool;

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

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
Expand All @@ -18,7 +19,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class FileDescriptorAssetPathFetcherTest {

@Mock private AssetManager assetManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.data;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -36,7 +37,7 @@
* com.bumptech.glide.load.data.HttpUrlFetcherTest}, response handling should go here.
*/
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 18)
@Config(manifest = Config.NONE, sdk = ROBOLECTRIC_SDK)
public class HttpUrlFetcherServerTest {
private static final String DEFAULT_PATH = "/fakepath";
private static final int TIMEOUT_TIME_MS = 300;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.data;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
Expand Down Expand Up @@ -30,7 +31,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class HttpUrlFetcherTest {
@Mock private HttpURLConnection urlConnection;
@Mock private HttpUrlFetcher.HttpUrlConnectionFactory connectionFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.data;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
Expand All @@ -23,7 +24,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class LocalUriFetcherTest {
private TestLocalUriFetcher fetcher;
@Mock private DataFetcher.DataCallback<Closeable> callback;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.data;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
Expand All @@ -18,7 +19,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class StreamAssetPathFetcherTest {
@Mock private AssetManager assetManager;
@Mock private InputStream expected;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.data.mediastore;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.google.common.truth.Truth.assertThat;

import android.net.Uri;
Expand All @@ -10,7 +11,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class MediaStoreUtilTest {

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

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand All @@ -19,7 +20,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class ThumbFetcherTest {

@Mock private ThumbnailStreamOpener opener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.data.mediastore;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
Expand Down Expand Up @@ -36,7 +37,7 @@
import org.robolectric.fakes.RoboCursor;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class ThumbnailStreamOpenerTest {
private Harness harness;

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

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -28,7 +29,7 @@

@RunWith(RobolectricTestRunner.class)
@Config(
sdk = 18,
sdk = ROBOLECTRIC_SDK,
shadows = {ContentResolverShadow.class})
public class FileDescriptorLocalUriFetcherTest {

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

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.verify;

Expand All @@ -26,7 +27,7 @@

@RunWith(RobolectricTestRunner.class)
@Config(
sdk = 18,
sdk = ROBOLECTRIC_SDK,
shadows = {ContentResolverShadow.class})
public class StreamLocalUriFetcherTest {
@Mock private DataFetcher.DataCallback<InputStream> callback;
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.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.bumptech.glide.tests.Util.anyResource;
import static com.bumptech.glide.tests.Util.isADataSource;
import static com.bumptech.glide.tests.Util.mockResource;
Expand Down Expand Up @@ -41,7 +42,7 @@
import org.robolectric.shadows.ShadowLooper;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class EngineJobTest {
private EngineJobHarness harness;

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.RobolectricConstants.ROBOLECTRIC_SDK;
import static org.junit.Assert.assertThrows;

import androidx.annotation.NonNull;
Expand All @@ -23,7 +24,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class EngineKeyTest {
@Mock private Transformation<Object> transformation;

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.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.bumptech.glide.tests.Util.mockResource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand All @@ -21,7 +22,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class EngineResourceTest {
private EngineResource<Object> engineResource;
@Mock private EngineResource.ResourceListener listener;
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.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.bumptech.glide.tests.Util.anyResource;
import static com.bumptech.glide.tests.Util.isADataSource;
import static com.bumptech.glide.tests.Util.mockResource;
Expand Down Expand Up @@ -44,7 +45,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
@SuppressWarnings("unchecked")
public class EngineTest {
private EngineTestHarness harness;
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.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.bumptech.glide.tests.Util.mockResource;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.never;
Expand All @@ -16,7 +17,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class ResourceRecyclerTest {

private ResourceRecycler recycler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.engine.bitmap_recycle;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.mockito.ArgumentMatchers.eq;
Expand All @@ -16,7 +17,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class AttributeStrategyKeyTest {

private AttributeStrategy.KeyPool keyPool;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.engine.bitmap_recycle;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

Expand All @@ -11,7 +12,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class AttributeStrategyTest {

private AttributeStrategy strategy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.engine.bitmap_recycle;

import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertNull;

Expand All @@ -10,7 +11,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class GroupedLinkedMapTest {

private GroupedLinkedMap<Key, Object> map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static android.content.ComponentCallbacks2.TRIM_MEMORY_COMPLETE;
import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL;
import static android.content.ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN;
import static com.bumptech.glide.RobolectricConstants.ROBOLECTRIC_SDK;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
Expand All @@ -19,7 +20,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 18)
@Config(sdk = ROBOLECTRIC_SDK)
public class LruArrayPoolTest {
private static final int MAX_SIZE = 10;
private static final int MAX_PUT_SIZE = MAX_SIZE / 2;
Expand Down
Loading