org.robolectric.shadows.ShadowMimeTypeMap Java Examples

The following examples show how to use org.robolectric.shadows.ShadowMimeTypeMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileUtilsTest.java    From twitter-kit-android with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #2
Source File: MediaUtilsTest.java    From fresco with MIT License 5 votes vote down vote up
@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");
}
 
Example #3
Source File: CachedImageFileProviderTest.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
@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")));
}