Use CustomSliceRegistry directly when possible.
This is one step closer to (un)make CustomSliceManager an singleton. Bug: 123937830 Test: manual Change-Id: I844d0fb798c73e2af1945ecb667ba73fac9edf72
This commit is contained in:
@@ -19,14 +19,12 @@ package com.android.settings.slices;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.app.slice.Slice;
|
||||
@@ -82,9 +80,6 @@ public class SliceBroadcastReceiverTest {
|
||||
mSearchFeatureProvider = new SearchFeatureProviderImpl();
|
||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mFakeFeatureFactory.searchFeatureProvider = mSearchFeatureProvider;
|
||||
CustomSliceManager manager = new CustomSliceManager(mContext);
|
||||
when(mFakeFeatureFactory.slicesFeatureProvider.getCustomSliceManager(any()))
|
||||
.thenReturn(manager);
|
||||
}
|
||||
|
||||
@After
|
||||
|
@@ -19,8 +19,6 @@ package com.android.settings.slices;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -41,28 +39,17 @@ public class SpecialCaseSliceManagerTest {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private CustomSliceManager mCustomSliceManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mCustomSliceManager = spy(new CustomSliceManager(mContext));
|
||||
CustomSliceRegistry.sUriToSlice.clear();
|
||||
CustomSliceRegistry.sUriToSlice.put(FakeSliceable.URI, FakeSliceable.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSliceableFromUri_returnsCorrectObject() {
|
||||
final CustomSliceable sliceable = mCustomSliceManager.getSliceableFromUri(
|
||||
FakeSliceable.URI);
|
||||
|
||||
assertThat(sliceable).isInstanceOf(FakeSliceable.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSliceableFromIntentAction_returnsCorrectObject() {
|
||||
final CustomSliceable sliceable =
|
||||
mCustomSliceManager.getSliceableFromIntentAction(FakeSliceable.URI.toString());
|
||||
final CustomSliceable sliceable = CustomSliceable.createInstance(
|
||||
mContext, CustomSliceRegistry.getSliceClassByUri(FakeSliceable.URI));
|
||||
|
||||
assertThat(sliceable).isInstanceOf(FakeSliceable.class);
|
||||
}
|
||||
|
Reference in New Issue
Block a user