From 4af8cf92696f0db02627af8cb0b709f157e503d3 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 29 Jul 2021 15:48:24 -0700 Subject: [PATCH] Updating test build rules > Moving definition to bp files > Adding mokito-inline to allow mocking final classes > Moving src_common to src to avoid unnecessary code split Bug: 196825541 Test: Presubmit Change-Id: Ib6879cda6aee74f5b9050a16eb6ca94ed3b7e28c --- Android.bp | 22 +++++- Android.mk | 36 --------- AndroidManifest.xml | 1 + quickstep/Android.bp | 16 ++++ .../quickstep/ViewInflationDuringSwipeUp.java | 2 +- robolectric_tests/Android.bp | 1 - tests/Android.bp | 74 ++++++++++++++++++- tests/Android.mk | 54 -------------- tests/AndroidManifest-common.xml | 2 +- .../launcher3/ui/AbstractLauncherUiTest.java | 2 +- .../launcher3/ui/widget/BindWidgetTest.java | 2 +- .../android/launcher3/util}/WidgetUtils.java | 3 +- tests/src_common/README.md | 1 - 13 files changed, 115 insertions(+), 101 deletions(-) delete mode 100644 tests/Android.mk rename tests/{src_common/com/android/launcher3/common => src/com/android/launcher3/util}/WidgetUtils.java (97%) delete mode 100644 tests/src_common/README.md diff --git a/Android.bp b/Android.bp index 45d022f4fd..43d28c9ad2 100644 --- a/Android.bp +++ b/Android.bp @@ -224,7 +224,6 @@ filegroup { srcs: ["proguard.flags"], } - // Library with all the dependencies for building Launcher Go android_library { name: "LauncherGoResLib", @@ -253,3 +252,24 @@ android_library { }, } +// Build rule for Quickstep library +android_library { + name: "Launcher3QuickStepLib", + srcs: [ + ":launcher-src-no-build-config", + ], + resource_dirs: [ + "quickstep/res", + ], + static_libs: [ + "SystemUI-statsd", + "SystemUISharedLib", + "Launcher3CommonDepsLib" + ], + manifest: "quickstep/AndroidManifest.xml", + platform_apis: true, + min_sdk_version: "current", + lint: { + baseline_filename: "lint-baseline-launcher3.xml", + }, +} diff --git a/Android.mk b/Android.mk index c222f24afa..c1dbc5392d 100644 --- a/Android.mk +++ b/Android.mk @@ -52,42 +52,6 @@ LOCAL_LICENSE_CONDITIONS := notice LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE include $(BUILD_PACKAGE) -# -# Build rule for Quickstep library. -# -include $(CLEAR_VARS) -LOCAL_USE_AAPT2 := true -LOCAL_AAPT2_ONLY := true -LOCAL_MODULE_TAGS := optional - -LOCAL_STATIC_JAVA_LIBRARIES := \ - SystemUI-statsd \ - SystemUISharedLib -ifneq (,$(wildcard frameworks/base)) - LOCAL_PRIVATE_PLATFORM_APIS := true -else - LOCAL_SDK_VERSION := system_current - LOCAL_MIN_SDK_VERSION := 26 -endif -LOCAL_MODULE := Launcher3QuickStepLib -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 -LOCAL_LICENSE_CONDITIONS := notice -LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE -LOCAL_PRIVILEGED_MODULE := true -LOCAL_STATIC_ANDROID_LIBRARIES := Launcher3CommonDepsLib - -LOCAL_SRC_FILES := \ - $(call all-java-files-under, src) \ - $(call all-java-files-under, quickstep/src) \ - $(call all-java-files-under, src_shortcuts_overrides) - -LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/quickstep/res -LOCAL_PROGUARD_ENABLED := disabled - - -LOCAL_MANIFEST_FILE := quickstep/AndroidManifest.xml -include $(BUILD_STATIC_JAVA_LIBRARY) - # # Build rule for Quickstep app. # diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 8066816e89..c72f62d59a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -31,6 +31,7 @@ android:fullBackupOnly="true" android:fullBackupContent="@xml/backupscheme" android:hardwareAccelerated="true" + android:debuggable="true" android:icon="@drawable/ic_launcher_home" android:label="@string/derived_app_name" android:theme="@style/AppTheme" diff --git a/quickstep/Android.bp b/quickstep/Android.bp index 38c9919b07..7b3e6c45a2 100644 --- a/quickstep/Android.bp +++ b/quickstep/Android.bp @@ -26,3 +26,19 @@ filegroup { path: "robolectric_tests", srcs: ["robolectric_tests/src/**/*.java"], } + +filegroup { + name: "launcher3-quickstep-tests-src", + path: "tests", + srcs: ["tests/src/**/*.java"], +} + +filegroup { + name: "launcher3-quickstep-oop-tests-src", + path: "tests", + srcs: [ + "tests/src/com/android/quickstep/NavigationModeSwitchRule.java", + "tests/src/com/android/quickstep/AbstractQuickStepTest.java", + "tests/src/com/android/quickstep/TaplTestsQuickstep.java", + ] +} diff --git a/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java b/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java index f33abb06fc..0f5a1c8589 100644 --- a/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java +++ b/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java @@ -19,9 +19,9 @@ import static androidx.test.InstrumentationRegistry.getContext; import static androidx.test.InstrumentationRegistry.getInstrumentation; import static androidx.test.InstrumentationRegistry.getTargetContext; -import static com.android.launcher3.common.WidgetUtils.createWidgetInfo; import static com.android.launcher3.testcomponent.TestCommandReceiver.EXTRA_VALUE; import static com.android.launcher3.testcomponent.TestCommandReceiver.SET_LIST_VIEW_SERVICE_BINDER; +import static com.android.launcher3.util.WidgetUtils.createWidgetInfo; import static com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON; import static org.junit.Assert.assertEquals; diff --git a/robolectric_tests/Android.bp b/robolectric_tests/Android.bp index 9ed26ff89e..6473d002a2 100644 --- a/robolectric_tests/Android.bp +++ b/robolectric_tests/Android.bp @@ -40,7 +40,6 @@ android_robolectric_test { name: "LauncherRoboTests", srcs: [ ":launcher3-robolectric-src", - ":launcher3-test-src-common", ], java_resources: [":launcher3-robolectric-resources"], static_libs: [ diff --git a/tests/Android.bp b/tests/Android.bp index da55c28684..37231f9e30 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -20,7 +20,77 @@ package { default_applicable_licenses: ["packages_apps_Launcher3_license"], } +// Source code used for test filegroup { - name: "launcher3-test-src-common", - srcs: ["src_common/**/*.java"], + name: "launcher-tests-src", + srcs: ["src/**/*.java"], +} + +// Source code used for oop test helpers +filegroup { + name: "launcher-oop-tests-src", + srcs: [ + "src/com/android/launcher3/ui/AbstractLauncherUiTest.java", + "src/com/android/launcher3/ui/ActivityLeakTracker.java", + "src/com/android/launcher3/ui/PortraitLandscapeRunner.java", + "src/com/android/launcher3/util/Wait.java", + "src/com/android/launcher3/util/WidgetUtils.java", + "src/com/android/launcher3/util/rule/FailureWatcher.java", + "src/com/android/launcher3/util/rule/LauncherActivityRule.java", + "src/com/android/launcher3/util/rule/ScreenRecordRule.java", + "src/com/android/launcher3/util/rule/ShellCommandRule.java", + "src/com/android/launcher3/util/rule/SimpleActivityRule.java", + "src/com/android/launcher3/util/rule/TestStabilityRule.java", + "src/com/android/launcher3/ui/TaplTestsLauncher3.java", + "src/com/android/launcher3/testcomponent/BaseTestingActivity.java", + "src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java", + "src/com/android/launcher3/testcomponent/TestCommandReceiver.java", + "src/com/android/launcher3/testcomponent/TestLauncherActivity.java", + ], +} + +// Library with all the dependencies for building quickstep +android_library { + name: "Launcher3TestLib", + srcs: [ ], + resource_dirs: ["res"], + static_libs: [ + "launcher-aosp-tapl", + "androidx.test.runner", + "androidx.test.rules", + "androidx.test.ext.junit", + "androidx.test.espresso.core", + "androidx.test.espresso.contrib", + "androidx.test.espresso.intents", + "androidx.test.uiautomator_uiautomator", + "mockito-target-inline-minus-junit4", + "launcher_log_protos_lite", + "truth-prebuilt" + ], + manifest: "AndroidManifest-common.xml", + platform_apis: true, +} + +android_test { + name: "Launcher3Tests", + srcs: [ + ":launcher-tests-src", + ], + static_libs: ["Launcher3TestLib"], + libs: [ + "android.test.base", + "android.test.runner", + "android.test.mock", + ], + jni_libs: [ + "libdexmakerjvmtiagent", + "libstaticjvmtiagent", + ], + use_embedded_native_libs: false, + compile_multilib: "both", + instrumentation_for: "Launcher3", + manifest: "AndroidManifest.xml", + platform_apis: true, + test_config: "Launcher3Tests.xml", + data: [":Launcher3"] } diff --git a/tests/Android.mk b/tests/Android.mk deleted file mode 100644 index 6adc685981..0000000000 --- a/tests/Android.mk +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (C) 2015 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) - -# -# Build rule for Launcher3Tests -# -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests -LOCAL_STATIC_JAVA_LIBRARIES := \ - androidx.test.runner \ - androidx.test.rules \ - androidx.test.uiautomator_uiautomator \ - mockito-target-minus-junit4 \ - launcher_log_protos_lite - -LOCAL_PRIVATE_PLATFORM_APIS := true -LOCAL_STATIC_JAVA_LIBRARIES += launcher-aosp-tapl - -LOCAL_SRC_FILES := \ - $(call all-java-files-under, src) \ - $(call all-java-files-under, src_common) - - -LOCAL_FULL_LIBS_MANIFEST_FILES := $(LOCAL_PATH)/AndroidManifest-common.xml - -LOCAL_PACKAGE_NAME := Launcher3Tests - -LOCAL_INSTRUMENTATION_FOR := Launcher3 - -LOCAL_TEST_CONFIG := Launcher3Tests.xml - -LOCAL_COMPATIBILITY_SUPPORT_FILES := $(call intermediates-dir-for,APPS,Launcher3)/package.apk:Launcher3.apk - -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 -LOCAL_LICENSE_CONDITIONS := notice -LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE -include $(BUILD_PACKAGE) - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/AndroidManifest-common.xml b/tests/AndroidManifest-common.xml index 918ec4af1a..8222f75268 100644 --- a/tests/AndroidManifest-common.xml +++ b/tests/AndroidManifest-common.xml @@ -24,7 +24,7 @@ - +