Merge "Clean up unused MobilePlanPreferenceController" into main
diff --git a/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragment.java b/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragment.java
index 1731212..c017022 100644
--- a/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragment.java
@@ -17,15 +17,15 @@
package com.android.settings.deviceinfo.batteryinfo;
import android.app.settings.SettingsEnums;
+import android.content.Context;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
-/**
- * A fragment that shows battery hardware information.
- */
+/** A fragment that shows battery hardware information. */
@SearchIndexable
public class BatteryInfoFragment extends DashboardFragment {
@@ -47,5 +47,12 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.battery_info);
+ new BaseSearchIndexProvider(R.xml.battery_info) {
+ @Override
+ protected boolean isPageSearchEnabled(Context context) {
+ return FeatureFactory.getFeatureFactory()
+ .getBatterySettingsFeatureProvider()
+ .isBatteryInfoEnabled(context);
+ }
+ };
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index 2c9fb99..49777bc 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -59,6 +59,7 @@
import java.util.HashSet;
import java.util.Set;
+@Ignore("b/313014781")
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowEntityHeaderController.class, ShadowDeviceConfig.class})
public class AdvancedBluetoothDetailsHeaderControllerTest {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
index 8ac56dc..1904cb5 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
@@ -50,6 +50,7 @@
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -62,6 +63,7 @@
import org.robolectric.annotation.Config;
import org.robolectric.fakes.RoboMenu;
+@Ignore("b/313014781")
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {
com.android.settings.testutils.shadow.ShadowUserManager.class,
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPermissionActivityTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPermissionActivityTest.java
index 6f02753..4c58cd2 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPermissionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPermissionActivityTest.java
@@ -24,6 +24,7 @@
import android.content.Intent;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -32,6 +33,7 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
+@Ignore("b/313014781")
@RunWith(RobolectricTestRunner.class)
public class BluetoothPermissionActivityTest {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java
index 50c82d3..88ace91 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java
@@ -33,6 +33,7 @@
import com.android.settingslib.widget.FooterPreference;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -82,6 +83,7 @@
assertThat(TextUtils.equals(mFooterPreference.getTitle(), text)).isTrue();
}
+ @Ignore("b/313014781")
@Test
public void updateText_bluetoothOffScanningOff() {
Settings.Global.putInt(mContext.getContentResolver(),
@@ -91,6 +93,7 @@
assertThat(mFooterPreference.getTitle()).isEqualTo(BLUETOOTH_INFO_STRING);
}
+ @Ignore("b/313014781")
@Test
public void updateText_bluetoothOnScanningOff() {
Settings.Global.putInt(mContext.getContentResolver(),
@@ -100,6 +103,7 @@
assertThat(mFooterPreference.getTitle()).isEqualTo(BLUETOOTH_INFO_STRING);
}
+ @Ignore("b/313014781")
@Test
public void updateText_bluetoothOnScanningOn() {
Settings.Global.putInt(mContext.getContentResolver(),
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragmentTest.java b/tests/robotests/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragmentTest.java
new file mode 100644
index 0000000..d0dda84
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragmentTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2023 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.batteryinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(org.robolectric.RobolectricTestRunner.class)
+public class BatteryInfoFragmentTest {
+ private Context mContext;
+ private FakeFeatureFactory mFactory;
+ private BatteryInfoFragment mFragment;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mFactory = FakeFeatureFactory.setupForTest();
+ mFragment = new BatteryInfoFragment();
+ }
+
+ @Test
+ public void isPageSearchEnabled_batteryInfoEnabled_returnTrue() {
+ when(mFactory.batterySettingsFeatureProvider.isBatteryInfoEnabled(mContext))
+ .thenReturn(true);
+
+ final BaseSearchIndexProvider provider =
+ (BaseSearchIndexProvider) mFragment.SEARCH_INDEX_DATA_PROVIDER;
+
+ final Object obj =
+ org.robolectric.util.ReflectionHelpers.callInstanceMethod(
+ provider, /*methodName=*/ "isPageSearchEnabled",
+ ReflectionHelpers.ClassParameter.from(Context.class, mContext));
+ final boolean isEnabled = (Boolean) obj;
+ assertThat(isEnabled).isTrue();
+ }
+
+ @Test
+ public void isPageSearchEnabled_batteryInfoDisabled_returnFalse() {
+ when(mFactory.batterySettingsFeatureProvider.isBatteryInfoEnabled(mContext))
+ .thenReturn(false);
+
+ final BaseSearchIndexProvider provider =
+ (BaseSearchIndexProvider) mFragment.SEARCH_INDEX_DATA_PROVIDER;
+
+ final Object obj =
+ org.robolectric.util.ReflectionHelpers.callInstanceMethod(
+ provider, /*methodName=*/ "isPageSearchEnabled",
+ ReflectionHelpers.ClassParameter.from(Context.class, mContext));
+ final boolean isEnabled = (Boolean) obj;
+ assertThat(isEnabled).isFalse();
+ }
+}