blob: 4b586e4d7fad2a0bd4aece7b79b2d21d6eafd1d4 [file] [log] [blame]
Jiakai Zhang4d90da22023-07-12 16:51:48 +01001// 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
Cole Faustf8231dd2023-04-21 17:37:11 -070024 cfg.productVariables = ProductVariables{
Jiakai Zhang4d90da22023-07-12 16:51:48 +010025 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}