xref: /aosp_15_r20/build/soong/android/configured_jars_test.go (revision 333d2b3687b3a337dbcca9d65000bca186795e39)
1// Copyright 2023 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package android
16
17import (
18	"testing"
19)
20
21func TestOverrideConfiguredJarLocationFor(t *testing.T) {
22	cfg := NullConfig("", "")
23
24	cfg.productVariables = ProductVariables{
25		ConfiguredJarLocationOverrides: []string{
26			"platform:libfoo-old:com.android.foo:libfoo-new",
27			"com.android.bar:libbar-old:platform:libbar-new",
28		},
29	}
30
31	apex, jar := OverrideConfiguredJarLocationFor(cfg, "platform", "libfoo-old")
32	AssertStringEquals(t, "", "com.android.foo", apex)
33	AssertStringEquals(t, "", "libfoo-new", jar)
34
35	apex, jar = OverrideConfiguredJarLocationFor(cfg, "platform", "libbar-old")
36	AssertStringEquals(t, "", "platform", apex)
37	AssertStringEquals(t, "", "libbar-old", jar)
38
39	apex, jar = OverrideConfiguredJarLocationFor(cfg, "com.android.bar", "libbar-old")
40	AssertStringEquals(t, "", "platform", apex)
41	AssertStringEquals(t, "", "libbar-new", jar)
42
43	apex, jar = OverrideConfiguredJarLocationFor(cfg, "platform", "libbar-old")
44	AssertStringEquals(t, "", "platform", apex)
45	AssertStringEquals(t, "", "libbar-old", jar)
46}
47