use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LegacySuggestionContextualCardRendererTest method viewClick_shouldInvokeControllerPrimaryClick.
@Test
public void viewClick_shouldInvokeControllerPrimaryClick() {
final RecyclerView recyclerView = new RecyclerView(mActivity);
recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
final ContextualCard card = buildContextualCard();
final View cardView = LayoutInflater.from(mActivity).inflate(card.getViewType(), recyclerView, false);
final RecyclerView.ViewHolder viewHolder = mRenderer.createViewHolder(cardView, card.getViewType());
when(mControllerRendererPool.getController(mActivity, ContextualCard.CardType.LEGACY_SUGGESTION)).thenReturn(mController);
mRenderer.bindView(viewHolder, buildContextualCard());
assertThat(cardView).isNotNull();
cardView.performClick();
verify(mController).onPrimaryClick(any(ContextualCard.class));
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LegacySuggestionContextualCardRendererTest method viewClick_closeButton_shouldInvokeControllerDismissClick.
@Test
public void viewClick_closeButton_shouldInvokeControllerDismissClick() {
final RecyclerView recyclerView = new RecyclerView(mActivity);
recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
final ContextualCard card = buildContextualCard();
final View cardView = LayoutInflater.from(mActivity).inflate(card.getViewType(), recyclerView, false);
final RecyclerView.ViewHolder viewHolder = mRenderer.createViewHolder(cardView, card.getViewType());
final View closeButton = viewHolder.itemView.findViewById(R.id.close_button);
when(mControllerRendererPool.getController(mActivity, ContextualCard.CardType.LEGACY_SUGGESTION)).thenReturn(mController);
mRenderer.bindView(viewHolder, buildContextualCard());
assertThat(closeButton).isNotNull();
closeButton.performClick();
verify(mController).onDismissed(any(ContextualCard.class));
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceContextualCardControllerTest method onDismissed_cardShouldBeMarkedAsDismissed.
@Test
public void onDismissed_cardShouldBeMarkedAsDismissed() {
final Uri providerUri = CardContentProvider.REFRESH_CARD_URI;
mResolver.insert(providerUri, generateOneRow());
doNothing().when(mController).showFeedbackDialog(any(ContextualCard.class));
final ContextualCard card = getTestSliceCard();
mController.onDismissed(card);
final String[] columns = { CardDatabaseHelper.CardColumns.CARD_DISMISSED };
final String selection = CardDatabaseHelper.CardColumns.NAME + "=?";
final String[] selectionArgs = { TEST_CARD_NAME };
final Cursor cr = mResolver.query(providerUri, columns, selection, selectionArgs, null);
cr.moveToFirst();
final int qryDismissed = cr.getInt(0);
cr.close();
assertThat(qryDismissed).isEqualTo(1);
verify(mFeatureFactory.metricsFeatureProvider).action(any(), eq(SettingsEnums.ACTION_CONTEXTUAL_CARD_DISMISS), any(String.class));
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConditionContextualCardRendererTest method bindView_shouldSetListener.
@Test
public void bindView_shouldSetListener() {
final RecyclerView recyclerView = new RecyclerView(mActivity);
recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
final ContextualCard card = buildConditionContextualCard();
final View view = LayoutInflater.from(mActivity).inflate(card.getViewType(), recyclerView, false);
final RecyclerView.ViewHolder viewHolder = mRenderer.createViewHolder(view, card.getViewType());
final View cardView = view.findViewById(R.id.content);
when(mControllerRendererPool.getController(mActivity, ContextualCard.CardType.CONDITIONAL)).thenReturn(mController);
mRenderer.bindView(viewHolder, card);
assertThat(cardView).isNotNull();
assertThat(cardView.hasOnClickListeners()).isTrue();
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ContextualCardLogUtilsTest method parseCardClickList_isValid_returnCorrectData.
@Test
public void parseCardClickList_isValid_returnCorrectData() {
final ContextualCard testcard = new ContextualCard.Builder().setSliceUri(Uri.parse("testtest")).setRankingScore(-1d).build();
final List<ContextualCard> cardList = new ArrayList<>();
cardList.add(TEST_CARD);
cardList.add(testcard);
final String log = ContextualCardLogUtils.buildCardListLog(cardList);
final List<ContextualCardLogUtils.CardLog> cardClickLogList = ContextualCardLogUtils.parseCardListLog(log);
assertThat(cardClickLogList.size()).isEqualTo(2);
assertThat(cardClickLogList.get(0).getSliceUri()).isEqualTo(TEST_URI);
assertThat(cardClickLogList.get(0).getRankingScore()).isEqualTo(TEST_SCORE);
assertThat(cardClickLogList.get(1).getSliceUri()).isEqualTo("testtest");
assertThat(cardClickLogList.get(1).getRankingScore()).isEqualTo(-1d);
}
Aggregations