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
This commit is contained in:
Sunny Goyal 2021-07-29 15:48:24 -07:00
parent 0ec3e647ba
commit 4af8cf9269
13 changed files with 115 additions and 101 deletions

View File

@ -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",
},
}

View File

@ -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.
#

View File

@ -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"

View File

@ -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",
]
}

View File

@ -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;

View File

@ -40,7 +40,6 @@ android_robolectric_test {
name: "LauncherRoboTests",
srcs: [
":launcher3-robolectric-src",
":launcher3-test-src-common",
],
java_resources: [":launcher3-robolectric-resources"],
static_libs: [

View File

@ -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"]
}

View File

@ -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))

View File

@ -24,7 +24,7 @@
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<application android:debuggable="true">
<application android:debuggable="true" android:extractNativeLibs="true">
<uses-library android:name="android.test.runner"/>
<receiver

View File

@ -52,7 +52,6 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.common.WidgetUtils;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.tapl.LauncherInstrumentation;
@ -63,6 +62,7 @@ import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.LooperExecutor;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.WidgetUtils;
import com.android.launcher3.util.rule.FailureWatcher;
import com.android.launcher3.util.rule.LauncherActivityRule;
import com.android.launcher3.util.rule.ScreenRecordRule;

View File

@ -17,7 +17,7 @@ package com.android.launcher3.ui.widget;
import static androidx.test.InstrumentationRegistry.getTargetContext;
import static com.android.launcher3.common.WidgetUtils.createWidgetInfo;
import static com.android.launcher3.util.WidgetUtils.createWidgetInfo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.common;
package com.android.launcher3.util;
import static com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID;
@ -25,7 +25,6 @@ import android.os.Bundle;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.util.ContentWriter;
import com.android.launcher3.widget.LauncherAppWidgetHost;
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
import com.android.launcher3.widget.PendingAddWidgetInfo;

View File

@ -1 +0,0 @@
Common source code used by both android tests and robolectric tests