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