Search in sources :

Example 16 with ContextualCard

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));
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 17 with ContextualCard

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));
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 18 with ContextualCard

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));
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Cursor(android.database.Cursor) Uri(android.net.Uri) Test(org.junit.Test)

Example 19 with ContextualCard

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();
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 20 with ContextualCard

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);
}
Also used : ArrayList(java.util.ArrayList) ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) Test(org.junit.Test)

Aggregations

ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)35 Test (org.junit.Test)32 RecyclerView (androidx.recyclerview.widget.RecyclerView)21 View (android.view.View)15 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)10 ArrayList (java.util.ArrayList)6 Button (android.widget.Button)4 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 Suggestion (android.service.settings.suggestions.Suggestion)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 TimeoutException (java.util.concurrent.TimeoutException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1