instrument: work on instrumentation tests

This commit is contained in:
Vincent Breitmoser 2015-06-14 20:21:13 +02:00
parent 908545e521
commit db0266c0ae
5 changed files with 264 additions and 158 deletions

View File

@ -0,0 +1,156 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFTxJOIBEACpXpXjz5ivyR/uWJexJXZrLHrvBRcivQSxzvy5Owdun8MGOxzo
YTPAJzskZH4Gg9MIQj9puUke8A59o9KtNMAd3Szp6aQs3lv/eGOw0DUe6g8a6kJ+
oQsHMYYLnyuYrOvQrBewKhh4FynkryvUZCL25dgrMHeTeMAeslCscdT6JYd2gxgi
o0+Bn8R6BonS7hTZStfAOYB0SO7X+7R0CpPsMiHtNZASzLRkk53dB9AO6m81CurP
qh1oPjc7j1QIiwCszSD8IxuR3fH6nyUlMtqx/mRmKNlbIYnr3sN5VAMp7THq/Qjt
9XDs1XHBE+0H+yg7K4fPamSJsxy9zPq/rA9vy4pQIMzxugxeWEn4OPWtguRSYtI1
WA+Ki93QJ+DVRlpMvz/MA71ZkvWUHpFnIssU52NdHZrIZ21KCo7PiPRY9tQkVhz5
S39a8npSeCIwZ9bH3UGKrRyPkhal59rjPqhZky1X+O2iTfbbFrPE+I4b46pWX9XU
UgXDnUh8Qeymhh0f1DTcbquW2nwU/R1quKjw/TCZQxKnkAzCXsVFk2QoIG1qDVrU
YlKXTXoYaRfzhMSYSvh7JHqdldB+MyKAbXpLtZsYIlLkuqe/KI0IPfO69ajDxLOr
+wTtuA9T1SICGmQkjYkQiqVy4y7vDW4Zw143sPXreZhiBbLBoWAIJ/JcbQARAQAB
tAVYIDx4PokCNwQTAQoAIQULCQgHAwYVCgkLCAMEFgIDAQIZAQWCVPEk4wKeAQKb
AQAKCRCdYE0vMQcWo/TGD/9SEfE7LxWw4pPNTpVTECDztpLGrj7kCr0anO6XnCqL
3OYoZz5vZvKBmunoPT7VqerQIZCnhB0b0ZOI+l51J03Xwvfy1+MIQCnZz++JY94B
h5dv3QAj8WUJJ6KfKrAxoXG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egNm6zHI98oQWUKdfqT2oRpamVpwtuXwzya2m/77e9hVbqE
Desr/pd1+0UMmluaP7NNe+sBMT+W89wkeKzCK4wvH0E+gSK/UwZdPITpPEHkfsvV
4JBZ9tlieQRaK5eV8PKh+8N+5+IZOwEBDM3d4+6FhQ3OdQH7WzIPgQ==
=AYKY
-----END PGP PRIVATE KEY BLOCK-----

View File

@ -82,7 +82,7 @@ public class EncryptDecryptSymmetricTests {
}; };
@Test @Test
public void test01ImportKeys() throws Exception { public void testSymmetricTextEncryptDecrypt() throws Exception {
MainActivity activity = mActivity.getActivity(); MainActivity activity = mActivity.getActivity();

View File

@ -18,200 +18,103 @@
package org.sufficientlysecure.keychain; package org.sufficientlysecure.keychain;
import android.support.test.InstrumentationRegistry; import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.test.espresso.matcher.ViewMatchers; import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4; import android.support.test.runner.AndroidJUnit4;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Before; import org.junit.Before;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.MainActivity; import org.sufficientlysecure.keychain.ui.MainActivity;
import org.sufficientlysecure.keychain.util.ProgressScaler;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.Espresso.pressBack;
import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.matcher.RootMatchers.isDialog;
import static android.support.test.espresso.matcher.RootMatchers.isPlatformPopup;
import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.sufficientlysecure.keychain.actions.CustomActions.actionOpenDrawer; import static org.sufficientlysecure.keychain.actions.CustomActions.actionOpenDrawer;
import static org.sufficientlysecure.keychain.actions.CustomActions.tokenEncryptViewAddToken;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
@LargeTest @LargeTest
public class EncryptDecryptTests extends ActivityInstrumentationTestCase2<MainActivity> { public class EncryptDecryptTests {
public static final String SAMPLE_NAME = "Sample Name"; @Rule
public static final String SAMPLE_EMAIL = "sample_email@gmail.com"; public final ActivityTestRule<MainActivity> mActivity
public static final String SAMPLE_ADDITIONAL_EMAIL = "sample_additional_email@gmail.com"; = new ActivityTestRule<MainActivity>(MainActivity.class) {
public static final String SAMPLE_PASSWORD = "sample_password"; @Override
private MainActivity mActivity; protected Intent getActivityIntent() {
Intent intent = super.getActivityIntent();
public EncryptDecryptTests() { intent.putExtra(MainActivity.EXTRA_SKIP_FIRST_TIME, true);
super(MainActivity.class); return intent;
} }
};
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); Activity activity = mActivity.getActivity();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
mActivity = getActivity(); // import these two, make sure they're there
importKeysFromResource(activity, "x.sec.asc");
} }
@Test @Test
public void test01ImportKeys() throws Exception { public void testTextEncryptDecrypt() throws Exception {
UncachedKeyRing pubkey = readRingFromResource("valodim.pub.asc"); // navigate to encrypt/decrypt
new ProviderHelper(mActivity).savePublicKeyRing(pubkey);
// open drawer
onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer()); onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
onView(ViewMatchers.withText(R.string.nav_encrypt_decrypt)).perform(click());
onView(withId(R.id.encrypt_text)).perform(click());
// go to encrypt/decrypt overview {
onView(ViewMatchers.withText(R.string.nav_keys)).perform(click()); // TODO instrument this (difficult because of TokenCompleteView's async implementation)
onView(withId(R.id.recipient_list)).perform(tokenEncryptViewAddToken(0x9D604D2F310716A3L));
/* String text = "how much wood";
// Clicks create my key onView(withId(R.id.encrypt_text_text)).perform(typeText(text));
onView(withId(R.id.create_key_create_key_button))
.perform(click());
// Clicks next with empty name onView(withId(R.id.encrypt_copy)).perform(click());
onView(withId(R.id.create_key_next_button)) }
.perform(click());
onView(withId(R.id.create_key_name))
.check(matches(withError(R.string.create_key_empty)));
// Types name and clicks next // go to decrypt from clipboard view
onView(withId(R.id.create_key_name)) pressBack();
.perform(typeText(SAMPLE_NAME)); onView(withId(R.id.decrypt_from_clipboard)).perform(click());
onView(withId(R.id.create_key_next_button))
.perform(click());
// Clicks next with empty email // synchronization with passphrase caching thing doesn't work
onView(withId(R.id.create_key_next_button)) onView(withId(R.id.passphrase_passphrase)).inRoot(isPlatformPopup()).perform(typeText("x"));
.perform(click());
onView(withId(R.id.create_key_email))
.check(matches(withError(R.string.create_key_empty)));
// Types email
onView(withId(R.id.create_key_email))
.perform(typeText(SAMPLE_EMAIL));
// Adds same email as additional email and dismisses the snackbar
onView(withId(R.id.create_key_add_email))
.perform(click());
onView(withId(R.id.add_email_address))
.perform(typeText(SAMPLE_EMAIL));
onView(withText(android.R.string.ok))
.inRoot(isDialog())
.perform(click());
onView(allOf(withId(R.id.sb__text), withText(R.string.create_key_email_already_exists_text)))
.check(matches(isDisplayed()));
onView(allOf(withId(R.id.sb__text), withText(R.string.create_key_email_already_exists_text)))
.perform(swipeLeft());
// Adds additional email
onView(withId(R.id.create_key_add_email))
.perform(click());
onView(withId(R.id.add_email_address))
.perform(typeText(SAMPLE_ADDITIONAL_EMAIL));
onView(withText(android.R.string.ok))
.inRoot(isDialog())
.perform(click());
onView(withId(R.id.create_key_emails))
.check(matches(hasDescendant(allOf(withId(R.id.create_key_email_item_email), withText(SAMPLE_ADDITIONAL_EMAIL)))));
// Removes additional email and clicks next
onView(allOf(withId(R.id.create_key_email_item_delete_button), hasSibling(allOf(withId(R.id.create_key_email_item_email), withText(SAMPLE_ADDITIONAL_EMAIL)))))
.perform(click())
.check(doesNotExist());
onView(withId(R.id.create_key_next_button))
.perform(click(click()));
// Clicks next with empty password
onView(withId(R.id.create_key_next_button))
.perform(click());
onView(withId(R.id.create_key_passphrase))
.check(matches(withError(R.string.create_key_empty)));
// Types password
onView(withId(R.id.create_key_passphrase))
.perform(typeText(SAMPLE_PASSWORD));
// Clicks next with empty confirm password
onView(withId(R.id.create_key_next_button))
.perform(click());
onView(withId(R.id.create_key_passphrase_again))
.check(matches(withError(R.string.create_key_passphrases_not_equal)));
// Types confirm password
onView(withId(R.id.create_key_passphrase_again))
.perform(typeText(SAMPLE_PASSWORD));
// Clicks show password twice and clicks next
onView(withId(R.id.create_key_show_passphrase))
.perform(click());
onView(withId(R.id.create_key_passphrase))
.check(matches(withTransformationMethod(HideReturnsTransformationMethod.class)));
onView(withId(R.id.create_key_passphrase_again))
.check(matches(withTransformationMethod(HideReturnsTransformationMethod.class)));
onView(withId(R.id.create_key_show_passphrase))
.perform(click());
onView(withId(R.id.create_key_passphrase))
.check(matches(withTransformationMethod(PasswordTransformationMethod.class)));
onView(withId(R.id.create_key_passphrase_again))
.check(matches(withTransformationMethod(PasswordTransformationMethod.class)));
onView(withId(R.id.create_key_next_button))
.perform(click());
// Verifies name and email
onView(withId(R.id.name))
.check(matches(withText(SAMPLE_NAME)));
onView(withId(R.id.email))
.check(matches(withText(SAMPLE_EMAIL)));
// Verifies backstack
onView(withId(R.id.create_key_back_button))
.perform(click());
onView(withId(R.id.create_key_back_button))
.perform(click());
onView(withId(R.id.create_key_back_button))
.perform(click());
onView(withId(R.id.create_key_name))
.check(matches(withText(SAMPLE_NAME)));
onView(withId(R.id.create_key_next_button))
.perform(click());
onView(withId(R.id.create_key_email))
.check(matches(withText(SAMPLE_EMAIL)));
onView(withId(R.id.create_key_next_button))
.perform(click());
// TODO: Uncomment when fixed in main
// onView(withId(R.id.create_key_passphrase))
// .check(matches(withText(SAMPLE_PASSWORD)));
// onView(withId(R.id.create_key_passphrase_again))
// .check(matches(withText(SAMPLE_PASSWORD)));
onView(withId(R.id.create_key_next_button))
.perform(click());
onView(withId(R.id.name))
.check(matches(withText(SAMPLE_NAME)));
onView(withId(R.id.email))
.check(matches(withText(SAMPLE_EMAIL)));
// Clicks create key
onView(withId(R.id.create_key_next_button))
.perform(click());
*/
} }
UncachedKeyRing readRingFromResource(String name) throws Exception { static void importKeysFromResource(Context context, String name) throws Exception {
return UncachedKeyRing.fromStream(getInstrumentation().getContext().getAssets().open(name)).next(); IteratorWithIOThrow<UncachedKeyRing> stream = UncachedKeyRing.fromStream(
getInstrumentation().getContext().getAssets().open(name));
ProviderHelper helper = new ProviderHelper(context);
while(stream.hasNext()) {
UncachedKeyRing ring = stream.next();
if (ring.isSecret()) {
helper.saveSecretKeyRing(ring, new ProgressScaler());
} else {
helper.saveSecretKeyRing(ring, new ProgressScaler());
}
}
} }
} }

View File

@ -8,11 +8,59 @@ import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.view.View; import android.view.View;
import com.tokenautocomplete.TokenCompleteTextView;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter;
import static android.support.test.InstrumentationRegistry.getTargetContext;
public abstract class CustomActions { public abstract class CustomActions {
public static ViewAction tokenEncryptViewAddToken(long keyId) throws Exception {
CanonicalizedPublicKeyRing ring =
new ProviderHelper(getTargetContext()).getCanonicalizedPublicKeyRing(keyId);
final Object item = new KeyAdapter.KeyItem(ring);
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return ViewMatchers.isAssignableFrom(TokenCompleteTextView.class);
}
@Override
public String getDescription() {
return "add completion token";
}
@Override
public void perform(UiController uiController, View view) {
((TokenCompleteTextView) view).addObject(item);
}
};
}
public static ViewAction tokenViewAddToken(final Object item) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return ViewMatchers.isAssignableFrom(TokenCompleteTextView.class);
}
@Override
public String getDescription() {
return "add completion token";
}
@Override
public void perform(UiController uiController, View view) {
((TokenCompleteTextView) view).addObject(item);
}
};
}
public static ViewAction actionOpenDrawer() { public static ViewAction actionOpenDrawer() {
return new ViewAction() { return new ViewAction() {
@Override @Override

View File

@ -75,7 +75,6 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.encrypt_asymmetric_fragment, container, false); View view = inflater.inflate(R.layout.encrypt_asymmetric_fragment, container, false);
mSignKeySpinner = (KeySpinner) view.findViewById(R.id.sign); mSignKeySpinner = (KeySpinner) view.findViewById(R.id.sign);
mEncryptKeyView = (EncryptKeyCompletionView) view.findViewById(R.id.recipient_list); mEncryptKeyView = (EncryptKeyCompletionView) view.findViewById(R.id.recipient_list);
mEncryptKeyView.setThreshold(1); // Start working from first character mEncryptKeyView.setThreshold(1); // Start working from first character