Merge "Add a separate line at the bottom of list area in output switcher" into rvc-dev am: 02e311e537

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/11900663

Change-Id: Ida3ffa1110238057993e4ce345dce3cb3a8791d6
This commit is contained in:
tim peng
2020-06-20 10:25:04 +00:00
committed by Automerger Merge Worker
5 changed files with 116 additions and 3 deletions

View File

@@ -17,6 +17,9 @@
package com.android.settings.panel;
import static com.android.settings.panel.PanelContent.VIEW_TYPE_SLIDER;
import static com.android.settings.panel.PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -209,6 +212,54 @@ public class PanelFragmentTest {
assertThat(titleView.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void sliderLargeIconPanelType_displayFooterDivider() {
mFakePanelContent.setViewType(VIEW_TYPE_SLIDER_LARGE_ICON);
final ActivityController<FakeSettingsPanelActivity> activityController =
Robolectric.buildActivity(FakeSettingsPanelActivity.class);
activityController.setup();
final PanelFragment panelFragment = (PanelFragment)
Objects.requireNonNull(activityController
.get()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content));
final View footerDivider = panelFragment.mLayoutView.findViewById(R.id.footer_divider);
// Check visibility
assertThat(footerDivider.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void sliderPanelType_notDisplayFooterDivider() {
mFakePanelContent.setViewType(VIEW_TYPE_SLIDER);
final ActivityController<FakeSettingsPanelActivity> activityController =
Robolectric.buildActivity(FakeSettingsPanelActivity.class);
activityController.setup();
final PanelFragment panelFragment = (PanelFragment)
Objects.requireNonNull(activityController
.get()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content));
final View footerDivider = panelFragment.mLayoutView.findViewById(R.id.footer_divider);
// Check visibility
assertThat(footerDivider.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void defaultPanelType_notDisplayFooterDivider() {
mFakePanelContent.setViewType(0 /* viewType */);
final ActivityController<FakeSettingsPanelActivity> activityController =
Robolectric.buildActivity(FakeSettingsPanelActivity.class);
activityController.setup();
final PanelFragment panelFragment = (PanelFragment)
Objects.requireNonNull(activityController
.get()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content));
final View footerDivider = panelFragment.mLayoutView.findViewById(R.id.footer_divider);
// Check visibility
assertThat(footerDivider.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void onHeaderChanged_updateHeader_verifyTitle() {
mFakePanelContent.setIcon(IconCompat.createWithResource(mContext, R.drawable.ic_android));

View File

@@ -22,6 +22,7 @@ import static com.android.settings.panel.PanelSlicesAdapter.MAX_NUM_OF_SLICES;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_GROUP_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI;
import static com.google.common.truth.Truth.assertThat;
@@ -142,6 +143,53 @@ public class PanelSlicesAdapterTest {
assertThat(viewHolder.isDividerAllowedAbove()).isFalse();
}
@Test
public void sliderLargeIconPanel_shouldNotAllowDividerBelow() {
addTestLiveData(MEDIA_OUTPUT_SLICE_URI);
mFakePanelContent.setViewType(PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);
final PanelSlicesAdapter adapter =
new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
final int position = 0;
final ViewGroup view = new FrameLayout(mContext);
final SliceRowViewHolder viewHolder =
adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);
adapter.onBindViewHolder(viewHolder, position);
assertThat(viewHolder.isDividerAllowedBelow()).isFalse();
}
@Test
public void sliderPanelType_shouldAllowDividerBelow() {
addTestLiveData(VOLUME_MEDIA_URI);
mFakePanelContent.setViewType(PanelContent.VIEW_TYPE_SLIDER);
final PanelSlicesAdapter adapter =
new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
final int position = 0;
final ViewGroup view = new FrameLayout(mContext);
final SliceRowViewHolder viewHolder =
adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER);
adapter.onBindViewHolder(viewHolder, position);
assertThat(viewHolder.isDividerAllowedBelow()).isTrue();
}
@Test
public void defaultPanelType_shouldAllowDividerBelow() {
addTestLiveData(VOLUME_MEDIA_URI);
mFakePanelContent.setViewType(0 /* viewType */);
final PanelSlicesAdapter adapter =
new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
final int position = 0;
final ViewGroup view = new FrameLayout(mContext);
final SliceRowViewHolder viewHolder = adapter.onCreateViewHolder(view, 0/* viewType */);
adapter.onBindViewHolder(viewHolder, position);
assertThat(viewHolder.isDividerAllowedBelow()).isTrue();
}
@Test
public void outputSwitcherSlice_shouldAddFirstItemPadding() {
addTestLiveData(MEDIA_OUTPUT_SLICE_URI);
@@ -151,7 +199,7 @@ public class PanelSlicesAdapterTest {
final int position = 0;
final ViewGroup view = new FrameLayout(mContext);
final SliceRowViewHolder viewHolder =
adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER);
adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);
adapter.onBindViewHolder(viewHolder, position);
@@ -169,7 +217,7 @@ public class PanelSlicesAdapterTest {
final int position = 0;
final ViewGroup view = new FrameLayout(mContext);
final SliceRowViewHolder viewHolder =
adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER);
adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);
adapter.onBindViewHolder(viewHolder, position);