Merge "Allow ANGLE developer option toggle UI enabled if ANGLE is enabled." into main

This commit is contained in:
Peiyong Lin
2023-10-13 04:57:32 +00:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 3 deletions

View File

@@ -24,6 +24,8 @@ import static com.android.settings.development.graphicsdriver.GraphicsDriverEnab
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
@@ -472,4 +474,27 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
SystemProperties.removeChangeCallback(propertyChangeSignal1.getCountDownJob());
SystemProperties.removeChangeCallback(propertyChangeSignal2.getCountDownJob());
}
@Test
public void updateState_DeveloperOptionPropertyIsFalse() {
// Test that when debug.graphics.angle.developeroption.enable is false:
when(mSystemPropertiesMock.getBoolean(eq(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION),
anyBoolean())).thenReturn(false);
when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
.thenReturn("true");
// 1. "Enable ANGLE" switch is on, the switch should be enabled.
when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any()))
.thenReturn(ANGLE_DRIVER_SUFFIX);
mController.updateState(mPreference);
assertTrue(mPreference.isChecked());
assertTrue(mPreference.isEnabled());
// 2. "Enable ANGLE" switch is off, the switch should be disabled.
when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any()))
.thenReturn("");
mController.updateState(mPreference);
assertFalse(mPreference.isChecked());
assertFalse(mPreference.isEnabled());
}
}