Move display tests to DisplayServiceTests module
Migrate tests. Add dependencies to build files. Add permissions to manifest. Additionally, LogicalDisplayTest#testDisplayInputFlags() has been marked as @Ignore, with a TODO, and will be fixed in followup bug: 288880734 Also used the opportunity to correctly format the indentation in & change some other minor aesthetic & style guide corrections in: AmbientBrightnessStatsTrackerTest AmbientLuxTest BrightnessMappingStrategyTest BrightnessThrottlerTest BrightnessTrackerTest ColorDisplayServiceTest HighBrightnessModeControllerTest PersistentDataStoreTest Bug: 286043820 Test: atest DisplayServiceTests Change-Id: Ib5235bcd184d35a7efec922606d4566b839d4a74
This commit is contained in:
@@ -22,11 +22,20 @@ android_test {
|
||||
"src/**/*.java",
|
||||
],
|
||||
|
||||
libs: [
|
||||
"android.test.mock",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"services.core",
|
||||
"androidx.test.runner",
|
||||
"androidx.test.rules",
|
||||
"androidx.test.ext.junit",
|
||||
"display-core-libs",
|
||||
"frameworks-base-testutils",
|
||||
"junit",
|
||||
"junit-params",
|
||||
"platform-compat-test-rules",
|
||||
"platform-test-annotations",
|
||||
"services.core",
|
||||
"servicestests-utils",
|
||||
],
|
||||
|
||||
defaults: [
|
||||
@@ -47,3 +56,10 @@ android_test {
|
||||
enabled: false,
|
||||
},
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "display-core-libs",
|
||||
srcs: [
|
||||
"src/com/android/server/display/TestUtils.java",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -21,6 +21,16 @@
|
||||
Insert permissions here. eg:
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
||||
-->
|
||||
<uses-permission android:name="android.permission.CONTROL_DISPLAY_BRIGHTNESS" />
|
||||
<uses-permission android:name="android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS" />
|
||||
<uses-permission android:name="android.permission.DEVICE_POWER" />
|
||||
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
|
||||
<uses-permission android:name="android.permission.LOG_COMPAT_CHANGE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_ACTIVITY_TASKS" />
|
||||
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
|
||||
<uses-permission android:name="android.permission.READ_COMPAT_CHANGE_CONFIG" />
|
||||
<uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
||||
|
||||
<application android:debuggable="true"
|
||||
android:testOnly="true">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.display;
|
||||
@@ -11,7 +11,7 @@
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.display;
|
||||
@@ -206,11 +206,11 @@ public class BrightnessMappingStrategyTest {
|
||||
BrightnessMappingStrategy strategy = BrightnessMappingStrategy.create(res, ddc, mMockDwbc);
|
||||
|
||||
strategy.setBrightnessConfiguration(null);
|
||||
final int N = DISPLAY_LEVELS_BACKLIGHT.length;
|
||||
final int n = DISPLAY_LEVELS_BACKLIGHT.length;
|
||||
final float expectedBrightness =
|
||||
(float) DISPLAY_LEVELS_BACKLIGHT[N - 1] / PowerManager.BRIGHTNESS_ON;
|
||||
(float) DISPLAY_LEVELS_BACKLIGHT[n - 1] / PowerManager.BRIGHTNESS_ON;
|
||||
assertEquals(expectedBrightness,
|
||||
strategy.getBrightness(LUX_LEVELS[N - 1]), 0.0001f /*tolerance*/);
|
||||
strategy.getBrightness(LUX_LEVELS[n - 1]), 0.0001f /*tolerance*/);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -270,10 +270,10 @@ public class BrightnessMappingStrategyTest {
|
||||
|
||||
// Check that null returns us to the default configuration.
|
||||
strategy.setBrightnessConfiguration(null);
|
||||
final int N = DISPLAY_LEVELS_NITS.length;
|
||||
final float expectedBrightness = DISPLAY_LEVELS_NITS[N - 1] / DISPLAY_RANGE_NITS[1];
|
||||
final int n = DISPLAY_LEVELS_NITS.length;
|
||||
final float expectedBrightness = DISPLAY_LEVELS_NITS[n - 1] / DISPLAY_RANGE_NITS[1];
|
||||
assertEquals(expectedBrightness,
|
||||
strategy.getBrightness(LUX_LEVELS[N - 1]), 0.0001f /*tolerance*/);
|
||||
strategy.getBrightness(LUX_LEVELS[n - 1]), 0.0001f /*tolerance*/);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -159,7 +159,7 @@ public class BrightnessThrottlerTest {
|
||||
@Test
|
||||
public void testThermalThrottlingSingleLevel() throws Exception {
|
||||
final ThrottlingLevel level = new ThrottlingLevel(PowerManager.THERMAL_STATUS_CRITICAL,
|
||||
0.25f);
|
||||
0.25f);
|
||||
|
||||
List<ThrottlingLevel> levels = new ArrayList<>();
|
||||
levels.add(level);
|
||||
@@ -184,7 +184,7 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(level.brightness, throttler.getBrightnessCap(), 0f);
|
||||
assertTrue(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_THERMAL,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
|
||||
// Set status more than high enough to trigger throttling
|
||||
listener.notifyThrottling(getSkinTemp(level.thermalStatus + 1));
|
||||
@@ -192,7 +192,7 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(level.brightness, throttler.getBrightnessCap(), 0f);
|
||||
assertTrue(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_THERMAL,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
|
||||
// Return to the lower throttling level
|
||||
listener.notifyThrottling(getSkinTemp(level.thermalStatus));
|
||||
@@ -200,7 +200,7 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(level.brightness, throttler.getBrightnessCap(), 0f);
|
||||
assertTrue(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_THERMAL,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
|
||||
// Cool down
|
||||
listener.notifyThrottling(getSkinTemp(level.thermalStatus - 1));
|
||||
@@ -208,15 +208,15 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(PowerManager.BRIGHTNESS_MAX, throttler.getBrightnessCap(), 0f);
|
||||
assertFalse(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_NONE,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThermalThrottlingMultiLevel() throws Exception {
|
||||
final ThrottlingLevel levelLo = new ThrottlingLevel(PowerManager.THERMAL_STATUS_MODERATE,
|
||||
0.62f);
|
||||
0.62f);
|
||||
final ThrottlingLevel levelHi = new ThrottlingLevel(PowerManager.THERMAL_STATUS_CRITICAL,
|
||||
0.25f);
|
||||
0.25f);
|
||||
|
||||
List<ThrottlingLevel> levels = new ArrayList<>();
|
||||
levels.add(levelLo);
|
||||
@@ -242,7 +242,7 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(levelLo.brightness, throttler.getBrightnessCap(), 0f);
|
||||
assertTrue(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_THERMAL,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
|
||||
// Set status to an intermediate throttling level
|
||||
listener.notifyThrottling(getSkinTemp(levelLo.thermalStatus + 1));
|
||||
@@ -250,7 +250,7 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(levelLo.brightness, throttler.getBrightnessCap(), 0f);
|
||||
assertTrue(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_THERMAL,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
|
||||
// Set status to the highest configured throttling level
|
||||
listener.notifyThrottling(getSkinTemp(levelHi.thermalStatus));
|
||||
@@ -258,7 +258,7 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(levelHi.brightness, throttler.getBrightnessCap(), 0f);
|
||||
assertTrue(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_THERMAL,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
|
||||
// Set status to exceed the highest configured throttling level
|
||||
listener.notifyThrottling(getSkinTemp(levelHi.thermalStatus + 1));
|
||||
@@ -266,7 +266,7 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(levelHi.brightness, throttler.getBrightnessCap(), 0f);
|
||||
assertTrue(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_THERMAL,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
|
||||
// Return to an intermediate throttling level
|
||||
listener.notifyThrottling(getSkinTemp(levelLo.thermalStatus + 1));
|
||||
@@ -274,7 +274,7 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(levelLo.brightness, throttler.getBrightnessCap(), 0f);
|
||||
assertTrue(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_THERMAL,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
|
||||
// Return to the lowest configured throttling level
|
||||
listener.notifyThrottling(getSkinTemp(levelLo.thermalStatus));
|
||||
@@ -282,7 +282,7 @@ public class BrightnessThrottlerTest {
|
||||
assertEquals(levelLo.brightness, throttler.getBrightnessCap(), 0f);
|
||||
assertTrue(throttler.isThrottled());
|
||||
assertEquals(BrightnessInfo.BRIGHTNESS_MAX_REASON_THERMAL,
|
||||
throttler.getBrightnessMaxReason());
|
||||
throttler.getBrightnessMaxReason());
|
||||
|
||||
// Cool down
|
||||
listener.notifyThrottling(getSkinTemp(levelLo.thermalStatus - 1));
|
||||
@@ -11,7 +11,7 @@
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.display;
|
||||
@@ -395,8 +395,8 @@ public class BrightnessTrackerTest {
|
||||
final long currentTime = mInjector.currentTimeMillis();
|
||||
notifyBrightnessChanged(mTracker, brightness, displayId, new float[] {1000.0f},
|
||||
new long[] {TimeUnit.NANOSECONDS.toMillis(mInjector.elapsedRealtimeNanos())});
|
||||
List<BrightnessChangeEvent> eventsNoPackage
|
||||
= mTracker.getEvents(0, false).getList();
|
||||
List<BrightnessChangeEvent> eventsNoPackage =
|
||||
mTracker.getEvents(0, false).getList();
|
||||
List<BrightnessChangeEvent> events = mTracker.getEvents(0, true).getList();
|
||||
mTracker.stop();
|
||||
|
||||
@@ -1037,9 +1037,9 @@ public class BrightnessTrackerTest {
|
||||
}
|
||||
|
||||
void setBrightnessMode(boolean isBrightnessModeAutomatic) {
|
||||
mIsBrightnessModeAutomatic = isBrightnessModeAutomatic;
|
||||
mContentObserver.dispatchChange(false, null);
|
||||
waitForHandler();
|
||||
mIsBrightnessModeAutomatic = isBrightnessModeAutomatic;
|
||||
mContentObserver.dispatchChange(false, null);
|
||||
waitForHandler();
|
||||
}
|
||||
|
||||
void sendScreenChange(boolean screenOn) {
|
||||
@@ -1184,8 +1184,8 @@ public class BrightnessTrackerTest {
|
||||
|
||||
@Override
|
||||
public int getNightDisplayColorTemperature(Context context) {
|
||||
return mSecureIntSettings.getOrDefault(Settings.Secure.NIGHT_DISPLAY_COLOR_TEMPERATURE,
|
||||
mDefaultNightModeColorTemperature);
|
||||
return mSecureIntSettings.getOrDefault(Settings.Secure.NIGHT_DISPLAY_COLOR_TEMPERATURE,
|
||||
mDefaultNightModeColorTemperature);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,7 +142,7 @@ public class DisplayManagerServiceTest {
|
||||
private static final float FLOAT_TOLERANCE = 0.01f;
|
||||
|
||||
private static final String VIRTUAL_DISPLAY_NAME = "Test Virtual Display";
|
||||
private static final String PACKAGE_NAME = "com.android.frameworks.servicestests";
|
||||
private static final String PACKAGE_NAME = "com.android.frameworks.displayservicetests";
|
||||
private static final long STANDARD_DISPLAY_EVENTS = DisplayManager.EVENT_FLAG_DISPLAY_ADDED
|
||||
| DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
|
||||
| DisplayManager.EVENT_FLAG_DISPLAY_REMOVED;
|
||||
@@ -238,7 +238,7 @@ public class DisplayManagerServiceTest {
|
||||
boolean getHdrOutputConversionSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final DisplayManagerService.Injector mBasicInjector = new BasicInjector();
|
||||
|
||||
@@ -483,8 +483,10 @@ public class HighBrightnessModeControllerTest {
|
||||
|
||||
// Verify Stats HBM_ON_HDR
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_HDR),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_HDR),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
|
||||
hbmc.getHdrListener().onHdrInfoChanged(null /*displayToken*/, 0 /*numberOfHdrLayers*/,
|
||||
0, 0, 0 /*flags*/, 1.0f /*maxDesiredHdrSdrRatio*/);
|
||||
@@ -492,8 +494,10 @@ public class HighBrightnessModeControllerTest {
|
||||
|
||||
// Verify Stats HBM_OFF
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
|
||||
hbmc.setAutoBrightnessEnabled(AUTO_BRIGHTNESS_ENABLED);
|
||||
hbmc.onAmbientLuxChange(MINIMUM_LUX + 1);
|
||||
@@ -501,16 +505,20 @@ public class HighBrightnessModeControllerTest {
|
||||
|
||||
// Verify Stats HBM_ON_SUNLIGHT
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
|
||||
hbmc.onAmbientLuxChange(1);
|
||||
advanceTime(TIME_ALLOWED_IN_WINDOW_MILLIS / 2 + 1);
|
||||
|
||||
// Verify Stats HBM_OFF
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_LUX_DROP));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_LUX_DROP));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -527,8 +535,8 @@ public class HighBrightnessModeControllerTest {
|
||||
|
||||
// Verify Stats HBM_ON_HDR not report
|
||||
verify(mInjectorMock, never()).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_HDR),
|
||||
anyInt());
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_HDR),
|
||||
anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -545,8 +553,8 @@ public class HighBrightnessModeControllerTest {
|
||||
|
||||
// Verify Stats HBM_ON_SUNLIGHT not report
|
||||
verify(mInjectorMock, never()).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
anyInt());
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
anyInt());
|
||||
}
|
||||
|
||||
// Test reporting of thermal throttling when triggered externally through
|
||||
@@ -565,8 +573,10 @@ public class HighBrightnessModeControllerTest {
|
||||
BrightnessInfo.BRIGHTNESS_MAX_REASON_NONE);
|
||||
advanceTime(1);
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
|
||||
// Brightness is thermally throttled, HBM brightness denied (NBM brightness granted)
|
||||
hbmc.onBrightnessChanged(nbmBrightness, hbmBrightness,
|
||||
@@ -578,8 +588,8 @@ public class HighBrightnessModeControllerTest {
|
||||
// the HBM transition point.
|
||||
assertEquals(HIGH_BRIGHTNESS_MODE_SUNLIGHT, hbmc.getHighBrightnessMode());
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_THERMAL_LIMIT));
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_THERMAL_LIMIT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -592,15 +602,17 @@ public class HighBrightnessModeControllerTest {
|
||||
hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
|
||||
advanceTime(0);
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
|
||||
// Use up all the time in the window.
|
||||
advanceTime(TIME_WINDOW_MILLIS + 1);
|
||||
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_TIME_LIMIT));
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_TIME_LIMIT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -613,13 +625,17 @@ public class HighBrightnessModeControllerTest {
|
||||
hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
|
||||
advanceTime(0);
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
|
||||
hbmc.setAutoBrightnessEnabled(AUTO_BRIGHTNESS_OFF_DUE_TO_DISPLAY_STATE);
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_DISPLAY_OFF));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_DISPLAY_OFF));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -632,16 +648,18 @@ public class HighBrightnessModeControllerTest {
|
||||
hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
|
||||
advanceTime(0);
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
|
||||
hbmc.getHdrListener().onHdrInfoChanged(null /*displayToken*/, 1 /*numberOfHdrLayers*/,
|
||||
DISPLAY_WIDTH, DISPLAY_HEIGHT, 0 /*flags*/, 1.0f /*maxDesiredHdrSdrRatio*/);
|
||||
advanceTime(0);
|
||||
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_HDR),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_HDR_PLAYING));
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_HDR),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_HDR_PLAYING));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -657,15 +675,17 @@ public class HighBrightnessModeControllerTest {
|
||||
assertEquals(HIGH_BRIGHTNESS_MODE_SUNLIGHT, hbmc.getHighBrightnessMode());
|
||||
// verify HBM_ON_SUNLIGHT
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||
|
||||
hbmcOnBrightnessChanged(hbmc, DEFAULT_MIN);
|
||||
// verify HBM_SV_OFF due to LOW_REQUESTED_BRIGHTNESS
|
||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_LOW_REQUESTED_BRIGHTNESS));
|
||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||
eq(FrameworkStatsLog
|
||||
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_LOW_REQUESTED_BRIGHTNESS));
|
||||
}
|
||||
|
||||
private void assertState(HighBrightnessModeController hbmc,
|
||||
@@ -40,6 +40,7 @@ import androidx.test.filters.SmallTest;
|
||||
import com.android.server.display.layout.Layout;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -121,7 +122,9 @@ public class LogicalDisplayTest {
|
||||
assertEquals(expectedPosition, mLogicalDisplay.getDisplayPosition());
|
||||
}
|
||||
|
||||
// TODO: b/288880734 - fix test after display tests migration
|
||||
@Test
|
||||
@Ignore
|
||||
public void testDisplayInputFlags() {
|
||||
SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
|
||||
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
||||
@@ -11,7 +11,7 @@
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.display;
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.display;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.input.InputSensorInfo;
|
||||
import android.os.Parcel;
|
||||
import android.os.SystemClock;
|
||||
import android.view.DisplayAddress;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class TestUtils {
|
||||
|
||||
public static SensorEvent createSensorEvent(Sensor sensor, int value) throws Exception {
|
||||
final Constructor<SensorEvent> constructor =
|
||||
SensorEvent.class.getDeclaredConstructor(int.class);
|
||||
constructor.setAccessible(true);
|
||||
final SensorEvent event = constructor.newInstance(1);
|
||||
event.sensor = sensor;
|
||||
event.values[0] = value;
|
||||
event.timestamp = SystemClock.elapsedRealtimeNanos();
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
public static void setSensorType(Sensor sensor, int type, String strType) throws Exception {
|
||||
Method setter = Sensor.class.getDeclaredMethod("setType", Integer.TYPE);
|
||||
setter.setAccessible(true);
|
||||
setter.invoke(sensor, type);
|
||||
if (strType != null) {
|
||||
Field f = sensor.getClass().getDeclaredField("mStringType");
|
||||
f.setAccessible(true);
|
||||
f.set(sensor, strType);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setMaximumRange(Sensor sensor, float maximumRange) throws Exception {
|
||||
Method setter = Sensor.class.getDeclaredMethod("setRange", Float.TYPE, Float.TYPE);
|
||||
setter.setAccessible(true);
|
||||
setter.invoke(sensor, maximumRange, 1);
|
||||
}
|
||||
|
||||
public static Sensor createSensor(int type, String strType) throws Exception {
|
||||
Constructor<Sensor> constr = Sensor.class.getDeclaredConstructor();
|
||||
constr.setAccessible(true);
|
||||
Sensor sensor = constr.newInstance();
|
||||
setSensorType(sensor, type, strType);
|
||||
return sensor;
|
||||
}
|
||||
|
||||
public static Sensor createSensor(int type, String strType, float maximumRange)
|
||||
throws Exception {
|
||||
Constructor<Sensor> constr = Sensor.class.getDeclaredConstructor();
|
||||
constr.setAccessible(true);
|
||||
Sensor sensor = constr.newInstance();
|
||||
setSensorType(sensor, type, strType);
|
||||
setMaximumRange(sensor, maximumRange);
|
||||
return sensor;
|
||||
}
|
||||
|
||||
public static Sensor createSensor(String type, String name) {
|
||||
return new Sensor(new InputSensorInfo(
|
||||
name, "vendor", 0, 0, 0, 1f, 1f, 1, 1, 1, 1,
|
||||
type, "", 0, 0, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a custom {@link DisplayAddress} to ensure we're not relying on any specific
|
||||
* display-address implementation in our code. Intentionally uses default object (reference)
|
||||
* equality rules.
|
||||
*/
|
||||
public static class TestDisplayAddress extends DisplayAddress {
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) { }
|
||||
}
|
||||
}
|
||||
@@ -1093,15 +1093,15 @@ public class ColorDisplayServiceTest {
|
||||
@Test
|
||||
public void compositionColorSpaces_invalidResources() {
|
||||
when(mResourcesSpy.getIntArray(R.array.config_displayCompositionColorModes))
|
||||
.thenReturn(new int[] {
|
||||
ColorDisplayManager.COLOR_MODE_NATURAL,
|
||||
// Missing second color mode
|
||||
});
|
||||
.thenReturn(new int[] {
|
||||
ColorDisplayManager.COLOR_MODE_NATURAL,
|
||||
// Missing second color mode
|
||||
});
|
||||
when(mResourcesSpy.getIntArray(R.array.config_displayCompositionColorSpaces))
|
||||
.thenReturn(new int[] {
|
||||
Display.COLOR_MODE_SRGB,
|
||||
Display.COLOR_MODE_DISPLAY_P3
|
||||
});
|
||||
.thenReturn(new int[] {
|
||||
Display.COLOR_MODE_SRGB,
|
||||
Display.COLOR_MODE_DISPLAY_P3
|
||||
});
|
||||
setColorMode(ColorDisplayManager.COLOR_MODE_NATURAL);
|
||||
startService();
|
||||
verify(mDisplayTransformManager).setColorMode(
|
||||
@@ -1111,13 +1111,13 @@ public class ColorDisplayServiceTest {
|
||||
@Test
|
||||
public void compositionColorSpaces_validResources_validColorMode() {
|
||||
when(mResourcesSpy.getIntArray(R.array.config_displayCompositionColorModes))
|
||||
.thenReturn(new int[] {
|
||||
ColorDisplayManager.COLOR_MODE_NATURAL
|
||||
});
|
||||
.thenReturn(new int[] {
|
||||
ColorDisplayManager.COLOR_MODE_NATURAL
|
||||
});
|
||||
when(mResourcesSpy.getIntArray(R.array.config_displayCompositionColorSpaces))
|
||||
.thenReturn(new int[] {
|
||||
Display.COLOR_MODE_SRGB,
|
||||
});
|
||||
.thenReturn(new int[] {
|
||||
Display.COLOR_MODE_SRGB,
|
||||
});
|
||||
setColorMode(ColorDisplayManager.COLOR_MODE_NATURAL);
|
||||
startService();
|
||||
verify(mDisplayTransformManager).setColorMode(
|
||||
@@ -1127,13 +1127,13 @@ public class ColorDisplayServiceTest {
|
||||
@Test
|
||||
public void compositionColorSpaces_validResources_invalidColorMode() {
|
||||
when(mResourcesSpy.getIntArray(R.array.config_displayCompositionColorModes))
|
||||
.thenReturn(new int[] {
|
||||
ColorDisplayManager.COLOR_MODE_NATURAL
|
||||
});
|
||||
.thenReturn(new int[] {
|
||||
ColorDisplayManager.COLOR_MODE_NATURAL
|
||||
});
|
||||
when(mResourcesSpy.getIntArray(R.array.config_displayCompositionColorSpaces))
|
||||
.thenReturn(new int[] {
|
||||
Display.COLOR_MODE_SRGB,
|
||||
});
|
||||
.thenReturn(new int[] {
|
||||
Display.COLOR_MODE_SRGB,
|
||||
});
|
||||
setColorMode(ColorDisplayManager.COLOR_MODE_BOOSTED);
|
||||
startService();
|
||||
verify(mDisplayTransformManager).setColorMode(
|
||||
@@ -1143,7 +1143,7 @@ public class ColorDisplayServiceTest {
|
||||
@Test
|
||||
public void getColorMode_noAvailableModes_returnsNotSet() {
|
||||
when(mResourcesSpy.getIntArray(R.array.config_availableColorModes))
|
||||
.thenReturn(new int[] {});
|
||||
.thenReturn(new int[] {});
|
||||
startService();
|
||||
verify(mDisplayTransformManager, never()).setColorMode(anyInt(), any(), anyInt());
|
||||
assertThat(mBinderService.getColorMode()).isEqualTo(-1);
|
||||
@@ -268,9 +268,9 @@ public final class AmbientLuxTest {
|
||||
controller.mBrightnessFilter = spy(new AmbientFilterStubber());
|
||||
|
||||
for (float luxOverride = 0.1f; luxOverride <= 10000; luxOverride *= 10) {
|
||||
setEstimatedBrightnessAndUpdate(controller, luxOverride);
|
||||
assertEquals(controller.mPendingAmbientColorTemperature,
|
||||
ambientColorTemperature, 0.001);
|
||||
setEstimatedBrightnessAndUpdate(controller, luxOverride);
|
||||
assertEquals(controller.mPendingAmbientColorTemperature,
|
||||
ambientColorTemperature, 0.001);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,9 +286,9 @@ public final class AmbientLuxTest {
|
||||
controller.mBrightnessFilter = spy(new AmbientFilterStubber());
|
||||
|
||||
for (float luxOverride = 0.1f; luxOverride <= 10000; luxOverride *= 10) {
|
||||
setEstimatedBrightnessAndUpdate(controller, luxOverride);
|
||||
assertEquals(controller.mPendingAmbientColorTemperature,
|
||||
ambientColorTemperature, 0.001);
|
||||
setEstimatedBrightnessAndUpdate(controller, luxOverride);
|
||||
assertEquals(controller.mPendingAmbientColorTemperature,
|
||||
ambientColorTemperature, 0.001);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,22 +366,22 @@ public final class AmbientLuxTest {
|
||||
|
||||
@Test
|
||||
public void testSpline_InvalidCombinations() throws Exception {
|
||||
setBrightnesses(100.0f, 200.0f);
|
||||
setBiases(0.0f, 1.0f);
|
||||
setHighLightBrightnesses(150.0f, 250.0f);
|
||||
setHighLightBiases(0.0f, 1.0f);
|
||||
setBrightnesses(100.0f, 200.0f);
|
||||
setBiases(0.0f, 1.0f);
|
||||
setHighLightBrightnesses(150.0f, 250.0f);
|
||||
setHighLightBiases(0.0f, 1.0f);
|
||||
|
||||
DisplayWhiteBalanceController controller =
|
||||
DisplayWhiteBalanceFactory.create(mHandler, mSensorManagerMock, mResourcesSpy);
|
||||
final float ambientColorTemperature = 8000.0f;
|
||||
setEstimatedColorTemperature(controller, ambientColorTemperature);
|
||||
controller.mBrightnessFilter = spy(new AmbientFilterStubber());
|
||||
DisplayWhiteBalanceController controller =
|
||||
DisplayWhiteBalanceFactory.create(mHandler, mSensorManagerMock, mResourcesSpy);
|
||||
final float ambientColorTemperature = 8000.0f;
|
||||
setEstimatedColorTemperature(controller, ambientColorTemperature);
|
||||
controller.mBrightnessFilter = spy(new AmbientFilterStubber());
|
||||
|
||||
for (float luxOverride = 0.1f; luxOverride <= 10000; luxOverride *= 10) {
|
||||
setEstimatedBrightnessAndUpdate(controller, luxOverride);
|
||||
assertEquals(controller.mPendingAmbientColorTemperature,
|
||||
ambientColorTemperature, 0.001);
|
||||
}
|
||||
for (float luxOverride = 0.1f; luxOverride <= 10000; luxOverride *= 10) {
|
||||
setEstimatedBrightnessAndUpdate(controller, luxOverride);
|
||||
assertEquals(controller.mPendingAmbientColorTemperature,
|
||||
ambientColorTemperature, 0.001);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -486,7 +486,7 @@ public final class AmbientLuxTest {
|
||||
private void mockResourcesFloat(int id, float floatValue) {
|
||||
doAnswer(new Answer<Void>() {
|
||||
public Void answer(InvocationOnMock invocation) {
|
||||
TypedValue value = (TypedValue)invocation.getArgument(1);
|
||||
TypedValue value = (TypedValue) invocation.getArgument(1);
|
||||
value.type = TypedValue.TYPE_FLOAT;
|
||||
value.data = Float.floatToIntBits(floatValue);
|
||||
return null;
|
||||
@@ -1 +0,0 @@
|
||||
include /services/core/java/com/android/server/display/OWNERS
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"presubmit": [
|
||||
{
|
||||
"name": "FrameworksServicesTests",
|
||||
"options": [
|
||||
{"include-filter": "com.android.server.display"},
|
||||
{"exclude-annotation": "android.platform.test.annotations.FlakyTest"},
|
||||
{"exclude-annotation": "androidx.test.filters.FlakyTest"},
|
||||
{"exclude-annotation": "org.junit.Ignore"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user