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.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.net.wifi;
18 
19 import android.os.PersistableBundle;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 
24 /** Test utils for {@link OuiKeyedData} */
25 public class OuiKeyedDataUtil {
26     private static final String STRING_FIELD_KEY = "stringField";
27     private static final String ARRAY_FIELD_KEY = "arrayField";
28 
29     private static final String STRING_FIELD_VALUE = "someString";
30     private static final int[] ARRAY_FIELD_VALUE = new int[] {1, 2, 3};
31 
32     /**
33      * Generate a single OuiKeyedData object containing several test fields.
34      */
createTestOuiKeyedData(int oui)35     public static OuiKeyedData createTestOuiKeyedData(int oui) {
36         PersistableBundle bundle = new PersistableBundle();
37         bundle.putString(STRING_FIELD_KEY, STRING_FIELD_VALUE);
38         bundle.putIntArray(ARRAY_FIELD_KEY, ARRAY_FIELD_VALUE);
39         return new OuiKeyedData.Builder(oui, bundle).build();
40     }
41 
42     /**
43      * Generate a list of OuiKeyedData objects, each containing several test fields.
44      */
createTestOuiKeyedDataList(int size)45     public static List<OuiKeyedData> createTestOuiKeyedDataList(int size) {
46         List<OuiKeyedData> ouiKeyedDataList = new ArrayList<>();
47         for (int i = 0; i < size; i++) {
48             ouiKeyedDataList.add(createTestOuiKeyedData(i + 1));
49         }
50         return ouiKeyedDataList;
51     }
52 }
53