Game Driver: Add SwitchBar to control GUP feature
Uncheck the global switch will hide the preference controllers and force all apps to use system graphics driver. This change also add a content observer to notify all the preference controllers of settings global changes. Bug: 119221883 Test: make RunSettingsRoboTests Change-Id: Ice9ded17c759791a3728c552f79881e2215ac081
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2019 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.development.gup;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.provider.Settings;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class GameDriverContentObserverTest {
|
||||
@Mock
|
||||
private ContentResolver mResolver;
|
||||
@Mock
|
||||
private GameDriverContentObserver.OnGameDriverContentChangedListener mListener;
|
||||
|
||||
private GameDriverContentObserver mGameDriverContentObserver;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mGameDriverContentObserver = spy(new GameDriverContentObserver(null, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onChange_shouldCallListener() {
|
||||
mGameDriverContentObserver.mListener = mListener;
|
||||
mGameDriverContentObserver.onChange(true);
|
||||
|
||||
verify(mListener).onGameDriverContentChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void register_shouldRegisterContentObserver() {
|
||||
mGameDriverContentObserver.register(mResolver);
|
||||
|
||||
verify(mResolver).registerContentObserver(
|
||||
Settings.Global.getUriFor(Settings.Global.GUP_DEV_ALL_APPS), false,
|
||||
mGameDriverContentObserver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unregister_shouldUnregisterContentObserver() {
|
||||
mGameDriverContentObserver.unregister(mResolver);
|
||||
|
||||
verify(mResolver).unregisterContentObserver(mGameDriverContentObserver);
|
||||
}
|
||||
}
|
@@ -17,11 +17,13 @@
|
||||
package com.android.settings.development.gup;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_ALL_APPS;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -46,6 +48,8 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock
|
||||
private SwitchPreference mPreference;
|
||||
@Mock
|
||||
private GameDriverContentObserver mGameDriverContentObserver;
|
||||
|
||||
private Context mContext;
|
||||
private ContentResolver mResolver;
|
||||
@@ -58,34 +62,86 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
mResolver = mContext.getContentResolver();
|
||||
mController = new GupEnableForAllAppsPreferenceController(mContext, "testKey");
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_developmentSettingsEnabled_available() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
public void getAvailability_developmentSettingsEnabledAndGupSettingsOn_available() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_developmentSettingsDisabled_disabledDependentSetting() {
|
||||
public void getAvailability_developmentSettingsDisabled_conditionallyUnavailable() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_gupSettingsOff_conditionallyUnavailable() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_shouldAddSwitchPreference() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
mController.displayPreference(mScreen);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStart_shouldRegister() {
|
||||
mController.mGameDriverContentObserver = mGameDriverContentObserver;
|
||||
mController.onStart();
|
||||
|
||||
verify(mGameDriverContentObserver).register(mResolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStop_shouldUnregister() {
|
||||
mController.mGameDriverContentObserver = mGameDriverContentObserver;
|
||||
mController.onStop();
|
||||
|
||||
verify(mGameDriverContentObserver).unregister(mResolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_availableAndGupDefault_visibleAndUncheck() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference, atLeastOnce()).setVisible(true);
|
||||
verify(mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_availableAndGupAllApps_visibleAndCheck() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_ALL_APPS);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference, atLeastOnce()).setVisible(true);
|
||||
verify(mPreference).setChecked(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_gupSettingsOff_notVisibleAndUncheck() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setVisible(false);
|
||||
verify(mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_check_shouldUpdateSettingsGlobal() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
mController.displayPreference(mScreen);
|
||||
mController.onPreferenceChange(mPreference, true);
|
||||
|
||||
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
|
||||
@@ -95,7 +151,6 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
@Test
|
||||
public void onPreferenceChange_uncheck_shouldUpdateSettingsGlobal() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_ALL_APPS);
|
||||
mController.displayPreference(mScreen);
|
||||
mController.onPreferenceChange(mPreference, false);
|
||||
|
||||
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
|
||||
|
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright 2019 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.development.gup;
|
||||
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settings.widget.SwitchBarController;
|
||||
import com.android.settings.widget.SwitchWidgetController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class GupGlobalSwitchBarControllerTest {
|
||||
@Mock
|
||||
private SwitchBar mSwitchBar;
|
||||
@Mock
|
||||
private SwitchWidgetController mSwitchWidgetController;
|
||||
@Mock
|
||||
private GameDriverContentObserver mGameDriverContentObserver;
|
||||
|
||||
private Context mContext;
|
||||
private ContentResolver mResolver;
|
||||
private GupGlobalSwitchBarController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mResolver = mContext.getContentResolver();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructor_gupOn_shouldCheckSwitchBar() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
|
||||
verify(mSwitchBar).setChecked(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructor_gupOff_shouldUncheckSwitchBar() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
|
||||
verify(mSwitchBar).setChecked(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructor_developmentSettingsEnabled_shouldEnableSwitchBar() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
|
||||
verify(mSwitchBar).setEnabled(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructor_developmentSettingsDisabled_shouldDisableSwitchBar() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
|
||||
verify(mSwitchBar).setEnabled(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStart_shouldStartListeningAndRegister() {
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
mController.mSwitchWidgetController = mSwitchWidgetController;
|
||||
mController.mGameDriverContentObserver = mGameDriverContentObserver;
|
||||
mController.onStart();
|
||||
|
||||
verify(mSwitchWidgetController).startListening();
|
||||
verify(mGameDriverContentObserver).register(mResolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStop_shouldStopListeningAndUnregister() {
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
mController.mSwitchWidgetController = mSwitchWidgetController;
|
||||
mController.mGameDriverContentObserver = mGameDriverContentObserver;
|
||||
mController.onStop();
|
||||
|
||||
verify(mSwitchWidgetController).stopListening();
|
||||
verify(mGameDriverContentObserver).unregister(mResolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSwitchToggled_checked_shouldTurnOnGup() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
mController.onSwitchToggled(true);
|
||||
|
||||
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
|
||||
.isEqualTo(GUP_DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSwitchToggled_unchecked_shouldTurnOffGup() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
mController.onSwitchToggled(false);
|
||||
|
||||
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
|
||||
.isEqualTo(GUP_OFF);
|
||||
}
|
||||
}
|
@@ -17,11 +17,14 @@
|
||||
package com.android.settings.development.gup;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
@@ -65,6 +68,8 @@ public class GupPreferenceControllerTest {
|
||||
private PackageManager mPackageManager;
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock
|
||||
private GameDriverContentObserver mGameDriverContentObserver;
|
||||
|
||||
private Context mContext;
|
||||
private PreferenceGroup mGroup;
|
||||
@@ -84,19 +89,28 @@ public class GupPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_developmentSettingsEnabled_available() {
|
||||
public void getAvailability_developmentSettingsEnabledAndGupSettingsOn_available() {
|
||||
loadDefaultConfig();
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_developmentSettingsDisabled_disabledDependentSetting() {
|
||||
public void getAvailability_developmentSettingsDisabled_conditionallyUnavailable() {
|
||||
loadDefaultConfig();
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_gupSettingsOff_conditionallyUnavailable() {
|
||||
loadDefaultConfig();
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,11 +124,46 @@ public class GupPreferenceControllerTest {
|
||||
assertThat(mGroup.getPreference(1).getKey()).isEqualTo(APP_3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStart_shouldRegister() {
|
||||
loadDefaultConfig();
|
||||
mController.mGameDriverContentObserver = mGameDriverContentObserver;
|
||||
mController.onStart();
|
||||
|
||||
verify(mGameDriverContentObserver).register(mResolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStop_shouldUnregister() {
|
||||
loadDefaultConfig();
|
||||
mController.mGameDriverContentObserver = mGameDriverContentObserver;
|
||||
mController.onStop();
|
||||
|
||||
verify(mGameDriverContentObserver).unregister(mResolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_available_visible() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
loadDefaultConfig();
|
||||
|
||||
assertThat(mGroup.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_gupSettingsOff_notVisible() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
loadDefaultConfig();
|
||||
|
||||
assertThat(mGroup.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPreference_configDefault_shouldSetDefaultAttributes() {
|
||||
loadDefaultConfig();
|
||||
final ListPreference preference =
|
||||
mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
|
||||
|
||||
assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
|
||||
assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
|
||||
@@ -130,7 +179,7 @@ public class GupPreferenceControllerTest {
|
||||
public void createPreference_configGup_shouldSetGupAttributes() {
|
||||
loadConfig(TEST_PKG_NAME, "");
|
||||
final ListPreference preference =
|
||||
mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
|
||||
|
||||
assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
|
||||
assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
|
||||
@@ -146,7 +195,7 @@ public class GupPreferenceControllerTest {
|
||||
public void createPreference_configSystem_shouldSetSystemAttributes() {
|
||||
loadConfig("", TEST_PKG_NAME);
|
||||
final ListPreference preference =
|
||||
mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
|
||||
|
||||
assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
|
||||
assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
|
||||
@@ -162,7 +211,7 @@ public class GupPreferenceControllerTest {
|
||||
public void onPreferenceChange_selectDefault_shouldUpdateAttributesAndSettingsGlobal() {
|
||||
loadDefaultConfig();
|
||||
final ListPreference preference =
|
||||
mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.onPreferenceChange(preference, mValueList[DEFAULT]);
|
||||
|
||||
assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
|
||||
@@ -178,7 +227,7 @@ public class GupPreferenceControllerTest {
|
||||
public void onPreferenceChange_selectGup_shouldUpdateAttributesAndSettingsGlobal() {
|
||||
loadDefaultConfig();
|
||||
final ListPreference preference =
|
||||
mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.onPreferenceChange(preference, mValueList[GUP]);
|
||||
|
||||
assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]);
|
||||
@@ -194,7 +243,7 @@ public class GupPreferenceControllerTest {
|
||||
public void onPreferenceChange_selectSystem_shouldUpdateAttributesAndSettingsGlobal() {
|
||||
loadDefaultConfig();
|
||||
final ListPreference preference =
|
||||
mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.onPreferenceChange(preference, mValueList[SYSTEM]);
|
||||
|
||||
assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]);
|
||||
@@ -230,6 +279,7 @@ public class GupPreferenceControllerTest {
|
||||
mController = new GupPreferenceController(mContext, "testKey");
|
||||
mGroup = spy(new PreferenceCategory(mContext));
|
||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
when(mGroup.getContext()).thenReturn(mContext);
|
||||
when(mGroup.getPreferenceManager()).thenReturn(preferenceManager);
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mGroup);
|
||||
mController.displayPreference(mScreen);
|
||||
|
Reference in New Issue
Block a user