Search in sources :

Example 11 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowTime method set.

@Implementation(maxSdk = KITKAT_WATCH)
public void set(long millis) {
    Calendar c = getCalendar();
    c.setTimeInMillis(millis);
    set(c.get(Calendar.SECOND), c.get(Calendar.MINUTE), c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.MONTH), c.get(Calendar.YEAR));
}
Also used : Calendar(java.util.Calendar) Implementation(org.robolectric.annotation.Implementation)

Example 12 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowToast method makeText.

@Implementation
public static Toast makeText(Context context, CharSequence text, int duration) {
    Toast toast = new Toast(context);
    toast.setDuration(duration);
    shadowOf(toast).text = text.toString();
    return toast;
}
Also used : Toast(android.widget.Toast) Implementation(org.robolectric.annotation.Implementation)

Example 13 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowTypeface method createFromAsset.

@Implementation
public static Typeface createFromAsset(AssetManager mgr, String path) {
    AndroidManifest appManifest = Shadows.shadowOf(RuntimeEnvironment.application).getAppManifest();
    ArrayList<String> paths = new ArrayList<>();
    paths.add(getAssetsPath(appManifest, path));
    List<AndroidManifest> libraryManifests = appManifest.getLibraryManifests();
    for (AndroidManifest libraryManifest : libraryManifests) {
        paths.add(getAssetsPath(libraryManifest, path));
    }
    for (String assetPath : paths) {
        if (new File(assetPath).exists()) {
            return createUnderlyingTypeface(path, Typeface.NORMAL);
        }
    }
    throw new RuntimeException("Font not found at " + paths);
}
Also used : ArrayList(java.util.ArrayList) AndroidManifest(org.robolectric.manifest.AndroidManifest) File(java.io.File) Implementation(org.robolectric.annotation.Implementation)

Example 14 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowCamera method open.

@Implementation
public static Camera open() {
    lastOpenedCameraId = 0;
    Camera camera = newInstanceOf(Camera.class);
    Shadows.shadowOf(camera).id = 0;
    return camera;
}
Also used : Camera(android.hardware.Camera) Implementation(org.robolectric.annotation.Implementation)

Example 15 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowCamera method open.

@Implementation
public static Camera open(int cameraId) {
    lastOpenedCameraId = cameraId;
    Camera camera = newInstanceOf(Camera.class);
    Shadows.shadowOf(camera).id = cameraId;
    return camera;
}
Also used : Camera(android.hardware.Camera) Implementation(org.robolectric.annotation.Implementation)

Aggregations

Implementation (org.robolectric.annotation.Implementation)114 Bitmap (android.graphics.Bitmap)17 HiddenApi (org.robolectric.annotation.HiddenApi)10 BitmapDrawable (android.graphics.drawable.BitmapDrawable)6 View (android.view.View)6 IOException (java.io.IOException)6 ContentProvider (android.content.ContentProvider)5 IContentProvider (android.content.IContentProvider)5 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)5 Rect (android.graphics.Rect)4 Message (android.os.Message)4 RealObject (org.robolectric.annotation.RealObject)4 FileTypedResource (org.robolectric.res.FileTypedResource)4 Point (android.graphics.Point)3 AccessibilityWindowInfo (android.view.accessibility.AccessibilityWindowInfo)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 LinkedList (java.util.LinkedList)3 Activity (android.app.Activity)2 Dialog (android.app.Dialog)2