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

Commit d0cfab09 authored by Heemin Seog's avatar Heemin Seog
Browse files

Setup on device testing for sys ui

This borrows on the testing infrastructure set up by the phone sys ui
team and provides an examples via test for CarNavigationBarController.

Bug: 143227120
Test: atest CarNavigationBarControllerTest
Change-Id: I10fd4e2e51f2faf75ade5b40e47441a9e948f075
parent ec2b60ef
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
@@ -63,6 +63,64 @@ android_library {

}

android_library {
    name: "CarSystemUI-tests",
    manifest: "tests/AndroidManifest.xml",
    resource_dirs: [
        "tests/res",
        "res-keyguard",
        "res",
    ],
    srcs: [
        "tests/src/**/*.java",
        "src/**/*.java",
        "src/**/I*.aidl",
    ],
    static_libs: [
        "SystemUI-tests",
        "CarNotificationLib",
        "SystemUIPluginLib",
        "SystemUISharedLib",
        "SettingsLib",
        "android.car.userlib",
        "androidx.legacy_legacy-support-v4",
        "androidx.recyclerview_recyclerview",
        "androidx.preference_preference",
        "androidx.appcompat_appcompat",
        "androidx.mediarouter_mediarouter",
        "androidx.palette_palette",
        "androidx.legacy_legacy-preference-v14",
        "androidx.leanback_leanback",
        "androidx.slice_slice-core",
        "androidx.slice_slice-view",
        "androidx.slice_slice-builders",
        "androidx.arch.core_core-runtime",
        "androidx.lifecycle_lifecycle-extensions",
        "SystemUI-tags",
        "SystemUI-proto",
        "metrics-helper-lib",
        "androidx.test.rules", "hamcrest-library",
        "mockito-target-inline-minus-junit4",
        "testables",
        "truth-prebuilt",
        "dagger2-2.19",
        "//external/kotlinc:kotlin-annotations",
    ],
    libs: [
        "android.test.runner",
        "telephony-common",
        "android.test.base",
        "android.car",
    ],

    aaptflags: [
        "--extra-packages",
        "com.android.systemui",
    ],

    plugins: ["dagger2-compiler-2.19"],
}

android_app {
    name: "CarSystemUI",

+15 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.widget.LinearLayout;

import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.navigationbar.car.CarNavigationBarController.NotificationsShadeController;
import com.android.systemui.statusbar.phone.StatusBarIconController;

/**
@@ -35,7 +36,7 @@ import com.android.systemui.statusbar.phone.StatusBarIconController;
public class CarNavigationBarView extends LinearLayout {
    private View mNavButtons;
    private CarNavigationButton mNotificationsButton;
    private CarNavigationBarController.NotificationsShadeController mNotificationsShadeController;
    private NotificationsShadeController mNotificationsShadeController;
    private Context mContext;
    private View mLockScreenButtons;
    // used to wire in open/close gestures for notifications
@@ -81,13 +82,18 @@ public class CarNavigationBarView extends LinearLayout {
        return super.onInterceptTouchEvent(ev);
    }

    public void setNotificationsPanelController(
            CarNavigationBarController.NotificationsShadeController controller) {
    /** Sets the notifications panel controller. */
    public void setNotificationsPanelController(NotificationsShadeController controller) {
        mNotificationsShadeController = controller;
    }

    /** Gets the notifications panel controller. */
    public NotificationsShadeController getNotificationsPanelController() {
        return mNotificationsShadeController;
    }

    /**
     * Set a touch listener that will be called from onInterceptTouchEvent and onTouchEvent
     * Sets a touch listener that will be called from onInterceptTouchEvent and onTouchEvent
     *
     * @param statusBarWindowTouchListener The listener to call from touch and intercept touch
     */
@@ -95,6 +101,11 @@ public class CarNavigationBarView extends LinearLayout {
        mStatusBarWindowTouchListener = statusBarWindowTouchListener;
    }

    /** Gets the touch listener that will be called from onInterceptTouchEvent and onTouchEvent. */
    public OnTouchListener getStatusBarWindowTouchListener() {
        return mStatusBarWindowTouchListener;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mStatusBarWindowTouchListener != null) {
+88 −0
Original line number Diff line number Diff line
# 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.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_USE_AAPT2 := true
LOCAL_MODULE_TAGS := tests

LOCAL_JACK_FLAGS := --multi-dex native
LOCAL_DX_FLAGS := --multi-dex

LOCAL_PACKAGE_NAME := CarSystemUITests
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_COMPATIBILITY_SUITE := device-tests

LOCAL_STATIC_ANDROID_LIBRARIES := \
    CarSystemUI-tests

LOCAL_MULTILIB := both

LOCAL_JNI_SHARED_LIBRARIES := \
    libdexmakerjvmtiagent \
    libmultiplejvmtiagentsinterferenceagent

LOCAL_JAVA_LIBRARIES := \
    android.test.runner \
    telephony-common \
    android.test.base \

LOCAL_AAPT_FLAGS := --extra-packages com.android.systemui

# sign this with platform cert, so this test is allowed to inject key events into
# UI it doesn't own. This is necessary to allow screenshots to be taken
LOCAL_CERTIFICATE := platform

# Provide jack a list of classes to exclude from code coverage.
# This is needed because the CarSystemUITests compile CarSystemUI source directly, rather than using
# LOCAL_INSTRUMENTATION_FOR := CarSystemUI.
#
# We want to exclude the test classes from code coverage measurements, but they share the same
# package as the rest of SystemUI so they can't be easily filtered by package name.
#
# Generate a comma separated list of patterns based on the test source files under src/
# SystemUI classes are in ../src/ so they won't be excluded.
# Example:
#   Input files: src/com/android/systemui/Test.java src/com/android/systemui/AnotherTest.java
#   Generated exclude list: com.android.systemui.Test*,com.android.systemui.AnotherTest*

# Filter all src files under src/ to just java files
local_java_files := $(filter %.java,$(call all-java-files-under, src))

# Transform java file names into full class names.
# This only works if the class name matches the file name and the directory structure
# matches the package.
local_classes := $(subst /,.,$(patsubst src/%.java,%,$(local_java_files)))
local_comma := ,
local_empty :=
local_space := $(local_empty) $(local_empty)

# Convert class name list to jacoco exclude list
# This appends a * to all classes and replace the space separators with commas.
jacoco_exclude := $(subst $(space),$(comma),$(patsubst %,%*,$(local_classes)))

LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.systemui.*,com.android.keyguard.*
LOCAL_JACK_COVERAGE_EXCLUDE_FILTER := $(jacoco_exclude)

ifeq ($(EXCLUDE_SYSTEMUI_TESTS),)
    include $(BUILD_PACKAGE)
endif

# Reset variables
local_java_files :=
local_classes :=
local_comma :=
local_space :=
jacoco_exclude :=
+40 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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.
  -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:sharedUserId="android.uid.system"
          package="com.android.systemui.tests">

    <application android:debuggable="true" android:largeHeap="true">
        <uses-library android:name="android.test.runner" />

        <provider
            android:name="androidx.lifecycle.ProcessLifecycleOwnerInitializer"
            tools:replace="android:authorities"
            android:authorities="${applicationId}.lifecycle-tests"
            android:exported="false"
            android:enabled="false"
            android:multiprocess="true" />
    </application>

    <instrumentation android:name="android.testing.TestableInstrumentation"
        android:targetPackage="com.android.systemui.tests"
        android:label="Tests for CarSystemUI">
    </instrumentation>
</manifest>
+30 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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.
  -->
<configuration description="Runs Tests for CarSystemUI.">
    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
        <option name="test-file-name" value="CarSystemUITests.apk" />
    </target_preparer>

    <option name="test-suite-tag" value="apct" />
    <option name="test-suite-tag" value="framework-base-presubmit" />
    <option name="test-tag" value="CarSystemUITests" />
    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
        <option name="package" value="com.android.systemui.tests" />
        <option name="runner" value="android.testing.TestableInstrumentation" />
        <option name="hidden-api-checks" value="false"/>
    </test>
</configuration>
Loading