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

Commit abff40bc authored by Hongwei Wang's avatar Hongwei Wang Committed by Android (Google) Code Review
Browse files

Merge "Add flicker test for WM Shell"

parents 51412036 bbf561ac
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
# WM Shell Test

This contains all tests written for WM (WindowManager) Shell and it's currently
divided into 3 categories

- unittest, tests against individual functions, usually @SmallTest and do not
  require UI automation nor real device to run
- integration, this maybe a mix of functional and integration tests. Contains
  tests verify the WM Shell as a whole, like talking to WM core. This usually
  involves mocking the window manager service or even talking to the real one.
  Due to this nature, test cases in this package is normally annotated as
  @LargeTest and runs with UI automation on real device
- flicker, similar to functional tests with its sole focus on flickerness. See
  [WM Shell Flicker Test Package](http://cs/android/framework/base/libs/WindowManager/Shell/tests/flicker/)
  for more details
+34 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2020 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.
//

android_test {
    name: "WMShellFlickerTests",
    srcs: ["src/**/*.java", "src/**/*.kt"],
    manifest: "AndroidManifest.xml",
    test_config: "AndroidTest.xml",
    platform_apis: true,
    certificate: "platform",
    test_suites: ["device-tests"],
    libs: ["android.test.runner"],
    static_libs: [
        "androidx.test.ext.junit",
        "flickerlib",
        "truth-prebuilt",
        "app-helpers-core",
        "launcher-helper-lib",
        "launcher-aosp-tapl"
    ],
}
+43 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 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.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.android.wm.shell.flicker">

    <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29"/>
    <!-- Read and write traces from external storage -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <!-- Write secure settings -->
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
    <!-- Capture screen contents -->
    <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" />
    <!-- Enable / Disable tracing !-->
    <uses-permission android:name="android.permission.DUMP" />
    <!-- Run layers trace -->
    <uses-permission android:name="android.permission.HARDWARE_TEST"/>
    <!-- Workaround grant runtime permission exception from b/152733071 -->
    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/>
    <uses-permission android:name="android.permission.READ_LOGS"/>
    <application>
        <uses-library android:name="android.test.runner"/>
    </application>

    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
                     android:targetPackage="com.android.wm.shell.flicker"
                     android:label="WindowManager Shell Flicker Tests">
    </instrumentation>
</manifest>
+40 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
 * Copyright 2020 Google Inc. All Rights Reserved.
 -->
<configuration description="Runs WindowManager Shell Flicker Tests">
    <option name="test-tag" value="FlickerTests" />
    <target_preparer class="com.android.tradefed.targetprep.DeviceSetup">
        <!-- keeps the screen on during tests -->
        <option name="screen-always-on" value="on" />
        <!-- prevents the phone from restarting -->
        <option name="force-skip-system-props" value="true" />
        <!-- set WM tracing verbose level to all -->
        <option name="run-command" value="cmd window tracing level all" />
        <!-- inform WM to log all transactions -->
        <option name="run-command" value="cmd window tracing transaction" />
        <!-- restart launcher to activate TAPL -->
        <option name="run-command" value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.DeviceCleaner">
        <!-- reboot the device to teardown any crashed tests -->
        <option name="cleanup-action" value="REBOOT" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
        <option name="cleanup-apks" value="true"/>
        <option name="test-file-name" value="WMShellFlickerTests.apk"/>
        <option name="test-file-name" value="WMShellFlickerTestApp.apk" />
    </target_preparer>
    <test class="com.android.tradefed.testtype.AndroidJUnitTest">
        <option name="package" value="com.android.wm.shell.flicker"/>
        <option name="exclude-annotation" value="androidx.test.filters.FlakyTest" />
        <option name="shell-timeout" value="6600s" />
        <option name="test-timeout" value="6000s" />
        <option name="hidden-api-checks" value="false" />
    </test>
    <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
        <option name="directory-keys" value="/storage/emulated/0/Android/data/com.android.wm.shell.flicker/files" />
        <option name="collect-on-run-ended-only" value="true" />
        <option name="clean-up" value="true" />
    </metrics_collector>
</configuration>
+10 −0
Original line number Diff line number Diff line
# WM Shell Flicker Test Package

Please reference the following links

- [Introduction to Flicker Test Library](http://cs/android/platform_testing/libraries/flicker/)
- [Flicker Test in frameworks/base](http://cs/android/frameworks/base/tests/FlickerTests/)

on what is Flicker Test and how to write a Flicker Test

To run the Flicker Tests for WM Shell, simply run `atest WMShellFlickerTests`
Loading