Jiakai Zhang | 4d90da2 | 2023-07-12 16:51:48 +0100 | [diff] [blame] | 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 | |
| 15 | package android |
| 16 | |
| 17 | import ( |
| 18 | "testing" |
| 19 | ) |
| 20 | |
| 21 | func TestOverrideConfiguredJarLocationFor(t *testing.T) { |
| 22 | cfg := NullConfig("", "") |
| 23 | |
Cole Faust | f8231dd | 2023-04-21 17:37:11 -0700 | [diff] [blame] | 24 | cfg.productVariables = ProductVariables{ |
Jiakai Zhang | 4d90da2 | 2023-07-12 16:51:48 +0100 | [diff] [blame] | 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 | } |