Java 类org.robolectric.annotation.Implementation 实例源码

项目:GitHub    文件:VolleyStreamFetcherServerTest.java   
@SuppressWarnings("unused")
@Implementation
public static long elapsedRealtime() {
  // The default is to return something using the main looper, which doesn't exist on
  // Volley's threads.
  return System.currentTimeMillis();
}
项目:GitHub    文件:GlideTest.java   
@Implementation
@SuppressWarnings("unused")
public Bitmap getFrameAtTime() {
  Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  Shadows.shadowOf(bitmap).appendDescription(" from MediaMetadataRetriever");
  return bitmap;
}
项目:bcg    文件:ShadowSnackbar.java   
@Implementation
public static Snackbar make(@NonNull View view, @NonNull CharSequence text, int duration) {
    Snackbar snackbar = null;

    try {
        Constructor<Snackbar> constructor = Snackbar.class.getDeclaredConstructor(ViewGroup.class);

        //just in case, maybe they'll change the method signature in the future
        if (null == constructor)
            throw new IllegalArgumentException("Seems like the constructor was not found!");


        if (Modifier.isPrivate(constructor.getModifiers())) {
            constructor.setAccessible(true);
        }

        snackbar = constructor.newInstance(findSuitableParent(view));
        snackbar.setText(text);
        snackbar.setDuration(duration);
    } catch (Exception e) {
        e.printStackTrace();
    }

    shadowOf(snackbar).text = text.toString();

    shadowSnackbars.add(shadowOf(snackbar));

    return snackbar;
}
项目:GitHub    文件:GlideTest.java   
@Implementation
public InputStream openInputStream(Uri uri) {
  if (!URI_TO_INPUT_STREAMS.containsKey(uri)) {
    throw new IllegalArgumentException(
        "You must first register an InputStream for uri: " + uri);
  }
  return URI_TO_INPUT_STREAMS.get(uri);
}
项目:GitHub    文件:GlideTest.java   
@Implementation
public AssetFileDescriptor openAssetFileDescriptor(Uri uri, String type) {
  if (!URI_TO_FILE_DESCRIPTOR.containsKey(uri)) {
    throw new IllegalArgumentException(
        "You must first register an AssetFileDescriptor for " + "uri: " + uri);
  }
  return URI_TO_FILE_DESCRIPTOR.get(uri);
}
项目:spruce-android    文件:ShadowPointF.java   
@Override @Implementation
public boolean equals(Object object) {
    if (object == null) return false;
    if (this == object) return true;
    if (object.getClass() != PointF.class) return false;

    PointF that = (PointF) object;
    if (this.realPointF.x == that.x && this.realPointF.y == that.y) return true;

    return false;
}
项目:GitHub    文件:TransformationUtilsTest.java   
@Implementation
public static Bitmap createBitmap(int width, int height, Bitmap.Config config) {
  // Robolectric doesn't match the framework behavior with null configs, so we have to do so
  // here.
  Preconditions.checkNotNull("Config must not be null");
  return ShadowBitmap.createBitmap(width, height, config);
}
项目:GitHub    文件:MyShadowBitmap.java   
@Implementation
public static Bitmap createBitmap(int colors[], int width, int height, Bitmap.Config config) {
  Bitmap bitmap = Shadow.newInstanceOf(Bitmap.class);
  MyShadowBitmap shadowBitmap = (MyShadowBitmap) ShadowExtractor.extract(bitmap);
  shadowBitmap.width = width;
  shadowBitmap.height = height;
  shadowBitmap.mPixels = new int[width * height];
  for (int i = 0; i < colors.length; i++) {
    shadowBitmap.mPixels[i] = colors[i];
  }
  return bitmap;
}
项目:RxNetwork    文件:ShadowConnectivityManagerWithCallback.java   
@Implementation(minSdk = LOLLIPOP)
@RequiresApi(LOLLIPOP)
public void registerNetworkCallback(NetworkRequest request, NetworkCallback networkCallback) {
  networkCallbacks.add(networkCallback);
  // simulate available connection
  networkCallback.onAvailable(getActiveNetwork());
}
项目:mobile-store    文件:ProperMultiRepoUpdaterTest.java   
@Implementation
@SuppressWarnings("unused")
public static String get(String key) {
    if ("ro.product.cpu.abilist".equals(key)) {
        return "armeabi";
    }
    return ShadowSystemProperties.get(key);
}
项目:mobile-store    文件:ShadowContextImpl.java   
@Override
@Implementation
public Object getSystemService(String name) {
    if ("appops".equals(name)) {
        return null;
    }

    return super.getSystemService(name);
}
项目:mobile-store    文件:ShadowLog.java   
@Implementation
public static synchronized boolean isLoggable(String tag, int level) {
    if ((TextUtils.equals(tag, "CursorWindowStats") && level <= Log.INFO)
            || (TextUtils.equals(tag, "SQLiteCursor") && level <= Log.DEBUG)) {
        return false;
    }

    return org.robolectric.shadows.ShadowLog.isLoggable(tag, level);
}
项目:q-mail    文件:ShadowOpenPgpAsyncTask.java   
@Implementation
public AsyncTask<Void, Integer, Intent> executeOnExecutor(Executor executor, Void... params) {
    return super.execute(params);
}
项目:spruce-android    文件:ShadowPointF.java   
@Override @Implementation
public String toString() {
    return "Point(" + realPointF.x + ", " + realPointF.y + ")";
}
项目:android-perftracking    文件:TrackerShadow.java   
@Implementation public static void endMethod(int trackingId) {
  mockTracker.endMethod(trackingId);
}
项目:RxNetwork    文件:ShadowNetworkCapabilities.java   
@Implementation
public void setLinkUpstreamBandwidthKbps(int upKbps) {
  mLinkUpBandwidthKbps = upKbps;
}
项目:GitHub    文件:ViewTargetTest.java   
@SuppressWarnings("unused")
@Implementation
public void addOnPreDrawListener(OnPreDrawListener listener) {
  checkIsAlive();
  preDrawListeners.add(listener);
}
项目:GitHub    文件:ViewTargetTest.java   
@SuppressWarnings("unused")
@Implementation
public void removeOnPreDrawListener(OnPreDrawListener listener) {
  checkIsAlive();
  preDrawListeners.remove(listener);
}
项目:GitHub    文件:ViewTargetTest.java   
@Implementation
public boolean isAlive() {
  return isAlive;
}
项目:GitHub    文件:ViewTargetTest.java   
@Implementation
public void requestLayout() {
  isLayoutRequested = true;
}
项目:GitHub    文件:ViewTargetTest.java   
@Implementation
public int getHeight() {
  return height;
}
项目:GitHub    文件:ViewTargetTest.java   
@Implementation
public boolean isLaidOut() {
  return isLaidOut;
}
项目:Presenter-Client-Android    文件:ShadowBluetoothSocket.java   
@Implementation
public void connect() throws IOException {
    if (!connectionSucceed) {
        throw new IOException("Connection failed");
    }
}
项目:androidadvanced    文件:ShadowRecyclerViewAdapter.java   
@Implementation
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    realObject.onBindViewHolder(holder, position);
    holders.put(position, holder);
}
项目:android-perftracking    文件:TrackerShadow.java   
@Implementation public static void endCustom(int trackingId) {
  mockTracker.endCustom(trackingId);
}
项目:GitHub    文件:AppWidgetTargetTest.java   
@Implementation
public void updateAppWidget(ComponentName componentName, RemoteViews views) {
  updatedComponentName = componentName;
  updatedRemoteViews = views;
}
项目:GitHub    文件:NotificationTargetTest.java   
@Implementation
public void notify(String notificationTag, int notificationId, Notification notification) {
  updatedNotificationTag = notificationTag;
  updatedNotificationId = notificationId;
  updatedNotification = notification;
}
项目:GitHub    文件:GifDrawableTest.java   
@Implementation
public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) {
  drawnBitmaps.add(bitmap);
}
项目:GitHub    文件:FitCenterTest.java   
@Implementation
@Override
public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
  // Do nothing.
}
项目:GitHub    文件:DownsamplerTest.java   
@Implementation
public int getAllocationByteCount() {
  return getWidth() * getHeight() * (getConfig() == Bitmap.Config.ARGB_8888 ? 4 : 2);
}
项目:RxNetwork    文件:ShadowConnectivityManagerWithCallback.java   
@Implementation
public boolean getBackgroundDataSetting() {
  return backgroundDataSetting;
}
项目:android-perftracking    文件:TrackerShadow.java   
@Implementation public static int startCustom(String measurementId) {
  return mockTracker.startCustom(measurementId);
}
项目:GitHub    文件:MemorySizeCalculatorTest.java   
@Implementation
public boolean isLowRamDevice() {
  return isLowRam;
}
项目:RxNetwork    文件:ShadowNetworkCapabilities.java   
@Implementation
public int getLinkDownstreamBandwidthKbps() {
  return mLinkDownBandwidthKbps;
}
项目:GitHub    文件:GlideShadowLooper.java   
@Implementation
public static MessageQueue myQueue() {
  return mock(MessageQueue.class);
}
项目:GitHub    文件:ContentResolverShadow.java   
@Implementation
public InputStream openInputStream(Uri uri) {
  return inputStreamMap.get(uri);
}
项目:android-perftracking    文件:TrackerShadow.java   
@Implementation public static int startUrl(URL url, String verb) {
  return mockTracker.startUrl(url, verb);
}
项目:RxNetwork    文件:ShadowNetworkCapabilities.java   
@Implementation
public void setLinkDownstreamBandwidthKbps(int downKbps) {
  mLinkDownBandwidthKbps = downKbps;
}
项目:RxNetwork    文件:ShadowConnectivityManagerWithCallback.java   
@Implementation(minSdk = M)
public Network getActiveNetwork() {
  return netIdToNetwork.get(getActiveNetworkInfo().getType());
}
项目:android-perftracking    文件:TrackerShadow.java   
@Implementation public static int startMethod(Object object, String method) {
  return mockTracker.startMethod(object, method);
}