diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-17 19:24:07 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-17 19:24:07 +0200 |
commit | 374b21410e82877efcdd1e5110376e975bddbf9f (patch) | |
tree | e17df8931d627e58da677aee274249e1d51c34e2 /OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EditKeyTest.java | |
parent | 1a7677008bae900fb11a383d04766737aaa3f02f (diff) | |
parent | 04d2b6a5076a1a7264687999152f8c24ece773ab (diff) | |
download | open-keychain-374b21410e82877efcdd1e5110376e975bddbf9f.tar.gz open-keychain-374b21410e82877efcdd1e5110376e975bddbf9f.tar.bz2 open-keychain-374b21410e82877efcdd1e5110376e975bddbf9f.zip |
Merge branch 'v/instrument' into v/multi-decrypt
Conflicts:
.travis.yml
OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/CreateKeyActivityTest.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
Diffstat (limited to 'OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EditKeyTest.java')
-rw-r--r-- | OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EditKeyTest.java | 89 |
1 files changed, 89 insertions, 0 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..6773a7b2d --- /dev/null +++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EditKeyTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2015 Vincent Breitmoser <look@my.amazin.horse> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.sufficientlysecure.keychain; + + +import android.app.Activity; +import android.content.Intent; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; +import android.test.suitebuilder.annotation.LargeTest; +import android.widget.AdapterView; + +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.provider.KeychainDatabase; +import org.sufficientlysecure.keychain.ui.MainActivity; +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.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); + + } + + +} |