aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EditKeyTest.java86
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java2
2 files changed, 87 insertions, 1 deletions
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EditKeyTest.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EditKeyTest.java
new file mode 100644
index 000000000..cee658f3e
--- /dev/null
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EditKeyTest.java
@@ -0,0 +1,86 @@
+package org.sufficientlysecure.keychain;
+
+
+import android.app.Activity;
+import android.content.Intent;
+import android.database.sqlite.SQLiteCursor;
+import android.support.test.espresso.Espresso;
+import android.support.test.espresso.action.ViewActions;
+import android.support.test.espresso.matcher.ViewMatchers;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import android.test.suitebuilder.annotation.LargeTest;
+import android.widget.AdapterView;
+
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.collection.IsMapContaining;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.sufficientlysecure.keychain.matcher.CustomMatchers;
+import org.sufficientlysecure.keychain.provider.KeychainDatabase;
+import org.sufficientlysecure.keychain.provider.ProviderHelper;
+import org.sufficientlysecure.keychain.ui.KeyListFragment.KeyListAdapter;
+import org.sufficientlysecure.keychain.ui.MainActivity;
+import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter.KeyItem;
+import org.sufficientlysecure.keychain.ui.util.Notify.Style;
+
+import static android.support.test.espresso.Espresso.onData;
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom;
+import static android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA;
+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.anything;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.sufficientlysecure.keychain.TestHelpers.checkSnackbar;
+import static org.sufficientlysecure.keychain.TestHelpers.importKeysFromResource;
+import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withKeyItemId;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@RunWith(AndroidJUnit4.class)
+@LargeTest
+public class EditKeyTest {
+
+ @Rule
+ public final ActivityTestRule<MainActivity> mActivity
+ = new ActivityTestRule<MainActivity>(MainActivity.class) {
+ @Override
+ protected Intent getActivityIntent() {
+ Intent intent = super.getActivityIntent();
+ intent.putExtra(MainActivity.EXTRA_SKIP_FIRST_TIME, true);
+ return intent;
+ }
+ };
+
+ @Test
+ public void test01Edit() throws Exception {
+ Activity activity = mActivity.getActivity();
+
+ new KeychainDatabase(activity).clearDatabase();
+
+ // import key for testing, get a stable initial state
+ importKeysFromResource(activity, "x.sec.asc");
+
+ // navigate to edit key dialog
+ onData(withKeyItemId(0x9D604D2F310716A3L))
+ .inAdapterView(allOf(isAssignableFrom(AdapterView.class),
+ isDescendantOfA(withId(R.id.key_list_list))))
+ .perform(click());
+ onView(withId(R.id.menu_key_view_edit)).perform(click());
+
+ // no-op should yield snackbar
+ onView(withText(R.string.btn_save)).perform(click());
+ checkSnackbar(Style.ERROR, R.string.msg_mf_error_noop);
+
+ }
+
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
index 8253801d9..36ba47672 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
@@ -179,7 +179,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
+ Tables.API_APPS + "(" + ApiAppsAllowedKeysColumns.PACKAGE_NAME + ") ON DELETE CASCADE"
+ ")";
- KeychainDatabase(Context context) {
+ public KeychainDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
mContext = context;