Delete about phone v1 code

Bug: 36458278
Test: make RunSettingsRoboTests -j40
Change-Id: Ib8f420a86caa1da0165aa5c161eb584a009ed2b9
This commit is contained in:
jeffreyhuang
2017-11-29 16:41:48 -08:00
parent b8eb89579c
commit 7ef47a9c5d
25 changed files with 34 additions and 1786 deletions

View File

@@ -30,12 +30,9 @@ import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.support.v7.preference.PreferenceScreen;
import android.telephony.TelephonyManager;
import android.util.FeatureFlagUtils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -98,8 +95,6 @@ public class DeviceInfoSettingsTest {
SettingsShadowSystemProperties.class
})
public void getPrefXml_shouldReturnDeviceInfoXml() {
SystemProperties.set(FeatureFlagUtils.FFLAG_OVERRIDE_PREFIX + FeatureFlags.DEVICE_INFO_V2,
"true");
assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(R.xml.device_info_settings_v2);
}
@@ -142,8 +137,6 @@ public class DeviceInfoSettingsTest {
@Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class,
SettingsShadowSystemProperties.class})
public void onCreate_singleSim_shouldAddSingleSimCount() {
SystemProperties.set(FeatureFlagUtils.FFLAG_OVERRIDE_PREFIX + FeatureFlags.DEVICE_INFO_V2,
"true");
doReturn(1).when(mTelephonyManager).getPhoneCount();
mSettings.onCreate(null /* icicle */);
@@ -156,8 +149,6 @@ public class DeviceInfoSettingsTest {
@Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class,
SettingsShadowSystemProperties.class})
public void onCreate_dualeSim_shouldAddDualSimCount() {
SystemProperties.set(FeatureFlagUtils.FFLAG_OVERRIDE_PREFIX + FeatureFlags.DEVICE_INFO_V2,
"true");
doReturn(2).when(mTelephonyManager).getPhoneCount();
mSettings.onCreate(null /* icicle */);

View File

@@ -1,86 +0,0 @@
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.deviceinfo;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
import static org.robolectric.shadow.api.Shadow.extract;
import android.net.ConnectivityManager;
import android.support.v7.preference.Preference;
import com.android.settings.TestConfig;
import com.android.settings.deviceinfo.firmwareversion.BasebandVersionDialogController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
/**
* Deprecated in favor of {@link BasebandVersionDialogController}
*/
@Deprecated
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
shadows = ShadowConnectivityManager.class)
public class BasebandVersionPreferenceControllerTest {
@Mock
private Preference mPreference;
private BasebandVersionPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mController = new BasebandVersionPreferenceController(RuntimeEnvironment.application);
}
@Test
public void isAvailable_wifiOnly_shouldReturnFalse() {
ShadowConnectivityManager connectivityManager =
extract(RuntimeEnvironment.application.getSystemService(ConnectivityManager.class));
connectivityManager.setNetworkSupported(ConnectivityManager.TYPE_MOBILE, false);
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isAvailable_hasMobile_shouldReturnTrue() {
ShadowConnectivityManager connectivityManager =
extract(RuntimeEnvironment.application.getSystemService(ConnectivityManager.class));
connectivityManager.setNetworkSupported(ConnectivityManager.TYPE_MOBILE, true);
assertThat(mController.isAvailable()).isTrue();
}
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
public void updateState_shouldLoadFromSysProperty() {
SettingsShadowSystemProperties.set("gsm.version.baseband", "test");
mController.updateState(mPreference);
verify(mPreference).setSummary("test");
}
}

View File

@@ -1,110 +0,0 @@
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.deviceinfo;
import static android.arch.lifecycle.Lifecycle.Event.ON_START;
import static android.arch.lifecycle.Lifecycle.Event.ON_STOP;
import static com.android.settings.deviceinfo.BatteryInfoPreferenceController
.BATTERY_INFO_RECEIVER_INTENT_FILTER;
import static com.android.settings.deviceinfo.BatteryInfoPreferenceController.KEY_BATTERY_LEVEL;
import static com.android.settings.deviceinfo.BatteryInfoPreferenceController.KEY_BATTERY_STATUS;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
import android.os.BatteryManager;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.TestConfig;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class BatteryInfoPreferenceControllerTest {
private Context mContext;
@Mock
private PreferenceScreen mScreen;
private Preference mBatteryLevel;
private Preference mBatteryStatus;
private Lifecycle mLifecycle;
private BatteryInfoPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mController = new BatteryInfoPreferenceController(mContext, mLifecycle);
mBatteryLevel = new Preference(mContext);
mBatteryStatus = new Preference(mContext);
when(mScreen.findPreference(KEY_BATTERY_STATUS)).thenReturn(mBatteryStatus);
when(mScreen.findPreference(KEY_BATTERY_LEVEL)).thenReturn(mBatteryLevel);
}
@Test
public void isAlwaysAvailable() {
assertThat(mController.getPreferenceKey()).isNull();
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void runThroughLifecycle_shouldRegisterUnregisterBatteryInfoReceiver() {
final Context context = mock(Context.class);
mController = new BatteryInfoPreferenceController(context, mLifecycle);
mLifecycle.handleLifecycleEvent(ON_START);
mLifecycle.handleLifecycleEvent(ON_STOP);
verify(context).registerReceiver(mController.mBatteryInfoReceiver,
BATTERY_INFO_RECEIVER_INTENT_FILTER);
verify(context).unregisterReceiver(mController.mBatteryInfoReceiver);
}
@Test
public void onReceiveBatteryInfoBroadcast_shouldUpdatePreferences() {
mController.displayPreference(mScreen);
final Intent intent = new Intent(Intent.ACTION_BATTERY_CHANGED);
intent.putExtra(BatteryManager.EXTRA_LEVEL, 50);
intent.putExtra(BatteryManager.EXTRA_SCALE, 100);
intent.putExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_CHARGING);
mController.mBatteryInfoReceiver.onReceive(mContext, intent);
assertThat(mBatteryLevel.getSummary()).isEqualTo("50%");
assertThat(mBatteryStatus.getSummary())
.isEqualTo(mContext.getText(R.string.battery_info_status_charging));
}
}

View File

@@ -19,6 +19,7 @@ package com.android.settings.deviceinfo;
import static com.android.settings.deviceinfo.DeviceModelPreferenceController.getDeviceModel;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
@@ -26,16 +27,12 @@ import static org.mockito.Mockito.when;
import android.app.Fragment;
import android.content.Context;
import android.os.SystemProperties;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.util.FeatureFlagUtils;
import com.android.settings.R;
import com.android.settings.TestConfig;
import com.android.settings.core.FeatureFlags;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
import org.junit.Before;
import org.junit.Test;
@@ -57,6 +54,7 @@ public class DeviceModelPreferenceControllerTest {
@Mock
private PreferenceScreen mPreferenceScreen;
private Context mContext;
private DeviceModelPreferenceController mController;
@@ -76,12 +74,7 @@ public class DeviceModelPreferenceControllerTest {
}
@Test
@Config(shadows = {
SettingsShadowSystemProperties.class
})
public void displayPref_shouldSetSummary() {
SystemProperties.set(FeatureFlagUtils.FFLAG_OVERRIDE_PREFIX + FeatureFlags.DEVICE_INFO_V2,
"true");
mController.displayPreference(mPreferenceScreen);
verify(mPreference).setSummary(mContext.getResources().getString(R.string.model_summary,

View File

@@ -1,74 +0,0 @@
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.deviceinfo;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.UserManager;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.TestConfig;
import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionDialogController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
/**
* Deprecated in favor of {@link FirmwareVersionDialogController}
*/
@Deprecated
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class FirmwareVersionPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@Mock
private Preference mPreference;
@Mock
private PreferenceScreen mPreferenceScreen;
@Mock
private UserManager mUserManager;
private FirmwareVersionPreferenceController mController;
private Lifecycle mLifecycle;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mLifecycle = new Lifecycle(() -> mLifecycle);
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn(null);
mController = new FirmwareVersionPreferenceController(mContext, mLifecycle);
when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
.thenReturn(mPreference);
}
@Test
public void isAlwaysAvailable() {
assertThat(mController.isAvailable()).isTrue();
}
}