Merge "Move display tests to DisplayServiceTests module" into udc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ffa5a8496a
@@ -22,11 +22,20 @@ android_test {
|
|||||||
"src/**/*.java",
|
"src/**/*.java",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
libs: [
|
||||||
|
"android.test.mock",
|
||||||
|
],
|
||||||
|
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"services.core",
|
"androidx.test.ext.junit",
|
||||||
"androidx.test.runner",
|
"display-core-libs",
|
||||||
"androidx.test.rules",
|
"frameworks-base-testutils",
|
||||||
|
"junit",
|
||||||
|
"junit-params",
|
||||||
|
"platform-compat-test-rules",
|
||||||
"platform-test-annotations",
|
"platform-test-annotations",
|
||||||
|
"services.core",
|
||||||
|
"servicestests-utils",
|
||||||
],
|
],
|
||||||
|
|
||||||
defaults: [
|
defaults: [
|
||||||
@@ -47,3 +56,10 @@ android_test {
|
|||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "display-core-libs",
|
||||||
|
srcs: [
|
||||||
|
"src/com/android/server/display/TestUtils.java",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,6 +21,16 @@
|
|||||||
Insert permissions here. eg:
|
Insert permissions here. eg:
|
||||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
<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"
|
<application android:debuggable="true"
|
||||||
android:testOnly="true">
|
android:testOnly="true">
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.server.display;
|
package com.android.server.display;
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.server.display;
|
package com.android.server.display;
|
||||||
@@ -206,11 +206,11 @@ public class BrightnessMappingStrategyTest {
|
|||||||
BrightnessMappingStrategy strategy = BrightnessMappingStrategy.create(res, ddc, mMockDwbc);
|
BrightnessMappingStrategy strategy = BrightnessMappingStrategy.create(res, ddc, mMockDwbc);
|
||||||
|
|
||||||
strategy.setBrightnessConfiguration(null);
|
strategy.setBrightnessConfiguration(null);
|
||||||
final int N = DISPLAY_LEVELS_BACKLIGHT.length;
|
final int n = DISPLAY_LEVELS_BACKLIGHT.length;
|
||||||
final float expectedBrightness =
|
final float expectedBrightness =
|
||||||
(float) DISPLAY_LEVELS_BACKLIGHT[N - 1] / PowerManager.BRIGHTNESS_ON;
|
(float) DISPLAY_LEVELS_BACKLIGHT[n - 1] / PowerManager.BRIGHTNESS_ON;
|
||||||
assertEquals(expectedBrightness,
|
assertEquals(expectedBrightness,
|
||||||
strategy.getBrightness(LUX_LEVELS[N - 1]), 0.0001f /*tolerance*/);
|
strategy.getBrightness(LUX_LEVELS[n - 1]), 0.0001f /*tolerance*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -270,10 +270,10 @@ public class BrightnessMappingStrategyTest {
|
|||||||
|
|
||||||
// Check that null returns us to the default configuration.
|
// Check that null returns us to the default configuration.
|
||||||
strategy.setBrightnessConfiguration(null);
|
strategy.setBrightnessConfiguration(null);
|
||||||
final int N = DISPLAY_LEVELS_NITS.length;
|
final int n = DISPLAY_LEVELS_NITS.length;
|
||||||
final float expectedBrightness = DISPLAY_LEVELS_NITS[N - 1] / DISPLAY_RANGE_NITS[1];
|
final float expectedBrightness = DISPLAY_LEVELS_NITS[n - 1] / DISPLAY_RANGE_NITS[1];
|
||||||
assertEquals(expectedBrightness,
|
assertEquals(expectedBrightness,
|
||||||
strategy.getBrightness(LUX_LEVELS[N - 1]), 0.0001f /*tolerance*/);
|
strategy.getBrightness(LUX_LEVELS[n - 1]), 0.0001f /*tolerance*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.server.display;
|
package com.android.server.display;
|
||||||
@@ -395,8 +395,8 @@ public class BrightnessTrackerTest {
|
|||||||
final long currentTime = mInjector.currentTimeMillis();
|
final long currentTime = mInjector.currentTimeMillis();
|
||||||
notifyBrightnessChanged(mTracker, brightness, displayId, new float[] {1000.0f},
|
notifyBrightnessChanged(mTracker, brightness, displayId, new float[] {1000.0f},
|
||||||
new long[] {TimeUnit.NANOSECONDS.toMillis(mInjector.elapsedRealtimeNanos())});
|
new long[] {TimeUnit.NANOSECONDS.toMillis(mInjector.elapsedRealtimeNanos())});
|
||||||
List<BrightnessChangeEvent> eventsNoPackage
|
List<BrightnessChangeEvent> eventsNoPackage =
|
||||||
= mTracker.getEvents(0, false).getList();
|
mTracker.getEvents(0, false).getList();
|
||||||
List<BrightnessChangeEvent> events = mTracker.getEvents(0, true).getList();
|
List<BrightnessChangeEvent> events = mTracker.getEvents(0, true).getList();
|
||||||
mTracker.stop();
|
mTracker.stop();
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ public class DisplayManagerServiceTest {
|
|||||||
private static final float FLOAT_TOLERANCE = 0.01f;
|
private static final float FLOAT_TOLERANCE = 0.01f;
|
||||||
|
|
||||||
private static final String VIRTUAL_DISPLAY_NAME = "Test Virtual Display";
|
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
|
private static final long STANDARD_DISPLAY_EVENTS = DisplayManager.EVENT_FLAG_DISPLAY_ADDED
|
||||||
| DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
|
| DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
|
||||||
| DisplayManager.EVENT_FLAG_DISPLAY_REMOVED;
|
| DisplayManager.EVENT_FLAG_DISPLAY_REMOVED;
|
||||||
@@ -483,8 +483,10 @@ public class HighBrightnessModeControllerTest {
|
|||||||
|
|
||||||
// Verify Stats HBM_ON_HDR
|
// Verify Stats HBM_ON_HDR
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_HDR),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
.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*/,
|
hbmc.getHdrListener().onHdrInfoChanged(null /*displayToken*/, 0 /*numberOfHdrLayers*/,
|
||||||
0, 0, 0 /*flags*/, 1.0f /*maxDesiredHdrSdrRatio*/);
|
0, 0, 0 /*flags*/, 1.0f /*maxDesiredHdrSdrRatio*/);
|
||||||
@@ -492,8 +494,10 @@ public class HighBrightnessModeControllerTest {
|
|||||||
|
|
||||||
// Verify Stats HBM_OFF
|
// Verify Stats HBM_OFF
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||||
|
eq(FrameworkStatsLog
|
||||||
|
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||||
|
|
||||||
hbmc.setAutoBrightnessEnabled(AUTO_BRIGHTNESS_ENABLED);
|
hbmc.setAutoBrightnessEnabled(AUTO_BRIGHTNESS_ENABLED);
|
||||||
hbmc.onAmbientLuxChange(MINIMUM_LUX + 1);
|
hbmc.onAmbientLuxChange(MINIMUM_LUX + 1);
|
||||||
@@ -501,16 +505,20 @@ public class HighBrightnessModeControllerTest {
|
|||||||
|
|
||||||
// Verify Stats HBM_ON_SUNLIGHT
|
// Verify Stats HBM_ON_SUNLIGHT
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||||
|
eq(FrameworkStatsLog
|
||||||
|
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||||
|
|
||||||
hbmc.onAmbientLuxChange(1);
|
hbmc.onAmbientLuxChange(1);
|
||||||
advanceTime(TIME_ALLOWED_IN_WINDOW_MILLIS / 2 + 1);
|
advanceTime(TIME_ALLOWED_IN_WINDOW_MILLIS / 2 + 1);
|
||||||
|
|
||||||
// Verify Stats HBM_OFF
|
// Verify Stats HBM_OFF
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_LUX_DROP));
|
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||||
|
eq(FrameworkStatsLog
|
||||||
|
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_LUX_DROP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -565,8 +573,10 @@ public class HighBrightnessModeControllerTest {
|
|||||||
BrightnessInfo.BRIGHTNESS_MAX_REASON_NONE);
|
BrightnessInfo.BRIGHTNESS_MAX_REASON_NONE);
|
||||||
advanceTime(1);
|
advanceTime(1);
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
.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)
|
// Brightness is thermally throttled, HBM brightness denied (NBM brightness granted)
|
||||||
hbmc.onBrightnessChanged(nbmBrightness, hbmBrightness,
|
hbmc.onBrightnessChanged(nbmBrightness, hbmBrightness,
|
||||||
@@ -592,8 +602,10 @@ public class HighBrightnessModeControllerTest {
|
|||||||
hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
|
hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
|
||||||
advanceTime(0);
|
advanceTime(0);
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
.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.
|
// Use up all the time in the window.
|
||||||
advanceTime(TIME_WINDOW_MILLIS + 1);
|
advanceTime(TIME_WINDOW_MILLIS + 1);
|
||||||
@@ -613,13 +625,17 @@ public class HighBrightnessModeControllerTest {
|
|||||||
hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
|
hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
|
||||||
advanceTime(0);
|
advanceTime(0);
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
.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);
|
hbmc.setAutoBrightnessEnabled(AUTO_BRIGHTNESS_OFF_DUE_TO_DISPLAY_STATE);
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_DISPLAY_OFF));
|
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_OFF),
|
||||||
|
eq(FrameworkStatsLog
|
||||||
|
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_SV_OFF_DISPLAY_OFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -632,8 +648,10 @@ public class HighBrightnessModeControllerTest {
|
|||||||
hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
|
hbmcOnBrightnessChanged(hbmc, TRANSITION_POINT + 0.01f);
|
||||||
advanceTime(0);
|
advanceTime(0);
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
.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*/,
|
hbmc.getHdrListener().onHdrInfoChanged(null /*displayToken*/, 1 /*numberOfHdrLayers*/,
|
||||||
DISPLAY_WIDTH, DISPLAY_HEIGHT, 0 /*flags*/, 1.0f /*maxDesiredHdrSdrRatio*/);
|
DISPLAY_WIDTH, DISPLAY_HEIGHT, 0 /*flags*/, 1.0f /*maxDesiredHdrSdrRatio*/);
|
||||||
@@ -657,8 +675,10 @@ public class HighBrightnessModeControllerTest {
|
|||||||
assertEquals(HIGH_BRIGHTNESS_MODE_SUNLIGHT, hbmc.getHighBrightnessMode());
|
assertEquals(HIGH_BRIGHTNESS_MODE_SUNLIGHT, hbmc.getHighBrightnessMode());
|
||||||
// verify HBM_ON_SUNLIGHT
|
// verify HBM_ON_SUNLIGHT
|
||||||
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
verify(mInjectorMock).reportHbmStateChange(eq(displayStatsId),
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
eq(FrameworkStatsLog
|
||||||
eq(FrameworkStatsLog.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
.DISPLAY_HBM_STATE_CHANGED__STATE__HBM_ON_SUNLIGHT),
|
||||||
|
eq(FrameworkStatsLog
|
||||||
|
.DISPLAY_HBM_STATE_CHANGED__REASON__HBM_TRANSITION_REASON_UNKNOWN));
|
||||||
|
|
||||||
hbmcOnBrightnessChanged(hbmc, DEFAULT_MIN);
|
hbmcOnBrightnessChanged(hbmc, DEFAULT_MIN);
|
||||||
// verify HBM_SV_OFF due to LOW_REQUESTED_BRIGHTNESS
|
// verify HBM_SV_OFF due to LOW_REQUESTED_BRIGHTNESS
|
||||||
@@ -40,6 +40,7 @@ import androidx.test.filters.SmallTest;
|
|||||||
import com.android.server.display.layout.Layout;
|
import com.android.server.display.layout.Layout;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -121,7 +122,9 @@ public class LogicalDisplayTest {
|
|||||||
assertEquals(expectedPosition, mLogicalDisplay.getDisplayPosition());
|
assertEquals(expectedPosition, mLogicalDisplay.getDisplayPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: b/288880734 - fix test after display tests migration
|
||||||
@Test
|
@Test
|
||||||
|
@Ignore
|
||||||
public void testDisplayInputFlags() {
|
public void testDisplayInputFlags() {
|
||||||
SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
|
SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
|
||||||
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.server.display;
|
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) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -486,7 +486,7 @@ public final class AmbientLuxTest {
|
|||||||
private void mockResourcesFloat(int id, float floatValue) {
|
private void mockResourcesFloat(int id, float floatValue) {
|
||||||
doAnswer(new Answer<Void>() {
|
doAnswer(new Answer<Void>() {
|
||||||
public Void answer(InvocationOnMock invocation) {
|
public Void answer(InvocationOnMock invocation) {
|
||||||
TypedValue value = (TypedValue)invocation.getArgument(1);
|
TypedValue value = (TypedValue) invocation.getArgument(1);
|
||||||
value.type = TypedValue.TYPE_FLOAT;
|
value.type = TypedValue.TYPE_FLOAT;
|
||||||
value.data = Float.floatToIntBits(floatValue);
|
value.data = Float.floatToIntBits(floatValue);
|
||||||
return null;
|
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