Refactoring DoubleTwistPreferenceController.
Made the availability and setting logic static so that it can be invoked without creating a controller. Bug: 62022517 Test: robotests Change-Id: I3a51c61849e6ba8b8aa850ca22d666a9f84d252f
This commit is contained in:
@@ -41,11 +41,12 @@ import java.util.List;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.android.settings.testutils.shadow.ShadowDoubleTwistPreferenceController;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class DoubleTwistPreferenceControllerTest {
|
||||
@@ -102,14 +103,16 @@ public class DoubleTwistPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowSecureSettings.class})
|
||||
@Config(shadows = {
|
||||
ShadowDoubleTwistPreferenceController.class,
|
||||
ShadowSecureSettings.class})
|
||||
public void onPreferenceChange_hasWorkProfile_shouldUpdateSettingForWorkProfileUser() {
|
||||
final int managedId = 2;
|
||||
ShadowSecureSettings.putIntForUser(
|
||||
null, Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 0, managedId);
|
||||
DoubleTwistPreferenceController controller =
|
||||
spy(new DoubleTwistPreferenceController(mContext, null, KEY_DOUBLE_TWIST));
|
||||
doReturn(managedId).when(controller).getManagedProfileUserId();
|
||||
ShadowDoubleTwistPreferenceController.setManagedProfileId(managedId);
|
||||
|
||||
// enable the gesture
|
||||
controller.onPreferenceChange(null, true);
|
||||
|
Reference in New Issue
Block a user