instrument: fix accidentally broken test

This commit is contained in:
Vincent Breitmoser 2015-06-17 23:11:11 +02:00
parent f5aa36ef9f
commit 297f53e171

View File

@ -17,17 +17,18 @@
package org.sufficientlysecure.keychain; package org.sufficientlysecure.keychain;
import android.support.test.InstrumentationRegistry;
import android.content.Intent;
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 android.text.method.HideReturnsTransformationMethod; import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod; import android.text.method.PasswordTransformationMethod;
import org.junit.Before; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity; import org.sufficientlysecure.keychain.ui.MainActivity;
import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.click;
@ -47,26 +48,29 @@ import static org.sufficientlysecure.keychain.matcher.EditTextMatchers.withTrans
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
@LargeTest @LargeTest
public class CreateKeyActivityTest extends ActivityInstrumentationTestCase2<CreateKeyActivity> { public class CreateKeyActivityTest {
public static final String SAMPLE_NAME = "Sample Name"; public static final String SAMPLE_NAME = "Sample Name";
public static final String SAMPLE_EMAIL = "sample_email@gmail.com"; public static final String SAMPLE_EMAIL = "sample_email@gmail.com";
public static final String SAMPLE_ADDITIONAL_EMAIL = "sample_additional_email@gmail.com"; public static final String SAMPLE_ADDITIONAL_EMAIL = "sample_additional_email@gmail.com";
public static final String SAMPLE_PASSWORD = "sample_password"; public static final String SAMPLE_PASSWORD = "sample_password";
public CreateKeyActivityTest() { @Rule
super(CreateKeyActivity.class); public final ActivityTestRule<MainActivity> mActivity
} = new ActivityTestRule<MainActivity>(MainActivity.class) {
@Override
@Before protected Intent getActivityIntent() {
public void setUp() throws Exception { Intent intent = super.getActivityIntent();
super.setUp(); intent.putExtra(MainActivity.EXTRA_SKIP_FIRST_TIME, true);
injectInstrumentation(InstrumentationRegistry.getInstrumentation()); return intent;
getActivity(); }
} };
@Test @Test
public void testCreateMyKey() { public void testCreateMyKey() {
mActivity.getActivity();
// Clicks create my key // Clicks create my key
onView(withId(R.id.create_key_create_key_button)) onView(withId(R.id.create_key_create_key_button))
.perform(click()); .perform(click());