Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5ff8661 authored by Fiona Campbell's avatar Fiona Campbell
Browse files

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
parent b6629a26
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -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",
    ],
}
+10 −0
Original line number Diff line number Diff line
@@ -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">
+1 −1
Original line number Diff line number Diff line
@@ -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

File moved.

+7 −7
Original line number Diff line number Diff line
@@ -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
Loading