Add "exported" mode to xx_aconfig_library build rules
Test: added unit tests and CI
Bug: 309990433
Change-Id: Iae1b85265d9780bde7d41ec2ec6e8e441c2b3814
diff --git a/aconfig/java_aconfig_library_test.go b/aconfig/java_aconfig_library_test.go
index af50848..05532e7 100644
--- a/aconfig/java_aconfig_library_test.go
+++ b/aconfig/java_aconfig_library_test.go
@@ -178,14 +178,48 @@
android.AssertStringEquals(t, "rule must contain test mode", rule.Args["mode"], ruleMode)
}
+func testCodegenModeWithError(t *testing.T, bpMode string, err string) {
+ android.GroupFixturePreparers(
+ PrepareForTestWithAconfigBuildComponents,
+ java.PrepareForTestWithJavaDefaultModules).
+ ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(err)).
+ RunTestWithBp(t, fmt.Sprintf(`
+ aconfig_declarations {
+ name: "my_aconfig_declarations",
+ package: "com.example.package",
+ srcs: ["foo.aconfig"],
+ }
+
+ java_aconfig_library {
+ name: "my_java_aconfig_library",
+ aconfig_declarations: "my_aconfig_declarations",
+ %s
+ }
+ `, bpMode))
+}
+
func TestDefaultProdMode(t *testing.T) {
testCodegenMode(t, "", "production")
}
func TestProdMode(t *testing.T) {
- testCodegenMode(t, "test: false,", "production")
+ testCodegenMode(t, "mode: `production`,", "production")
}
func TestTestMode(t *testing.T) {
- testCodegenMode(t, "test: true,", "test")
+ testCodegenMode(t, "mode: `test`,", "test")
+}
+
+func TestExportedMode(t *testing.T) {
+ testCodegenMode(t, "mode: `exported`,", "exported")
+}
+
+func TestUnsupportedMode(t *testing.T) {
+ testCodegenModeWithError(t, "mode: `unsupported`,", "mode: \"unsupported\" is not a supported mode")
+}
+
+// TODO: remove this test case when test prop is removed
+func TestBothModeAndTestAreSet(t *testing.T) {
+ testCodegenModeWithError(t, "mode: `test`, test: true",
+ "test prop should not be specified when mode prop is set")
}