Search in sources :

Example 1 with ContextualCard

use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConditionContextualCardRendererTest method viewClick_shouldInvokeControllerPrimaryClick.

@Test
public void viewClick_shouldInvokeControllerPrimaryClick() {
    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();
    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 2 with ContextualCard

use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceContextualCardRendererTest method viewClick_removeCard_shouldRemoveViewHolderFromSet.

@Test
public void viewClick_removeCard_shouldRemoveViewHolderFromSet() {
    final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
    final Button btnRemove = viewHolder.itemView.findViewById(R.id.remove);
    final ContextualCard card = buildContextualCard(TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
    mRenderer.bindView(viewHolder, card);
    assertThat(mRenderer.mFlippedCardSet).contains(viewHolder);
    doReturn(mController).when(mControllerRendererPool).getController(mActivity, ContextualCard.CardType.SLICE);
    btnRemove.performClick();
    assertThat(mRenderer.mFlippedCardSet).doesNotContain(viewHolder);
}
Also used : Button(android.widget.Button) ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 3 with ContextualCard

use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceContextualCardRendererTest method viewClick_removeCard_sliceLiveDataShouldRemoveObservers.

@Test
public void viewClick_removeCard_sliceLiveDataShouldRemoveObservers() {
    final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
    final Button btnRemove = viewHolder.itemView.findViewById(R.id.remove);
    final ContextualCard contextualCard = buildContextualCard(TEST_SLICE_URI);
    mRenderer.mSliceLiveDataMap.put(TEST_SLICE_URI, mSliceLiveData);
    mRenderer.bindView(viewHolder, contextualCard);
    doReturn(mController).when(mControllerRendererPool).getController(mActivity, ContextualCard.CardType.SLICE);
    btnRemove.performClick();
    assertThat(mRenderer.mSliceLiveDataMap.get(TEST_SLICE_URI).hasObservers()).isFalse();
}
Also used : Button(android.widget.Button) ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 4 with ContextualCard

use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceContextualCardRendererTest method viewClick_keepCard_shouldRemoveViewHolderFromSet.

@Test
public void viewClick_keepCard_shouldRemoveViewHolderFromSet() {
    final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
    final Button btnKeep = viewHolder.itemView.findViewById(R.id.keep);
    final ContextualCard card = buildContextualCard(TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
    mRenderer.bindView(viewHolder, card);
    assertThat(mRenderer.mFlippedCardSet).contains(viewHolder);
    btnKeep.performClick();
    assertThat(mRenderer.mFlippedCardSet).doesNotContain(viewHolder);
}
Also used : Button(android.widget.Button) ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 5 with ContextualCard

use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HotspotConditionControllerTest method buildContextualCard_noWifiAp_shouldHaveDefaultSsid.

@Test
public void buildContextualCard_noWifiAp_shouldHaveDefaultSsid() {
    final ContextualCard card = mController.buildContextualCard();
    assertThat(card.getSummaryText()).isEqualTo(mContext.getText(com.android.internal.R.string.wifi_tether_configure_ssid_default));
}
Also used : 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