use of com.android.settingslib.net.NetworkCycleChartData in project android_packages_apps_Settings by omnirom.
the class DataUsageListTest method startAppDataUsage_shouldAddCyclesInfoToLaunchArguments.
@Test
public void startAppDataUsage_shouldAddCyclesInfoToLaunchArguments() {
final long startTime = 1521583200000L;
final long endTime = 1521676800000L;
final List<NetworkCycleChartData> data = new ArrayList<>();
final NetworkCycleChartData.Builder builder = new NetworkCycleChartData.Builder();
builder.setStartTime(startTime).setEndTime(endTime);
data.add(builder.build());
ReflectionHelpers.setField(mDataUsageList, "mCycleData", data);
final Spinner spinner = mock(Spinner.class);
when(spinner.getSelectedItemPosition()).thenReturn(0);
ReflectionHelpers.setField(mDataUsageList, "mCycleSpinner", spinner);
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
mDataUsageList.startAppDataUsage(new AppItem());
verify(mActivity).startActivity(intent.capture());
final Bundle arguments = intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
assertThat(arguments.getLong(AppDataUsage.ARG_SELECTED_CYCLE)).isEqualTo(endTime);
final ArrayList<Long> cycles = (ArrayList) arguments.getSerializable(AppDataUsage.ARG_NETWORK_CYCLES);
assertThat(cycles).hasSize(2);
assertThat(cycles.get(0)).isEqualTo(endTime);
assertThat(cycles.get(1)).isEqualTo(startTime);
}
use of com.android.settingslib.net.NetworkCycleChartData in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsageList method startAppDataUsage.
@VisibleForTesting
void startAppDataUsage(AppItem item) {
final Bundle args = new Bundle();
args.putParcelable(AppDataUsage.ARG_APP_ITEM, item);
args.putParcelable(AppDataUsage.ARG_NETWORK_TEMPLATE, mTemplate);
if (mCycles == null) {
mCycles = new ArrayList<>();
for (NetworkCycleChartData data : mCycleData) {
if (mCycles.isEmpty()) {
mCycles.add(data.getEndTime());
}
mCycles.add(data.getStartTime());
}
}
args.putSerializable(AppDataUsage.ARG_NETWORK_CYCLES, mCycles);
args.putLong(AppDataUsage.ARG_SELECTED_CYCLE, mCycleData.get(mCycleSpinner.getSelectedItemPosition()).getEndTime());
new SubSettingLauncher(getContext()).setDestination(AppDataUsage.class.getName()).setTitleRes(R.string.data_usage_app_summary_title).setArguments(args).setSourceMetricsCategory(getMetricsCategory()).launch();
}
use of com.android.settingslib.net.NetworkCycleChartData in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsageListTest method startAppDataUsage_shouldAddCyclesInfoToLaunchArguments.
@Test
public void startAppDataUsage_shouldAddCyclesInfoToLaunchArguments() {
final long startTime = 1521583200000L;
final long endTime = 1521676800000L;
final List<NetworkCycleChartData> data = new ArrayList<>();
final NetworkCycleChartData.Builder builder = new NetworkCycleChartData.Builder();
builder.setStartTime(startTime).setEndTime(endTime);
data.add(builder.build());
ReflectionHelpers.setField(mDataUsageList, "mCycleData", data);
final Spinner spinner = mock(Spinner.class);
when(spinner.getSelectedItemPosition()).thenReturn(0);
ReflectionHelpers.setField(mDataUsageList, "mCycleSpinner", spinner);
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
mDataUsageList.startAppDataUsage(new AppItem());
verify(mActivity).startActivity(intent.capture());
final Bundle arguments = intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
assertThat(arguments.getLong(AppDataUsage.ARG_SELECTED_CYCLE)).isEqualTo(endTime);
final ArrayList<Long> cycles = (ArrayList) arguments.getSerializable(AppDataUsage.ARG_NETWORK_CYCLES);
assertThat(cycles).hasSize(2);
assertThat(cycles.get(0)).isEqualTo(endTime);
assertThat(cycles.get(1)).isEqualTo(startTime);
}
use of com.android.settingslib.net.NetworkCycleChartData in project android_packages_apps_Settings by omnirom.
the class DataUsageList method startAppDataUsage.
@VisibleForTesting
void startAppDataUsage(AppItem item) {
final Bundle args = new Bundle();
args.putParcelable(AppDataUsage.ARG_APP_ITEM, item);
args.putParcelable(AppDataUsage.ARG_NETWORK_TEMPLATE, mTemplate);
if (mCycles == null) {
mCycles = new ArrayList<>();
for (NetworkCycleChartData data : mCycleData) {
if (mCycles.isEmpty()) {
mCycles.add(data.getEndTime());
}
mCycles.add(data.getStartTime());
}
}
args.putSerializable(AppDataUsage.ARG_NETWORK_CYCLES, mCycles);
args.putLong(AppDataUsage.ARG_SELECTED_CYCLE, mCycleData.get(mCycleSpinner.getSelectedItemPosition()).getEndTime());
new SubSettingLauncher(getContext()).setDestination(AppDataUsage.class.getName()).setTitleRes(R.string.data_usage_app_summary_title).setArguments(args).setSourceMetricsCategory(getMetricsCategory()).launch();
}
Aggregations