mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +02:00
Don't let the doze dialog make the tests fail
This commit is contained in:
parent
b495b847f4
commit
dfb13ca7a4
2 changed files with 17 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.b44t.messenger;
|
package com.b44t.messenger;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -62,16 +63,29 @@ public class TestUtils {
|
||||||
Intent intent =
|
Intent intent =
|
||||||
Intent.makeMainActivity(
|
Intent.makeMainActivity(
|
||||||
new ComponentName(getInstrumentation().getTargetContext(), ConversationListActivity.class));
|
new ComponentName(getInstrumentation().getTargetContext(), ConversationListActivity.class));
|
||||||
TestUtils.createOfflineAccount();
|
createOfflineAccount();
|
||||||
|
prepare();
|
||||||
return new ActivityScenarioRule<>(intent);
|
return new ActivityScenarioRule<>(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static <T extends Activity> ActivityScenarioRule<T> getOnlineActivityRule(Class<T> activityClass) {
|
||||||
|
Context context = getInstrumentation().getTargetContext();
|
||||||
|
AccountManager.getInstance().beginAccountCreation(context);
|
||||||
|
prepare();
|
||||||
|
return new ActivityScenarioRule<>(new Intent(getInstrumentation().getTargetContext(), activityClass));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void prepare() {
|
||||||
|
Prefs.setBooleanPreference(getInstrumentation().getTargetContext(), Prefs.DOZE_ASKED_DIRECTLY, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform action of waiting for a certain view within a single root view
|
* Perform action of waiting for a certain view within a single root view
|
||||||
*
|
*
|
||||||
* @param matcher Generic Matcher used to find our view
|
* @param matcher Generic Matcher used to find our view
|
||||||
*/
|
*/
|
||||||
static ViewAction searchFor(Matcher<View> matcher) {
|
private static ViewAction searchFor(Matcher<View> matcher) {
|
||||||
return new ViewAction() {
|
return new ViewAction() {
|
||||||
|
|
||||||
public Matcher<View> getConstraints() {
|
public Matcher<View> getConstraints() {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package com.b44t.messenger.uitests.online;
|
package com.b44t.messenger.uitests.online;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.test.ext.junit.rules.ActivityScenarioRule;
|
import androidx.test.ext.junit.rules.ActivityScenarioRule;
|
||||||
|
@ -18,7 +16,6 @@ import org.junit.runner.RunWith;
|
||||||
import org.thoughtcrime.securesms.BuildConfig;
|
import org.thoughtcrime.securesms.BuildConfig;
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.WelcomeActivity;
|
import org.thoughtcrime.securesms.WelcomeActivity;
|
||||||
import org.thoughtcrime.securesms.connect.AccountManager;
|
|
||||||
|
|
||||||
import static androidx.test.espresso.Espresso.onView;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static androidx.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
|
@ -28,19 +25,12 @@ import static androidx.test.espresso.matcher.ViewMatchers.isClickable;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
|
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withHint;
|
import static androidx.test.espresso.matcher.ViewMatchers.withHint;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class OnboardingTest {
|
public class OnboardingTest {
|
||||||
@Rule
|
@Rule
|
||||||
public ActivityScenarioRule<WelcomeActivity> activityRule = new ActivityScenarioRule<>(getIntent());
|
public ActivityScenarioRule<WelcomeActivity> activityRule = TestUtils.getOnlineActivityRule(WelcomeActivity.class);
|
||||||
|
|
||||||
private Intent getIntent() {
|
|
||||||
Context context = getInstrumentation().getTargetContext();
|
|
||||||
AccountManager.getInstance().beginAccountCreation(context);
|
|
||||||
return new Intent(getInstrumentation().getTargetContext(), WelcomeActivity.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAccountCreation() {
|
public void testAccountCreation() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue