• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.0
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 package android.aconfig.test;
18 
19 import static org.junit.Assert.assertTrue;
20 
21 import android.aconfig.DeviceProtosTestUtil;
22 import android.aconfig.nano.Aconfig.parsed_flag;
23 
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.junit.runners.JUnit4;
27 
28 import java.util.List;
29 import java.util.Set;
30 
31 @RunWith(JUnit4.class)
32 public class DeviceProtosTestUtilTest {
33 
34     private static final Set<String> PLATFORM_CONTAINERS = Set.of("system", "vendor", "product");
35 
36     @Test
testDeviceProtos_loadAndParseFlagProtos()37     public void testDeviceProtos_loadAndParseFlagProtos() throws Exception {
38         List<parsed_flag> flags = DeviceProtosTestUtil.loadAndParseFlagProtos();
39         int platformFlags = 0;
40         int mainlineFlags = 0;
41         for (parsed_flag pf : flags) {
42             if (PLATFORM_CONTAINERS.contains(pf.container)) {
43                 platformFlags++;
44             } else {
45                 mainlineFlags++;
46             }
47         }
48 
49         assertTrue(platformFlags > 3);
50         assertTrue(mainlineFlags > 3);
51     }
52 }
53