@Test public void testExtractMimeNativelySupportedFileExtension() { ShadowMimeTypeMap mimeTypeMap = Shadows.shadowOf(MimeTypeMap.getSingleton()); mimeTypeMap.addExtensionMimeTypMapping("jpg", "image/jpg"); String path = "file/with/natively/supported/extension.jpg"; assertThat(MediaUtils.extractMime(path)).isEqualTo("image/jpg"); }
@Before public void setUp() { final ShadowMimeTypeMap mimeTypeMap = (ShadowMimeTypeMap) ShadowExtractor .extract(MimeTypeMap.getSingleton()); mimeTypeMap.addExtensionMimeTypMapping("jpg", "image/jpeg"); mimeTypeMap.addExtensionMimeTypMapping("jpeg", "image/jpeg"); mimeTypeMap.addExtensionMimeTypMapping("png", "image/png"); this.mimeTypeMap = mimeTypeMap; }
@Test public void itAddsExtension () throws Exception { final ShadowMimeTypeMap shadowMimeTypeMap = Robolectric.shadowOf(MimeTypeMap.getSingleton()); shadowMimeTypeMap.addExtensionMimeTypMapping("png", "image/png"); final File picFile = this.tmp.newFile(); IoHelper.copy(new File("./res/drawable-hdpi/ic_hosaka_meji.png"), picFile); // Just something to test with. final List<File> actual = CachedImageFileProvider.addFileExtensions(Collections.singletonList(picFile)); assertThat(actual, hasItem(new File(picFile.getAbsolutePath() + ".png"))); }
public static ShadowMimeTypeMap shadowOf(MimeTypeMap instance) { return (ShadowMimeTypeMap) shadowOf_(instance); }