Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapActivity.java +6 −4 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.view.View; import android.widget.EditText; import android.widget.TextView; import com.android.bluetooth.BluetoothMethodProxy; import com.android.bluetooth.R; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -87,9 +88,9 @@ public class BluetoothPbapActivity extends AlertActivity private boolean mTimeout = false; private static final int DISMISS_TIMEOUT_DIALOG = 0; @VisibleForTesting static final int DISMISS_TIMEOUT_DIALOG = 0; private static final int DISMISS_TIMEOUT_DIALOG_VALUE = 2000; @VisibleForTesting static final long DISMISS_TIMEOUT_DIALOG_DELAY_MS = 2_000; private BluetoothDevice mDevice; Loading Loading @@ -218,8 +219,9 @@ public class BluetoothPbapActivity extends AlertActivity changeButtonVisibility(DialogInterface.BUTTON_NEGATIVE, View.GONE); } mTimeoutHandler.sendMessageDelayed(mTimeoutHandler.obtainMessage(DISMISS_TIMEOUT_DIALOG), DISMISS_TIMEOUT_DIALOG_VALUE); BluetoothMethodProxy.getInstance() .handlerSendMessageDelayed( mTimeoutHandler, DISMISS_TIMEOUT_DIALOG, DISMISS_TIMEOUT_DIALOG_DELAY_MS); } @Override Loading android/app/tests/unit/src/com/android/bluetooth/pbap/BluetoothPbapActivityTest.java +19 −2 Original line number Diff line number Diff line Loading @@ -24,9 +24,16 @@ import static android.content.pm.PackageManager.DONT_KILL_APP; import static androidx.lifecycle.Lifecycle.State; import static androidx.lifecycle.Lifecycle.State.DESTROYED; import static com.android.bluetooth.pbap.BluetoothPbapActivity.DISMISS_TIMEOUT_DIALOG; import static com.android.bluetooth.pbap.BluetoothPbapActivity.DISMISS_TIMEOUT_DIALOG_DELAY_MS; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading @@ -38,6 +45,8 @@ import androidx.test.filters.LargeTest; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.BluetoothMethodProxy; import org.junit.After; import org.junit.Before; import org.junit.Test; Loading @@ -54,8 +63,13 @@ public class BluetoothPbapActivityTest { ActivityScenario<BluetoothPbapActivity> mActivityScenario; BluetoothMethodProxy mMethodProxy; @Before public void setUp() { mMethodProxy = spy(BluetoothMethodProxy.getInstance()); BluetoothMethodProxy.setInstanceForTesting(mMethodProxy); mIntent = new Intent(); mIntent.setClass(mTargetContext, BluetoothPbapActivity.class); mIntent.setAction(BluetoothPbapService.AUTH_CHALL_ACTION); Loading @@ -72,6 +86,7 @@ public class BluetoothPbapActivityTest { mActivityScenario.close(); } enableActivity(false); BluetoothMethodProxy.setInstanceForTesting(null); } @Test Loading Loading @@ -121,14 +136,16 @@ public class BluetoothPbapActivityTest { } @Test public void onReceiveTimeoutIntent_finishesActivity() throws Exception { public void onReceiveTimeoutIntent_sendsDismissDialogMessage() throws Exception { Intent intent = new Intent(BluetoothPbapService.USER_CONFIRM_TIMEOUT_ACTION); mActivityScenario.onActivity(activity -> { activity.mReceiver.onReceive(activity, intent); }); assertActivityState(DESTROYED); verify(mMethodProxy) .handlerSendMessageDelayed( any(), eq(DISMISS_TIMEOUT_DIALOG), eq(DISMISS_TIMEOUT_DIALOG_DELAY_MS)); } @Test Loading Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapActivity.java +6 −4 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.view.View; import android.widget.EditText; import android.widget.TextView; import com.android.bluetooth.BluetoothMethodProxy; import com.android.bluetooth.R; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -87,9 +88,9 @@ public class BluetoothPbapActivity extends AlertActivity private boolean mTimeout = false; private static final int DISMISS_TIMEOUT_DIALOG = 0; @VisibleForTesting static final int DISMISS_TIMEOUT_DIALOG = 0; private static final int DISMISS_TIMEOUT_DIALOG_VALUE = 2000; @VisibleForTesting static final long DISMISS_TIMEOUT_DIALOG_DELAY_MS = 2_000; private BluetoothDevice mDevice; Loading Loading @@ -218,8 +219,9 @@ public class BluetoothPbapActivity extends AlertActivity changeButtonVisibility(DialogInterface.BUTTON_NEGATIVE, View.GONE); } mTimeoutHandler.sendMessageDelayed(mTimeoutHandler.obtainMessage(DISMISS_TIMEOUT_DIALOG), DISMISS_TIMEOUT_DIALOG_VALUE); BluetoothMethodProxy.getInstance() .handlerSendMessageDelayed( mTimeoutHandler, DISMISS_TIMEOUT_DIALOG, DISMISS_TIMEOUT_DIALOG_DELAY_MS); } @Override Loading
android/app/tests/unit/src/com/android/bluetooth/pbap/BluetoothPbapActivityTest.java +19 −2 Original line number Diff line number Diff line Loading @@ -24,9 +24,16 @@ import static android.content.pm.PackageManager.DONT_KILL_APP; import static androidx.lifecycle.Lifecycle.State; import static androidx.lifecycle.Lifecycle.State.DESTROYED; import static com.android.bluetooth.pbap.BluetoothPbapActivity.DISMISS_TIMEOUT_DIALOG; import static com.android.bluetooth.pbap.BluetoothPbapActivity.DISMISS_TIMEOUT_DIALOG_DELAY_MS; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading @@ -38,6 +45,8 @@ import androidx.test.filters.LargeTest; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.BluetoothMethodProxy; import org.junit.After; import org.junit.Before; import org.junit.Test; Loading @@ -54,8 +63,13 @@ public class BluetoothPbapActivityTest { ActivityScenario<BluetoothPbapActivity> mActivityScenario; BluetoothMethodProxy mMethodProxy; @Before public void setUp() { mMethodProxy = spy(BluetoothMethodProxy.getInstance()); BluetoothMethodProxy.setInstanceForTesting(mMethodProxy); mIntent = new Intent(); mIntent.setClass(mTargetContext, BluetoothPbapActivity.class); mIntent.setAction(BluetoothPbapService.AUTH_CHALL_ACTION); Loading @@ -72,6 +86,7 @@ public class BluetoothPbapActivityTest { mActivityScenario.close(); } enableActivity(false); BluetoothMethodProxy.setInstanceForTesting(null); } @Test Loading Loading @@ -121,14 +136,16 @@ public class BluetoothPbapActivityTest { } @Test public void onReceiveTimeoutIntent_finishesActivity() throws Exception { public void onReceiveTimeoutIntent_sendsDismissDialogMessage() throws Exception { Intent intent = new Intent(BluetoothPbapService.USER_CONFIRM_TIMEOUT_ACTION); mActivityScenario.onActivity(activity -> { activity.mReceiver.onReceive(activity, intent); }); assertActivityState(DESTROYED); verify(mMethodProxy) .handlerSendMessageDelayed( any(), eq(DISMISS_TIMEOUT_DIALOG), eq(DISMISS_TIMEOUT_DIALOG_DELAY_MS)); } @Test Loading