Disable the usage summary when there's no usage data.
- when the preference is initialized, check for the network's overall total usage. If there is no data available, disable launching the detail page. Change-Id: Ie81a5471de134bac63dedd3c39f4afe44201efe5 Fixes: 74451774 Fixes: 35855928 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -486,11 +486,13 @@ public class DataUsageSummaryPreferenceTest {
|
||||
final long cycleEnd = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(daysLeft)
|
||||
+ TimeUnit.HOURS.toMillis(1);
|
||||
final Activity activity = Robolectric.setupActivity(Activity.class);
|
||||
mSummaryPreference = spy(mSummaryPreference);
|
||||
mSummaryPreference.setUsageInfo(cycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
|
||||
new Intent());
|
||||
mSummaryPreference.setUsageNumbers(1000000L, -1L, true);
|
||||
final String cycleText = "The quick fox";
|
||||
mSummaryPreference.setWifiMode(true, cycleText);
|
||||
doReturn(200L).when(mSummaryPreference).getHistoriclUsageLevel();
|
||||
|
||||
bindViewHolder();
|
||||
assertThat(mUsageTitle.getText().toString())
|
||||
@@ -522,6 +524,17 @@ public class DataUsageSummaryPreferenceTest {
|
||||
.isEqualTo(R.string.wifi_data_usage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetWifiMode_noUsageInfo_shouldDisableLaunchButton() {
|
||||
mSummaryPreference = spy(mSummaryPreference);
|
||||
mSummaryPreference.setWifiMode(true, "Test cycle text");
|
||||
doReturn(0L).when(mSummaryPreference).getHistoriclUsageLevel();
|
||||
|
||||
bindViewHolder();
|
||||
|
||||
assertThat(mLaunchButton.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
private void bindViewHolder() {
|
||||
mSummaryPreference.onBindViewHolder(mHolder);
|
||||
mUsageTitle = (TextView) mHolder.findViewById(R.id.usage_title);
|
||||
|
Reference in New Issue
Block a user