Search in sources :

Example 1 with LocalStorage

use of com.orgzly.android.LocalStorage in project orgzly-android by orgzly.

the class SavedSearchesFragmentTest method testExportSavedSearches.

@Test
public void testExportSavedSearches() throws IOException {
    Intents.init();
    // Uri to get back after sending Intent.ACTION_CREATE_DOCUMENT
    DocumentFile file = DocumentFile.fromFile(new LocalStorage(context).downloadsDirectory("searches.json"));
    Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, new Intent().setData(file.getUri()));
    intending(hasAction(Intent.ACTION_CREATE_DOCUMENT)).respondWith(result);
    onActionItemClick(R.id.saved_searches_export, R.string.export);
    onSnackbar().check(matches(withText(context.getResources().getQuantityString(R.plurals.exported_searches, 4, 4))));
    Intents.release();
    file.delete();
}
Also used : DocumentFile(androidx.documentfile.provider.DocumentFile) LocalStorage(com.orgzly.android.LocalStorage) Instrumentation(android.app.Instrumentation) Intent(android.content.Intent) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Aggregations

Instrumentation (android.app.Instrumentation)1 Intent (android.content.Intent)1 DocumentFile (androidx.documentfile.provider.DocumentFile)1 LocalStorage (com.orgzly.android.LocalStorage)1 OrgzlyTest (com.orgzly.android.OrgzlyTest)1 Test (org.junit.Test)1