• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012 AndroidPlot.com
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.androidplot.mock;
18 
19 import android.content.*;
20 import android.content.pm.ApplicationInfo;
21 import android.content.pm.PackageManager;
22 import android.content.res.AssetManager;
23 import android.content.res.Resources;
24 import android.database.DatabaseErrorHandler;
25 import android.database.sqlite.SQLiteDatabase;
26 import android.graphics.Bitmap;
27 import android.graphics.Paint;
28 import android.graphics.drawable.Drawable;
29 import android.net.Uri;
30 import android.os.Bundle;
31 import android.os.Handler;
32 import android.os.Looper;
33 import mockit.Instantiation;
34 import mockit.Mock;
35 import mockit.MockClass;
36 
37 import java.io.*;
38 
39 @MockClass(realClass = Context.class)
40 public class MockContext {
41 
42     /**
43      * Useful for when methods are going to actually be called on a Context instance.
44      * See {@link com.androidplot.PlotTest#testConfigure()} for an example.
45      */
46     public static final class MockContext2 extends Context {
47 
MockContext2()48         public MockContext2() {}
49 
50         @Override
getAssets()51         public AssetManager getAssets() {
52             return null;  //To change body of implemented methods use File | Settings | File Templates.
53         }
54 
55         @Mock
getResources()56         public android.content.res.Resources getResources() { throw new IllegalArgumentException();}
57 
58         @Override
getPackageManager()59         public PackageManager getPackageManager() {
60             return null;  //To change body of implemented methods use File | Settings | File Templates.
61         }
62 
63         @Override
getContentResolver()64         public ContentResolver getContentResolver() {
65             return null;  //To change body of implemented methods use File | Settings | File Templates.
66         }
67 
68         @Override
getMainLooper()69         public Looper getMainLooper() {
70             return null;  //To change body of implemented methods use File | Settings | File Templates.
71         }
72 
73         @Override
getApplicationContext()74         public Context getApplicationContext() {
75             return null;  //To change body of implemented methods use File | Settings | File Templates.
76         }
77 
78         @Override
setTheme(int i)79         public void setTheme(int i) {
80             //To change body of implemented methods use File | Settings | File Templates.
81         }
82 
83         @Override
getTheme()84         public Resources.Theme getTheme() {
85             return null;  //To change body of implemented methods use File | Settings | File Templates.
86         }
87 
88         @Override
getClassLoader()89         public ClassLoader getClassLoader() {
90             return null;  //To change body of implemented methods use File | Settings | File Templates.
91         }
92 
93         @Override
getPackageName()94         public String getPackageName() {
95             return null;  //To change body of implemented methods use File | Settings | File Templates.
96         }
97 
98         @Override
getApplicationInfo()99         public ApplicationInfo getApplicationInfo() {
100             return null;  //To change body of implemented methods use File | Settings | File Templates.
101         }
102 
103         @Override
getPackageResourcePath()104         public String getPackageResourcePath() {
105             return null;  //To change body of implemented methods use File | Settings | File Templates.
106         }
107 
108         @Override
getPackageCodePath()109         public String getPackageCodePath() {
110             return null;  //To change body of implemented methods use File | Settings | File Templates.
111         }
112 
113         @Override
getSharedPreferences(String s, int i)114         public SharedPreferences getSharedPreferences(String s, int i) {
115             return null;  //To change body of implemented methods use File | Settings | File Templates.
116         }
117 
118         @Override
openFileInput(String s)119         public FileInputStream openFileInput(String s) throws FileNotFoundException {
120             return null;  //To change body of implemented methods use File | Settings | File Templates.
121         }
122 
123         @Override
openFileOutput(String s, int i)124         public FileOutputStream openFileOutput(String s, int i) throws FileNotFoundException {
125             return null;  //To change body of implemented methods use File | Settings | File Templates.
126         }
127 
128         @Override
deleteFile(String s)129         public boolean deleteFile(String s) {
130             return false;  //To change body of implemented methods use File | Settings | File Templates.
131         }
132 
133         @Override
getFileStreamPath(String s)134         public File getFileStreamPath(String s) {
135             return null;  //To change body of implemented methods use File | Settings | File Templates.
136         }
137 
138         @Override
getFilesDir()139         public File getFilesDir() {
140             return null;  //To change body of implemented methods use File | Settings | File Templates.
141         }
142 
143         @Override
getExternalFilesDir(String s)144         public File getExternalFilesDir(String s) {
145             return null;  //To change body of implemented methods use File | Settings | File Templates.
146         }
147 
148         @Override
getObbDir()149         public File getObbDir() {
150             return null;  //To change body of implemented methods use File | Settings | File Templates.
151         }
152 
153         @Override
getCacheDir()154         public File getCacheDir() {
155             return null;  //To change body of implemented methods use File | Settings | File Templates.
156         }
157 
158         @Override
getExternalCacheDir()159         public File getExternalCacheDir() {
160             return null;  //To change body of implemented methods use File | Settings | File Templates.
161         }
162 
163         @Override
fileList()164         public String[] fileList() {
165             return new String[0];  //To change body of implemented methods use File | Settings | File Templates.
166         }
167 
168         @Override
getDir(String s, int i)169         public File getDir(String s, int i) {
170             return null;  //To change body of implemented methods use File | Settings | File Templates.
171         }
172 
173         @Override
openOrCreateDatabase(String s, int i, SQLiteDatabase.CursorFactory cursorFactory)174         public SQLiteDatabase openOrCreateDatabase(String s, int i, SQLiteDatabase.CursorFactory cursorFactory) {
175             return null;  //To change body of implemented methods use File | Settings | File Templates.
176         }
177 
178         @Override
openOrCreateDatabase(String s, int i, SQLiteDatabase.CursorFactory cursorFactory, DatabaseErrorHandler databaseErrorHandler)179         public SQLiteDatabase openOrCreateDatabase(String s, int i, SQLiteDatabase.CursorFactory cursorFactory, DatabaseErrorHandler databaseErrorHandler) {
180             return null;  //To change body of implemented methods use File | Settings | File Templates.
181         }
182 
183         @Override
deleteDatabase(String s)184         public boolean deleteDatabase(String s) {
185             return false;  //To change body of implemented methods use File | Settings | File Templates.
186         }
187 
188         @Override
getDatabasePath(String s)189         public File getDatabasePath(String s) {
190             return null;  //To change body of implemented methods use File | Settings | File Templates.
191         }
192 
193         @Override
databaseList()194         public String[] databaseList() {
195             return new String[0];  //To change body of implemented methods use File | Settings | File Templates.
196         }
197 
198         @Override
getWallpaper()199         public Drawable getWallpaper() {
200             return null;  //To change body of implemented methods use File | Settings | File Templates.
201         }
202 
203         @Override
peekWallpaper()204         public Drawable peekWallpaper() {
205             return null;  //To change body of implemented methods use File | Settings | File Templates.
206         }
207 
208         @Override
getWallpaperDesiredMinimumWidth()209         public int getWallpaperDesiredMinimumWidth() {
210             return 0;  //To change body of implemented methods use File | Settings | File Templates.
211         }
212 
213         @Override
getWallpaperDesiredMinimumHeight()214         public int getWallpaperDesiredMinimumHeight() {
215             return 0;  //To change body of implemented methods use File | Settings | File Templates.
216         }
217 
218         @Override
setWallpaper(Bitmap bitmap)219         public void setWallpaper(Bitmap bitmap) throws IOException {
220             //To change body of implemented methods use File | Settings | File Templates.
221         }
222 
223         @Override
setWallpaper(InputStream inputStream)224         public void setWallpaper(InputStream inputStream) throws IOException {
225             //To change body of implemented methods use File | Settings | File Templates.
226         }
227 
228         @Override
clearWallpaper()229         public void clearWallpaper() throws IOException {
230             //To change body of implemented methods use File | Settings | File Templates.
231         }
232 
233         @Override
startActivity(Intent intent)234         public void startActivity(Intent intent) {
235             //To change body of implemented methods use File | Settings | File Templates.
236         }
237 
238         //@Override
startActivity(Intent intent, Bundle bundle)239         public void startActivity(Intent intent, Bundle bundle) {
240             //To change body of implemented methods use File | Settings | File Templates.
241         }
242 
243         @Override
startActivities(Intent[] intents)244         public void startActivities(Intent[] intents) {
245             //To change body of implemented methods use File | Settings | File Templates.
246         }
247 
248         //@Override
startActivities(Intent[] intents, Bundle bundle)249         public void startActivities(Intent[] intents, Bundle bundle) {
250             //To change body of implemented methods use File | Settings | File Templates.
251         }
252 
253         @Override
startIntentSender(IntentSender intentSender, Intent intent, int i, int i1, int i2)254         public void startIntentSender(IntentSender intentSender, Intent intent, int i, int i1, int i2) throws IntentSender.SendIntentException {
255             //To change body of implemented methods use File | Settings | File Templates.
256         }
257 
258         //@Override
startIntentSender(IntentSender intentSender, Intent intent, int i, int i1, int i2, Bundle bundle)259         public void startIntentSender(IntentSender intentSender, Intent intent, int i, int i1, int i2, Bundle bundle) throws IntentSender.SendIntentException {
260             //To change body of implemented methods use File | Settings | File Templates.
261         }
262 
263         @Override
sendBroadcast(Intent intent)264         public void sendBroadcast(Intent intent) {
265             //To change body of implemented methods use File | Settings | File Templates.
266         }
267 
268         @Override
sendBroadcast(Intent intent, String s)269         public void sendBroadcast(Intent intent, String s) {
270             //To change body of implemented methods use File | Settings | File Templates.
271         }
272 
273         @Override
sendOrderedBroadcast(Intent intent, String s)274         public void sendOrderedBroadcast(Intent intent, String s) {
275             //To change body of implemented methods use File | Settings | File Templates.
276         }
277 
278         @Override
sendOrderedBroadcast(Intent intent, String s, BroadcastReceiver broadcastReceiver, Handler handler, int i, String s1, Bundle bundle)279         public void sendOrderedBroadcast(Intent intent, String s, BroadcastReceiver broadcastReceiver, Handler handler, int i, String s1, Bundle bundle) {
280             //To change body of implemented methods use File | Settings | File Templates.
281         }
282 
283         @Override
sendStickyBroadcast(Intent intent)284         public void sendStickyBroadcast(Intent intent) {
285             //To change body of implemented methods use File | Settings | File Templates.
286         }
287 
288         @Override
sendStickyOrderedBroadcast(Intent intent, BroadcastReceiver broadcastReceiver, Handler handler, int i, String s, Bundle bundle)289         public void sendStickyOrderedBroadcast(Intent intent, BroadcastReceiver broadcastReceiver, Handler handler, int i, String s, Bundle bundle) {
290             //To change body of implemented methods use File | Settings | File Templates.
291         }
292 
293         @Override
removeStickyBroadcast(Intent intent)294         public void removeStickyBroadcast(Intent intent) {
295             //To change body of implemented methods use File | Settings | File Templates.
296         }
297 
298         @Override
registerReceiver(BroadcastReceiver broadcastReceiver, IntentFilter intentFilter)299         public Intent registerReceiver(BroadcastReceiver broadcastReceiver, IntentFilter intentFilter) {
300             return null;  //To change body of implemented methods use File | Settings | File Templates.
301         }
302 
303         @Override
registerReceiver(BroadcastReceiver broadcastReceiver, IntentFilter intentFilter, String s, Handler handler)304         public Intent registerReceiver(BroadcastReceiver broadcastReceiver, IntentFilter intentFilter, String s, Handler handler) {
305             return null;  //To change body of implemented methods use File | Settings | File Templates.
306         }
307 
308         @Override
unregisterReceiver(BroadcastReceiver broadcastReceiver)309         public void unregisterReceiver(BroadcastReceiver broadcastReceiver) {
310             //To change body of implemented methods use File | Settings | File Templates.
311         }
312 
313         @Override
startService(Intent intent)314         public ComponentName startService(Intent intent) {
315             return null;  //To change body of implemented methods use File | Settings | File Templates.
316         }
317 
318         @Override
stopService(Intent intent)319         public boolean stopService(Intent intent) {
320             return false;  //To change body of implemented methods use File | Settings | File Templates.
321         }
322 
323         @Override
bindService(Intent intent, ServiceConnection serviceConnection, int i)324         public boolean bindService(Intent intent, ServiceConnection serviceConnection, int i) {
325             return false;  //To change body of implemented methods use File | Settings | File Templates.
326         }
327 
328         @Override
unbindService(ServiceConnection serviceConnection)329         public void unbindService(ServiceConnection serviceConnection) {
330             //To change body of implemented methods use File | Settings | File Templates.
331         }
332 
333         @Override
startInstrumentation(ComponentName componentName, String s, Bundle bundle)334         public boolean startInstrumentation(ComponentName componentName, String s, Bundle bundle) {
335             return false;  //To change body of implemented methods use File | Settings | File Templates.
336         }
337 
338         @Override
getSystemService(String s)339         public Object getSystemService(String s) {
340             return null;  //To change body of implemented methods use File | Settings | File Templates.
341         }
342 
343         @Override
checkPermission(String s, int i, int i1)344         public int checkPermission(String s, int i, int i1) {
345             return 0;  //To change body of implemented methods use File | Settings | File Templates.
346         }
347 
348         @Override
checkCallingPermission(String s)349         public int checkCallingPermission(String s) {
350             return 0;  //To change body of implemented methods use File | Settings | File Templates.
351         }
352 
353         @Override
checkCallingOrSelfPermission(String s)354         public int checkCallingOrSelfPermission(String s) {
355             return 0;  //To change body of implemented methods use File | Settings | File Templates.
356         }
357 
358         @Override
enforcePermission(String s, int i, int i1, String s1)359         public void enforcePermission(String s, int i, int i1, String s1) {
360             //To change body of implemented methods use File | Settings | File Templates.
361         }
362 
363         @Override
enforceCallingPermission(String s, String s1)364         public void enforceCallingPermission(String s, String s1) {
365             //To change body of implemented methods use File | Settings | File Templates.
366         }
367 
368         @Override
enforceCallingOrSelfPermission(String s, String s1)369         public void enforceCallingOrSelfPermission(String s, String s1) {
370             //To change body of implemented methods use File | Settings | File Templates.
371         }
372 
373         @Override
grantUriPermission(String s, Uri uri, int i)374         public void grantUriPermission(String s, Uri uri, int i) {
375             //To change body of implemented methods use File | Settings | File Templates.
376         }
377 
378         @Override
revokeUriPermission(Uri uri, int i)379         public void revokeUriPermission(Uri uri, int i) {
380             //To change body of implemented methods use File | Settings | File Templates.
381         }
382 
383         @Override
checkUriPermission(Uri uri, int i, int i1, int i2)384         public int checkUriPermission(Uri uri, int i, int i1, int i2) {
385             return 0;  //To change body of implemented methods use File | Settings | File Templates.
386         }
387 
388         @Override
checkCallingUriPermission(Uri uri, int i)389         public int checkCallingUriPermission(Uri uri, int i) {
390             return 0;  //To change body of implemented methods use File | Settings | File Templates.
391         }
392 
393         @Override
checkCallingOrSelfUriPermission(Uri uri, int i)394         public int checkCallingOrSelfUriPermission(Uri uri, int i) {
395             return 0;  //To change body of implemented methods use File | Settings | File Templates.
396         }
397 
398         @Override
checkUriPermission(Uri uri, String s, String s1, int i, int i1, int i2)399         public int checkUriPermission(Uri uri, String s, String s1, int i, int i1, int i2) {
400             return 0;  //To change body of implemented methods use File | Settings | File Templates.
401         }
402 
403         @Override
enforceUriPermission(Uri uri, int i, int i1, int i2, String s)404         public void enforceUriPermission(Uri uri, int i, int i1, int i2, String s) {
405             //To change body of implemented methods use File | Settings | File Templates.
406         }
407 
408         @Override
enforceCallingUriPermission(Uri uri, int i, String s)409         public void enforceCallingUriPermission(Uri uri, int i, String s) {
410             //To change body of implemented methods use File | Settings | File Templates.
411         }
412 
413         @Override
enforceCallingOrSelfUriPermission(Uri uri, int i, String s)414         public void enforceCallingOrSelfUriPermission(Uri uri, int i, String s) {
415             //To change body of implemented methods use File | Settings | File Templates.
416         }
417 
418         @Override
enforceUriPermission(Uri uri, String s, String s1, int i, int i1, int i2, String s2)419         public void enforceUriPermission(Uri uri, String s, String s1, int i, int i1, int i2, String s2) {
420             //To change body of implemented methods use File | Settings | File Templates.
421         }
422 
423         @Override
createPackageContext(String s, int i)424         public Context createPackageContext(String s, int i) throws PackageManager.NameNotFoundException {
425             return null;  //To change body of implemented methods use File | Settings | File Templates.
426         }
427     }
428 }
429