OSDN Git Service

Rename bindService to bindServiceAsUser to follow convention.
[android-x86/frameworks-base.git] / test-runner / src / android / test / mock / MockContext.java
1 /*
2  * Copyright (C) 2007 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.ComponentName;
20 import android.content.ContentResolver;
21 import android.content.Context;
22 import android.content.Intent;
23 import android.content.IntentFilter;
24 import android.content.BroadcastReceiver;
25 import android.content.IntentSender;
26 import android.content.ServiceConnection;
27 import android.content.SharedPreferences;
28 import android.content.pm.ApplicationInfo;
29 import android.content.pm.PackageManager;
30 import android.content.res.AssetManager;
31 import android.content.res.Configuration;
32 import android.content.res.Resources;
33 import android.database.DatabaseErrorHandler;
34 import android.database.sqlite.SQLiteDatabase;
35 import android.graphics.Bitmap;
36 import android.graphics.drawable.Drawable;
37 import android.net.Uri;
38 import android.os.Bundle;
39 import android.os.Handler;
40 import android.os.Looper;
41 import android.os.UserHandle;
42 import android.view.CompatibilityInfoHolder;
43 import android.view.Display;
44
45 import java.io.File;
46 import java.io.FileInputStream;
47 import java.io.FileNotFoundException;
48 import java.io.FileOutputStream;
49 import java.io.IOException;
50 import java.io.InputStream;
51
52 /**
53  * A mock {@link android.content.Context} class.  All methods are non-functional and throw 
54  * {@link java.lang.UnsupportedOperationException}.  You can use this to inject other dependencies,
55  * mocks, or monitors into the classes you are testing.
56  */
57 public class MockContext extends Context {
58
59     @Override
60     public AssetManager getAssets() {
61         throw new UnsupportedOperationException();
62     }
63
64     @Override
65     public Resources getResources() {
66         throw new UnsupportedOperationException();
67     }
68
69     @Override
70     public PackageManager getPackageManager() {
71         throw new UnsupportedOperationException();
72     }
73
74     @Override
75     public ContentResolver getContentResolver() {
76         throw new UnsupportedOperationException();
77     }
78
79     @Override
80     public Looper getMainLooper() {
81         throw new UnsupportedOperationException();
82     }
83     
84     @Override
85     public Context getApplicationContext() {
86         throw new UnsupportedOperationException();
87     }
88     
89     @Override
90     public void setTheme(int resid) {
91         throw new UnsupportedOperationException();
92     }
93
94     @Override
95     public Resources.Theme getTheme() {
96         throw new UnsupportedOperationException();
97     }
98
99     @Override
100     public ClassLoader getClassLoader() {
101         throw new UnsupportedOperationException();
102     }
103
104     @Override
105     public String getPackageName() {
106         throw new UnsupportedOperationException();
107     }
108
109     @Override
110     public ApplicationInfo getApplicationInfo() {
111         throw new UnsupportedOperationException();
112     }
113     
114     @Override
115     public String getPackageResourcePath() {
116         throw new UnsupportedOperationException();
117     }
118
119     /** @hide */
120     @Override
121     public File getSharedPrefsFile(String name) {
122         throw new UnsupportedOperationException();
123     }
124
125     @Override
126     public String getPackageCodePath() {
127         throw new UnsupportedOperationException();
128     }
129
130     @Override
131     public SharedPreferences getSharedPreferences(String name, int mode) {
132         throw new UnsupportedOperationException();
133     }
134
135     @Override
136     public FileInputStream openFileInput(String name) throws FileNotFoundException {
137         throw new UnsupportedOperationException();
138     }
139
140     @Override
141     public FileOutputStream openFileOutput(String name, int mode) throws FileNotFoundException {
142         throw new UnsupportedOperationException();
143     }
144
145     @Override
146     public boolean deleteFile(String name) {
147         throw new UnsupportedOperationException();
148     }
149
150     @Override
151     public File getFileStreamPath(String name) {
152         throw new UnsupportedOperationException();
153     }
154
155     @Override
156     public String[] fileList() {
157         throw new UnsupportedOperationException();
158     }
159
160     @Override
161     public File getFilesDir() {
162         throw new UnsupportedOperationException();
163     }
164
165     @Override
166     public File getExternalFilesDir(String type) {
167         throw new UnsupportedOperationException();
168     }
169
170     @Override
171     public File getObbDir() {
172         throw new UnsupportedOperationException();
173     }
174     
175     @Override
176     public File getCacheDir() {
177         throw new UnsupportedOperationException();
178     }
179
180     @Override
181     public File getExternalCacheDir() {
182         throw new UnsupportedOperationException();
183     }
184
185     @Override
186     public File getDir(String name, int mode) {
187         throw new UnsupportedOperationException();
188     }
189
190     @Override
191     public SQLiteDatabase openOrCreateDatabase(String file, int mode, 
192             SQLiteDatabase.CursorFactory factory) {
193         throw new UnsupportedOperationException();
194     }
195
196     @Override
197     public SQLiteDatabase openOrCreateDatabase(String file, int mode,
198             SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler) {
199         throw new UnsupportedOperationException();
200     }
201
202     @Override
203     public File getDatabasePath(String name) {
204         throw new UnsupportedOperationException();
205     }
206
207     @Override
208     public String[] databaseList() {
209         throw new UnsupportedOperationException();
210     }
211
212     @Override
213     public boolean deleteDatabase(String name) {
214         throw new UnsupportedOperationException();
215     }
216
217     @Override
218     public Drawable getWallpaper() {
219         throw new UnsupportedOperationException();
220     }
221
222     @Override
223     public Drawable peekWallpaper() {
224         throw new UnsupportedOperationException();
225     }
226
227     @Override
228     public int getWallpaperDesiredMinimumWidth() {
229         throw new UnsupportedOperationException();
230     }
231
232     @Override
233     public int getWallpaperDesiredMinimumHeight() {
234         throw new UnsupportedOperationException();
235     }
236
237     @Override
238     public void setWallpaper(Bitmap bitmap) throws IOException {
239         throw new UnsupportedOperationException();
240     }
241
242     @Override
243     public void setWallpaper(InputStream data) throws IOException {
244         throw new UnsupportedOperationException();
245     }
246
247     @Override
248     public void clearWallpaper() {
249         throw new UnsupportedOperationException();
250     }
251
252     @Override
253     public void startActivity(Intent intent) {
254         throw new UnsupportedOperationException();
255     }
256
257     @Override
258     public void startActivity(Intent intent, Bundle options) {
259         startActivity(intent);
260     }
261
262     @Override
263     public void startActivities(Intent[] intents) {
264         throw new UnsupportedOperationException();
265     }
266
267     @Override
268     public void startActivities(Intent[] intents, Bundle options) {
269         startActivities(intents);
270     }
271
272     @Override
273     public void startIntentSender(IntentSender intent,
274             Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
275             throws IntentSender.SendIntentException {
276         throw new UnsupportedOperationException();
277     }
278
279     @Override
280     public void startIntentSender(IntentSender intent,
281             Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
282             Bundle options) throws IntentSender.SendIntentException {
283         startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags);
284     }
285     
286     @Override
287     public void sendBroadcast(Intent intent) {
288         throw new UnsupportedOperationException();
289     }
290
291     @Override
292     public void sendBroadcast(Intent intent, String receiverPermission) {
293         throw new UnsupportedOperationException();
294     }
295
296     @Override
297     public void sendOrderedBroadcast(Intent intent,
298             String receiverPermission) {
299         throw new UnsupportedOperationException();
300     }
301
302     @Override
303     public void sendOrderedBroadcast(Intent intent, String receiverPermission,
304             BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData,
305            Bundle initialExtras) {
306         throw new UnsupportedOperationException();
307     }
308
309     @Override
310     public void sendBroadcastAsUser(Intent intent, UserHandle user) {
311         throw new UnsupportedOperationException();
312     }
313
314     @Override
315     public void sendBroadcastAsUser(Intent intent, UserHandle user,
316             String receiverPermission) {
317         throw new UnsupportedOperationException();
318     }
319
320     @Override
321     public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
322             String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler,
323             int initialCode, String initialData, Bundle initialExtras) {
324         throw new UnsupportedOperationException();
325     }
326
327     @Override
328     public void sendStickyBroadcast(Intent intent) {
329         throw new UnsupportedOperationException();
330     }
331
332     @Override
333     public void sendStickyOrderedBroadcast(Intent intent,
334             BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData,
335            Bundle initialExtras) {
336         throw new UnsupportedOperationException();
337     }
338
339     @Override
340     public void removeStickyBroadcast(Intent intent) {
341         throw new UnsupportedOperationException();
342     }
343
344     @Override
345     public void sendStickyBroadcastAsUser(Intent intent, UserHandle user) {
346         throw new UnsupportedOperationException();
347     }
348
349     @Override
350     public void sendStickyOrderedBroadcastAsUser(Intent intent,
351             UserHandle user, BroadcastReceiver resultReceiver,
352             Handler scheduler, int initialCode, String initialData,
353             Bundle initialExtras) {
354         throw new UnsupportedOperationException();
355     }
356
357     @Override
358     public void removeStickyBroadcastAsUser(Intent intent, UserHandle user) {
359         throw new UnsupportedOperationException();
360     }
361
362     @Override
363     public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
364         throw new UnsupportedOperationException();
365     }
366
367     @Override
368     public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter,
369             String broadcastPermission, Handler scheduler) {
370         throw new UnsupportedOperationException();
371     }
372
373     /** @hide */
374     @Override
375     public Intent registerReceiverAsUser(BroadcastReceiver receiver, UserHandle user,
376             IntentFilter filter, String broadcastPermission, Handler scheduler) {
377         throw new UnsupportedOperationException();
378     }
379
380     @Override
381     public void unregisterReceiver(BroadcastReceiver receiver) {
382         throw new UnsupportedOperationException();
383     }
384
385     @Override
386     public ComponentName startService(Intent service) {
387         throw new UnsupportedOperationException();
388     }
389
390     @Override
391     public boolean stopService(Intent service) {
392         throw new UnsupportedOperationException();
393     }
394
395     /** @hide */
396     @Override
397     public ComponentName startServiceAsUser(Intent service, UserHandle user) {
398         throw new UnsupportedOperationException();
399     }
400
401     /** @hide */
402     @Override
403     public boolean stopServiceAsUser(Intent service, UserHandle user) {
404         throw new UnsupportedOperationException();
405     }
406
407     @Override
408     public boolean bindService(Intent service, ServiceConnection conn, int flags) {
409         throw new UnsupportedOperationException();
410     }
411
412     /** @hide */
413     @Override
414     public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags,
415             UserHandle user) {
416         throw new UnsupportedOperationException();
417     }
418
419     @Override
420     public void unbindService(ServiceConnection conn) {
421         throw new UnsupportedOperationException();
422     }
423
424     @Override
425     public boolean startInstrumentation(ComponentName className,
426             String profileFile, Bundle arguments) {
427         throw new UnsupportedOperationException();
428     }
429
430     @Override
431     public Object getSystemService(String name) {
432         throw new UnsupportedOperationException();
433     }
434
435     @Override
436     public int checkPermission(String permission, int pid, int uid) {
437         throw new UnsupportedOperationException();
438     }
439
440     @Override
441     public int checkCallingPermission(String permission) {
442         throw new UnsupportedOperationException();
443     }
444
445     @Override
446     public int checkCallingOrSelfPermission(String permission) {
447         throw new UnsupportedOperationException();
448     }
449
450     @Override
451     public void enforcePermission(
452             String permission, int pid, int uid, String message) {
453         throw new UnsupportedOperationException();
454     }
455
456     @Override
457     public void enforceCallingPermission(String permission, String message) {
458         throw new UnsupportedOperationException();
459     }
460
461     @Override
462     public void enforceCallingOrSelfPermission(String permission, String message) {
463         throw new UnsupportedOperationException();
464     }
465
466     @Override
467     public void grantUriPermission(String toPackage, Uri uri, int modeFlags) {
468         throw new UnsupportedOperationException();
469     }
470
471     @Override
472     public void revokeUriPermission(Uri uri, int modeFlags) {
473         throw new UnsupportedOperationException();
474     }
475
476     @Override
477     public int checkUriPermission(Uri uri, int pid, int uid, int modeFlags) {
478         throw new UnsupportedOperationException();
479     }
480
481     @Override
482     public int checkCallingUriPermission(Uri uri, int modeFlags) {
483         throw new UnsupportedOperationException();
484     }
485
486     @Override
487     public int checkCallingOrSelfUriPermission(Uri uri, int modeFlags) {
488         throw new UnsupportedOperationException();
489     }
490
491     @Override
492     public int checkUriPermission(Uri uri, String readPermission,
493             String writePermission, int pid, int uid, int modeFlags) {
494         throw new UnsupportedOperationException();
495     }
496
497     @Override
498     public void enforceUriPermission(
499             Uri uri, int pid, int uid, int modeFlags, String message) {
500         throw new UnsupportedOperationException();
501     }
502
503     @Override
504     public void enforceCallingUriPermission(
505             Uri uri, int modeFlags, String message) {
506         throw new UnsupportedOperationException();
507     }
508
509     @Override
510     public void enforceCallingOrSelfUriPermission(
511             Uri uri, int modeFlags, String message) {
512         throw new UnsupportedOperationException();
513     }
514
515     public void enforceUriPermission(
516             Uri uri, String readPermission, String writePermission,
517             int pid, int uid, int modeFlags, String message) {
518         throw new UnsupportedOperationException();
519     }
520
521     @Override
522     public Context createPackageContext(String packageName, int flags)
523             throws PackageManager.NameNotFoundException {
524         throw new UnsupportedOperationException();
525     }
526
527     /** {@hide} */
528     @Override
529     public Context createPackageContextAsUser(String packageName, int flags, UserHandle user)
530             throws PackageManager.NameNotFoundException {
531         throw new UnsupportedOperationException();
532     }
533
534     @Override
535     public Context createConfigurationContext(Configuration overrideConfiguration) {
536         throw new UnsupportedOperationException();
537     }
538
539     @Override
540     public Context createDisplayContext(Display display) {
541         throw new UnsupportedOperationException();
542     }
543
544     @Override
545     public boolean isRestricted() {
546         throw new UnsupportedOperationException();        
547     }
548
549     /** @hide */
550     @Override
551     public CompatibilityInfoHolder getCompatibilityInfo(int displayId) {
552         throw new UnsupportedOperationException();
553     }
554 }