Add entry point to launch media output slice
Add media output panel type to launch media output slice. Bug: 121083246 Test: make -j RunSettingsRoboTests Change-Id: Ibf706146430e309fef6cbf0e1e86c2d5b78b50d5
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package com.android.settings.panel;
|
||||
|
||||
import static com.android.settings.media.MediaOutputSlice.MEDIA_PACKAGE_NAME;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class MediaOutputPanelTest {
|
||||
|
||||
private static final String TEST_PACKAGENAME = "com.test.packagename";
|
||||
|
||||
private MediaOutputPanel mPanel;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mPanel = MediaOutputPanel.create(RuntimeEnvironment.application, TEST_PACKAGENAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlices_containsNecessarySlices() {
|
||||
final List<Uri> uris = mPanel.getSlices();
|
||||
|
||||
assertThat(uris).containsExactly(CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlices_verifyPackageName_isEqual() {
|
||||
final List<Uri> uris = mPanel.getSlices();
|
||||
|
||||
assertThat(uris.get(0).getQueryParameter(MEDIA_PACKAGE_NAME)).isEqualTo(TEST_PACKAGENAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSeeMoreIntent_isNull() {
|
||||
assertThat(mPanel.getSeeMoreIntent()).isNull();
|
||||
}
|
||||
}
|
@@ -17,6 +17,8 @@
|
||||
|
||||
package com.android.settings.panel;
|
||||
|
||||
import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -32,6 +34,8 @@ import org.robolectric.RuntimeEnvironment;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class PanelFeatureProviderImplTest {
|
||||
|
||||
private static final String TEST_PACKAGENAME = "com.test.packagename";
|
||||
|
||||
private Context mContext;
|
||||
private PanelFeatureProviderImpl mProvider;
|
||||
|
||||
@@ -44,7 +48,7 @@ public class PanelFeatureProviderImplTest {
|
||||
@Test
|
||||
public void getPanel_internetConnectivityKey_returnsCorrectPanel() {
|
||||
final PanelContent panel = mProvider.getPanel(mContext,
|
||||
Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
|
||||
Settings.Panel.ACTION_INTERNET_CONNECTIVITY, TEST_PACKAGENAME);
|
||||
|
||||
assertThat(panel).isInstanceOf(InternetConnectivityPanel.class);
|
||||
}
|
||||
@@ -52,8 +56,16 @@ public class PanelFeatureProviderImplTest {
|
||||
@Test
|
||||
public void getPanel_volume_returnsCorrectPanel() {
|
||||
final PanelContent panel = mProvider.getPanel(mContext,
|
||||
Settings.Panel.ACTION_VOLUME);
|
||||
Settings.Panel.ACTION_VOLUME, TEST_PACKAGENAME);
|
||||
|
||||
assertThat(panel).isInstanceOf(VolumePanel.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPanel_mediaOutputKey_returnsCorrectPanel() {
|
||||
final PanelContent panel = mProvider.getPanel(mContext,
|
||||
ACTION_MEDIA_OUTPUT, TEST_PACKAGENAME);
|
||||
|
||||
assertThat(panel).isInstanceOf(MediaOutputPanel.class);
|
||||
}
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ public class PanelFragmentTest {
|
||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mFakeFeatureFactory.panelFeatureProvider = mPanelFeatureProvider;
|
||||
mFakePanelContent = new FakePanelContent();
|
||||
doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any());
|
||||
doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any(), any());
|
||||
|
||||
ActivityController<FakeSettingsPanelActivity> activityController =
|
||||
Robolectric.buildActivity(FakeSettingsPanelActivity.class);
|
||||
|
@@ -58,7 +58,7 @@ public class PanelSlicesAdapterTest {
|
||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mFakeFeatureFactory.panelFeatureProvider = mPanelFeatureProvider;
|
||||
mFakePanelContent = new FakePanelContent();
|
||||
doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any());
|
||||
doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any(), any());
|
||||
|
||||
ActivityController<FakeSettingsPanelActivity> activityController =
|
||||
Robolectric.buildActivity(FakeSettingsPanelActivity.class);
|
||||
|
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.panel;
|
||||
|
||||
import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_PACKAGE_NAME;
|
||||
import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class SettingsPanelActivityTest {
|
||||
|
||||
@Test
|
||||
public void startMediaOutputSlice_withPackageName_bundleShouldHaveValue() {
|
||||
final Intent intent = new Intent()
|
||||
.setAction("com.android.settings.panel.action.MEDIA_OUTPUT")
|
||||
.putExtra("com.android.settings.panel.extra.PACKAGE_NAME",
|
||||
"com.google.android.music");
|
||||
|
||||
final SettingsPanelActivity activity =
|
||||
Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
|
||||
|
||||
assertThat(activity.mBundle.getString(KEY_PANEL_PACKAGE_NAME))
|
||||
.isEqualTo("com.google.android.music");
|
||||
assertThat(activity.mBundle.getString(KEY_PANEL_TYPE_ARGUMENT))
|
||||
.isEqualTo("com.android.settings.panel.action.MEDIA_OUTPUT");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startMediaOutputSlice_withoutPackageName_bundleShouldNotHaveValue() {
|
||||
final Intent intent = new Intent()
|
||||
.setAction("com.android.settings.panel.action.MEDIA_OUTPUT");
|
||||
|
||||
final SettingsPanelActivity activity =
|
||||
Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
|
||||
|
||||
assertThat(activity.mBundle.containsKey(KEY_PANEL_PACKAGE_NAME)).isFalse();
|
||||
assertThat(activity.mBundle.containsKey(KEY_PANEL_TYPE_ARGUMENT)).isFalse();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user