diff options
author | sail <sail@google.com> | 2017-08-31 16:48:09 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-09-07 04:37:37 +0000 |
commit | 53e1ce35f713139629cb24df6ea1245e11464a42 (patch) | |
tree | bf94bb3fcbf38857e65c4637aa0dde6bd637868b /java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java | |
parent | 273fd7bc5840a71cf8445455bc0bb1945e2cfc8d (diff) |
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
Diffstat (limited to 'java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java')
-rw-r--r-- | java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java | 13 |
1 files changed, 13 insertions, 0 deletions
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); } |