Don't let the doze dialog make the tests fail

This commit is contained in:
Hocuri 2021-10-01 13:31:38 +02:00
parent b495b847f4
commit dfb13ca7a4
No known key found for this signature in database
GPG key ID: 0D45AD9007D18DCD
2 changed files with 17 additions and 13 deletions

View file

@ -1,5 +1,6 @@
package com.b44t.messenger;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@ -62,16 +63,29 @@ public class TestUtils {
Intent intent =
Intent.makeMainActivity(
new ComponentName(getInstrumentation().getTargetContext(), ConversationListActivity.class));
TestUtils.createOfflineAccount();
createOfflineAccount();
prepare();
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
*
* @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() {
public Matcher<View> getConstraints() {