Merge changes from topic "media_output_dialog" into rvc-qpr-dev
* changes: Redirect to output switcher panel to the new dialog Update rule of launching media output dialog Update OutputSwitcher from MediaOutputSlice to MediaOutputDialog in Settings Add PairNewBluetoothReceiver to launch Bluetooth pairing page
This commit is contained in:
@@ -23,6 +23,8 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -54,6 +56,7 @@ import com.android.settingslib.media.MediaOutputSliceConstants;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -203,31 +206,45 @@ public class MediaOutputIndicatorSliceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMediaOutputSliceIntent_withActiveLocalMedia_verifyIntentExtra() {
|
||||
public void onNotifyChange_withActiveLocalMedia_verifyIntentExtra() {
|
||||
when(mMediaController.getSessionToken()).thenReturn(mToken);
|
||||
when(mMediaController.getPackageName()).thenReturn(TEST_PACKAGE_NAME);
|
||||
doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
|
||||
.getActiveLocalMediaController();
|
||||
final Intent intent = mMediaOutputIndicatorSlice.getMediaOutputSliceIntent();
|
||||
ArgumentCaptor<Intent> argument = ArgumentCaptor.forClass(Intent.class);
|
||||
|
||||
mMediaOutputIndicatorSlice.onNotifyChange(null);
|
||||
verify(mContext, times(2)).sendBroadcast(argument.capture());
|
||||
List<Intent> intentList = argument.getAllValues();
|
||||
Intent intent = intentList.get(0);
|
||||
|
||||
assertThat(TextUtils.equals(TEST_PACKAGE_NAME, intent.getStringExtra(
|
||||
MediaOutputSliceConstants.EXTRA_PACKAGE_NAME))).isTrue();
|
||||
assertThat(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT).isEqualTo(intent.getAction());
|
||||
assertThat(TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, intent.getPackage())).isTrue();
|
||||
assertThat(MediaOutputSliceConstants.ACTION_LAUNCH_MEDIA_OUTPUT_DIALOG).isEqualTo(
|
||||
intent.getAction());
|
||||
assertThat(TextUtils.equals(MediaOutputSliceConstants.SYSTEMUI_PACKAGE_NAME,
|
||||
intent.getPackage())).isTrue();
|
||||
assertThat(mToken == intent.getExtras().getParcelable(
|
||||
MediaOutputSliceConstants.KEY_MEDIA_SESSION_TOKEN)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMediaOutputSliceIntent_withoutActiveLocalMedia_verifyIntentExtra() {
|
||||
public void onNotifyChange_withoutActiveLocalMedia_verifyIntentExtra() {
|
||||
doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
|
||||
.getActiveLocalMediaController();
|
||||
final Intent intent = mMediaOutputIndicatorSlice.getMediaOutputSliceIntent();
|
||||
ArgumentCaptor<Intent> argument = ArgumentCaptor.forClass(Intent.class);
|
||||
|
||||
mMediaOutputIndicatorSlice.onNotifyChange(null);
|
||||
verify(mContext, times(2)).sendBroadcast(argument.capture());
|
||||
List<Intent> intentList = argument.getAllValues();
|
||||
Intent intent = intentList.get(0);
|
||||
|
||||
assertThat(TextUtils.isEmpty(intent.getStringExtra(
|
||||
MediaOutputSliceConstants.EXTRA_PACKAGE_NAME))).isTrue();
|
||||
assertThat(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT).isEqualTo(intent.getAction());
|
||||
assertThat(TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, intent.getPackage())).isTrue();
|
||||
assertThat(MediaOutputSliceConstants.ACTION_LAUNCH_MEDIA_OUTPUT_DIALOG).isEqualTo(
|
||||
intent.getAction());
|
||||
assertThat(TextUtils.equals(MediaOutputSliceConstants.SYSTEMUI_PACKAGE_NAME,
|
||||
intent.getPackage())).isTrue();
|
||||
assertThat(intent.getExtras().getParcelable(
|
||||
MediaOutputSliceConstants.KEY_MEDIA_SESSION_TOKEN) == null).isTrue();
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.panel;
|
||||
|
||||
import static com.android.settings.panel.SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME;
|
||||
import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT;
|
||||
import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -67,13 +66,4 @@ public class PanelFeatureProviderImplTest {
|
||||
|
||||
assertThat(panel).isInstanceOf(VolumePanel.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPanel_mediaOutputKey_returnsCorrectPanel() {
|
||||
mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, ACTION_MEDIA_OUTPUT);
|
||||
|
||||
final PanelContent panel = mProvider.getPanel(mContext, mBundle);
|
||||
|
||||
assertThat(panel).isInstanceOf(MediaOutputPanel.class);
|
||||
}
|
||||
}
|
||||
|
@@ -299,9 +299,9 @@ public class MediaOutputPreferenceControllerTest {
|
||||
|
||||
mPreference.setKey(TEST_KEY);
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
verify(mContext).startActivity(intentCaptor.capture());
|
||||
verify(mContext).sendBroadcast(intentCaptor.capture());
|
||||
assertThat(intentCaptor.getValue().getAction())
|
||||
.isEqualTo(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT);
|
||||
.isEqualTo(MediaOutputSliceConstants.ACTION_LAUNCH_MEDIA_OUTPUT_DIALOG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user