1 /*
2  * Copyright (C) 2016 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 com.android.server.wifi;
18 
19 import java.util.HashMap;
20 
21 public class MockResources extends android.test.mock.MockResources {
22 
23     private HashMap<Integer, Boolean> mBooleanValues;
24     private HashMap<Integer, Integer> mIntegerValues;
25     private HashMap<Integer, String>  mStringValues;
26     private HashMap<Integer, CharSequence> mTextValues;
27     private HashMap<Integer, int[]> mIntArrayValues;
28     private HashMap<Integer, String[]> mStringArrayValues;
29 
MockResources()30     public MockResources() {
31         mBooleanValues = new HashMap<Integer, Boolean>();
32         mIntegerValues = new HashMap<Integer, Integer>();
33         mStringValues  = new HashMap<Integer, String>();
34         mTextValues    = new HashMap<Integer, CharSequence>();
35         mIntArrayValues = new HashMap<Integer, int[]>();
36         mStringArrayValues = new HashMap<Integer, String[]>();
37     }
38 
39     @Override
getBoolean(int id)40     public boolean getBoolean(int id) {
41         if (mBooleanValues.containsKey(id)) {
42             return mBooleanValues.get(id);
43         } else {
44             return false;
45         }
46     }
47 
48     @Override
getInteger(int id)49     public int getInteger(int id) {
50         if (mIntegerValues.containsKey(id)) {
51             return mIntegerValues.get(id);
52         } else {
53             return 0;
54         }
55     }
56 
57     @Override
getString(int id)58     public String getString(int id) {
59         if (mStringValues.containsKey(id)) {
60             return mStringValues.get(id);
61         } else {
62             return null;
63         }
64     }
65 
66     @Override
getText(int id)67     public CharSequence getText(int id) {
68         if (mTextValues.containsKey(id))  {
69             return mTextValues.get(id);
70         } else {
71             return null;
72         }
73     }
74 
75     @Override
getIntArray(int id)76     public int[] getIntArray(int id) {
77         if (mIntArrayValues.containsKey(id))  {
78             return mIntArrayValues.get(id);
79         } else {
80             return null;
81         }
82     }
83 
84     @Override
getStringArray(int id)85     public String[] getStringArray(int id) {
86         if (mStringArrayValues.containsKey(id))  {
87             return mStringArrayValues.get(id);
88         } else {
89             return null;
90         }
91     }
92 
93     @Override
getColor(int id)94     public int getColor(int id) {
95         return 0;
96     }
97 
setBoolean(int id, boolean value)98     public void setBoolean(int id, boolean value) {
99         mBooleanValues.put(id, value);
100     }
101 
setInteger(int id, int value)102     public void setInteger(int id, int value) {
103         mIntegerValues.put(id, value);
104     }
105 
setString(int id, String value)106     public void setString(int id, String value) {
107         mStringValues.put(id, value);
108     }
109 
setText(int id, CharSequence value)110     public void setText(int id, CharSequence value) {
111         mTextValues.put(id, value);
112     }
113 
setIntArray(int id, int[] value)114     public void setIntArray(int id, int[] value) {
115         mIntArrayValues.put(id, value);
116     }
117 
setStringArray(int id, String[] value)118     public void setStringArray(int id, String[] value) {
119         mStringArrayValues.put(id, value);
120     }
121 }
122