当前位置: 首页>>代码示例>>Java>>正文


Java Implements类代码示例

本文整理汇总了Java中org.robolectric.annotation.Implements的典型用法代码示例。如果您正苦于以下问题:Java Implements类的具体用法?Java Implements怎么用?Java Implements使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Implements类属于org.robolectric.annotation包,在下文中一共展示了Implements类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reset

import org.robolectric.annotation.Implements; //导入依赖的package包/类
public static void reset(Config config) {
  Robolectric.application = null;
  Robolectric.packageManager = null;
  Robolectric.activityThread = null;

  ShadowLooper.resetThreadLoopers();
  ShadowChoreographer.resetThreadLoopers();

  List<Class<?>> klasses = Lists.newArrayList();
  klasses.addAll(Arrays.asList(Robolectric.DEFAULT_SHADOW_CLASSES));
  klasses.addAll(Arrays.asList(config.shadows()));

  for (Class<?> klass : klasses) {
    if (klass.getAnnotation(Implements.class).resetStaticState()) {
      staticMethod("reset").in(klass).invoke();
    }
  }
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:19,代码来源:Robolectric.java

示例2: getShadowedClass

import org.robolectric.annotation.Implements; //导入依赖的package包/类
private Class<?> getShadowedClass(Method shadowMethod) {
  Class<?> shadowingClass = shadowMethod.getDeclaringClass();
  if (shadowingClass.equals(Object.class)) {
    return Object.class;
  }

  Implements implementsAnnotation = shadowingClass.getAnnotation(Implements.class);
  if (implementsAnnotation == null) {
    throw new RuntimeException(shadowingClass + " has no @" + Implements.class.getSimpleName() + " annotation");
  }
  String shadowedClassName = implementsAnnotation.className();
  if (shadowedClassName.isEmpty()) {
    return implementsAnnotation.value();
  } else {
    try {
      return shadowingClass.getClassLoader().loadClass(shadowedClassName);
    } catch (ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:22,代码来源:ShadowWrangler.java

示例3: verifyClass

import org.robolectric.annotation.Implements; //导入依赖的package包/类
private void verifyClass(final Class<?> shadowClass) {
  Implements annotation = shadowClass.getAnnotation(Implements.class);
  Class implementedClass = annotation.value();
  if (implementedClass.getName().equals(Robolectric.Anything.class.getName())) return;

  try {
    shadowClass.getConstructor(implementedClass);
  } catch (NoSuchMethodException e) {
    try {
      shadowClass.getConstructor();
    } catch (NoSuchMethodException e1) {
      mismatches.add("Missing constructor for " + shadowClass.getSimpleName());
    }
  }


  String expectedName = ShadowMap.convertToShadowName(implementedClass.getName());
  if (!shadowClass.getName().equals(expectedName)) {
    mismatches.add("Shadow class " + shadowClass.getName() + " didn't have the expected name, should be " + expectedName);
  }

  for (Method shadowMethod : shadowClass.getDeclaredMethods()) {
    verifyMethod(implementedClass, shadowMethod);
  }
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:26,代码来源:RobolectricWiringTest.java

示例4: getShadowInfo

import org.robolectric.annotation.Implements; //导入依赖的package包/类
private static ShadowInfo getShadowInfo(Class<?> shadowClass) {
  Implements implementsAnnotation = shadowClass.getAnnotation(Implements.class);
  if (implementsAnnotation == null) {
    throw new IllegalArgumentException(shadowClass + " is not annotated with @Implements");
  }

  String className = implementsAnnotation.className();
  try {
    if (className.isEmpty()) {
      className = implementsAnnotation.value().getName();
    }
    ShadowConfig shadowConfig = createShadowConfig(shadowClass.getName(),
        implementsAnnotation.callThroughByDefault(),
        implementsAnnotation.inheritImplementationMethods(),
        implementsAnnotation.looseSignatures());
    return new ShadowInfo(className, shadowConfig);
  } catch (TypeNotPresentException typeLoadingException) {
    String unloadableClassName = shadowClass.getSimpleName();
    if (typeLoadingException.typeName().startsWith("com.google.android.maps")) {
      warnAbout(unloadableClassName);
      return null;
    } else if (isIgnorableClassLoadingException(typeLoadingException)) {
      //this allows users of the robolectric.jar file to use the non-Google APIs version of the api
      warnAbout(unloadableClassName);
    } else {
      throw typeLoadingException;
    }
  }
  return null;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:31,代码来源:ShadowMap.java


注:本文中的org.robolectric.annotation.Implements类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。