Search in sources :

Example 21 with UsageView

use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by DirtyUnicorns.

the class BatteryInfoTest method assertHistoryAndEnhancedProjection.

private void assertHistoryAndEnhancedProjection(BatteryInfo info) {
    mockBatteryStatsHistory();
    UsageView view = mock(UsageView.class);
    doReturn(mContext).when(view).getContext();
    SparseIntArray pointsExpected = new SparseIntArray();
    pointsExpected.append(2000, 96);
    pointsExpected.append(2500, 95);
    pointsExpected.append(3000, 94);
    doReturn(pointsExpected).when(mFeatureFactory.powerUsageFeatureProvider).getEnhancedBatteryPredictionCurve(any(Context.class), anyLong());
    info.bindHistory(view);
    verify(view, times(2)).configureGraph(anyInt(), anyInt());
    verify(view, times(1)).addPath(any(SparseIntArray.class));
    ArgumentCaptor<SparseIntArray> pointsActual = ArgumentCaptor.forClass(SparseIntArray.class);
    verify(view, times(1)).addProjectedPath(pointsActual.capture());
    assertThat(pointsActual.getValue()).isEqualTo(pointsExpected);
}
Also used : Context(android.content.Context) UsageView(com.android.settings.graph.UsageView) SparseIntArray(android.util.SparseIntArray)

Example 22 with UsageView

use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by DirtyUnicorns.

the class ChartDataUsagePreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    UsageView chart = (UsageView) holder.findViewById(R.id.data_usage);
    if (mNetwork == null)
        return;
    int top = getTop();
    chart.clearPaths();
    chart.configureGraph(toInt(mEnd - mStart), top);
    calcPoints(chart);
    chart.setBottomLabels(new CharSequence[] { Utils.formatDateRange(getContext(), mStart, mStart), Utils.formatDateRange(getContext(), mEnd, mEnd) });
    bindNetworkPolicy(chart, mPolicy, top);
}
Also used : UsageView(com.android.settings.graph.UsageView)

Example 23 with UsageView

use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by crdroidandroid.

the class ChartDataUsagePreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    UsageView chart = (UsageView) holder.findViewById(R.id.data_usage);
    if (mNetwork == null)
        return;
    int top = getTop();
    chart.clearPaths();
    chart.configureGraph(toInt(mEnd - mStart), top);
    calcPoints(chart);
    chart.setBottomLabels(new CharSequence[] { Utils.formatDateRange(getContext(), mStart, mStart), Utils.formatDateRange(getContext(), mEnd, mEnd) });
    bindNetworkPolicy(chart, mPolicy, top);
}
Also used : UsageView(com.android.settings.graph.UsageView)

Example 24 with UsageView

use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by crdroidandroid.

the class BatteryInfoTest method assertHistoryAndEnhancedProjection.

private void assertHistoryAndEnhancedProjection(BatteryInfo info) {
    mockBatteryStatsHistory();
    UsageView view = mock(UsageView.class);
    doReturn(mContext).when(view).getContext();
    SparseIntArray pointsExpected = new SparseIntArray();
    pointsExpected.append(2000, 96);
    pointsExpected.append(2500, 95);
    pointsExpected.append(3000, 94);
    doReturn(pointsExpected).when(mFeatureFactory.powerUsageFeatureProvider).getEnhancedBatteryPredictionCurve(any(Context.class), anyLong());
    info.bindHistory(view);
    verify(view, times(2)).configureGraph(anyInt(), anyInt());
    verify(view, times(1)).addPath(any(SparseIntArray.class));
    ArgumentCaptor<SparseIntArray> pointsActual = ArgumentCaptor.forClass(SparseIntArray.class);
    verify(view, times(1)).addProjectedPath(pointsActual.capture());
    assertThat(pointsActual.getValue()).isEqualTo(pointsExpected);
}
Also used : Context(android.content.Context) UsageView(com.android.settings.graph.UsageView) SparseIntArray(android.util.SparseIntArray)

Example 25 with UsageView

use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by SudaMod.

the class BatteryInfoTest method assertOnlyHistory.

private void assertOnlyHistory(BatteryInfo info) {
    mockBatteryStatsHistory();
    UsageView view = mock(UsageView.class);
    doReturn(mContext).when(view).getContext();
    info.bindHistory(view);
    verify(view, times(1)).configureGraph(anyInt(), anyInt());
    verify(view, times(1)).addPath(any(SparseIntArray.class));
    verify(view, never()).addProjectedPath(any(SparseIntArray.class));
}
Also used : UsageView(com.android.settings.graph.UsageView) SparseIntArray(android.util.SparseIntArray)

Aggregations

UsageView (com.android.settings.graph.UsageView)31 SparseIntArray (android.util.SparseIntArray)15 TextView (android.widget.TextView)11 View (android.view.View)6 Context (android.content.Context)5