Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,8 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { private static final String CARD_DESCRIPTION = "•••• 1234"; private static final Icon CARD_IMAGE = Icon.createWithBitmap(Bitmap.createBitmap(70, 50, Bitmap.Config.ARGB_8888)); private static final Icon INVALID_CARD_IMAGE = Icon.createWithContentUri("content://media/external/images/media"); private static final int PRIMARY_USER_ID = 0; private static final int SECONDARY_USER_ID = 10; Loading Loading @@ -443,6 +445,14 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { assertNull(mTile.getState().sideViewCustomDrawable); } @Test public void testQueryCards_invalidDrawable_noSideViewDrawable() { when(mKeyguardStateController.isUnlocked()).thenReturn(true); setUpInvalidWalletCard(/* hasCard= */ true); assertNull(mTile.getState().sideViewCustomDrawable); } @Test public void testQueryCards_error_notUpdateSideViewDrawable() { String errorMessage = "getWalletCardsError"; Loading Loading @@ -503,9 +513,33 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { mTestableLooper.processAllMessages(); } private void setUpInvalidWalletCard(boolean hasCard) { GetWalletCardsResponse response = new GetWalletCardsResponse( hasCard ? Collections.singletonList(createInvalidWalletCard(mContext)) : Collections.EMPTY_LIST, 0); mTile.handleSetListening(true); verify(mController).queryWalletCards(mCallbackCaptor.capture()); mCallbackCaptor.getValue().onWalletCardsRetrieved(response); mTestableLooper.processAllMessages(); } private WalletCard createWalletCard(Context context) { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mWalletIntent, PendingIntent.FLAG_IMMUTABLE); return new WalletCard.Builder(CARD_ID, CARD_IMAGE, CARD_DESCRIPTION, pendingIntent).build(); } private WalletCard createInvalidWalletCard(Context context) { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mWalletIntent, PendingIntent.FLAG_IMMUTABLE); return new WalletCard.Builder( CARD_ID, INVALID_CARD_IMAGE, CARD_DESCRIPTION, pendingIntent).build(); } } packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java +5 −5 Original line number Diff line number Diff line Loading @@ -243,15 +243,15 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { } mSelectedCard = cards.get(selectedIndex); switch (mSelectedCard.getCardImage().getType()) { case TYPE_BITMAP: case TYPE_ADAPTIVE_BITMAP: mCardViewDrawable = mSelectedCard.getCardImage().loadDrawable(mContext); break; case TYPE_URI: case TYPE_URI_ADAPTIVE_BITMAP: mCardViewDrawable = null; break; case TYPE_RESOURCE: case TYPE_BITMAP: case TYPE_ADAPTIVE_BITMAP: case TYPE_DATA: mCardViewDrawable = mSelectedCard.getCardImage().loadDrawable(mContext); mCardViewDrawable = null; break; default: Log.e(TAG, "Unknown icon type: " + mSelectedCard.getCardImage().getType()); Loading packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java +10 −4 Original line number Diff line number Diff line Loading @@ -330,13 +330,19 @@ public class WalletScreenController implements QAWalletCardViewInfo(Context context, WalletCard walletCard) { mWalletCard = walletCard; Icon cardImageIcon = mWalletCard.getCardImage(); if (cardImageIcon.getType() == Icon.TYPE_URI) { mCardDrawable = null; } else { if (cardImageIcon.getType() == Icon.TYPE_BITMAP || cardImageIcon.getType() == Icon.TYPE_ADAPTIVE_BITMAP) { mCardDrawable = mWalletCard.getCardImage().loadDrawable(context); } else { mCardDrawable = null; } Icon icon = mWalletCard.getCardIcon(); mIconDrawable = icon == null ? null : icon.loadDrawable(context); if (icon != null && (icon.getType() == Icon.TYPE_BITMAP || icon.getType() == Icon.TYPE_ADAPTIVE_BITMAP)) { mIconDrawable = icon.loadDrawable(context); } else { mIconDrawable = null; } } @Override Loading packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java +5 −0 Original line number Diff line number Diff line Loading @@ -283,6 +283,11 @@ public class WalletView extends FrameLayout implements WalletCardCarousel.OnCard return mCardLabel; } @VisibleForTesting ImageView getIcon() { return mIcon; } @Nullable private static Drawable getHeaderIcon(Context context, WalletCardViewInfo walletCard) { Drawable icon = walletCard.getIcon(); Loading packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java +39 −0 Original line number Diff line number Diff line Loading @@ -315,6 +315,31 @@ public class WalletScreenControllerTest extends SysuiTestCase { assertEquals(GONE, mWalletView.getErrorView().getVisibility()); } @Test public void queryCards_hasCards_showCarousel_invalidIconSource_noIcon() { GetWalletCardsResponse response = new GetWalletCardsResponse( Collections.singletonList(createWalletCardWithInvalidIcon(mContext)), 0); mController.queryWalletCards(); mTestableLooper.processAllMessages(); verify(mWalletClient).getWalletCards(any(), any(), mCallbackCaptor.capture()); QuickAccessWalletClient.OnWalletCardsRetrievedCallback callback = mCallbackCaptor.getValue(); assertEquals(mController, callback); callback.onWalletCardsRetrieved(response); mTestableLooper.processAllMessages(); assertEquals(VISIBLE, mWalletView.getCardCarousel().getVisibility()); assertEquals(GONE, mWalletView.getEmptyStateView().getVisibility()); assertEquals(GONE, mWalletView.getErrorView().getVisibility()); assertEquals(null, mWalletView.getIcon().getDrawable()); } @Test public void queryCards_noCards_showEmptyState() { GetWalletCardsResponse response = new GetWalletCardsResponse(Collections.EMPTY_LIST, 0); Loading Loading @@ -507,6 +532,16 @@ public class WalletScreenControllerTest extends SysuiTestCase { .build(); } private WalletCard createWalletCardWithInvalidIcon(Context context) { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mWalletIntent, PendingIntent.FLAG_IMMUTABLE); return new WalletCard.Builder( CARD_ID_1, createIconWithInvalidSource(), "•••• 1234", pendingIntent) .setCardIcon(createIconWithInvalidSource()) .setCardLabel("Hold to reader") .build(); } private WalletCard createCrazyWalletCard(Context context, boolean hasLabel) { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mWalletIntent, PendingIntent.FLAG_IMMUTABLE); Loading @@ -520,6 +555,10 @@ public class WalletScreenControllerTest extends SysuiTestCase { return Icon.createWithBitmap(Bitmap.createBitmap(70, 44, Bitmap.Config.ARGB_8888)); } private static Icon createIconWithInvalidSource() { return Icon.createWithContentUri("content://media/external/images/media"); } private WalletCardViewInfo createCardViewInfo(WalletCard walletCard) { return new WalletScreenController.QAWalletCardViewInfo( mContext, walletCard); Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,8 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { private static final String CARD_DESCRIPTION = "•••• 1234"; private static final Icon CARD_IMAGE = Icon.createWithBitmap(Bitmap.createBitmap(70, 50, Bitmap.Config.ARGB_8888)); private static final Icon INVALID_CARD_IMAGE = Icon.createWithContentUri("content://media/external/images/media"); private static final int PRIMARY_USER_ID = 0; private static final int SECONDARY_USER_ID = 10; Loading Loading @@ -443,6 +445,14 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { assertNull(mTile.getState().sideViewCustomDrawable); } @Test public void testQueryCards_invalidDrawable_noSideViewDrawable() { when(mKeyguardStateController.isUnlocked()).thenReturn(true); setUpInvalidWalletCard(/* hasCard= */ true); assertNull(mTile.getState().sideViewCustomDrawable); } @Test public void testQueryCards_error_notUpdateSideViewDrawable() { String errorMessage = "getWalletCardsError"; Loading Loading @@ -503,9 +513,33 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { mTestableLooper.processAllMessages(); } private void setUpInvalidWalletCard(boolean hasCard) { GetWalletCardsResponse response = new GetWalletCardsResponse( hasCard ? Collections.singletonList(createInvalidWalletCard(mContext)) : Collections.EMPTY_LIST, 0); mTile.handleSetListening(true); verify(mController).queryWalletCards(mCallbackCaptor.capture()); mCallbackCaptor.getValue().onWalletCardsRetrieved(response); mTestableLooper.processAllMessages(); } private WalletCard createWalletCard(Context context) { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mWalletIntent, PendingIntent.FLAG_IMMUTABLE); return new WalletCard.Builder(CARD_ID, CARD_IMAGE, CARD_DESCRIPTION, pendingIntent).build(); } private WalletCard createInvalidWalletCard(Context context) { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mWalletIntent, PendingIntent.FLAG_IMMUTABLE); return new WalletCard.Builder( CARD_ID, INVALID_CARD_IMAGE, CARD_DESCRIPTION, pendingIntent).build(); } }
packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java +5 −5 Original line number Diff line number Diff line Loading @@ -243,15 +243,15 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { } mSelectedCard = cards.get(selectedIndex); switch (mSelectedCard.getCardImage().getType()) { case TYPE_BITMAP: case TYPE_ADAPTIVE_BITMAP: mCardViewDrawable = mSelectedCard.getCardImage().loadDrawable(mContext); break; case TYPE_URI: case TYPE_URI_ADAPTIVE_BITMAP: mCardViewDrawable = null; break; case TYPE_RESOURCE: case TYPE_BITMAP: case TYPE_ADAPTIVE_BITMAP: case TYPE_DATA: mCardViewDrawable = mSelectedCard.getCardImage().loadDrawable(mContext); mCardViewDrawable = null; break; default: Log.e(TAG, "Unknown icon type: " + mSelectedCard.getCardImage().getType()); Loading
packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java +10 −4 Original line number Diff line number Diff line Loading @@ -330,13 +330,19 @@ public class WalletScreenController implements QAWalletCardViewInfo(Context context, WalletCard walletCard) { mWalletCard = walletCard; Icon cardImageIcon = mWalletCard.getCardImage(); if (cardImageIcon.getType() == Icon.TYPE_URI) { mCardDrawable = null; } else { if (cardImageIcon.getType() == Icon.TYPE_BITMAP || cardImageIcon.getType() == Icon.TYPE_ADAPTIVE_BITMAP) { mCardDrawable = mWalletCard.getCardImage().loadDrawable(context); } else { mCardDrawable = null; } Icon icon = mWalletCard.getCardIcon(); mIconDrawable = icon == null ? null : icon.loadDrawable(context); if (icon != null && (icon.getType() == Icon.TYPE_BITMAP || icon.getType() == Icon.TYPE_ADAPTIVE_BITMAP)) { mIconDrawable = icon.loadDrawable(context); } else { mIconDrawable = null; } } @Override Loading
packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java +5 −0 Original line number Diff line number Diff line Loading @@ -283,6 +283,11 @@ public class WalletView extends FrameLayout implements WalletCardCarousel.OnCard return mCardLabel; } @VisibleForTesting ImageView getIcon() { return mIcon; } @Nullable private static Drawable getHeaderIcon(Context context, WalletCardViewInfo walletCard) { Drawable icon = walletCard.getIcon(); Loading
packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java +39 −0 Original line number Diff line number Diff line Loading @@ -315,6 +315,31 @@ public class WalletScreenControllerTest extends SysuiTestCase { assertEquals(GONE, mWalletView.getErrorView().getVisibility()); } @Test public void queryCards_hasCards_showCarousel_invalidIconSource_noIcon() { GetWalletCardsResponse response = new GetWalletCardsResponse( Collections.singletonList(createWalletCardWithInvalidIcon(mContext)), 0); mController.queryWalletCards(); mTestableLooper.processAllMessages(); verify(mWalletClient).getWalletCards(any(), any(), mCallbackCaptor.capture()); QuickAccessWalletClient.OnWalletCardsRetrievedCallback callback = mCallbackCaptor.getValue(); assertEquals(mController, callback); callback.onWalletCardsRetrieved(response); mTestableLooper.processAllMessages(); assertEquals(VISIBLE, mWalletView.getCardCarousel().getVisibility()); assertEquals(GONE, mWalletView.getEmptyStateView().getVisibility()); assertEquals(GONE, mWalletView.getErrorView().getVisibility()); assertEquals(null, mWalletView.getIcon().getDrawable()); } @Test public void queryCards_noCards_showEmptyState() { GetWalletCardsResponse response = new GetWalletCardsResponse(Collections.EMPTY_LIST, 0); Loading Loading @@ -507,6 +532,16 @@ public class WalletScreenControllerTest extends SysuiTestCase { .build(); } private WalletCard createWalletCardWithInvalidIcon(Context context) { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mWalletIntent, PendingIntent.FLAG_IMMUTABLE); return new WalletCard.Builder( CARD_ID_1, createIconWithInvalidSource(), "•••• 1234", pendingIntent) .setCardIcon(createIconWithInvalidSource()) .setCardLabel("Hold to reader") .build(); } private WalletCard createCrazyWalletCard(Context context, boolean hasLabel) { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mWalletIntent, PendingIntent.FLAG_IMMUTABLE); Loading @@ -520,6 +555,10 @@ public class WalletScreenControllerTest extends SysuiTestCase { return Icon.createWithBitmap(Bitmap.createBitmap(70, 44, Bitmap.Config.ARGB_8888)); } private static Icon createIconWithInvalidSource() { return Icon.createWithContentUri("content://media/external/images/media"); } private WalletCardViewInfo createCardViewInfo(WalletCard walletCard) { return new WalletScreenController.QAWalletCardViewInfo( mContext, walletCard); Loading