Merge "Avoid media transcode can be bypass guard of developer options"
This commit is contained in:
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@@ -36,11 +37,14 @@ public class TranscodeDefaultOptionPreferenceControllerTest {
|
||||
"persist.sys.fuse.transcode_default";
|
||||
|
||||
private TranscodeDefaultOptionPreferenceController mUnderTest;
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
mUnderTest = new TranscodeDefaultOptionPreferenceController(context, "some_key");
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mUnderTest = new TranscodeDefaultOptionPreferenceController(mContext, "some_key");
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,4 +78,12 @@ public class TranscodeDefaultOptionPreferenceControllerTest {
|
||||
assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_developerOptionFalse_shouldReturnUNAVAILABLE() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@@ -36,11 +37,14 @@ import org.junit.runner.RunWith;
|
||||
public class TranscodeDisableCachePreferenceControllerTest {
|
||||
|
||||
private TranscodeDisableCachePreferenceController mUnderTest;
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
mUnderTest = new TranscodeDisableCachePreferenceController(context, "some_key");
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mUnderTest = new TranscodeDisableCachePreferenceController(mContext, "some_key");
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,4 +78,12 @@ public class TranscodeDisableCachePreferenceControllerTest {
|
||||
assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_developerOptionFalse_shouldReturnUNAVAILABLE() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
@@ -20,10 +20,13 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -34,11 +37,14 @@ public class TranscodeGlobalTogglePreferenceControllerTest {
|
||||
private static final String TRANSCODE_ENABLED_PROP_KEY = "persist.sys.fuse.transcode_enabled";
|
||||
|
||||
private TranscodeGlobalTogglePreferenceController mController;
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
mController = new TranscodeGlobalTogglePreferenceController(context, "test_key");
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mController = new TranscodeGlobalTogglePreferenceController(mContext, "test_key");
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,4 +81,12 @@ public class TranscodeGlobalTogglePreferenceControllerTest {
|
||||
// Verify the system property was updated.
|
||||
assertThat(SystemProperties.getBoolean(TRANSCODE_ENABLED_PROP_KEY, true)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_developerOptionFalse_shouldReturnUNAVAILABLE() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@@ -36,10 +37,14 @@ import org.junit.runner.RunWith;
|
||||
public class TranscodeNotificationPreferenceControllerTest {
|
||||
private TranscodeNotificationPreferenceController mUnderTest;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
mUnderTest = new TranscodeNotificationPreferenceController(context, "notification_key");
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mUnderTest = new TranscodeNotificationPreferenceController(mContext, "notification_key");
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,4 +78,12 @@ public class TranscodeNotificationPreferenceControllerTest {
|
||||
assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_developerOptionFalse_shouldReturnUNAVAILABLE() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@@ -36,11 +37,14 @@ public class TranscodeUserControlPreferenceControllerTest {
|
||||
"persist.sys.fuse.transcode_user_control";
|
||||
|
||||
private TranscodeUserControlPreferenceController mUnderTest;
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
mUnderTest = new TranscodeUserControlPreferenceController(context, "some_key");
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mUnderTest = new TranscodeUserControlPreferenceController(mContext, "some_key");
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,4 +78,12 @@ public class TranscodeUserControlPreferenceControllerTest {
|
||||
assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_developerOptionFalse_shouldReturnUNAVAILABLE() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user