Search in sources :

Example 11 with Sound

use of com.ichi2.libanki.Sound in project AnkiChinaAndroid by ankichinateam.

the class CollectionTest method test_furigana.

@Test
@Ignore("Pending port of media search from Rust code")
public void test_furigana() {
    Collection col = getCol();
    Models mm = col.getModels();
    Model m = mm.current();
    // filter should work
    m.getJSONArray("tmpls").getJSONObject(0).put("qfmt", "{{kana:Front}}");
    mm.save(m);
    Note n = col.newNote();
    n.setItem("Front", "foo[abc]");
    col.addNote(n);
    Card c = n.cards().get(0);
    assertTrue(c.q().endsWith("abc"));
    // and should avoid sound
    n.setItem("Front", "foo[sound:abc.mp3]");
    n.flush();
    String question = c.q(true);
    assertThat("Question «" + question + "» does not contains «anki:play».", question, containsString("anki:play"));
    // it shouldn't throw an error while people are editing
    m.getJSONArray("tmpls").getJSONObject(0).put("qfmt", "{{kana:}}");
    mm.save(m);
    c.q(true);
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Ignore(org.junit.Ignore) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test)

Example 12 with Sound

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

the class ReviewerTest method noErrorShouldOccurIfSoundFileNotPresent.

@Test
public void noErrorShouldOccurIfSoundFileNotPresent() {
    Note firstNote = addNoteUsingBasicModel("[[sound:not_on_file_system.mp3]]", "World");
    moveToReviewQueue(firstNote.firstCard());
    Reviewer reviewer = startReviewer();
    reviewer.generateQuestionSoundList();
    reviewer.displayCardQuestion();
    assertThat("If the sound file with given name is not present, then no error occurs", true);
}
Also used : Note(com.ichi2.libanki.Note) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 Uri (android.net.Uri)3 Note (com.ichi2.libanki.Note)3 MediaPlayer (android.media.MediaPlayer)2 AbstractFlashcardViewer (com.ichi2.anki.AbstractFlashcardViewer)2 RobolectricTest (com.ichi2.anki.RobolectricTest)2 IField (com.ichi2.anki.multimediacard.fields.IField)2 ImageField (com.ichi2.anki.multimediacard.fields.ImageField)2 TextField (com.ichi2.anki.multimediacard.fields.TextField)2 Collection (com.ichi2.libanki.Collection)2 Sound (com.ichi2.libanki.Sound)2 Anki2Importer (com.ichi2.libanki.importer.Anki2Importer)2 AnkiPackageImporter (com.ichi2.libanki.importer.AnkiPackageImporter)2 Importer (com.ichi2.libanki.importer.Importer)2 NoteImporter (com.ichi2.libanki.importer.NoteImporter)2 TextImporter (com.ichi2.libanki.importer.TextImporter)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 ArrayList (java.util.ArrayList)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2