Dupe BluetoothSettings and DeviceListPreferenceFragment

Create the obsolete version of the belowing fragments, so we could
flip between old page and new page.

BluetoothSettingsObsolete and DeviceListPreferenceObsoleteFragment
contains all the old logic but:
1. Logic about BluetoothPairingPreferenceController(ag/2239482),
since this preference shouldn't be checked in without the flag :(

This cl also adds logic in MasterSwitchPreferenceController to flip
these two pages.

Following cl will refactor these fragment to make it compatible
to new framework.

Bug: 35877041
Test: RunSettingsRoboTests
Change-Id: I1cc1bc2d49d8a3e11c3127e56f6409fbc84028d8
This commit is contained in:
jackqdyulei
2017-05-16 20:17:35 -07:00
parent 803f0c96e8
commit 5333ecd1fb
15 changed files with 1077 additions and 33 deletions

View File

@@ -31,16 +31,20 @@ import android.support.v7.preference.Preference;
import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
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.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class BluetoothSettingsTest {
@@ -50,17 +54,21 @@ public class BluetoothSettingsTest {
private UserManager mUserManager;
@Mock
private Resources mResource;
@Mock
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@Mock
private LocalBluetoothAdapter mLocalAdapter;
private BluetoothSettings mFragment;
private Preference mMyDevicePreference;
private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
mFragment = spy(new BluetoothSettings());
doReturn(mContext).when(mFragment).getContext();
doReturn(mResource).when(mFragment).getResources();
@@ -86,4 +94,22 @@ public class BluetoothSettingsTest {
assertThat(mMyDevicePreference.getTitle()).isEqualTo(FOOTAGE_MAC_STRING);
}
@Test
public void testSearchIndexProvider_pairPageEnabled_keyNotAdded() {
doReturn(true).when(mFeatureFactory.bluetoothFeatureProvider).isPairingPageEnabled();
final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
mContext);
assertThat(keys).doesNotContain(BluetoothSettings.DATA_KEY_REFERENCE);
}
@Test
public void testSearchIndexProvider_pairPageDisabled_keyAdded() {
final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
mContext);
assertThat(keys).contains(BluetoothSettings.DATA_KEY_REFERENCE);
}
}