Search in sources :

Example 66 with Implementation

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

the class ShadowAccessibilityWindowInfo method obtain.

@Implementation
public static AccessibilityWindowInfo obtain() {
    final AccessibilityWindowInfo obtainedInstance = ReflectionHelpers.callConstructor(AccessibilityWindowInfo.class);
    StrictEqualityWindowWrapper wrapper = new StrictEqualityWindowWrapper(obtainedInstance);
    obtainedInstances.put(wrapper, Thread.currentThread().getStackTrace());
    return obtainedInstance;
}
Also used : AccessibilityWindowInfo(android.view.accessibility.AccessibilityWindowInfo) Implementation(org.robolectric.annotation.Implementation)

Example 67 with Implementation

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

the class ShadowAccessibilityWindowInfo method equals.

@Override
@Implementation
public boolean equals(Object object) {
    if (!(object instanceof AccessibilityWindowInfo)) {
        return false;
    }
    final AccessibilityWindowInfo window = (AccessibilityWindowInfo) object;
    final ShadowAccessibilityWindowInfo otherShadow = (ShadowAccessibilityWindowInfo) ShadowExtractor.extract(window);
    boolean areEqual = (type == otherShadow.getType());
    areEqual &= (parent == otherShadow.getParent());
    areEqual &= (rootNode == otherShadow.getRoot());
    areEqual &= (layer == otherShadow.getLayer());
    areEqual &= (id == otherShadow.getId());
    areEqual &= (isAccessibilityFocused == otherShadow.isAccessibilityFocused());
    areEqual &= (isActive == otherShadow.isActive());
    areEqual &= (isFocused == otherShadow.isFocused());
    Rect anotherBounds = new Rect();
    otherShadow.getBoundsInScreen(anotherBounds);
    areEqual &= (boundsInScreen.equals(anotherBounds));
    return areEqual;
}
Also used : Rect(android.graphics.Rect) AccessibilityWindowInfo(android.view.accessibility.AccessibilityWindowInfo) Implementation(org.robolectric.annotation.Implementation)

Example 68 with Implementation

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

the class ShadowActivity method recreate.

@Implementation
public void recreate() {
    Bundle outState = new Bundle();
    final ActivityInvoker invoker = new ActivityInvoker();
    invoker.call("onSaveInstanceState", Bundle.class).with(outState);
    invoker.call("onPause").withNothing();
    invoker.call("onStop").withNothing();
    Object nonConfigInstance = invoker.call("onRetainNonConfigurationInstance").withNothing();
    setLastNonConfigurationInstance(nonConfigInstance);
    invoker.call("onDestroy").withNothing();
    invoker.call("onCreate", Bundle.class).with(outState);
    invoker.call("onStart").withNothing();
    invoker.call("onRestoreInstanceState", Bundle.class).with(outState);
    invoker.call("onResume").withNothing();
}
Also used : Bundle(android.os.Bundle) RealObject(org.robolectric.annotation.RealObject) Implementation(org.robolectric.annotation.Implementation)

Example 69 with Implementation

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

the class ShadowActivity method getWindow.

/**
   * Constructs a new Window (a {@link com.android.internal.policy.impl.PhoneWindow}) if no window has previously been
   * set.
   *
   * @return the window associated with this Activity
   */
@Implementation
public Window getWindow() {
    Window window = directlyOn(realActivity, Activity.class).getWindow();
    if (window == null) {
        try {
            window = ShadowWindow.create(realActivity);
            setWindow(window);
        } catch (Exception e) {
            throw new RuntimeException("Window creation failed!", e);
        }
    }
    return window;
}
Also used : Window(android.view.Window) Activity(android.app.Activity) InvocationTargetException(java.lang.reflect.InvocationTargetException) Implementation(org.robolectric.annotation.Implementation)

Example 70 with Implementation

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

the class ShadowActivity method showDialog.

@Implementation
public final boolean showDialog(int id, Bundle bundle) {
    this.lastShownDialogId = id;
    Dialog dialog = dialogForId.get(id);
    if (dialog == null) {
        final ActivityInvoker invoker = new ActivityInvoker();
        dialog = (Dialog) invoker.call("onCreateDialog", Integer.TYPE).with(id);
        if (dialog == null) {
            return false;
        }
        if (bundle == null) {
            invoker.call("onPrepareDialog", Integer.TYPE, Dialog.class).with(id, dialog);
        } else {
            invoker.call("onPrepareDialog", Integer.TYPE, Dialog.class, Bundle.class).with(id, dialog, bundle);
        }
        dialogForId.put(id, dialog);
    }
    dialog.show();
    return true;
}
Also used : Dialog(android.app.Dialog) Bundle(android.os.Bundle) 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