use of com.ichi2.anki.multimediacard.fields.MediaClipField in project Anki-Android by ankidroid.
the class NoteServiceTest method importImageToDirectoryTest.
// Similar test like above, but with an ImageField instead of a MediaClipField
@Test
public void importImageToDirectoryTest() throws IOException {
File fileImage = directory.newFile("testimage.png");
// writes a line in the file so the file's length isn't 0
try (FileWriter fileWriter = new FileWriter(fileImage)) {
fileWriter.write("line1");
}
ImageField imgField = new ImageField();
imgField.setImagePath(fileImage.getAbsolutePath());
NoteService.importMediaToDirectory(mTestCol, imgField);
File outFile = new File(mTestCol.getMedia().dir(), fileImage.getName());
assertEquals("path should be equal to the new file made in NoteService.importMediaToDirectory", outFile.getAbsolutePath(), imgField.getImagePath());
}
use of com.ichi2.anki.multimediacard.fields.MediaClipField in project Anki-Android by ankidroid.
the class NoteServiceTest method tempAudioIsDeletedAfterImport.
/**
* Sometimes media files cannot be imported directly to the media directory,
* so they are copied to cache then imported and deleted.
* This tests if cached media are properly deleted after import.
*/
@Test
public void tempAudioIsDeletedAfterImport() {
File file = createTransientFile("foo");
MediaClipField field = new MediaClipField();
field.setAudioPath(file.getAbsolutePath());
field.setHasTemporaryMedia(true);
NoteService.importMediaToDirectory(mTestCol, field);
assertFalse("Audio temporary file should have been deleted after importing", file.exists());
}
use of com.ichi2.anki.multimediacard.fields.MediaClipField in project Anki-Android by ankidroid.
the class NoteServiceTest method tempImageIsDeletedAfterImport.
// Similar test like above, but with an ImageField instead of a MediaClipField
@Test
public void tempImageIsDeletedAfterImport() {
File file = createTransientFile("foo");
ImageField field = new ImageField();
field.setImagePath(file.getAbsolutePath());
field.setHasTemporaryMedia(true);
NoteService.importMediaToDirectory(mTestCol, field);
assertFalse("Image temporary file should have been deleted after importing", file.exists());
}
Aggregations