Search in sources :

Example 1 with Option

use of org.liberty.android.fantastischmemo.entity.Option in project AnyMemo by helloworld1.

the class OptionTest method testGetDictApp.

@SmallTest
@Test
public void testGetDictApp() {
    Option option = new Option(getContext());
    editor.putString(AMPrefKeys.DICT_APP_KEY, "COLORDICT");
    editor.commit();
    assertEquals(Option.DictApp.COLORDICT, option.getDictApp());
    editor.putString(AMPrefKeys.DICT_APP_KEY, "FORA");
    editor.commit();
    assertEquals(Option.DictApp.FORA, option.getDictApp());
    editor.putString(AMPrefKeys.DICT_APP_KEY, "BLUEDICT");
    editor.commit();
    assertEquals(Option.DictApp.BLUEDICT, option.getDictApp());
}
Also used : Option(org.liberty.android.fantastischmemo.entity.Option) SmallTest(android.support.test.filters.SmallTest) AbstractPreferencesTest(org.liberty.android.fantastischmemo.test.AbstractPreferencesTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 2 with Option

use of org.liberty.android.fantastischmemo.entity.Option in project AnyMemo by helloworld1.

the class OptionTest method testGetButtonStyle.

@SmallTest
@Test
public void testGetButtonStyle() {
    Option option = new Option(getContext());
    editor.putString(AMPrefKeys.BUTTON_STYLE_KEY, "ANYMEMO");
    editor.commit();
    assertEquals(Option.ButtonStyle.ANYMEMO, option.getButtonStyle());
    editor.putString(AMPrefKeys.BUTTON_STYLE_KEY, "MNEMOSYNE");
    editor.commit();
    assertEquals(Option.ButtonStyle.MNEMOSYNE, option.getButtonStyle());
    editor.putString(AMPrefKeys.BUTTON_STYLE_KEY, "ANKI");
    editor.commit();
    assertEquals(Option.ButtonStyle.ANKI, option.getButtonStyle());
}
Also used : Option(org.liberty.android.fantastischmemo.entity.Option) SmallTest(android.support.test.filters.SmallTest) AbstractPreferencesTest(org.liberty.android.fantastischmemo.test.AbstractPreferencesTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 3 with Option

use of org.liberty.android.fantastischmemo.entity.Option in project AnyMemo by helloworld1.

the class OptionTest method testGetSpeakingType.

@SmallTest
@Test
public void testGetSpeakingType() {
    Option option = new Option(getContext());
    editor.putString(AMPrefKeys.SPEECH_CONTROL_KEY, "TAP");
    editor.commit();
    assertEquals(Option.SpeakingType.TAP, option.getSpeakingType());
    editor.putString(AMPrefKeys.SPEECH_CONTROL_KEY, "AUTO");
    editor.commit();
    assertEquals(Option.SpeakingType.AUTO, option.getSpeakingType());
    editor.putString(AMPrefKeys.SPEECH_CONTROL_KEY, "MANUAL");
    editor.commit();
    assertEquals(Option.SpeakingType.MANUAL, option.getSpeakingType());
    editor.putString(AMPrefKeys.SPEECH_CONTROL_KEY, "AUTOTAP");
    editor.commit();
    assertEquals(Option.SpeakingType.AUTOTAP, option.getSpeakingType());
}
Also used : Option(org.liberty.android.fantastischmemo.entity.Option) SmallTest(android.support.test.filters.SmallTest) AbstractPreferencesTest(org.liberty.android.fantastischmemo.test.AbstractPreferencesTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 4 with Option

use of org.liberty.android.fantastischmemo.entity.Option in project AnyMemo by helloworld1.

the class RecentListUtilTest method testAddRecentListWithinLimit.

@SmallTest
@Test
public void testAddRecentListWithinLimit() {
    Option mockOption = mock(Option.class);
    when(mockOption.getRecentCount()).thenReturn(7);
    RecentListUtil recentListUtil = new RecentListUtil(getContext(), mockOption);
    recentListUtil.addToRecentList("/sdcard/a.db");
    assertEquals("/sdcard/a.db", recentListUtil.getRecentDBPath());
    recentListUtil.addToRecentList("/sdcard/b.db");
    String[] recentList = recentListUtil.getAllRecentDBPath();
    assertEquals("/sdcard/b.db", recentList[0]);
    assertEquals("/sdcard/a.db", recentList[1]);
}
Also used : RecentListUtil(org.liberty.android.fantastischmemo.utils.RecentListUtil) Option(org.liberty.android.fantastischmemo.entity.Option) SmallTest(android.support.test.filters.SmallTest) AbstractPreferencesTest(org.liberty.android.fantastischmemo.test.AbstractPreferencesTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 5 with Option

use of org.liberty.android.fantastischmemo.entity.Option in project AnyMemo by helloworld1.

the class RecentListUtilTest method testAddRecentListLargerThanLimit.

@SmallTest
@Test
public void testAddRecentListLargerThanLimit() {
    // Mock recent count limit to 3.
    Option mockOption = mock(Option.class);
    when(mockOption.getRecentCount()).thenReturn(3);
    // Add 5 dbs
    RecentListUtil recentListUtil = new RecentListUtil(getContext(), mockOption);
    recentListUtil.addToRecentList("/sdcard/1.db");
    recentListUtil.addToRecentList("/sdcard/2.db");
    recentListUtil.addToRecentList("/sdcard/3.db");
    recentListUtil.addToRecentList("/sdcard/4.db");
    recentListUtil.addToRecentList("/sdcard/5.db");
    // Only 3 should be in recent list
    String[] recentList = recentListUtil.getAllRecentDBPath();
    assertEquals(3, recentList.length);
    assertEquals("/sdcard/5.db", recentList[0]);
    assertEquals("/sdcard/4.db", recentList[1]);
    assertEquals("/sdcard/3.db", recentList[2]);
}
Also used : RecentListUtil(org.liberty.android.fantastischmemo.utils.RecentListUtil) Option(org.liberty.android.fantastischmemo.entity.Option) SmallTest(android.support.test.filters.SmallTest) AbstractPreferencesTest(org.liberty.android.fantastischmemo.test.AbstractPreferencesTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Aggregations

SmallTest (android.support.test.filters.SmallTest)9 Test (org.junit.Test)9 Option (org.liberty.android.fantastischmemo.entity.Option)9 AbstractPreferencesTest (org.liberty.android.fantastischmemo.test.AbstractPreferencesTest)9 RecentListUtil (org.liberty.android.fantastischmemo.utils.RecentListUtil)5