Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 1 | // Copyright 2018 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 java |
| 16 | |
| 17 | import ( |
| 18 | "reflect" |
| 19 | "testing" |
| 20 | |
| 21 | "android/soong/android" |
| 22 | ) |
| 23 | |
| 24 | func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) { |
Colin Cross | 323dc60 | 2020-09-18 14:25:31 -0700 | [diff] [blame] | 25 | t.Parallel() |
Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 26 | expected := []string{"Foo", "Bar"} |
| 27 | module := LibraryFactory().(*Library) |
| 28 | module.properties.Libs = append(module.properties.Libs, expected...) |
| 29 | dpInfo := &android.IdeInfo{} |
| 30 | |
| 31 | module.IDEInfo(dpInfo) |
| 32 | |
| 33 | if !reflect.DeepEqual(dpInfo.Deps, expected) { |
| 34 | t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) { |
Colin Cross | 323dc60 | 2020-09-18 14:25:31 -0700 | [diff] [blame] | 39 | t.Parallel() |
Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 40 | expected := []string{"Foo", "Bar"} |
| 41 | module := LibraryFactory().(*Library) |
| 42 | module.properties.Static_libs = append(module.properties.Static_libs, expected...) |
| 43 | dpInfo := &android.IdeInfo{} |
| 44 | |
| 45 | module.IDEInfo(dpInfo) |
| 46 | |
| 47 | if !reflect.DeepEqual(dpInfo.Deps, expected) { |
| 48 | t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func TestCollectJavaLibraryPropertiesAddScrs(t *testing.T) { |
Colin Cross | 323dc60 | 2020-09-18 14:25:31 -0700 | [diff] [blame] | 53 | t.Parallel() |
Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 54 | expected := []string{"Foo", "Bar"} |
| 55 | module := LibraryFactory().(*Library) |
| 56 | module.expandIDEInfoCompiledSrcs = append(module.expandIDEInfoCompiledSrcs, expected...) |
| 57 | dpInfo := &android.IdeInfo{} |
| 58 | |
| 59 | module.IDEInfo(dpInfo) |
| 60 | |
| 61 | if !reflect.DeepEqual(dpInfo.Srcs, expected) { |
| 62 | t.Errorf("Library.IDEInfo() Srcs = %v, want %v", dpInfo.Srcs, expected) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | func TestCollectJavaLibraryPropertiesAddAidlIncludeDirs(t *testing.T) { |
Colin Cross | 323dc60 | 2020-09-18 14:25:31 -0700 | [diff] [blame] | 67 | t.Parallel() |
Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 68 | expected := []string{"Foo", "Bar"} |
| 69 | module := LibraryFactory().(*Library) |
| 70 | module.deviceProperties.Aidl.Include_dirs = append(module.deviceProperties.Aidl.Include_dirs, expected...) |
| 71 | dpInfo := &android.IdeInfo{} |
| 72 | |
| 73 | module.IDEInfo(dpInfo) |
| 74 | |
| 75 | if !reflect.DeepEqual(dpInfo.Aidl_include_dirs, expected) { |
| 76 | t.Errorf("Library.IDEInfo() Aidl_include_dirs = %v, want %v", dpInfo.Aidl_include_dirs, expected) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | func TestCollectJavaLibraryPropertiesAddJarjarRules(t *testing.T) { |
Colin Cross | 323dc60 | 2020-09-18 14:25:31 -0700 | [diff] [blame] | 81 | t.Parallel() |
Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 82 | expected := "Jarjar_rules.txt" |
| 83 | module := LibraryFactory().(*Library) |
Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 84 | module.expandJarjarRules = android.PathForTesting(expected) |
Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 85 | dpInfo := &android.IdeInfo{} |
| 86 | |
| 87 | module.IDEInfo(dpInfo) |
| 88 | |
| 89 | if dpInfo.Jarjar_rules[0] != expected { |
| 90 | t.Errorf("Library.IDEInfo() Jarjar_rules = %v, want %v", dpInfo.Jarjar_rules[0], expected) |
| 91 | } |
| 92 | } |