• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.content.ContentResolver;
4 import android.graphics.Bitmap;
5 import android.net.Uri;
6 import android.provider.MediaStore;
7 import com.xtremelabs.robolectric.Robolectric;
8 import com.xtremelabs.robolectric.internal.Implementation;
9 import com.xtremelabs.robolectric.internal.Implements;
10 
11 @SuppressWarnings({"UnusedDeclaration"})
12 @Implements(MediaStore.class)
13 public class ShadowMediaStore {
14 
15     @Implements(MediaStore.Images.class)
16     public static class ShadowImages {
17         @Implements(MediaStore.Images.Media.class)
18         public static class ShadowMedia {
19             @Implementation
getBitmap(ContentResolver cr, Uri url)20             public static Bitmap getBitmap(ContentResolver cr, Uri url) {
21                 return ShadowBitmapFactory.create(url.toString());
22             }
23         }
24     }
25 
reset()26     public static void reset() {
27         Robolectric.Reflection.setFinalStaticField(MediaStore.Images.Media.class, "EXTERNAL_CONTENT_URI",
28                 Uri.parse("content://media/external/images/media"));
29 
30         Robolectric.Reflection.setFinalStaticField(MediaStore.Images.Media.class, "INTERNAL_CONTENT_URI",
31                 Uri.parse("content://media/internal/images/media"));
32 
33         Robolectric.Reflection.setFinalStaticField(MediaStore.Video.Media.class, "EXTERNAL_CONTENT_URI",
34                 Uri.parse("content://media/external/video/media"));
35 
36         Robolectric.Reflection.setFinalStaticField(MediaStore.Video.Media.class, "INTERNAL_CONTENT_URI",
37                 Uri.parse("content://media/internal/video/media"));
38     }
39 }
40