From 558cc6befca479d33c20ca58f426bda486b5ee8f Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Tue, 23 Jun 2015 00:00:19 +0200 Subject: instrument: adapt to new decrypt file dialog, and some minor fixes --- .../keychain/ui/AsymmetricFileOperationTests.java | 3 --- .../keychain/ui/MiscFileOperationTests.java | 30 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'OpenKeychain/src/androidTest') 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 ad9d52ef9..cfeb04328 100644 --- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java +++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java @@ -52,7 +52,6 @@ import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.typeText; import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist; import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.contrib.DrawerActions.openDrawer; import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction; import static android.support.test.espresso.intent.matcher.IntentMatchers.hasCategories; import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtra; @@ -140,8 +139,6 @@ public class AsymmetricFileOperationTests { handleOpenFileIntentKitKat(outputFile); onView(withId(R.id.decrypt_files)).perform(click()); - onView(withId(R.id.decrypt_files_action_decrypt)).perform(click()); - { // decrypt onView(withId(R.id.passphrase_passphrase)).perform(typeText("x")); onView(withText(R.string.btn_unlock)).perform(click()); diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/MiscFileOperationTests.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/MiscFileOperationTests.java index bdd96b0f0..b519ed445 100644 --- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/MiscFileOperationTests.java +++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/MiscFileOperationTests.java @@ -39,6 +39,7 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.TestHelpers; import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.service.PassphraseCacheService; +import org.sufficientlysecure.keychain.ui.util.Notify.Style; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; @@ -51,6 +52,7 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.hasItem; +import static org.sufficientlysecure.keychain.TestHelpers.checkSnackbar; import static org.sufficientlysecure.keychain.TestHelpers.getImageNames; import static org.sufficientlysecure.keychain.TestHelpers.importKeysFromResource; import static org.sufficientlysecure.keychain.TestHelpers.pickRandom; @@ -97,8 +99,6 @@ public class MiscFileOperationTests { handleOpenFileIntentKitKat(file); onView(withId(R.id.decrypt_files)).perform(click()); - onView(withId(R.id.decrypt_files_action_decrypt)).perform(click()); - { // decrypt // open context menu @@ -112,6 +112,17 @@ public class MiscFileOperationTests { } + @Test + public void testDecryptEmptySelection() throws Exception { + + // decrypt any non-pgp file + handleOpenFileEmptyKitKat(); + onView(withId(R.id.decrypt_files)).perform(click()); + + checkSnackbar(Style.ERROR, R.string.no_file_selected); + + } + @Test public void testDecryptNonPgpClipboard() throws Exception { @@ -134,6 +145,21 @@ public class MiscFileOperationTests { } + @TargetApi(VERSION_CODES.KITKAT) + private void handleOpenFileEmptyKitKat() { + Intent data = new Intent(); + data.setData(null); + + Intents.intending(allOf( + hasAction(Intent.ACTION_OPEN_DOCUMENT), + hasType("*/*"), + hasCategories(hasItem(Intent.CATEGORY_OPENABLE)) + // hasExtraWithKey(Intent.EXTRA_ALLOW_MULTIPLE) + )).respondWith( + new ActivityResult(Activity.RESULT_OK, data) + ); + } + @TargetApi(VERSION_CODES.KITKAT) private void handleOpenFileIntentKitKat(File file) { Intent data = new Intent(); -- cgit v1.2.3