Skip to content

Commit

Permalink
Pass through file URIs to ContentResolver implementation.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 467108418
  • Loading branch information
sjudd authored and glide-copybara-robot committed Aug 12, 2022
1 parent 2538359 commit dcc5f34
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
Expand All @@ -38,8 +40,10 @@
public class ThumbnailStreamOpenerTest {
private Harness harness;

@Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder();

@Before
public void setUp() {
public void setUp() throws Exception {
harness = new Harness();
}

Expand Down Expand Up @@ -123,15 +127,15 @@ private static ContentResolver getContentResolver() {
return ApplicationProvider.getApplicationContext().getContentResolver();
}

private static class Harness {
private class Harness {
final MatrixCursor cursor = new MatrixCursor(new String[1]);
final File file = new File("fake/uri");
final File file = temporaryFolder.newFile();
final Uri uri = Uri.fromFile(file);
final ThumbnailQuery query = mock(ThumbnailQuery.class);
final FileService service = mock(FileService.class);
final ArrayPool byteArrayPool = new LruArrayPool();

Harness() {
Harness() throws Exception {
cursor.addRow(new String[] {file.getAbsolutePath()});
when(query.query(eq(uri))).thenReturn(cursor);
when(service.get(eq(file.getAbsolutePath()))).thenReturn(file);
Expand Down

0 comments on commit dcc5f34

Please sign in to comment.