Apply top intro preference in Settings app (1/n)

Based on content in footer, we need to convert some footers
to top info prefernce.

Test: Run robo test and see the screens
Bug: 173087905
Change-Id: Ie62a503481f9d385f5468896fba8f607cb3437d3
This commit is contained in:
Tsung-Mao Fang
2020-11-16 18:13:36 +08:00
parent 564eaec283
commit 00956fb4e1
15 changed files with 86 additions and 83 deletions

View File

@@ -158,13 +158,13 @@ public class TetherSettingsTest {
final TetherSettings spyTetherSettings = spy(new TetherSettings());
when(spyTetherSettings.getContext()).thenReturn(mContext);
final Preference mockPreference = mock(Preference.class);
when(spyTetherSettings.findPreference(TetherSettings.KEY_TETHER_PREFS_FOOTER))
when(spyTetherSettings.findPreference(TetherSettings.KEY_TETHER_PREFS_TOP_INTRO))
.thenReturn(mockPreference);
final WifiManager mockWifiManager = mock(WifiManager.class);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mockWifiManager);
when(mockWifiManager.isStaApConcurrencySupported()).thenReturn(true);
spyTetherSettings.setFooterPreferenceTitle();
spyTetherSettings.setTopIntroPreferenceTitle();
verify(mockPreference, never()).setTitle(R.string.tethering_footer_info);
verify(mockPreference).setTitle(R.string.tethering_footer_info_sta_ap_concurrency);

View File

@@ -34,7 +34,7 @@ import android.provider.Settings;
import androidx.preference.PreferenceScreen;
import com.android.settingslib.widget.FooterPreference;
import com.android.settingslib.widget.TopIntroPreference;
import org.junit.Before;
import org.junit.Test;
@@ -45,25 +45,25 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class GraphicsDriverFooterPreferenceControllerTest {
public class GraphicsDriverTopIntroPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
@Mock
private FooterPreference mPreference;
private TopIntroPreference mPreference;
@Mock
private GraphicsDriverContentObserver mGraphicsDriverContentObserver;
private Context mContext;
private ContentResolver mResolver;
private GraphicsDriverFooterPreferenceController mController;
private GraphicsDriverTopIntroPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mResolver = mContext.getContentResolver();
mController = spy(new GraphicsDriverFooterPreferenceController(mContext, "key"));
mController = spy(new GraphicsDriverTopIntroPreferenceController(mContext, "key"));
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}

View File

@@ -1,15 +1,17 @@
/*
* Copyright (C) 2018 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
* 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.
* 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.display;
@@ -31,14 +33,14 @@ import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.class)
public class NightDisplayFooterPreferenceControllerTest {
public class NightDisplayTopIntroPreferenceControllerTest {
private NightDisplayFooterPreferenceController mController;
private NightDisplayTopIntroPreferenceController mController;
@Before
public void setUp() {
mController =
new NightDisplayFooterPreferenceController(RuntimeEnvironment.application, "key");
new NightDisplayTopIntroPreferenceController(RuntimeEnvironment.application, "key");
}
@After

View File

@@ -32,15 +32,15 @@ import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
@Ignore
public class MultiUserFooterPreferenceControllerTest {
public class MultiUserTopIntroPreferenceControllerTest {
private Context mContext;
private MultiUserFooterPreferenceController mController;
private MultiUserTopIntroPreferenceController mController;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mController = new MultiUserFooterPreferenceController(mContext, "footer");
mController = new MultiUserTopIntroPreferenceController(mContext, "top_info");
}
@Test

View File

@@ -128,8 +128,8 @@ public class UserSettingsTest {
mFragment = spy(new UserSettings());
ReflectionHelpers.setField(mFragment, "mAddUserWhenLockedPreferenceController",
mock(AddUserWhenLockedPreferenceController.class));
ReflectionHelpers.setField(mFragment, "mMultiUserFooterPreferenceController",
mock(MultiUserFooterPreferenceController.class));
ReflectionHelpers.setField(mFragment, "mMultiUserTopIntroPreferenceController",
mock(MultiUserTopIntroPreferenceController.class));
ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
ReflectionHelpers.setField(mFragment, "mUserCaps", mUserCapabilities);
ReflectionHelpers.setField(mFragment, "mDefaultIconDrawable", mDefaultIconDrawable);