diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-23 23:13:11 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-23 23:13:11 +0200 |
commit | ed82f0de9e880091c86845fcdf4fb58bdbb52798 (patch) | |
tree | fb8c0bed272111c8ad6b80712c5486391eb03319 /OpenKeychain/src | |
parent | 8d141176bd3bf8f67b04580dd7e988d8a846c0f5 (diff) | |
download | open-keychain-ed82f0de9e880091c86845fcdf4fb58bdbb52798.tar.gz open-keychain-ed82f0de9e880091c86845fcdf4fb58bdbb52798.tar.bz2 open-keychain-ed82f0de9e880091c86845fcdf4fb58bdbb52798.zip |
instrument: save file
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r-- | OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java index 50b7211b1..20ee6a8b1 100644 --- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java +++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java @@ -125,7 +125,7 @@ public class AsymmetricFileOperationTests { handleAddFileIntent(file); onView(withId(R.id.file_list_entry_add)).perform(click()); - handleSaveFileIntent(outputFile); + handleSaveEncryptedFileIntent(outputFile); onView(withId(R.id.encrypt_save)).perform(click()); assertThat("output file has been written", true, is(outputFile.exists())); @@ -145,6 +145,9 @@ public class AsymmetricFileOperationTests { onView(isRecyclerItemView(R.id.decrypted_files_list, hasDescendant(withText(file.getName())))) .check(matches(allOf(withEncryptionStatus(true), withSignatureNone()))); + } + + { // delete original file // open context menu onView(allOf(isDescendantOfA(isRecyclerItemView(R.id.decrypted_files_list, @@ -169,6 +172,29 @@ public class AsymmetricFileOperationTests { } + { // save file (*after* deletion~) + + // open context menu + onView(allOf(isDescendantOfA(isRecyclerItemView(R.id.decrypted_files_list, + hasDescendant(withText(file.getName())))), + withId(R.id.context_menu))).perform(click()); + + File savedFile = + new File(getInstrumentation().getTargetContext().getFilesDir(), "vo.png"); + handleSaveDecryptedFileIntent(savedFile, file.getName()); + + // save decrypted content + onView(withText(R.string.btn_save)).perform(click()); + + checkSnackbar(Style.OK, R.string.file_saved); + assertThat("decrypted file has been saved", true, is(savedFile.exists())); + + // cleanup + // noinspection ResultOfMethodCallIgnored + file.delete(); + + } + } private void handleAddFileIntent(File file) { @@ -208,7 +234,22 @@ public class AsymmetricFileOperationTests { } @TargetApi(VERSION_CODES.KITKAT) - private void handleSaveFileIntent(File file) { + private void handleSaveDecryptedFileIntent(File file, String expectedTitle) { + Intent data = new Intent(); + data.setData(Uri.fromFile(file)); + + Intents.intending(allOf( + hasAction(Intent.ACTION_CREATE_DOCUMENT), + hasExtra("android.content.extra.SHOW_ADVANCED", true), + hasExtra(Intent.EXTRA_TITLE, expectedTitle), + hasCategories(hasItem(Intent.CATEGORY_OPENABLE)) + )).respondWith( + new ActivityResult(Activity.RESULT_OK, data) + ); + } + + @TargetApi(VERSION_CODES.KITKAT) + private void handleSaveEncryptedFileIntent(File file) { try { //noinspection ResultOfMethodCallIgnored |