1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0dd
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <vector>
20 #include <utility>
21 #include <functional>
22 #include <string>
23 
24 // The pair describes a feature flag by an aconfig function and a raw
25 // flag name. For a legacy feature flag, the function pointer is null.
26 typedef std::pair<std::function<bool()>, std::string> p_flag;
27 
28 namespace android::test::flag {
29 
30 // Returns a group of flags that don't meet expected conditions. Each
31 // element in the returned group contains an expected condition and a
32 // feature flag represented by a string. The input parameter `flag_conditions`
33 // is a group of pairs, with each pair containing the expected condition
34 // and a group of feature flags.
35 std::vector<std::pair<bool, std::string>> GetFlagsNotMetRequirements(
36     const std::vector<std::pair<bool, std::vector<p_flag>>> flag_conditions);
37 
38 // Returns true if the value of `feature_flag` meets `expected_condition`,
39 // false when the condition doesn't meet.
40 bool CheckFlagCondition(bool expected_condition, const p_flag feature_flag);
41 
42 }  // namespace android::test::flag