Search in sources :

Example 71 with Media

use of com.ichi2.libanki.Media in project Anki-Android by ankidroid.

the class ImageFieldTest method testNoImagePathConcat.

@Test
public void testNoImagePathConcat() {
    String goodImage = "<img src='1.png'/>";
    Collection col = collectionWithMediaDirectory("media");
    String imageSrc = ImageField.getImageFullPath(col, goodImage);
    assertThat("Valid media should have path", imageSrc, equalTo("media/1.png"));
}
Also used : Collection(com.ichi2.libanki.Collection) Test(org.junit.Test)

Example 72 with Media

use of com.ichi2.libanki.Media in project Anki-Android by ankidroid.

the class ImageFieldTest method collectionWithMediaDirectory.

@CheckResult
protected Collection collectionWithMediaDirectory(String dir) {
    Media media = mock(Media.class);
    when(media.dir()).thenReturn(dir);
    Collection collectionMock = mock(Collection.class);
    when(collectionMock.getMedia()).thenReturn(media);
    return collectionMock;
}
Also used : Media(com.ichi2.libanki.Media) Collection(com.ichi2.libanki.Collection) CheckResult(androidx.annotation.CheckResult)

Aggregations

File (java.io.File)43 IOException (java.io.IOException)26 Collection (com.ichi2.libanki.Collection)25 JSONObject (com.ichi2.utils.JSONObject)19 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)17 ZipFile (java.util.zip.ZipFile)14 JSONException (com.ichi2.utils.JSONException)10 FileOutputStream (java.io.FileOutputStream)10 List (java.util.List)10 JSONArray (com.ichi2.utils.JSONArray)9 FileInputStream (java.io.FileInputStream)9 FileNotFoundException (java.io.FileNotFoundException)9 SharedPreferences (android.content.SharedPreferences)8 JSONObject (org.json.JSONObject)8 Resources (android.content.res.Resources)7 Uri (android.net.Uri)7 RobolectricTest (com.ichi2.anki.RobolectricTest)7 ConfirmModSchemaException (com.ichi2.anki.exception.ConfirmModSchemaException)7 AnkiPackageImporter (com.ichi2.libanki.importer.AnkiPackageImporter)7