1# Copyright (C) 2016 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 15 16############################################################## 17# FrameworksServicesLib app just for Robolectric test target # 18############################################################## 19LOCAL_PATH := $(call my-dir) 20 21include $(CLEAR_VARS) 22 23LOCAL_PACKAGE_NAME := FrameworksServicesLib 24LOCAL_PRIVATE_PLATFORM_APIS := true 25LOCAL_MODULE_TAGS := optional 26 27LOCAL_PRIVILEGED_MODULE := true 28 29LOCAL_STATIC_JAVA_LIBRARIES := \ 30 services.backup \ 31 services.core 32 33include $(BUILD_PACKAGE) 34 35############################################## 36# FrameworksServices Robolectric test target # 37############################################## 38include $(CLEAR_VARS) 39 40# Dependency platform-robolectric-android-all-stubs below contains a bunch of Android classes as 41# stubs that throw RuntimeExceptions when we use them. The goal is to include hidden APIs that 42# weren't included in Robolectric's Android jar files. However, we are testing the framework itself 43# here, so if we write stuff that is being used in the tests and exist in 44# platform-robolectric-android-all-stubs, the class loader is going to pick up the latter, and thus 45# we are going to test what we don't want. To solve this: 46# 47# 1. If the class being used should be visible to bundled apps: 48# => Bypass the stubs target by including them in LOCAL_SRC_FILES and LOCAL_AIDL_INCLUDES 49# (if aidl). 50# 51# 2. If it's not visible: 52# => Remove the class from the stubs jar (common/robolectric/android-all/android-all-stubs.jar) 53# and add the class path to 54# common/robolectric/android-all/android-all-stubs_removed_classes.txt. 55# 56 57INTERNAL_BACKUP := ../../core/java/com/android/internal/backup 58 59LOCAL_SRC_FILES := \ 60 $(call all-java-files-under, src) \ 61 $(call all-Iaidl-files-under, $(INTERNAL_BACKUP)) \ 62 $(call all-java-files-under, ../../core/java/android/app/backup) \ 63 $(call all-Iaidl-files-under, ../../core/java/android/app/backup) \ 64 ../../core/java/android/content/pm/PackageInfo.java \ 65 ../../core/java/android/app/IBackupAgent.aidl \ 66 ../../core/java/android/util/KeyValueSettingObserver.java 67 68LOCAL_AIDL_INCLUDES := \ 69 $(call all-Iaidl-files-under, $(INTERNAL_BACKUP)) \ 70 $(call all-Iaidl-files-under, ../../core/java/android/app/backup) \ 71 ../../core/java/android/app/IBackupAgent.aidl 72 73LOCAL_STATIC_JAVA_LIBRARIES := \ 74 platform-robolectric-android-all-stubs \ 75 android-support-test \ 76 mockito-robolectric-prebuilt \ 77 platform-test-annotations \ 78 truth-prebuilt \ 79 testng 80 81LOCAL_JAVA_LIBRARIES := \ 82 junit \ 83 platform-robolectric-3.6.1-prebuilt 84 85LOCAL_INSTRUMENTATION_FOR := FrameworksServicesLib 86LOCAL_MODULE := FrameworksServicesRoboTests 87 88LOCAL_MODULE_TAGS := optional 89 90include $(BUILD_STATIC_JAVA_LIBRARY) 91 92############################################################### 93# FrameworksServices runner target to run the previous target # 94############################################################### 95include $(CLEAR_VARS) 96 97LOCAL_MODULE := RunFrameworksServicesRoboTests 98 99LOCAL_SDK_VERSION := current 100 101LOCAL_STATIC_JAVA_LIBRARIES := \ 102 FrameworksServicesRoboTests 103 104LOCAL_TEST_PACKAGE := FrameworksServicesLib 105 106LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))backup/java 107 108include prebuilts/misc/common/robolectric/3.6.1/run_robotests.mk 109