blob: e0d8f7d5ada7894d29c74268c9f98b949c766a69 [file] [log] [blame]
Joe Onorato175073c2023-06-01 14:42:59 -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
Joe Onorato981c9262023-06-21 15:16:23 -070015package aconfig
Joe Onorato175073c2023-06-01 14:42:59 -070016
17import (
18 "strings"
19 "testing"
20
21 "android/soong/android"
22)
23
Joe Onorato981c9262023-06-21 15:16:23 -070024func TestAconfigDeclarations(t *testing.T) {
Joe Onorato175073c2023-06-01 14:42:59 -070025 bp := `
Joe Onorato981c9262023-06-21 15:16:23 -070026 aconfig_declarations {
Joe Onorato175073c2023-06-01 14:42:59 -070027 name: "module_name",
Joe Onorato81b25ed2023-06-21 13:49:37 -070028 package: "com.example.package",
Zhi Dou8a35a6f2023-07-19 18:04:24 +000029 srcs: [
30 "foo.aconfig",
31 "bar.aconfig",
32 ],
Joe Onorato175073c2023-06-01 14:42:59 -070033 }
34 `
35 result := runTest(t, android.FixtureExpectsNoErrors, bp)
36
Joe Onorato981c9262023-06-21 15:16:23 -070037 module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)
Joe Onorato175073c2023-06-01 14:42:59 -070038
39 // Check that the provider has the right contents
Joe Onorato981c9262023-06-21 15:16:23 -070040 depData := result.ModuleProvider(module, declarationsProviderKey).(declarationsProviderData)
Joe Onorato81b25ed2023-06-21 13:49:37 -070041 android.AssertStringEquals(t, "package", depData.Package, "com.example.package")
42 if !strings.HasSuffix(depData.IntermediatePath.String(), "/intermediate.pb") {
43 t.Errorf("Missing intermediates path in provider: %s", depData.IntermediatePath.String())
Joe Onorato175073c2023-06-01 14:42:59 -070044 }
45}