From 53e1ce35f713139629cb24df6ea1245e11464a42 Mon Sep 17 00:00:00 2001 From: sail Date: Thu, 31 Aug 2017 16:48:09 -0700 Subject: Use simulator to add in-call UI integration tests This CL uses the simulator connection service to perform integration tests for incallui. The main pieces of this CL are: - DialerCallEvent - this is how we track changes to the incallui calls - Simulator.Event - this is how we track changes to a simulator connection With the above two we can do things like: - block until a DialerCall switches from ACTIVE TO ONHOLD: - DialerCallEspresso.waitForNextEvent(tracker, call, new DialerCallEvent(STATE_CHANGE, "ACTIVE", "ONHOLD") - block for a connection to recive a particular DTMF code: - SimulatorConnectionEspresso.waitForNextEvent(call, Event.DTMF) Future CLs will include things like: - fling to answer / reject - conference calls - screenshot diffing - video calling Test: InCallActivityTest PiperOrigin-RevId: 167211015 Change-Id: Ib013b10fe963092fad0816b07b1659efd69d9468 --- .../answer/impl/answermethod/AnswerMethodFactory.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java') diff --git a/java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java b/java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java index 35f36f727..ccb132b95 100644 --- a/java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java +++ b/java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java @@ -19,12 +19,15 @@ package com.android.incallui.answer.impl.answermethod; import android.app.Activity; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.support.v4.app.Fragment; +import com.android.dialer.common.LogUtil; import com.android.dialer.compat.ActivityCompat; import com.android.incallui.util.AccessibilityUtil; /** Creates the appropriate {@link AnswerMethod} for the circumstances. */ public class AnswerMethodFactory { + private static boolean shouldUseTwoButtonMethodForTesting; @NonNull public static AnswerMethod createAnswerMethod(@NonNull Activity activity) { @@ -45,7 +48,17 @@ public class AnswerMethodFactory { return !(answerMethod instanceof TwoButtonMethod) && needTwoButton(answerMethod.getActivity()); } + @VisibleForTesting + public static void setShouldUseTwoButtonMethodForTesting(boolean shouldUse) { + shouldUseTwoButtonMethodForTesting = shouldUse; + } + private static boolean needTwoButton(@NonNull Activity activity) { + if (shouldUseTwoButtonMethodForTesting) { + LogUtil.i("AnswerMethodFactory.needTwoButton", "enabled for testing"); + return true; + } + return AccessibilityUtil.isTouchExplorationEnabled(activity) || ActivityCompat.isInMultiWindowMode(activity); } -- cgit v1.2.3