Game Driver: rename GUP to Game Driver

Bug: 119221883
Test: make RunSettingsRoboTests
Change-Id: Ia7b9e3978ad96436a66843e6b5d1bd1e15f367c9
This commit is contained in:
Yiwei Zhang
2019-01-24 14:04:58 -08:00
parent 8aa568f1f5
commit bf854fc41b
15 changed files with 249 additions and 210 deletions

View File

@@ -14,12 +14,12 @@
* limitations under the License.
*/
package com.android.settings.development.gup;
package com.android.settings.development.gamedriver;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
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.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
import static com.google.common.truth.Truth.assertThat;
@@ -52,9 +52,10 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class GupPreferenceControllerTest {
public class GameDriverAppPreferenceControllerTest {
private static final int DEFAULT = 0;
private static final int GUP = 1;
private static final int GAME_DRIVER = 1;
private static final int SYSTEM = 2;
private static final String TEST_APP_NAME = "testApp";
private static final String TEST_PKG_NAME = "testPkg";
@@ -75,7 +76,7 @@ public class GupPreferenceControllerTest {
private PreferenceGroup mGroup;
private PreferenceManager mPreferenceManager;
private ContentResolver mResolver;
private GupPreferenceController mController;
private GameDriverAppPreferenceController mController;
private CharSequence[] mValueList;
private String mDialogTitle;
@@ -84,15 +85,17 @@ public class GupPreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mResolver = mContext.getContentResolver();
mValueList = mContext.getResources().getStringArray(R.array.gup_app_preference_values);
mDialogTitle = mContext.getResources().getString(R.string.gup_app_preference_title);
mValueList =
mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
}
@Test
public void getAvailability_developmentSettingsEnabledAndGupSettingsOn_available() {
public void getAvailability_developmentSettingsEnabledAndGameDriverOn_available() {
loadDefaultConfig();
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@@ -106,9 +109,9 @@ public class GupPreferenceControllerTest {
}
@Test
public void getAvailability_gupSettingsOff_conditionallyUnavailable() {
public void getAvailability_gameDriverOff_conditionallyUnavailable() {
loadDefaultConfig();
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}
@@ -145,15 +148,16 @@ public class GupPreferenceControllerTest {
@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);
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
loadDefaultConfig();
assertThat(mGroup.isVisible()).isTrue();
}
@Test
public void updateState_gupSettingsOff_notVisible() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
public void updateState_gameDriverOff_notVisible() {
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
loadDefaultConfig();
assertThat(mGroup.isVisible()).isFalse();
@@ -176,7 +180,7 @@ public class GupPreferenceControllerTest {
}
@Test
public void createPreference_configGup_shouldSetGupAttributes() {
public void createPreference_configGAME_DRIVER_shouldSetGameDriverAttributes() {
loadConfig(TEST_PKG_NAME, "");
final ListPreference preference =
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
@@ -186,9 +190,9 @@ public class GupPreferenceControllerTest {
assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
assertThat(preference.getEntries()).isEqualTo(mValueList);
assertThat(preference.getEntryValues()).isEqualTo(mValueList);
assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]);
assertThat(preference.getValue()).isEqualTo(mValueList[GUP]);
assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]);
assertThat(preference.getEntry()).isEqualTo(mValueList[GAME_DRIVER]);
assertThat(preference.getValue()).isEqualTo(mValueList[GAME_DRIVER]);
assertThat(preference.getSummary()).isEqualTo(mValueList[GAME_DRIVER]);
}
@Test
@@ -217,25 +221,25 @@ public class GupPreferenceControllerTest {
assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]);
assertThat(preference.getSummary()).isEqualTo(mValueList[DEFAULT]);
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS))
.isEqualTo("");
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS))
.isEqualTo("");
}
@Test
public void onPreferenceChange_selectGup_shouldUpdateAttributesAndSettingsGlobal() {
public void onPreferenceChange_selectGAME_DRIVER_shouldUpdateAttributesAndSettingsGlobal() {
loadDefaultConfig();
final ListPreference preference =
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
mController.onPreferenceChange(preference, mValueList[GUP]);
mController.onPreferenceChange(preference, mValueList[GAME_DRIVER]);
assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]);
assertThat(preference.getValue()).isEqualTo(mValueList[GUP]);
assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]);
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
assertThat(preference.getEntry()).isEqualTo(mValueList[GAME_DRIVER]);
assertThat(preference.getValue()).isEqualTo(mValueList[GAME_DRIVER]);
assertThat(preference.getSummary()).isEqualTo(mValueList[GAME_DRIVER]);
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS))
.isEqualTo(TEST_PKG_NAME);
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS))
.isEqualTo("");
}
@@ -249,9 +253,9 @@ public class GupPreferenceControllerTest {
assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]);
assertThat(preference.getValue()).isEqualTo(mValueList[SYSTEM]);
assertThat(preference.getSummary()).isEqualTo(mValueList[SYSTEM]);
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS))
.isEqualTo("");
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS))
.isEqualTo(TEST_PKG_NAME);
}
@@ -273,10 +277,10 @@ public class GupPreferenceControllerTest {
private void loadDefaultConfig() { loadConfig("", ""); }
private void loadConfig(String optIn, String optOut) {
Settings.Global.putString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS, optIn);
Settings.Global.putString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS, optOut);
Settings.Global.putString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS, optIn);
Settings.Global.putString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS, optOut);
mController = new GupPreferenceController(mContext, "testKey");
mController = new GameDriverAppPreferenceController(mContext, "testKey");
mGroup = spy(new PreferenceCategory(mContext));
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
when(mGroup.getContext()).thenReturn(mContext);

View File

@@ -14,13 +14,14 @@
* limitations under the License.
*/
package com.android.settings.development.gup;
package com.android.settings.development.gamedriver;
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;
@@ -31,6 +32,7 @@ import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class GameDriverContentObserverTest {
@Mock
private ContentResolver mResolver;
@Mock
@@ -57,7 +59,7 @@ public class GameDriverContentObserverTest {
mGameDriverContentObserver.register(mResolver);
verify(mResolver).registerContentObserver(
Settings.Global.getUriFor(Settings.Global.GUP_DEV_ALL_APPS), false,
Settings.Global.getUriFor(Settings.Global.GAME_DRIVER_ALL_APPS), false,
mGameDriverContentObserver);
}

View File

@@ -14,11 +14,12 @@
* limitations under the License.
*/
package com.android.settings.development.gup;
package com.android.settings.development.gamedriver;
import static com.google.common.truth.Truth.assertThat;
import com.android.internal.logging.nano.MetricsProto;
import android.app.settings.SettingsEnums;
import com.android.settings.R;
import org.junit.Before;
@@ -27,12 +28,13 @@ import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class GupDashboardTest {
private GupDashboard mDashboard;
public class GameDriverDashboardTest {
private GameDriverDashboard mDashboard;
@Before
public void setUp() {
mDashboard = new GupDashboard();
mDashboard = new GameDriverDashboard();
}
@Test
@@ -41,14 +43,13 @@ public class GupDashboardTest {
}
@Test
public void getMetricesCategory_shouldReturnGupDashboard() {
public void getMetricesCategory_shouldReturnGameDriverDashboard() {
assertThat(mDashboard.getMetricsCategory())
.isEqualTo(MetricsProto.MetricsEvent.SETTINGS_GUP_DASHBOARD);
.isEqualTo(SettingsEnums.SETTINGS_GAME_DRIVER_DASHBOARD);
}
@Test
public void getPreferenceScreen_shouldReturnGupSettings() {
assertThat(mDashboard.getPreferenceScreenResId())
.isEqualTo(R.xml.gup_settings);
public void getPreferenceScreen_shouldReturnGameDriverSettings() {
assertThat(mDashboard.getPreferenceScreenResId()).isEqualTo(R.xml.game_driver_settings);
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.android.settings.development.gup;
package com.android.settings.development.gamedriver;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
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.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.atLeastOnce;
@@ -43,7 +43,8 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class GupEnableForAllAppsPreferenceControllerTest {
public class GameDriverEnableForAllAppsPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
@Mock
@@ -53,14 +54,14 @@ public class GupEnableForAllAppsPreferenceControllerTest {
private Context mContext;
private ContentResolver mResolver;
private GupEnableForAllAppsPreferenceController mController;
private GameDriverEnableForAllAppsPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mResolver = mContext.getContentResolver();
mController = new GupEnableForAllAppsPreferenceController(mContext, "testKey");
mController = new GameDriverEnableForAllAppsPreferenceController(mContext, "testKey");
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
@@ -68,8 +69,9 @@ public class GupEnableForAllAppsPreferenceControllerTest {
}
@Test
public void getAvailability_developmentSettingsEnabledAndGupSettingsOn_available() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
public void getAvailability_developmentSettingsEnabledAndGameDriverSettingsOn_available() {
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@@ -82,15 +84,16 @@ public class GupEnableForAllAppsPreferenceControllerTest {
}
@Test
public void getAvailability_gupSettingsOff_conditionallyUnavailable() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
public void getAvailability_gameDriverOff_conditionallyUnavailable() {
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}
@Test
public void displayPreference_shouldAddSwitchPreference() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mController.updateState(mPreference);
verify(mPreference).setChecked(false);
@@ -113,8 +116,9 @@ public class GupEnableForAllAppsPreferenceControllerTest {
}
@Test
public void updateState_availableAndGupDefault_visibleAndUncheck() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
public void updateState_availableAndGameDriverDefault_visibleAndUncheck() {
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mController.updateState(mPreference);
verify(mPreference, atLeastOnce()).setVisible(true);
@@ -122,8 +126,9 @@ public class GupEnableForAllAppsPreferenceControllerTest {
}
@Test
public void updateState_availableAndGupAllApps_visibleAndCheck() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_ALL_APPS);
public void updateState_availableAndGameDriverAllApps_visibleAndCheck() {
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_ALL_APPS);
mController.updateState(mPreference);
verify(mPreference, atLeastOnce()).setVisible(true);
@@ -131,8 +136,8 @@ public class GupEnableForAllAppsPreferenceControllerTest {
}
@Test
public void updateState_gupSettingsOff_notVisibleAndUncheck() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
public void updateState_gameDriverOff_notVisibleAndUncheck() {
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
mController.updateState(mPreference);
verify(mPreference).setVisible(false);
@@ -141,19 +146,23 @@ public class GupEnableForAllAppsPreferenceControllerTest {
@Test
public void onPreferenceChange_check_shouldUpdateSettingsGlobal() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mController.onPreferenceChange(mPreference, true);
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
.isEqualTo(GUP_ALL_APPS);
assertThat(Settings.Global.getInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
.isEqualTo(GAME_DRIVER_ALL_APPS);
}
@Test
public void onPreferenceChange_uncheck_shouldUpdateSettingsGlobal() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_ALL_APPS);
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_ALL_APPS);
mController.onPreferenceChange(mPreference, false);
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
.isEqualTo(GUP_DEFAULT);
assertThat(Settings.Global.getInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
.isEqualTo(GAME_DRIVER_DEFAULT);
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.android.settings.development.gup;
package com.android.settings.development.gamedriver;
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
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.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
@@ -45,6 +45,7 @@ import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class GameDriverFooterPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
@Mock
@@ -67,21 +68,23 @@ public class GameDriverFooterPreferenceControllerTest {
@Test
public void getAvailabilityStatus_gameDriverOff_availableUnsearchable() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
}
@Test
public void getAvailabilityStatus_gameDriverDefault_conditionallyUnavailable() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}
@Test
public void getAvailabilityStatus_gameDriverAllApps_conditionallyUnavailable() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_ALL_APPS);
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_ALL_APPS);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}

View File

@@ -14,10 +14,10 @@
* limitations under the License.
*/
package com.android.settings.development.gup;
package com.android.settings.development.gamedriver;
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.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
@@ -39,7 +39,8 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class GupGlobalSwitchBarControllerTest {
public class GameDriverGlobalSwitchBarControllerTest {
@Mock
private SwitchBar mSwitchBar;
@Mock
@@ -49,7 +50,7 @@ public class GupGlobalSwitchBarControllerTest {
private Context mContext;
private ContentResolver mResolver;
private GupGlobalSwitchBarController mController;
private GameDriverGlobalSwitchBarController mController;
@Before
public void setUp() {
@@ -59,19 +60,20 @@ public class GupGlobalSwitchBarControllerTest {
}
@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));
public void constructor_gameDriverOn_shouldCheckSwitchBar() {
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mController = new GameDriverGlobalSwitchBarController(
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));
public void constructor_gameDriverOff_shouldUncheckSwitchBar() {
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
mController = new GameDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setChecked(false);
}
@@ -79,8 +81,8 @@ public class GupGlobalSwitchBarControllerTest {
@Test
public void constructor_developmentSettingsEnabled_shouldEnableSwitchBar() {
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
mController =
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
mController = new GameDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setEnabled(true);
}
@@ -88,16 +90,16 @@ public class GupGlobalSwitchBarControllerTest {
@Test
public void constructor_developmentSettingsDisabled_shouldDisableSwitchBar() {
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
mController =
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
mController = new GameDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setEnabled(false);
}
@Test
public void onStart_shouldStartListeningAndRegister() {
mController =
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
mController = new GameDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
mController.mSwitchWidgetController = mSwitchWidgetController;
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.onStart();
@@ -108,8 +110,8 @@ public class GupGlobalSwitchBarControllerTest {
@Test
public void onStop_shouldStopListeningAndUnregister() {
mController =
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
mController = new GameDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
mController.mSwitchWidgetController = mSwitchWidgetController;
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.onStop();
@@ -119,24 +121,27 @@ public class GupGlobalSwitchBarControllerTest {
}
@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));
public void onSwitchToggled_checked_shouldTurnOnGameDriver() {
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
mController = new GameDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
mController.onSwitchToggled(true);
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
.isEqualTo(GUP_DEFAULT);
assertThat(Settings.Global.getInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
.isEqualTo(GAME_DRIVER_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));
public void onSwitchToggled_unchecked_shouldTurnOffGameDriver() {
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mController = new GameDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
mController.onSwitchToggled(false);
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
.isEqualTo(GUP_OFF);
assertThat(Settings.Global.getInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
.isEqualTo(GAME_DRIVER_OFF);
}
}