Convert Launcher Android.mk to Android.bp to setup RoboTests

Bug: 181083996
Test: m Launcher3 && install Launcher3 and test basic things
Test: m RunLauncherRoboTests (90 tests run and 3 fails)

Change-Id: Icdc839d06413409cbd52d10a5ef9fe27b0a57baa
This commit is contained in:
Hyunyoung Song 2021-02-25 00:58:05 -08:00
parent d6844dcb7f
commit 5a007fe0f6
8 changed files with 138 additions and 143 deletions

View File

@ -93,3 +93,93 @@ java_library {
sdk_version: "current", sdk_version: "current",
min_sdk_version: "28", min_sdk_version: "28",
} }
//
// Build rule for Launcher3 dependencies lib.
//
android_library {
name: "Launcher3CommonDepsLib",
static_libs: [
"androidx.recyclerview_recyclerview",
"androidx.dynamicanimation_dynamicanimation",
"androidx.preference_preference",
"androidx.slice_slice-view",
"iconloader_base",
"LauncherPluginLib",
"launcher_quickstep_log_protos_lite"
],
srcs: [
"src_build_config/**/*.java",
],
resource_dirs: ["res"],
optimize: {
enabled: false,
},
sdk_version: "current",
min_sdk_version: "26",
manifest: "AndroidManifest-common.xml",
}
//
// Build rule for Launcher3 app.
//
android_app {
name: "Launcher3",
static_libs: [
"Launcher3CommonDepsLib",
],
srcs: [
"src/**/*.java",
"src_shortcuts_overrides/**/*.java",
"src_ui_overrides/**/*.java",
"ext_tests/src/**/*.java",
],
resource_dirs: [
"ext_tests/res",
],
optimize: {
proguard_flags_files: ["proguard.flags"],
// Proguard is disable for testing. Derivarive prjects to keep proguard enabled
enabled: false,
},
sdk_version: "current",
min_sdk_version: "26",
target_sdk_version: "29",
privileged: true,
system_ext_specific: true,
overrides: [
"Home",
"Launcher2",
],
required: ["privapp_whitelist_com.android.launcher3"],
jacoco: {
include_filter: ["com.android.launcher3.**"],
},
additional_manifests: [
"AndroidManifest-common.xml",
],
}
//
// Launcher Robolectric test target.
//
java_library {
name: "Launcher3TestCommon",
libs: [
"Launcher3CommonDepsLib",
],
srcs: [
"src/**/*.java",
"src_shortcuts_overrides/**/*.java",
"src_ui_overrides/**/*.java",
"ext_tests/src/**/*.java",
"tests/src_common/**/*.java",
],
target_sdk_version: "29",
sdk_version: "current",
min_sdk_version: "26",
}

View File

@ -16,79 +16,6 @@
LOCAL_PATH := $(call my-dir) LOCAL_PATH := $(call my-dir)
#
# Build rule for Launcher3 dependencies lib.
#
include $(CLEAR_VARS)
LOCAL_USE_AAPT2 := true
LOCAL_AAPT2_ONLY := true
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_ANDROID_LIBRARIES := \
androidx.recyclerview_recyclerview \
androidx.dynamicanimation_dynamicanimation \
androidx.preference_preference \
androidx.slice_slice-view \
iconloader_base
LOCAL_STATIC_JAVA_LIBRARIES := \
LauncherPluginLib \
launcher_quickstep_log_protos_lite \
search_ui
LOCAL_SRC_FILES := \
$(call all-java-files-under, src_build_config) \
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SDK_VERSION := current
LOCAL_MIN_SDK_VERSION := 26
LOCAL_MODULE := Launcher3CommonDepsLib
LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
LOCAL_LICENSE_CONDITIONS := notice
LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MANIFEST_FILE := AndroidManifest-common.xml
include $(BUILD_STATIC_JAVA_LIBRARY)
#
# Build rule for Launcher3 app.
#
include $(CLEAR_VARS)
LOCAL_USE_AAPT2 := true
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_ANDROID_LIBRARIES := Launcher3CommonDepsLib
LOCAL_SRC_FILES := \
$(call all-java-files-under, src) \
$(call all-java-files-under, src_shortcuts_overrides) \
$(call all-java-files-under, src_ui_overrides) \
$(call all-java-files-under, ext_tests/src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/ext_tests/res
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
# Proguard is disable for testing. Derivarive prjects to keep proguard enabled
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SDK_VERSION := current
LOCAL_MIN_SDK_VERSION := 26
LOCAL_PACKAGE_NAME := Launcher3
LOCAL_PRIVILEGED_MODULE := true
LOCAL_SYSTEM_EXT_MODULE := true
LOCAL_OVERRIDES_PACKAGES := Home Launcher2
LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.launcher3
LOCAL_FULL_LIBS_MANIFEST_FILES := $(LOCAL_PATH)/AndroidManifest-common.xml
LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.launcher3.*
include $(BUILD_PACKAGE)
# #
# Build rule for Launcher3 Go app for Android Go devices. # Build rule for Launcher3 Go app for Android Go devices.
# #

View File

@ -1,5 +1,4 @@
<resources> <resources>
<bool name="config_largeHeap">true</bool>
<!-- All Apps & Widgets --> <!-- All Apps & Widgets -->
<!-- Out of 100, the percent to shrink the workspace during spring loaded mode. --> <!-- Out of 100, the percent to shrink the workspace during spring loaded mode. -->

View File

@ -0,0 +1,46 @@
// Copyright (C) 2021 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.
//
// Launcher Robolectric test target.
//
// "robolectric_android-all-stub", not needed, we write our own stubs
android_robolectric_test {
name: "LauncherRoboTests",
srcs: [
"src/**/*.java",
],
java_resource_dirs: [
"resources",
"res",
"config",
],
static_libs: [
"truth-prebuilt",
"Launcher3TestCommon",
"androidx.test.runner",
"androidx.test.rules",
"mockito-robolectric-prebuilt",
],
//robolectric_prebuilt_version: "4.4",
libs: [
"platform-robolectric-4.4-prebuilt",
],
instrumentation_for: "Launcher3",
test_options: {
timeout: 36000,
},
}

View File

@ -1,68 +0,0 @@
# Copyright (C) 2018 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.
#############################################
# Launcher Robolectric test target. #
#############################################
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := LauncherRoboTests
LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
LOCAL_LICENSE_CONDITIONS := notice
LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SDK_VERSION := system_current
LOCAL_SRC_FILES := \
$(call all-java-files-under, src) \
$(call all-java-files-under, ../tests/src_common)
LOCAL_STATIC_JAVA_LIBRARIES := \
androidx.test.runner \
androidx.test.rules \
mockito-robolectric-prebuilt \
truth-prebuilt
LOCAL_JAVA_LIBRARIES := \
platform-robolectric-4.3.1-prebuilt
LOCAL_JAVA_RESOURCE_DIRS := resources config
LOCAL_INSTRUMENTATION_FOR := Launcher3
LOCAL_MODULE_TAGS := optional
# Generate test_config.properties
include external/robolectric-shadows/gen_test_config.mk
include $(BUILD_STATIC_JAVA_LIBRARY)
############################################
# Target to run the previous target. #
############################################
include $(CLEAR_VARS)
LOCAL_MODULE := RunLauncherRoboTests
LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
LOCAL_LICENSE_CONDITIONS := notice
LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE
LOCAL_SDK_VERSION := system_current
LOCAL_JAVA_LIBRARIES := LauncherRoboTests
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_TEST_PACKAGE := Launcher3
LOCAL_INSTRUMENT_SOURCE_DIRS := packages/apps/Launcher3/src
LOCAL_ROBOTEST_TIMEOUT := 36000
include prebuilts/misc/common/robolectric/4.4/run_robotests.mk

View File

@ -1,4 +1,5 @@
sdk=29 sdk=29
shadows= \ shadows= \
com.android.launcher3.shadows.LShadowAppPredictionManager \ com.android.launcher3.shadows.LShadowAppPredictionManager \
com.android.launcher3.shadows.LShadowAppWidgetManager \ com.android.launcher3.shadows.LShadowAppWidgetManager \
@ -11,4 +12,4 @@ shadows= \
com.android.launcher3.shadows.ShadowOverrides \ com.android.launcher3.shadows.ShadowOverrides \
com.android.launcher3.shadows.ShadowSurfaceTransactionApplier \ com.android.launcher3.shadows.ShadowSurfaceTransactionApplier \
application=com.android.launcher3.util.LauncherTestApplication application=com.android.launcher3.util.LauncherTestApplication