Search in sources :

Example 1 with AMFileUtil

use of org.liberty.android.fantastischmemo.utils.AMFileUtil in project AnyMemo by helloworld1.

the class CardTextUtilTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    mockOption = Mockito.mock(Option.class);
    Mockito.when(mockOption.getEnableArabicEngine()).thenReturn(false);
    appComponents = Mockito.mock(AppComponents.class);
    Mockito.when(appComponents.applicationContext()).thenReturn(getContext());
    Mockito.when(appComponents.amFileUtil()).thenReturn(new AMFileUtil(getContext(), new AMPrefUtil(getContext())));
}
Also used : AMFileUtil(org.liberty.android.fantastischmemo.utils.AMFileUtil) AppComponents(org.liberty.android.fantastischmemo.modules.AppComponents) Option(org.liberty.android.fantastischmemo.entity.Option) AMPrefUtil(org.liberty.android.fantastischmemo.utils.AMPrefUtil)

Example 2 with AMFileUtil

use of org.liberty.android.fantastischmemo.utils.AMFileUtil in project AnyMemo by helloworld1.

the class AbstractConverterTest method setUp.

@Before
public void setUp() throws Exception {
    // Set up necessary dependencies first
    amFileUtil = new AMFileUtil(getTargetContext(), new AMPrefUtil(getTargetContext()));
    converter = getConverter();
    String srcFileName = getFileNamePrefix() + "." + converter.getSrcExtension();
    srcFilePath = "/sdcard/" + getFileNamePrefix() + "." + converter.getSrcExtension();
    destFilePath = "/sdcard/" + getFileNamePrefix() + "." + converter.getDestExtension();
    // This amFileUtil is used on the test package so it can copy the
    // asset file from the test package.
    AMFileUtil amFileUtilForTest = new AMFileUtil(getContext(), new AMPrefUtil(getContext()));
    amFileUtilForTest.copyFileFromAsset(srcFileName, new File(srcFilePath));
}
Also used : AMFileUtil(org.liberty.android.fantastischmemo.utils.AMFileUtil) File(java.io.File) AMPrefUtil(org.liberty.android.fantastischmemo.utils.AMPrefUtil) Before(org.junit.Before)

Example 3 with AMFileUtil

use of org.liberty.android.fantastischmemo.utils.AMFileUtil in project AnyMemo by helloworld1.

the class ImportMergingTest method setUp.

@Before
public void setUp() throws Exception {
    // Reflect out the test context
    testContext = getContext();
    amFileUtil = new AMFileUtil(testContext, new AMPrefUtil(getContext()));
    newDbCardList = new ArrayList<Card>();
    Card c1 = new Card();
    c1.setQuestion("old question 1");
    c1.setAnswer("old answer 1");
    c1.setLearningData(new LearningData());
    c1.setCategory(new Category());
    Card c2 = new Card();
    c2.setQuestion("old question 2");
    c2.setAnswer("old answer 2");
    c2.setLearningData(new LearningData());
    c2.setCategory(new Category());
    newDbCardList.add(c1);
    newDbCardList.add(c2);
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) AMFileUtil(org.liberty.android.fantastischmemo.utils.AMFileUtil) LearningData(org.liberty.android.fantastischmemo.entity.LearningData) AMPrefUtil(org.liberty.android.fantastischmemo.utils.AMPrefUtil) Card(org.liberty.android.fantastischmemo.entity.Card) Before(org.junit.Before)

Example 4 with AMFileUtil

use of org.liberty.android.fantastischmemo.utils.AMFileUtil in project AnyMemo by helloworld1.

the class CardImageGetterTest method setUp.

@Before
public void setUp() {
    Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    screenWidth = display.getWidth();
    AppComponents appComponents = Mockito.mock(AppComponents.class);
    Mockito.when(appComponents.applicationContext()).thenReturn(getContext());
    Mockito.when(appComponents.amFileUtil()).thenReturn(new AMFileUtil(getContext(), new AMPrefUtil(getContext())));
    cardImageGetter = new CardImageGetter(appComponents, imageSearchPaths);
}
Also used : AMFileUtil(org.liberty.android.fantastischmemo.utils.AMFileUtil) AppComponents(org.liberty.android.fantastischmemo.modules.AppComponents) CardImageGetter(org.liberty.android.fantastischmemo.ui.CardImageGetter) Display(android.view.Display) WindowManager(android.view.WindowManager) AMPrefUtil(org.liberty.android.fantastischmemo.utils.AMPrefUtil) Before(org.junit.Before)

Example 5 with AMFileUtil

use of org.liberty.android.fantastischmemo.utils.AMFileUtil in project AnyMemo by helloworld1.

the class AMFileUtilTest method testDeleteDbSafe.

@SmallTest
@Test
public void testDeleteDbSafe() {
    AMPrefUtil mockPrefUtil = Mockito.mock(AMPrefUtil.class);
    AMFileUtil amFileUtil = new AMFileUtil(getContext(), mockPrefUtil);
    amFileUtil.deleteDbSafe(TestHelper.SAMPLE_DB_PATH);
    Mockito.verify(mockPrefUtil).removePrefKeys(TestHelper.SAMPLE_DB_PATH);
}
Also used : AMFileUtil(org.liberty.android.fantastischmemo.utils.AMFileUtil) AMPrefUtil(org.liberty.android.fantastischmemo.utils.AMPrefUtil) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Aggregations

AMFileUtil (org.liberty.android.fantastischmemo.utils.AMFileUtil)5 AMPrefUtil (org.liberty.android.fantastischmemo.utils.AMPrefUtil)5 Before (org.junit.Before)3 AppComponents (org.liberty.android.fantastischmemo.modules.AppComponents)2 SmallTest (android.support.test.filters.SmallTest)1 Display (android.view.Display)1 WindowManager (android.view.WindowManager)1 File (java.io.File)1 Test (org.junit.Test)1 Card (org.liberty.android.fantastischmemo.entity.Card)1 Category (org.liberty.android.fantastischmemo.entity.Category)1 LearningData (org.liberty.android.fantastischmemo.entity.LearningData)1 Option (org.liberty.android.fantastischmemo.entity.Option)1 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)1 CardImageGetter (org.liberty.android.fantastischmemo.ui.CardImageGetter)1