Merge "Misc clean up. move widgets from graph to widget package."

This commit is contained in:
TreeHugger Robot
2018-06-12 01:01:32 +00:00
committed by Android (Google) Code Review
16 changed files with 65 additions and 54 deletions

View File

@@ -25,8 +25,10 @@ import android.content.Context;
import android.net.NetworkStatsHistory;
import android.net.NetworkStatsHistory.Entry;
import android.util.SparseIntArray;
import com.android.settings.graph.UsageView;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.widget.UsageView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -65,7 +67,7 @@ public class ChartDataUsagePreferenceTest {
when(mNetworkStatsHistory.getIndexAfter(end)).thenReturn(7);
final UsageView usageView = mock(UsageView.class);
final ArgumentCaptor<SparseIntArray> pointsCaptor =
ArgumentCaptor.forClass(SparseIntArray.class);
ArgumentCaptor.forClass(SparseIntArray.class);
mPreference.calcPoints(usageView);
@@ -84,7 +86,7 @@ public class ChartDataUsagePreferenceTest {
when(mNetworkStatsHistory.getIndexAfter(end)).thenReturn(5);
final UsageView usageView = mock(UsageView.class);
final ArgumentCaptor<SparseIntArray> pointsCaptor =
ArgumentCaptor.forClass(SparseIntArray.class);
ArgumentCaptor.forClass(SparseIntArray.class);
mPreference.calcPoints(usageView);
@@ -113,9 +115,10 @@ public class ChartDataUsagePreferenceTest {
* Create a network entry to be used to calculate the usage chart. In the calculation, we only
* need bucketStart, total bytes (rx + tx), and bucketDuration (which is set when we create
* the NetworkStatsHistory object). Other fields are ignored, so we don't initialize here.
*
* @param start the timestamp when this entry begins
* @param rx the total number of received bytes
* @param tx the total number of transmitted bytes
* @param rx the total number of received bytes
* @param tx the total number of transmitted bytes
* @return the network entry with the corresponding start time and data usage
*/
private Entry createEntry(long start, long rx, long tx) {

View File

@@ -23,15 +23,14 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import androidx.preference.PreferenceViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.graph.UsageView;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.widget.UsageView;
import org.junit.Before;
import org.junit.Test;
@@ -41,6 +40,8 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import androidx.preference.PreferenceViewHolder;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.SettingsShadowTheme.class)
public class BatteryHistoryPreferenceTest {
@@ -63,7 +64,7 @@ public class BatteryHistoryPreferenceTest {
MockitoAnnotations.initMocks(this);
final Context context = RuntimeEnvironment.application;
final View itemView =
LayoutInflater.from(context).inflate(R.layout.battery_usage_graph, null);
LayoutInflater.from(context).inflate(R.layout.battery_usage_graph, null);
mBatteryHistoryPreference = new BatteryHistoryPreference(context, null);
mBatteryHistoryPreference.mBatteryInfo = mBatteryInfo;

View File

@@ -36,12 +36,11 @@ import android.os.BatteryStats;
import android.os.SystemClock;
import android.util.SparseIntArray;
import com.android.settings.graph.UsageView;
import com.android.settings.testutils.BatteryTestUtils;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.widget.UsageView;
import com.android.settingslib.R;
import com.android.settingslib.utils.PowerUtil;
import org.junit.Before;
import org.junit.Test;
@@ -172,7 +171,8 @@ public class BatteryInfoTest {
}
@Test
public void testGetBatteryInfo_basedOnUsageTrueBetweenSevenAndFifteenMinutes_usesCorrectString() {
public void
testGetBatteryInfo_basedOnUsageTrueBetweenSevenAndFifteenMinutes_usesCorrectString() {
Estimate estimate = new Estimate(Duration.ofMinutes(10).toMillis(),
true /* isBasedOnUsage */,
1000 /* averageDischargeTime */);

View File

@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -11,11 +12,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.android.settings.graph;
package com.android.settings.widget;
import static com.google.common.truth.Truth.assertThat;

View File

@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -11,11 +12,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package com.android.settings.graph;
package com.android.settings.widget;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;