Loading android/app/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -422,7 +422,8 @@ public class BluetoothOppLauncherActivity extends Activity { launchDevicePicker(); launchDevicePicker(); finish(); finish(); } catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) { showToast(exception.getMessage()); String message = exception.getMessage(); showToast(message != null ? message : "IllegalArgumentException"); finish(); finish(); } } } } Loading android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppLauncherActivityTest.java +2 −16 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy; Loading Loading @@ -187,7 +188,6 @@ public class BluetoothOppLauncherActivityTest { assertThat(file.length()).isGreaterThan(shareContent.length()); assertThat(file.length()).isGreaterThan(shareContent.length()); } } @Ignore("b/263754734") @Test @Test public void sendFileInfo_finishImmediately() throws Exception { public void sendFileInfo_finishImmediately() throws Exception { doReturn(true).when(mMethodProxy).bluetoothAdapterIsEnabled(any()); doReturn(true).when(mMethodProxy).bluetoothAdapterIsEnabled(any()); Loading @@ -195,7 +195,7 @@ public class BluetoothOppLauncherActivityTest { mIntent.setAction("unsupported-action"); mIntent.setAction("unsupported-action"); ActivityScenario<BluetoothOppLauncherActivity> scenario = ActivityScenario.launch(mIntent); ActivityScenario<BluetoothOppLauncherActivity> scenario = ActivityScenario.launch(mIntent); doThrow(new IllegalArgumentException()).when(mBluetoothOppManager).saveSendingFileInfo( doThrow(new IllegalArgumentException()).when(mBluetoothOppManager).saveSendingFileInfo( any(), any(String.class), any(), any()); any(), any(String.class), anyBoolean(), anyBoolean()); scenario.onActivity(activity -> { scenario.onActivity(activity -> { activity.sendFileInfo("text/plain", "content:///abc.txt", false, false); activity.sendFileInfo("text/plain", "content:///abc.txt", false, false); }); }); Loading @@ -208,18 +208,4 @@ public class BluetoothOppLauncherActivityTest { Thread.sleep(2_000); Thread.sleep(2_000); assertThat(activityScenario.getState()).isEqualTo(state); assertThat(activityScenario.getState()).isEqualTo(state); } } private void enableActivity(boolean enable) { int enabledState = enable ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DEFAULT; mTargetContext.getPackageManager().setApplicationEnabledSetting( mTargetContext.getPackageName(), enabledState, DONT_KILL_APP); ComponentName activityName = new ComponentName(mTargetContext, BluetoothOppLauncherActivity.class); mTargetContext.getPackageManager().setComponentEnabledSetting( activityName, enabledState, DONT_KILL_APP); } } } Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -422,7 +422,8 @@ public class BluetoothOppLauncherActivity extends Activity { launchDevicePicker(); launchDevicePicker(); finish(); finish(); } catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) { showToast(exception.getMessage()); String message = exception.getMessage(); showToast(message != null ? message : "IllegalArgumentException"); finish(); finish(); } } } } Loading
android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppLauncherActivityTest.java +2 −16 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy; Loading Loading @@ -187,7 +188,6 @@ public class BluetoothOppLauncherActivityTest { assertThat(file.length()).isGreaterThan(shareContent.length()); assertThat(file.length()).isGreaterThan(shareContent.length()); } } @Ignore("b/263754734") @Test @Test public void sendFileInfo_finishImmediately() throws Exception { public void sendFileInfo_finishImmediately() throws Exception { doReturn(true).when(mMethodProxy).bluetoothAdapterIsEnabled(any()); doReturn(true).when(mMethodProxy).bluetoothAdapterIsEnabled(any()); Loading @@ -195,7 +195,7 @@ public class BluetoothOppLauncherActivityTest { mIntent.setAction("unsupported-action"); mIntent.setAction("unsupported-action"); ActivityScenario<BluetoothOppLauncherActivity> scenario = ActivityScenario.launch(mIntent); ActivityScenario<BluetoothOppLauncherActivity> scenario = ActivityScenario.launch(mIntent); doThrow(new IllegalArgumentException()).when(mBluetoothOppManager).saveSendingFileInfo( doThrow(new IllegalArgumentException()).when(mBluetoothOppManager).saveSendingFileInfo( any(), any(String.class), any(), any()); any(), any(String.class), anyBoolean(), anyBoolean()); scenario.onActivity(activity -> { scenario.onActivity(activity -> { activity.sendFileInfo("text/plain", "content:///abc.txt", false, false); activity.sendFileInfo("text/plain", "content:///abc.txt", false, false); }); }); Loading @@ -208,18 +208,4 @@ public class BluetoothOppLauncherActivityTest { Thread.sleep(2_000); Thread.sleep(2_000); assertThat(activityScenario.getState()).isEqualTo(state); assertThat(activityScenario.getState()).isEqualTo(state); } } private void enableActivity(boolean enable) { int enabledState = enable ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DEFAULT; mTargetContext.getPackageManager().setApplicationEnabledSetting( mTargetContext.getPackageName(), enabledState, DONT_KILL_APP); ComponentName activityName = new ComponentName(mTargetContext, BluetoothOppLauncherActivity.class); mTargetContext.getPackageManager().setComponentEnabledSetting( activityName, enabledState, DONT_KILL_APP); } } }