1/*
2 * Copyright (C) 2008 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
17package android.test.mock;
18
19import android.content.res.AssetManager;
20import android.content.res.Resources;
21import android.content.res.Configuration;
22import android.content.res.TypedArray;
23import android.content.res.ColorStateList;
24import android.content.res.XmlResourceParser;
25import android.content.res.AssetFileDescriptor;
26import android.util.DisplayMetrics;
27import android.util.TypedValue;
28import android.util.AttributeSet;
29import android.graphics.drawable.Drawable;
30import android.graphics.Movie;
31
32import java.io.InputStream;
33
34/**
35 * A mock {@link android.content.res.Resources} class.  All methods are non-functional and throw
36 * {@link java.lang.UnsupportedOperationException}. Override it to provide the operations that you
37 * need.
38 */
39public class MockResources extends Resources {
40
41    public MockResources() {
42        super(new AssetManager(), null, null);
43    }
44
45    @Override
46    public void updateConfiguration(Configuration config, DisplayMetrics metrics) {
47        // this method is called from the constructor, so we just do nothing
48    }
49
50    @Override
51    public CharSequence getText(int id) throws NotFoundException {
52        throw new UnsupportedOperationException("mock object, not implemented");
53    }
54
55    @Override
56    public CharSequence getQuantityText(int id, int quantity) throws NotFoundException {
57        throw new UnsupportedOperationException("mock object, not implemented");
58    }
59
60    @Override
61    public String getString(int id) throws NotFoundException {
62        throw new UnsupportedOperationException("mock object, not implemented");
63    }
64
65    @Override
66    public String getString(int id, Object... formatArgs) throws NotFoundException {
67        throw new UnsupportedOperationException("mock object, not implemented");
68    }
69
70    @Override
71    public String getQuantityString(int id, int quantity, Object... formatArgs)
72            throws NotFoundException {
73        throw new UnsupportedOperationException("mock object, not implemented");
74    }
75
76    @Override
77    public String getQuantityString(int id, int quantity) throws NotFoundException {
78        throw new UnsupportedOperationException("mock object, not implemented");
79    }
80
81    @Override
82    public CharSequence getText(int id, CharSequence def) {
83        throw new UnsupportedOperationException("mock object, not implemented");
84    }
85
86    @Override
87    public CharSequence[] getTextArray(int id) throws NotFoundException {
88        throw new UnsupportedOperationException("mock object, not implemented");
89    }
90
91    @Override
92    public String[] getStringArray(int id) throws NotFoundException {
93        throw new UnsupportedOperationException("mock object, not implemented");
94    }
95
96    @Override
97    public int[] getIntArray(int id) throws NotFoundException {
98        throw new UnsupportedOperationException("mock object, not implemented");
99    }
100
101    @Override
102    public TypedArray obtainTypedArray(int id) throws NotFoundException {
103        throw new UnsupportedOperationException("mock object, not implemented");
104    }
105
106    @Override
107    public float getDimension(int id) throws NotFoundException {
108        throw new UnsupportedOperationException("mock object, not implemented");
109    }
110
111    @Override
112    public int getDimensionPixelOffset(int id) throws NotFoundException {
113        throw new UnsupportedOperationException("mock object, not implemented");
114    }
115
116    @Override
117    public int getDimensionPixelSize(int id) throws NotFoundException {
118        throw new UnsupportedOperationException("mock object, not implemented");
119    }
120
121    @Override
122    public Drawable getDrawable(int id) throws NotFoundException {
123        throw new UnsupportedOperationException("mock object, not implemented");
124    }
125
126    @Override
127    public Movie getMovie(int id) throws NotFoundException {
128        throw new UnsupportedOperationException("mock object, not implemented");
129    }
130
131    @Override
132    public int getColor(int id) throws NotFoundException {
133        throw new UnsupportedOperationException("mock object, not implemented");
134    }
135
136    @Override
137    public ColorStateList getColorStateList(int id) throws NotFoundException {
138        throw new UnsupportedOperationException("mock object, not implemented");
139    }
140
141    @Override
142    public int getInteger(int id) throws NotFoundException {
143        throw new UnsupportedOperationException("mock object, not implemented");
144    }
145
146    @Override
147    public XmlResourceParser getLayout(int id) throws NotFoundException {
148        throw new UnsupportedOperationException("mock object, not implemented");
149    }
150
151    @Override
152    public XmlResourceParser getAnimation(int id) throws NotFoundException {
153        throw new UnsupportedOperationException("mock object, not implemented");
154    }
155
156    @Override
157    public XmlResourceParser getXml(int id) throws NotFoundException {
158        throw new UnsupportedOperationException("mock object, not implemented");
159    }
160
161    @Override
162    public InputStream openRawResource(int id) throws NotFoundException {
163        throw new UnsupportedOperationException("mock object, not implemented");
164    }
165
166    @Override
167    public AssetFileDescriptor openRawResourceFd(int id) throws NotFoundException {
168        throw new UnsupportedOperationException("mock object, not implemented");
169    }
170
171    @Override
172    public void getValue(int id, TypedValue outValue, boolean resolveRefs)
173            throws NotFoundException {
174        throw new UnsupportedOperationException("mock object, not implemented");
175    }
176
177    @Override
178    public void getValue(String name, TypedValue outValue, boolean resolveRefs)
179            throws NotFoundException {
180        throw new UnsupportedOperationException("mock object, not implemented");
181    }
182
183    @Override
184    public TypedArray obtainAttributes(AttributeSet set, int[] attrs) {
185        throw new UnsupportedOperationException("mock object, not implemented");
186    }
187
188    @Override
189    public DisplayMetrics getDisplayMetrics() {
190        throw new UnsupportedOperationException("mock object, not implemented");
191    }
192
193    @Override
194    public Configuration getConfiguration() {
195        throw new UnsupportedOperationException("mock object, not implemented");
196    }
197
198    @Override
199    public int getIdentifier(String name, String defType, String defPackage) {
200        throw new UnsupportedOperationException("mock object, not implemented");
201    }
202
203    @Override
204    public String getResourceName(int resid) throws NotFoundException {
205        throw new UnsupportedOperationException("mock object, not implemented");
206    }
207
208    @Override
209    public String getResourcePackageName(int resid) throws NotFoundException {
210        throw new UnsupportedOperationException("mock object, not implemented");
211    }
212
213    @Override
214    public String getResourceTypeName(int resid) throws NotFoundException {
215        throw new UnsupportedOperationException("mock object, not implemented");
216    }
217
218    @Override
219    public String getResourceEntryName(int resid) throws NotFoundException {
220        throw new UnsupportedOperationException("mock object, not implemented");
221    }
222}
223