1# Copyright (C) 2019 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15LOCAL_PATH := $(call my-dir)
16include $(CLEAR_VARS)
17
18LOCAL_USE_AAPT2 := true
19LOCAL_MODULE_TAGS := tests
20
21LOCAL_JACK_FLAGS := --multi-dex native
22LOCAL_DX_FLAGS := --multi-dex
23
24LOCAL_PACKAGE_NAME := CarSystemUITests
25LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
26LOCAL_LICENSE_CONDITIONS := notice
27LOCAL_PRIVATE_PLATFORM_APIS := true
28LOCAL_COMPATIBILITY_SUITE := device-tests
29
30LOCAL_STATIC_ANDROID_LIBRARIES := \
31    CarSystemUI-tests
32
33LOCAL_MULTILIB := both
34
35LOCAL_JNI_SHARED_LIBRARIES := \
36    libdexmakerjvmtiagent \
37    libmultiplejvmtiagentsinterferenceagent
38
39LOCAL_JAVA_LIBRARIES := \
40    android.test.runner \
41    telephony-common \
42    android.test.base \
43
44LOCAL_AAPT_FLAGS := --extra-packages com.android.systemui
45
46# sign this with platform cert, so this test is allowed to inject key events into
47# UI it doesn't own. This is necessary to allow screenshots to be taken
48LOCAL_CERTIFICATE := platform
49
50# Provide jack a list of classes to exclude from code coverage.
51# This is needed because the CarSystemUITests compile CarSystemUI source directly, rather than using
52# LOCAL_INSTRUMENTATION_FOR := CarSystemUI.
53#
54# We want to exclude the test classes from code coverage measurements, but they share the same
55# package as the rest of SystemUI so they can't be easily filtered by package name.
56#
57# Generate a comma separated list of patterns based on the test source files under src/
58# SystemUI classes are in ../src/ so they won't be excluded.
59# Example:
60#   Input files: src/com/android/systemui/Test.java src/com/android/systemui/AnotherTest.java
61#   Generated exclude list: com.android.systemui.Test*,com.android.systemui.AnotherTest*
62
63# Filter all src files under src/ to just java files
64local_java_files := $(filter %.java,$(call all-java-files-under, src))
65
66# Transform java file names into full class names.
67# This only works if the class name matches the file name and the directory structure
68# matches the package.
69local_classes := $(subst /,.,$(patsubst src/%.java,%,$(local_java_files)))
70local_comma := ,
71local_empty :=
72local_space := $(local_empty) $(local_empty)
73
74# Convert class name list to jacoco exclude list
75# This appends a * to all classes and replace the space separators with commas.
76jacoco_exclude := $(subst $(space),$(comma),$(patsubst %,%*,$(local_classes)))
77
78LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.systemui.*,com.android.keyguard.*
79LOCAL_JACK_COVERAGE_EXCLUDE_FILTER := $(jacoco_exclude)
80
81ifeq ($(EXCLUDE_SYSTEMUI_TESTS),)
82    include $(BUILD_PACKAGE)
83endif
84
85# Reset variables
86local_java_files :=
87local_classes :=
88local_comma :=
89local_space :=
90jacoco_exclude :=
91