mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-07 03:28:09 -05:00
instrument: adapt to new decrypt file dialog, and some minor fixes
This commit is contained in:
parent
4826e0a8c8
commit
558cc6befc
@ -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());
|
||||
|
@ -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();
|
||||
|
@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
@ -152,7 +153,10 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
final ImportKeyResult result =
|
||||
returnData.getParcelable(OperationResult.EXTRA_RESULT);
|
||||
|
||||
result.createNotify(getActivity()).show();
|
||||
Activity activity = getActivity();
|
||||
if (result != null && activity != null) {
|
||||
result.createNotify(activity).show();
|
||||
}
|
||||
|
||||
getLoaderManager().restartLoader(LOADER_ID_UNIFIED, null, DecryptFragment.this);
|
||||
}
|
||||
|
@ -28,15 +28,10 @@ import android.support.v4.app.Fragment;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.intents.OpenKeychainIntents;
|
||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
public class DisplayTextActivity extends BaseActivity {
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import android.app.Activity;
|
||||
@ -152,7 +151,7 @@ public class EncryptDecryptOverviewFragment extends Fragment {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
Uri uri = data.getData();
|
||||
if (uri == null) {
|
||||
Notify.create(getActivity(), R.string.no_file_selected, Notify.Style.ERROR).show(this);
|
||||
Notify.create(getActivity(), R.string.no_file_selected, Notify.Style.ERROR).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@
|
||||
<string name="file_delete_confirmation_title">"Delete original files?"</string>
|
||||
<string name="file_delete_confirmation">"The following files will be deleted:%s"</string>
|
||||
<string name="file_delete_successful">"%1$d out of %2$d files have been deleted.%3$s"</string>
|
||||
<string name="no_file_selected">"Select a file first."</string>
|
||||
<string name="no_file_selected">"No file selected."</string>
|
||||
<string name="encrypt_sign_successful">"Successfully signed and/or encrypted."</string>
|
||||
<string name="encrypt_sign_clipboard_successful">"Successfully signed and/or encrypted to clipboard."</string>
|
||||
<string name="select_encryption_key">"Select at least one encryption key."</string>
|
||||
|
Loading…
Reference in New Issue
Block a user