blob: f4e944a80ebf03596f6395530570419283e62dda [file] [log] [blame]
Jiyong Parkd1063c12019-07-17 20:08:41 +09001// 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 (
Jiyong Parkd1063c12019-07-17 20:08:41 +090018 "testing"
Jiyong Parkd1063c12019-07-17 20:08:41 +090019)
20
Paul Duffin82d90432019-11-30 09:24:33 +000021// Needed in an _test.go file in this package to ensure tests run correctly, particularly in IDE.
22func TestMain(m *testing.M) {
23 runTestWithBuildDir(m)
Jiyong Parkd1063c12019-07-17 20:08:41 +090024}
25
Jiyong Parka7bc8ad2019-10-15 15:20:07 +090026func TestDepNotInRequiredSdks(t *testing.T) {
27 testSdkError(t, `module "myjavalib".*depends on "otherlib".*that isn't part of the required SDKs:.*`, `
28 sdk {
29 name: "mysdk",
Paul Duffina0dbf432019-12-05 11:25:53 +000030 java_header_libs: ["sdkmember"],
Jiyong Parka7bc8ad2019-10-15 15:20:07 +090031 }
32
33 sdk_snapshot {
34 name: "mysdk@1",
Paul Duffina0dbf432019-12-05 11:25:53 +000035 java_header_libs: ["sdkmember_mysdk_1"],
Jiyong Parka7bc8ad2019-10-15 15:20:07 +090036 }
37
38 java_import {
39 name: "sdkmember",
40 prefer: false,
41 host_supported: true,
42 }
43
44 java_import {
45 name: "sdkmember_mysdk_1",
46 sdk_member_name: "sdkmember",
47 host_supported: true,
48 }
49
50 java_library {
51 name: "myjavalib",
52 srcs: ["Test.java"],
53 libs: [
54 "sdkmember",
55 "otherlib",
56 ],
57 system_modules: "none",
58 sdk_version: "none",
59 compile_dex: true,
60 host_supported: true,
61 }
62
63 // this lib is no in mysdk
64 java_library {
65 name: "otherlib",
66 srcs: ["Test.java"],
67 system_modules: "none",
68 sdk_version: "none",
69 compile_dex: true,
70 host_supported: true,
71 }
72
73 apex {
74 name: "myapex",
75 java_libs: ["myjavalib"],
76 uses_sdks: ["mysdk@1"],
77 key: "myapex.key",
78 certificate: ":myapex.cert",
79 }
80 `)
81}