Merge "Run unit test with the prod flag java lib" into main
This commit is contained in:
@@ -2,8 +2,8 @@ package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
java_defaults {
|
||||
name: "AconfigDemoActivityDefault",
|
||||
android_app {
|
||||
name: "AconfigDemoActivity",
|
||||
manifest: "AndroidManifest.xml",
|
||||
srcs: [
|
||||
"src/**/*.java"
|
||||
@@ -11,30 +11,18 @@ java_defaults {
|
||||
platform_apis: true,
|
||||
certificate: "platform",
|
||||
static_libs: [
|
||||
"ContentLibs",
|
||||
"dagger2",
|
||||
"jsr330",
|
||||
],
|
||||
jni_libs: [
|
||||
"libexample_cpp_lib",
|
||||
],
|
||||
optimize: {
|
||||
enabled: true,
|
||||
proguard_compatibility: false,
|
||||
shrink: true,
|
||||
optimize: false,
|
||||
obfuscate: false,
|
||||
shrink_resources: true,
|
||||
},
|
||||
required: ["libexample_rust_jni"],
|
||||
plugins: ["dagger2-compiler"]
|
||||
}
|
||||
|
||||
android_app {
|
||||
name: "AconfigDemoActivity",
|
||||
defaults: ["AconfigDemoActivityDefault"],
|
||||
static_libs: [
|
||||
"ContentLibs",
|
||||
]
|
||||
plugins: ["dagger2-compiler"],
|
||||
optimize: {
|
||||
proguard_flags_files: ["proguard.flags"],
|
||||
},
|
||||
}
|
||||
|
||||
aconfig_declarations {
|
||||
@@ -43,7 +31,6 @@ aconfig_declarations {
|
||||
srcs: ["aconfig_demo_flags.aconfig"],
|
||||
}
|
||||
|
||||
|
||||
java_aconfig_library {
|
||||
name: "aconfig_demo_flags_java_lib",
|
||||
aconfig_declarations: "aconfig_demo_flags",
|
||||
@@ -130,82 +117,3 @@ java_aconfig_library {
|
||||
host_supported: true,
|
||||
test: true
|
||||
}
|
||||
|
||||
|
||||
// Option 1
|
||||
// Create a test version of the library under testing
|
||||
// The test version of this library shares the common
|
||||
// settings in a java_defaults target with the production
|
||||
// version library. The test version library statically
|
||||
// links to the test flag library, and the production
|
||||
// version library links to the production version flag
|
||||
// library.
|
||||
|
||||
java_library {
|
||||
name: "ContentLibsTest1",
|
||||
defaults: ["ContentLibsDefault"],
|
||||
static_libs: [
|
||||
"aconfig_demo_flags_java_lib_test",
|
||||
],
|
||||
}
|
||||
|
||||
// Create the test version of the android_app. This app is used
|
||||
// for self-instrumentation test. This app uses the test version
|
||||
// of the library which uses flags.
|
||||
// Please check tests/unittests/Android.bp:AconfigDemoUnitTests1
|
||||
android_app {
|
||||
name: "AconfigDemoActivityTest1",
|
||||
defaults: ["AconfigDemoActivityDefault"],
|
||||
optimize: {
|
||||
enabled: false,
|
||||
},
|
||||
static_libs: [
|
||||
"ContentLibsTest1",
|
||||
]
|
||||
}
|
||||
|
||||
// Option 2
|
||||
// Instead of creating two verions of the library containing flags,
|
||||
// it could work that create one version of the library and dynamically
|
||||
// link to the flag library. The flag library here just works as a stub
|
||||
// library for the purpose of building. The real flag library should be
|
||||
// statically linked in the final binary.
|
||||
|
||||
|
||||
// This library is created to demonstrate dynamically linking to flag
|
||||
// library
|
||||
java_library {
|
||||
name: "ContentLibs2",
|
||||
defaults: ["ContentLibsDefault"],
|
||||
sdk_version: "current",
|
||||
libs: [
|
||||
// link the flag library for building purpose
|
||||
"aconfig_demo_flags_java_lib",
|
||||
],
|
||||
}
|
||||
|
||||
// This app is created to demonstrate the production version of the app
|
||||
// statically links to the production version of the flag library.
|
||||
android_app {
|
||||
name: "AconfigDemoActivity2",
|
||||
defaults: ["AconfigDemoActivityDefault"],
|
||||
static_libs: [
|
||||
"ContentLibs2",
|
||||
"aconfig_demo_flags_java_lib",
|
||||
]
|
||||
}
|
||||
|
||||
// This app is created to demonstrate the test version of app uses the same
|
||||
// ContentLibs2 library, but links to test version of the flag library.
|
||||
// Please check tests/unittests/Android.bp:AconfigDemoUnitTests2
|
||||
android_app {
|
||||
name: "AconfigDemoActivityTest2",
|
||||
defaults: ["AconfigDemoActivityDefault"],
|
||||
optimize: {
|
||||
enabled: false,
|
||||
},
|
||||
static_libs: [
|
||||
"ContentLibs2",
|
||||
"aconfig_demo_flags_java_lib",
|
||||
]
|
||||
}
|
||||
|
||||
1
samples/AconfigDemo/proguard.flags
Normal file
1
samples/AconfigDemo/proguard.flags
Normal file
@@ -0,0 +1 @@
|
||||
-keep class **.FakeFeatureFlagsImpl { *; }
|
||||
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- This test config file is auto-generated. -->
|
||||
<configuration description="Runs AconfigDemoUnitTests1.">
|
||||
<configuration description="Runs AconfigDemoUnitTests.">
|
||||
<target_preparer class="com.android.tradefed.targetprep.DeviceSetup">
|
||||
<option name="run-command" value="pm uninstall com.example.android.aconfig.demo" />
|
||||
<option name="run-command" value="pm uninstall com.example.android.aconfig.demo.tests" />
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
|
||||
<option name="cleanup-apks" value="true" />
|
||||
<option name="test-file-name" value="AconfigDemoUnitTests1.apk" />
|
||||
<option name="test-file-name" value="AconfigDemoActivityTest1.apk" />
|
||||
<option name="test-file-name" value="AconfigDemoUnitTests.apk" />
|
||||
<option name="test-file-name" value="AconfigDemoActivity.apk" />
|
||||
</target_preparer>
|
||||
|
||||
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2023 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.
|
||||
-->
|
||||
<!-- This test config file is auto-generated. -->
|
||||
<configuration description="Runs AconfigDemoUnitTests2.">
|
||||
<target_preparer class="com.android.tradefed.targetprep.DeviceSetup">
|
||||
<option name="run-command" value="pm uninstall com.example.android.aconfig.demo" />
|
||||
<option name="run-command" value="pm uninstall com.example.android.aconfig.demo.tests" />
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
|
||||
<option name="cleanup-apks" value="true" />
|
||||
<option name="test-file-name" value="AconfigDemoUnitTests2.apk" />
|
||||
<option name="test-file-name" value="AconfigDemoActivityTest2.apk" />
|
||||
</target_preparer>
|
||||
|
||||
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
|
||||
<option name="package" value="com.example.android.aconfig.demo.tests" />
|
||||
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
|
||||
</test>
|
||||
</configuration>
|
||||
@@ -24,7 +24,7 @@ java_test_host {
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "AconfigDemoUnitTests1",
|
||||
name: "AconfigDemoUnitTests",
|
||||
srcs: ["*.java"],
|
||||
certificate: "platform",
|
||||
static_libs: [
|
||||
@@ -34,23 +34,7 @@ android_test {
|
||||
"platform-test-annotations",
|
||||
],
|
||||
manifest: "AndroidManifest.xml",
|
||||
test_config: "AconfigDemoUnitTests1.xml",
|
||||
data: [":AconfigDemoActivityTest1"],
|
||||
instrumentation_for: "AconfigDemoActivityTest1",
|
||||
test_config: "AconfigDemoUnitTests.xml",
|
||||
data: [":AconfigDemoActivity"],
|
||||
instrumentation_for: "AconfigDemoActivity",
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "AconfigDemoUnitTests2",
|
||||
srcs: ["*.java"],
|
||||
certificate: "platform",
|
||||
static_libs: [
|
||||
"junit",
|
||||
"androidx.test.runner",
|
||||
"flag-junit-base",
|
||||
"platform-test-annotations",
|
||||
],
|
||||
manifest: "AndroidManifest.xml",
|
||||
test_config: "AconfigDemoUnitTests2.xml",
|
||||
data: [":AconfigDemoActivityTest2"],
|
||||
instrumentation_for: "AconfigDemoActivityTest2",
|
||||
}
|
||||
Reference in New Issue
Block a user