blob: 46e72967c94777d75f08a0545371f06939b56a88 [file] [log] [blame]
Brandon Lee5d45c6f2018-08-15 15:35:38 -07001// 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
15package java
16
17import (
18 "reflect"
19 "testing"
20
21 "android/soong/android"
22)
23
24func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070025 t.Parallel()
Brandon Lee5d45c6f2018-08-15 15:35:38 -070026 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
38func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070039 t.Parallel()
Brandon Lee5d45c6f2018-08-15 15:35:38 -070040 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
52func TestCollectJavaLibraryPropertiesAddScrs(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070053 t.Parallel()
Brandon Lee5d45c6f2018-08-15 15:35:38 -070054 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
66func TestCollectJavaLibraryPropertiesAddAidlIncludeDirs(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070067 t.Parallel()
Brandon Lee5d45c6f2018-08-15 15:35:38 -070068 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
80func TestCollectJavaLibraryPropertiesAddJarjarRules(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070081 t.Parallel()
Brandon Lee5d45c6f2018-08-15 15:35:38 -070082 expected := "Jarjar_rules.txt"
83 module := LibraryFactory().(*Library)
Steven Morelandc4efd9c2019-01-18 11:51:25 -080084 module.expandJarjarRules = android.PathForTesting(expected)
Brandon Lee5d45c6f2018-08-15 15:35:38 -070085 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}