Merge "Bug fix for QuickAccessWallet." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
637ad5dc1e
@@ -184,8 +184,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
|
||||
|
||||
@Override
|
||||
public CharSequence getTileLabel() {
|
||||
CharSequence qawLabel = mQuickAccessWalletClient.getServiceLabel();
|
||||
return qawLabel == null ? mLabel : qawLabel;
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
private void queryWalletCards() {
|
||||
|
||||
@@ -222,6 +222,11 @@ public class WalletScreenController implements
|
||||
if (mIsDismissed) {
|
||||
return;
|
||||
}
|
||||
int cardWidthPx = mCardCarousel.getCardWidthPx();
|
||||
int cardHeightPx = mCardCarousel.getCardHeightPx();
|
||||
if (cardWidthPx == 0 || cardHeightPx == 0) {
|
||||
return;
|
||||
}
|
||||
if (!mHasRegisteredListener) {
|
||||
// Listener is registered even when device is locked. Should only be registered once.
|
||||
mWalletClient.addWalletServiceEventListener(this);
|
||||
@@ -231,8 +236,6 @@ public class WalletScreenController implements
|
||||
mWalletView.show();
|
||||
mWalletView.hideErrorMessage();
|
||||
int iconSizePx = mContext.getResources().getDimensionPixelSize(R.dimen.wallet_icon_size);
|
||||
int cardWidthPx = mCardCarousel.getCardWidthPx();
|
||||
int cardHeightPx = mCardCarousel.getCardHeightPx();
|
||||
GetWalletCardsRequest request =
|
||||
new GetWalletCardsRequest(cardWidthPx, cardHeightPx, iconSizePx, MAX_CARDS);
|
||||
mWalletClient.getWalletCards(mExecutor, request, this);
|
||||
|
||||
@@ -232,6 +232,11 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
|
||||
assertEquals(icon, state.icon);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTileLabel() {
|
||||
assertEquals(mContext.getString(R.string.wallet_title), mTile.getTileLabel().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleUpdateState_hasCard_deviceLocked_tileInactive() {
|
||||
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
|
||||
|
||||
@@ -71,15 +71,17 @@ import java.util.Collections;
|
||||
public class WalletScreenControllerTest extends SysuiTestCase {
|
||||
|
||||
private static final int MAX_CARDS = 10;
|
||||
private static final int CARD_CAROUSEL_WIDTH = 10;
|
||||
private static final String CARD_ID = "card_id";
|
||||
private static final CharSequence SHORTCUT_SHORT_LABEL = "View all";
|
||||
private static final CharSequence SHORTCUT_LONG_LABEL = "Add a payment method";
|
||||
private static final CharSequence SERVICE_LABEL = "Wallet app";
|
||||
private final WalletView mWalletView = new WalletView(mContext);
|
||||
private final Drawable mWalletLogo = mContext.getDrawable(android.R.drawable.ic_lock_lock);
|
||||
private final Intent mWalletIntent = new Intent(QuickAccessWalletService.ACTION_VIEW_WALLET)
|
||||
.setComponent(new ComponentName(mContext.getPackageName(), "WalletActivity"));
|
||||
|
||||
private WalletView mWalletView;
|
||||
|
||||
@Mock
|
||||
QuickAccessWalletClient mWalletClient;
|
||||
@Mock
|
||||
@@ -104,6 +106,8 @@ public class WalletScreenControllerTest extends SysuiTestCase {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mTestableLooper = TestableLooper.get(this);
|
||||
when(mUserTracker.getUserContext()).thenReturn(mContext);
|
||||
mWalletView = new WalletView(mContext);
|
||||
mWalletView.getCardCarousel().setExpectedViewWidth(CARD_CAROUSEL_WIDTH);
|
||||
when(mWalletClient.getLogo()).thenReturn(mWalletLogo);
|
||||
when(mWalletClient.getShortcutLongLabel()).thenReturn(SHORTCUT_LONG_LABEL);
|
||||
when(mWalletClient.getShortcutShortLabel()).thenReturn(SHORTCUT_SHORT_LABEL);
|
||||
@@ -132,7 +136,12 @@ public class WalletScreenControllerTest extends SysuiTestCase {
|
||||
|
||||
verify(mWalletClient).getWalletCards(any(), any(), mCallbackCaptor.capture());
|
||||
|
||||
mCallbackCaptor.getValue().onWalletCardsRetrieved(response);
|
||||
QuickAccessWalletClient.OnWalletCardsRetrievedCallback callback =
|
||||
mCallbackCaptor.getValue();
|
||||
|
||||
assertEquals(mController, callback);
|
||||
|
||||
callback.onWalletCardsRetrieved(response);
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
assertEquals(VISIBLE, mWalletView.getCardCarouselContainer().getVisibility());
|
||||
|
||||
Reference in New Issue
Block a user