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

Add isInitialized visible for testing method #5163

Merged
merged 1 commit into from
Jun 8, 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
5 changes: 5 additions & 0 deletions library/src/main/java/com/bumptech/glide/Glide.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public static void init(@NonNull Context context, @NonNull GlideBuilder builder)
}
}

@VisibleForTesting
public static synchronized boolean isInitialized() {
return glide != null;
}

/**
* Allows hardware Bitmaps to be used prior to the first frame in the app being drawn as soon as
* this method is called.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

import android.content.Context;
Expand Down Expand Up @@ -69,4 +70,16 @@ public void run() throws Throwable {
// Make sure the second exception isn't hidden by some Glide initialization related exception.
assertThrows(TestException.class, initializeGlide);
}

@Test
public void isInitialized_whenNotInitialized_returnsFalse() {
assertThat(Glide.isInitialized()).isFalse();
}

@Test
public void isInitialized_whenInitialized_returnsTrue() {
Glide.get(context);

assertThat(Glide.isInitialized()).isTrue();
}
}