• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 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 sdk
16
17import (
18	"testing"
19)
20
21// Ensure that module_exports generates a module_exports_snapshot module.
22func TestModuleExportsSnapshot(t *testing.T) {
23	t.Parallel()
24	packageBp := `
25		module_exports {
26			name: "myexports",
27			java_libs: [
28				"myjavalib",
29			],
30		}
31
32		java_library {
33			name: "myjavalib",
34			srcs: ["Test.java"],
35			system_modules: "none",
36			sdk_version: "none",
37		}
38	`
39
40	result := testSdkWithFs(t, ``,
41		map[string][]byte{
42			"package/Test.java":  nil,
43			"package/Android.bp": []byte(packageBp),
44		})
45
46	CheckSnapshot(t, result, "myexports", "package",
47		checkAndroidBpContents(`
48// This is auto-generated. DO NOT EDIT.
49
50apex_contributions_defaults {
51    name: "myexports.contributions",
52    contents: ["prebuilt_myjavalib"],
53}
54
55java_import {
56    name: "myjavalib",
57    prefer: false,
58    visibility: ["//visibility:public"],
59    apex_available: ["//apex_available:platform"],
60    jars: ["java/myjavalib.jar"],
61}
62`),
63	)
64}
65