Home | History | Annotate | Download | only in java
      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) {
     25 	expected := []string{"Foo", "Bar"}
     26 	module := LibraryFactory().(*Library)
     27 	module.properties.Libs = append(module.properties.Libs, expected...)
     28 	dpInfo := &android.IdeInfo{}
     29 
     30 	module.IDEInfo(dpInfo)
     31 
     32 	if !reflect.DeepEqual(dpInfo.Deps, expected) {
     33 		t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected)
     34 	}
     35 }
     36 
     37 func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
     38 	expected := []string{"Foo", "Bar"}
     39 	module := LibraryFactory().(*Library)
     40 	module.properties.Static_libs = append(module.properties.Static_libs, expected...)
     41 	dpInfo := &android.IdeInfo{}
     42 
     43 	module.IDEInfo(dpInfo)
     44 
     45 	if !reflect.DeepEqual(dpInfo.Deps, expected) {
     46 		t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected)
     47 	}
     48 }
     49 
     50 func TestCollectJavaLibraryPropertiesAddScrs(t *testing.T) {
     51 	expected := []string{"Foo", "Bar"}
     52 	module := LibraryFactory().(*Library)
     53 	module.expandIDEInfoCompiledSrcs = append(module.expandIDEInfoCompiledSrcs, expected...)
     54 	dpInfo := &android.IdeInfo{}
     55 
     56 	module.IDEInfo(dpInfo)
     57 
     58 	if !reflect.DeepEqual(dpInfo.Srcs, expected) {
     59 		t.Errorf("Library.IDEInfo() Srcs = %v, want %v", dpInfo.Srcs, expected)
     60 	}
     61 }
     62 
     63 func TestCollectJavaLibraryPropertiesAddAidlIncludeDirs(t *testing.T) {
     64 	expected := []string{"Foo", "Bar"}
     65 	module := LibraryFactory().(*Library)
     66 	module.deviceProperties.Aidl.Include_dirs = append(module.deviceProperties.Aidl.Include_dirs, expected...)
     67 	dpInfo := &android.IdeInfo{}
     68 
     69 	module.IDEInfo(dpInfo)
     70 
     71 	if !reflect.DeepEqual(dpInfo.Aidl_include_dirs, expected) {
     72 		t.Errorf("Library.IDEInfo() Aidl_include_dirs = %v, want %v", dpInfo.Aidl_include_dirs, expected)
     73 	}
     74 }
     75 
     76 func TestCollectJavaLibraryPropertiesAddJarjarRules(t *testing.T) {
     77 	expected := "Jarjar_rules.txt"
     78 	module := LibraryFactory().(*Library)
     79 	module.expandJarjarRules = android.PathForTesting(expected)
     80 	dpInfo := &android.IdeInfo{}
     81 
     82 	module.IDEInfo(dpInfo)
     83 
     84 	if dpInfo.Jarjar_rules[0] != expected {
     85 		t.Errorf("Library.IDEInfo() Jarjar_rules = %v, want %v", dpInfo.Jarjar_rules[0], expected)
     86 	}
     87 }
     88