Merge "Fix PanelSlicesAdapterTest" into main
This commit is contained in:
@@ -43,6 +43,7 @@ import android.widget.LinearLayout;
|
|||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.slice.Slice;
|
import androidx.slice.Slice;
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.panel.PanelSlicesAdapter.SliceRowViewHolder;
|
import com.android.settings.panel.PanelSlicesAdapter.SliceRowViewHolder;
|
||||||
@@ -50,14 +51,14 @@ import com.android.settings.testutils.FakeFeatureFactory;
|
|||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnit;
|
||||||
|
import org.mockito.junit.MockitoRule;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
import org.robolectric.android.controller.ActivityController;
|
import org.robolectric.android.controller.ActivityController;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.annotation.Implementation;
|
import org.robolectric.annotation.Implementation;
|
||||||
@@ -69,6 +70,8 @@ import java.util.Map;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = PanelSlicesAdapterTest.ShadowLayoutInflater.class)
|
@Config(shadows = PanelSlicesAdapterTest.ShadowLayoutInflater.class)
|
||||||
public class PanelSlicesAdapterTest {
|
public class PanelSlicesAdapterTest {
|
||||||
|
@Rule
|
||||||
|
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
|
|
||||||
private static LayoutInflater sLayoutInflater;
|
private static LayoutInflater sLayoutInflater;
|
||||||
|
|
||||||
@@ -81,8 +84,7 @@ public class PanelSlicesAdapterTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
mContext = RuntimeEnvironment.application;
|
|
||||||
|
|
||||||
mPanelFeatureProvider = spy(new PanelFeatureProviderImpl());
|
mPanelFeatureProvider = spy(new PanelFeatureProviderImpl());
|
||||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
@@ -104,8 +106,7 @@ public class PanelSlicesAdapterTest {
|
|||||||
|
|
||||||
private void addTestLiveData(Uri uri) {
|
private void addTestLiveData(Uri uri) {
|
||||||
// Create a slice to return for the LiveData
|
// Create a slice to return for the LiveData
|
||||||
final Slice slice = spy(new Slice());
|
final Slice slice = new Slice();
|
||||||
doReturn(uri).when(slice).getUri();
|
|
||||||
final LiveData<Slice> liveData = mock(LiveData.class);
|
final LiveData<Slice> liveData = mock(LiveData.class);
|
||||||
when(liveData.getValue()).thenReturn(slice);
|
when(liveData.getValue()).thenReturn(slice);
|
||||||
mData.put(uri, liveData);
|
mData.put(uri, liveData);
|
||||||
@@ -126,7 +127,6 @@ public class PanelSlicesAdapterTest {
|
|||||||
/**
|
/**
|
||||||
* ViewHolder should load and set the action label correctly.
|
* ViewHolder should load and set the action label correctly.
|
||||||
*/
|
*/
|
||||||
@Ignore("b/313576125")
|
|
||||||
@Test
|
@Test
|
||||||
public void setActionLabel_loadsActionLabel() {
|
public void setActionLabel_loadsActionLabel() {
|
||||||
addTestLiveData(VOLUME_NOTIFICATION_URI);
|
addTestLiveData(VOLUME_NOTIFICATION_URI);
|
||||||
@@ -167,7 +167,6 @@ public class PanelSlicesAdapterTest {
|
|||||||
return foundLabel;
|
return foundLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("b/313576125")
|
|
||||||
@Test
|
@Test
|
||||||
public void sizeOfAdapter_shouldNotExceedMaxNum() {
|
public void sizeOfAdapter_shouldNotExceedMaxNum() {
|
||||||
for (int i = 0; i < MAX_NUM_OF_SLICES + 2; i++) {
|
for (int i = 0; i < MAX_NUM_OF_SLICES + 2; i++) {
|
||||||
@@ -186,7 +185,6 @@ public class PanelSlicesAdapterTest {
|
|||||||
assertThat(adapter.getData().size()).isEqualTo(MAX_NUM_OF_SLICES);
|
assertThat(adapter.getData().size()).isEqualTo(MAX_NUM_OF_SLICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("b/313576125")
|
|
||||||
@Test
|
@Test
|
||||||
public void mediaOutputIndicatorSlice_notSliderPanel_noSliderLayout() {
|
public void mediaOutputIndicatorSlice_notSliderPanel_noSliderLayout() {
|
||||||
addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
|
addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
|
||||||
@@ -203,7 +201,6 @@ public class PanelSlicesAdapterTest {
|
|||||||
assertThat(viewHolder.mSliceSliderLayout).isNull();
|
assertThat(viewHolder.mSliceSliderLayout).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("b/313576125")
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_viewTypeSlider_verifyActionLabelSet() {
|
public void onBindViewHolder_viewTypeSlider_verifyActionLabelSet() {
|
||||||
addTestLiveData(VOLUME_NOTIFICATION_URI);
|
addTestLiveData(VOLUME_NOTIFICATION_URI);
|
||||||
|
Reference in New Issue
Block a user