Rename GameDriver* to GraphicsDriver*.

To make graphics driver selection more generic, rename GameDriver
specific classes to GraphicsDriver.

Bug: b/148626177
Test: make RunSettingsRoboTests ROBOTEST_FILTER=GraphicsDriver
Change-Id: If2780b32e2826bda56de11734736260f916182d0
This commit is contained in:
Peiyong Lin
2020-02-11 11:03:13 -08:00
parent 9368270fe2
commit 4e89f929d7
14 changed files with 162 additions and 152 deletions

View File

@@ -14,12 +14,12 @@
* limitations under the License.
*/
package com.android.settings.development.gamedriver;
package com.android.settings.development.graphicsdriver;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
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.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
import static com.google.common.truth.Truth.assertThat;
@@ -53,7 +53,7 @@ import org.robolectric.RuntimeEnvironment;
import java.util.Arrays;
@RunWith(RobolectricTestRunner.class)
public class GameDriverAppPreferenceControllerTest {
public class GraphicsDriverAppPreferenceControllerTest {
private static final int DEFAULT = 0;
private static final int GAME_DRIVER = 1;
@@ -71,13 +71,13 @@ public class GameDriverAppPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
@Mock
private GameDriverContentObserver mGameDriverContentObserver;
private GraphicsDriverContentObserver mGraphicsDriverContentObserver;
private Context mContext;
private PreferenceGroup mGroup;
private PreferenceManager mPreferenceManager;
private ContentResolver mResolver;
private GameDriverAppPreferenceController mController;
private GraphicsDriverAppPreferenceController mController;
private CharSequence[] mValueList;
private String mDialogTitle;
private String mPreferencePrereleaseDriver;
@@ -137,19 +137,19 @@ public class GameDriverAppPreferenceControllerTest {
@Test
public void onStart_shouldRegister() {
loadDefaultConfig();
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.mGraphicsDriverContentObserver = mGraphicsDriverContentObserver;
mController.onStart();
verify(mGameDriverContentObserver).register(mResolver);
verify(mGraphicsDriverContentObserver).register(mResolver);
}
@Test
public void onStop_shouldUnregister() {
loadDefaultConfig();
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.mGraphicsDriverContentObserver = mGraphicsDriverContentObserver;
mController.onStop();
verify(mGameDriverContentObserver).unregister(mResolver);
verify(mGraphicsDriverContentObserver).unregister(mResolver);
}
@Test
@@ -295,7 +295,9 @@ public class GameDriverAppPreferenceControllerTest {
when(mContext.getPackageManager()).thenReturn(mPackageManager);
}
private void loadDefaultConfig() { loadConfig("", "", ""); }
private void loadDefaultConfig() {
loadConfig("", "", "");
}
private void loadConfig(String optIn, String prereleaseOptIn, String optOut) {
Settings.Global.putString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS, optIn);
@@ -303,7 +305,7 @@ public class GameDriverAppPreferenceControllerTest {
mResolver, Settings.Global.GAME_DRIVER_PRERELEASE_OPT_IN_APPS, prereleaseOptIn);
Settings.Global.putString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS, optOut);
mController = new GameDriverAppPreferenceController(mContext, "testKey");
mController = new GraphicsDriverAppPreferenceController(mContext, "testKey");
mGroup = spy(new PreferenceCategory(mContext));
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
when(mGroup.getContext()).thenReturn(mContext);

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.settings.development.gamedriver;
package com.android.settings.development.graphicsdriver;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -28,45 +28,44 @@ 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 {
public class GraphicsDriverContentObserverTest {
@Mock
private ContentResolver mResolver;
@Mock
private GameDriverContentObserver.OnGameDriverContentChangedListener mListener;
private GraphicsDriverContentObserver.OnGraphicsDriverContentChangedListener mListener;
private GameDriverContentObserver mGameDriverContentObserver;
private GraphicsDriverContentObserver mGraphicsDriverContentObserver;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mGameDriverContentObserver = spy(new GameDriverContentObserver(null, null));
mGraphicsDriverContentObserver = spy(new GraphicsDriverContentObserver(null, null));
}
@Test
public void onChange_shouldCallListener() {
mGameDriverContentObserver.mListener = mListener;
mGameDriverContentObserver.onChange(true);
mGraphicsDriverContentObserver.mListener = mListener;
mGraphicsDriverContentObserver.onChange(true);
verify(mListener).onGameDriverContentChanged();
verify(mListener).onGraphicsDriverContentChanged();
}
@Test
public void register_shouldRegisterContentObserver() {
mGameDriverContentObserver.register(mResolver);
mGraphicsDriverContentObserver.register(mResolver);
verify(mResolver).registerContentObserver(
Settings.Global.getUriFor(Settings.Global.GAME_DRIVER_ALL_APPS), false,
mGameDriverContentObserver);
mGraphicsDriverContentObserver);
}
@Test
public void unregister_shouldUnregisterContentObserver() {
mGameDriverContentObserver.unregister(mResolver);
mGraphicsDriverContentObserver.unregister(mResolver);
verify(mResolver).unregisterContentObserver(mGameDriverContentObserver);
verify(mResolver).unregisterContentObserver(mGraphicsDriverContentObserver);
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.settings.development.gamedriver;
package com.android.settings.development.graphicsdriver;
import static com.google.common.truth.Truth.assertThat;
@@ -28,13 +28,13 @@ import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class GameDriverDashboardTest {
public class GraphicsDriverDashboardTest {
private GameDriverDashboard mDashboard;
private GraphicsDriverDashboard mDashboard;
@Before
public void setUp() {
mDashboard = new GameDriverDashboard();
mDashboard = new GraphicsDriverDashboard();
}
@Test
@@ -43,13 +43,13 @@ public class GameDriverDashboardTest {
}
@Test
public void getMetricesCategory_shouldReturnGameDriverDashboard() {
public void getMetricesCategory_shouldReturnGraphicsDriverDashboard() {
assertThat(mDashboard.getMetricsCategory())
.isEqualTo(SettingsEnums.SETTINGS_GAME_DRIVER_DASHBOARD);
}
@Test
public void getPreferenceScreen_shouldReturnGameDriverSettings() {
public void getPreferenceScreen_shouldReturnGraphicsDriverSettings() {
assertThat(mDashboard.getPreferenceScreenResId()).isEqualTo(R.xml.graphics_driver_settings);
}
}

View File

@@ -14,14 +14,14 @@
* limitations under the License.
*/
package com.android.settings.development.gamedriver;
package com.android.settings.development.graphicsdriver;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
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.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_PRERELEASE_ALL_APPS;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_PRERELEASE_ALL_APPS;
import static com.google.common.truth.Truth.assertThat;
@@ -48,18 +48,18 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class GameDriverEnableForAllAppsPreferenceControllerTest {
public class GraphicsDriverEnableForAllAppsPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
@Mock
private ListPreference mPreference;
@Mock
private GameDriverContentObserver mGameDriverContentObserver;
private GraphicsDriverContentObserver mGraphicsDriverContentObserver;
private Context mContext;
private ContentResolver mResolver;
private GameDriverEnableForAllAppsPreferenceController mController;
private GraphicsDriverEnableForAllAppsPreferenceController mController;
private String mPreferenceDefault;
private String mPreferenceGameDriver;
private String mPreferencePrereleaseDriver;
@@ -81,7 +81,7 @@ public class GameDriverEnableForAllAppsPreferenceControllerTest {
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mController = new GameDriverEnableForAllAppsPreferenceController(mContext, "testKey");
mController = new GraphicsDriverEnableForAllAppsPreferenceController(mContext, "testKey");
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
}
@@ -120,18 +120,18 @@ public class GameDriverEnableForAllAppsPreferenceControllerTest {
@Test
public void onStart_shouldRegister() {
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.mGraphicsDriverContentObserver = mGraphicsDriverContentObserver;
mController.onStart();
verify(mGameDriverContentObserver).register(mResolver);
verify(mGraphicsDriverContentObserver).register(mResolver);
}
@Test
public void onStop_shouldUnregister() {
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.mGraphicsDriverContentObserver = mGraphicsDriverContentObserver;
mController.onStop();
verify(mGameDriverContentObserver).unregister(mResolver);
verify(mGraphicsDriverContentObserver).unregister(mResolver);
}
@Test

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.android.settings.development.gamedriver;
package com.android.settings.development.graphicsdriver;
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
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.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.google.common.truth.Truth.assertThat;
@@ -45,25 +45,25 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class GameDriverFooterPreferenceControllerTest {
public class GraphicsDriverFooterPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
@Mock
private FooterPreference mPreference;
@Mock
private GameDriverContentObserver mGameDriverContentObserver;
private GraphicsDriverContentObserver mGraphicsDriverContentObserver;
private Context mContext;
private ContentResolver mResolver;
private GameDriverFooterPreferenceController mController;
private GraphicsDriverFooterPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mResolver = mContext.getContentResolver();
mController = spy(new GameDriverFooterPreferenceController(mContext, "key"));
mController = spy(new GraphicsDriverFooterPreferenceController(mContext, "key"));
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
@@ -92,17 +92,17 @@ public class GameDriverFooterPreferenceControllerTest {
@Test
public void onStart_shouldRegister() {
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.mGraphicsDriverContentObserver = mGraphicsDriverContentObserver;
mController.onStart();
verify(mGameDriverContentObserver).register(mResolver);
verify(mGraphicsDriverContentObserver).register(mResolver);
}
@Test
public void onStop_shouldUnregister() {
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.mGraphicsDriverContentObserver = mGraphicsDriverContentObserver;
mController.onStop();
verify(mGameDriverContentObserver).unregister(mResolver);
verify(mGraphicsDriverContentObserver).unregister(mResolver);
}
}

View File

@@ -14,10 +14,11 @@
* limitations under the License.
*/
package com.android.settings.development.gamedriver;
package com.android.settings.development.graphicsdriver;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_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,18 +40,18 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class GameDriverGlobalSwitchBarControllerTest {
public class GraphicsDriverGlobalSwitchBarControllerTest {
@Mock
private SwitchBar mSwitchBar;
@Mock
private SwitchWidgetController mSwitchWidgetController;
@Mock
private GameDriverContentObserver mGameDriverContentObserver;
private GraphicsDriverContentObserver mGraphicsDriverContentObserver;
private Context mContext;
private ContentResolver mResolver;
private GameDriverGlobalSwitchBarController mController;
private GraphicsDriverGlobalSwitchBarController mController;
@Before
public void setUp() {
@@ -63,7 +64,7 @@ public class GameDriverGlobalSwitchBarControllerTest {
public void constructor_gameDriverOn_shouldCheckSwitchBar() {
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mController = new GameDriverGlobalSwitchBarController(
mController = new GraphicsDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setChecked(true);
@@ -72,7 +73,7 @@ public class GameDriverGlobalSwitchBarControllerTest {
@Test
public void constructor_gameDriverOff_shouldUncheckSwitchBar() {
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
mController = new GameDriverGlobalSwitchBarController(
mController = new GraphicsDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setChecked(false);
@@ -81,7 +82,7 @@ public class GameDriverGlobalSwitchBarControllerTest {
@Test
public void constructor_developmentSettingsEnabled_shouldEnableSwitchBar() {
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
mController = new GameDriverGlobalSwitchBarController(
mController = new GraphicsDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setEnabled(true);
@@ -90,7 +91,7 @@ public class GameDriverGlobalSwitchBarControllerTest {
@Test
public void constructor_developmentSettingsDisabled_shouldDisableSwitchBar() {
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
mController = new GameDriverGlobalSwitchBarController(
mController = new GraphicsDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setEnabled(false);
@@ -98,32 +99,32 @@ public class GameDriverGlobalSwitchBarControllerTest {
@Test
public void onStart_shouldStartListeningAndRegister() {
mController = new GameDriverGlobalSwitchBarController(
mController = new GraphicsDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
mController.mSwitchWidgetController = mSwitchWidgetController;
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.mGraphicsDriverContentObserver = mGraphicsDriverContentObserver;
mController.onStart();
verify(mSwitchWidgetController).startListening();
verify(mGameDriverContentObserver).register(mResolver);
verify(mGraphicsDriverContentObserver).register(mResolver);
}
@Test
public void onStop_shouldStopListeningAndUnregister() {
mController = new GameDriverGlobalSwitchBarController(
mController = new GraphicsDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
mController.mSwitchWidgetController = mSwitchWidgetController;
mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.mGraphicsDriverContentObserver = mGraphicsDriverContentObserver;
mController.onStop();
verify(mSwitchWidgetController).stopListening();
verify(mGameDriverContentObserver).unregister(mResolver);
verify(mGraphicsDriverContentObserver).unregister(mResolver);
}
@Test
public void onSwitchToggled_checked_shouldTurnOnGameDriver() {
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
mController = new GameDriverGlobalSwitchBarController(
mController = new GraphicsDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
mController.onSwitchToggled(true);
@@ -136,7 +137,7 @@ public class GameDriverGlobalSwitchBarControllerTest {
public void onSwitchToggled_unchecked_shouldTurnOffGameDriver() {
Settings.Global.putInt(
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mController = new GameDriverGlobalSwitchBarController(
mController = new GraphicsDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
mController.onSwitchToggled(false);