| Joe Onorato | 175073c | 2023-06-01 14:42:59 -0700 | [diff] [blame] | 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 |  | 
| Joe Onorato | 981c926 | 2023-06-21 15:16:23 -0700 | [diff] [blame] | 15 | package aconfig | 
| Joe Onorato | 175073c | 2023-06-01 14:42:59 -0700 | [diff] [blame] | 16 |  | 
 | 17 | import ( | 
 | 18 | 	"testing" | 
 | 19 |  | 
 | 20 | 	"android/soong/android" | 
 | 21 | ) | 
 | 22 |  | 
| Joe Onorato | 981c926 | 2023-06-21 15:16:23 -0700 | [diff] [blame] | 23 | func TestAconfigValueSet(t *testing.T) { | 
| Joe Onorato | 175073c | 2023-06-01 14:42:59 -0700 | [diff] [blame] | 24 | 	bp := ` | 
| Joe Onorato | 981c926 | 2023-06-21 15:16:23 -0700 | [diff] [blame] | 25 | 				aconfig_values { | 
| Joe Onorato | 175073c | 2023-06-01 14:42:59 -0700 | [diff] [blame] | 26 | 					name: "one", | 
 | 27 | 					srcs: [ "blah.aconfig_values" ], | 
| Joe Onorato | 81b25ed | 2023-06-21 13:49:37 -0700 | [diff] [blame] | 28 | 					package: "foo.package" | 
| Joe Onorato | 175073c | 2023-06-01 14:42:59 -0700 | [diff] [blame] | 29 | 				} | 
 | 30 |  | 
| Joe Onorato | 981c926 | 2023-06-21 15:16:23 -0700 | [diff] [blame] | 31 | 				aconfig_value_set { | 
| Joe Onorato | 175073c | 2023-06-01 14:42:59 -0700 | [diff] [blame] | 32 | 					name: "module_name", | 
 | 33 |           values: [ "one" ], | 
 | 34 | 				} | 
 | 35 | 			` | 
 | 36 | 	result := runTest(t, android.FixtureExpectsNoErrors, bp) | 
 | 37 |  | 
 | 38 | 	module := result.ModuleForTests("module_name", "").Module().(*ValueSetModule) | 
 | 39 |  | 
 | 40 | 	// Check that the provider has the right contents | 
| Colin Cross | 5a37718 | 2023-12-14 14:46:23 -0800 | [diff] [blame] | 41 | 	depData, _ := android.SingletonModuleProvider(result, module, valueSetProviderKey) | 
| Joe Onorato | 81b25ed | 2023-06-21 13:49:37 -0700 | [diff] [blame] | 42 | 	android.AssertStringEquals(t, "AvailablePackages", "blah.aconfig_values", depData.AvailablePackages["foo.package"][0].String()) | 
| Joe Onorato | 175073c | 2023-06-01 14:42:59 -0700 | [diff] [blame] | 43 | } |