Refactor WifiSlice to CustomSliceManager
Modify the WifiSliceCode to follow the pattern for Slices that do not match existing UI components. Test: robotests Bug: 80263568 Change-Id: Id69e019608777282f4b64ff945e8c30c97aaf577
This commit is contained in:
committed by
Matt Fritze
parent
3df19f92b0
commit
7f0a30226a
@@ -47,10 +47,12 @@ import androidx.slice.core.SliceAction;
|
||||
import androidx.slice.widget.SliceLiveData;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class WifiSliceBuilderTest {
|
||||
public class WifiSliceTest {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private WifiSlice mWifiSlice;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
@@ -62,11 +64,13 @@ public class WifiSliceBuilderTest {
|
||||
|
||||
// Set-up specs for SliceMetadata.
|
||||
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
||||
|
||||
mWifiSlice = new WifiSlice(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWifiSlice_correctSliceContent() {
|
||||
final Slice wifiSlice = WifiSliceBuilder.getSlice(mContext);
|
||||
final Slice wifiSlice = mWifiSlice.getSlice();
|
||||
final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
|
||||
|
||||
final List<SliceAction> toggles = metadata.getToggles();
|
||||
@@ -83,11 +87,11 @@ public class WifiSliceBuilderTest {
|
||||
|
||||
@Test
|
||||
public void handleUriChange_updatesWifi() {
|
||||
final Intent intent = new Intent(WifiSliceBuilder.ACTION_WIFI_SLICE_CHANGED);
|
||||
final Intent intent = mWifiSlice.getIntent();
|
||||
intent.putExtra(android.app.slice.Slice.EXTRA_TOGGLE_STATE, true);
|
||||
final WifiManager wifiManager = mContext.getSystemService(WifiManager.class);
|
||||
|
||||
WifiSliceBuilder.handleUriChange(mContext, intent);
|
||||
mWifiSlice.onNotifyChange(intent);
|
||||
|
||||
assertThat(wifiManager.getWifiState()).isEqualTo(WifiManager.WIFI_STATE_ENABLED);
|
||||
}
|
||||
@@ -99,8 +99,9 @@ public class WifiCallingSliceHelperTest {
|
||||
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mSlicesFeatureProvider = mFeatureFactory.getSlicesFeatureProvider();
|
||||
CustomSliceManager manager = new CustomSliceManager(mContext);
|
||||
when(mSlicesFeatureProvider.getCustomSliceManager(any(Context.class)))
|
||||
.thenReturn(new CustomSliceManager(mContext));
|
||||
.thenReturn(manager);
|
||||
|
||||
// Prevent crash in SliceMetadata.
|
||||
Resources resources = spy(mContext.getResources());
|
||||
|
||||
Reference in New Issue
Block a user