Commit 999749a5 authored by David Maunder's avatar David Maunder Committed by Chromium LUCI CQ

Hide price drop box when feature is turned off

The display logic was written before the user ability to turn off price
drops was introduced. The code needs to be updated to hide the price box
(upon next render of the tab grid) if the feature is turned off.
Turning the feature off means the SHOPPING_PERSISTED_TAB_DATA_FETCHER
is null.

Bug: 1155731
Change-Id: I734ffd3538ee62cbd5ea8314d7f6eb76a5931985
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575419
Commit-Queue: David Maunder <davidjm@chromium.org>
Reviewed-by: default avatarYue Zhang <yuezhanggg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833934}
parent 53bd3e24
......@@ -218,11 +218,11 @@ class TabGridViewBinder {
pageInfoButton.getPrimaryTextView().setText(query);
}
} else if (TabProperties.SHOPPING_PERSISTED_TAB_DATA_FETCHER == propertyKey) {
PriceCardView priceCardView =
(PriceCardView) view.fastFindViewById(R.id.price_info_box_outer);
if (model.get(TabProperties.SHOPPING_PERSISTED_TAB_DATA_FETCHER) != null) {
model.get(TabProperties.SHOPPING_PERSISTED_TAB_DATA_FETCHER)
.fetch((shoppingPersistedTabData) -> {
PriceCardView priceCardView = (PriceCardView) view.fastFindViewById(
R.id.price_info_box_outer);
if (shoppingPersistedTabData.getPriceDrop() == null) {
priceCardView.setVisibility(View.GONE);
} else {
......@@ -232,6 +232,8 @@ class TabGridViewBinder {
priceCardView.setVisibility(View.VISIBLE);
}
});
} else {
priceCardView.setVisibility(View.GONE);
}
} else if (TabProperties.PAGE_INFO_LISTENER == propertyKey) {
TabListMediator.TabActionListener listener =
......
......@@ -620,6 +620,20 @@ public class TabListViewHolderTest extends DummyUiActivityTestCase {
tab, fetcher, View.GONE, EXPECTED_PRICE_STRING, EXPECTED_PREVIOUS_PRICE_STRING);
}
@Test
@MediumTest
@UiThreadTest
public void testPriceStringTurnFeatureOff() {
Tab tab = MockTab.createAndInitialize(1, false);
MockShoppingPersistedTabDataFetcher fetcher = new MockShoppingPersistedTabDataFetcher(tab);
fetcher.setPriceStrings(EXPECTED_PRICE_STRING, EXPECTED_PREVIOUS_PRICE_STRING);
testPriceString(
tab, fetcher, View.VISIBLE, EXPECTED_PRICE_STRING, EXPECTED_PREVIOUS_PRICE_STRING);
mGridModel.set(TabProperties.SHOPPING_PERSISTED_TAB_DATA_FETCHER, null);
PriceCardView priceCardView = mTabGridView.findViewById(R.id.price_info_box_outer);
Assert.assertEquals(View.GONE, priceCardView.getVisibility());
}
private void testPriceString(Tab tab, MockShoppingPersistedTabDataFetcher fetcher,
int expectedVisibility, String expectedCurrentPrice, String expectedPreviousPrice) {
TabUiFeatureUtilities.ENABLE_PRICE_TRACKING.setForTesting(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment