org.robolectric.annotation.Config.shadows()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.robolectric.annotation.Config.shadows()方法的一些代码示例,展示了Config.shadows()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.shadows()方法的具体详情如下:
包路径:org.robolectric.annotation.Config
类名称:Config
方法名:shadows

Config.shadows介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

@Override @Nonnull
protected Class<?>[] getExtraShadows(FrameworkMethod frameworkMethod) {
 Config config = ((RobolectricFrameworkMethod) frameworkMethod).config.get(Config.class);
 return config.shadows();
}

代码示例来源:origin: robolectric/robolectric

public static void withConfig(InstrumentationConfiguration.Builder builder, Config config) {
 for (Class<?> clazz : config.shadows()) {
  Implements annotation = clazz.getAnnotation(Implements.class);
  if (annotation == null) {
   throw new IllegalArgumentException(clazz + " is not annotated with @Implements");
  }
  String className = annotation.className();
  if (className.isEmpty()) {
   className = annotation.value().getName();
  }
  if (!className.isEmpty()) {
   builder.addInstrumentedClass(className);
  }
 }
 for (String packageName : config.instrumentedPackages()) {
  builder.addInstrumentedPackage(packageName);
 }
}

代码示例来源:origin: robolectric/robolectric

shadows.addAll(Arrays.asList(overlayConfig.shadows()));
this.shadows = shadows.toArray(new Class[shadows.size()]);

代码示例来源:origin: robolectric/robolectric

@Test
public void withOverlay_withShadows_maintainsOrder() throws Exception {
 Config.Implementation base = new Config.Builder().build();
 Config withString = overlay(base, new Builder().setShadows(new Class[]{String.class}).build());
 assertThat(withString.shadows()).asList().contains(String.class);
 Config withMore = overlay(withString,
   new Builder().setShadows(new Class[]{Map.class, String.class}).build());
 assertThat(withMore.shadows()).asList().containsAllOf(String.class, Map.class, String.class);
}

代码示例来源:origin: robolectric/robolectric

public Builder(Config config) {
 sdk = config.sdk();
 minSdk = config.minSdk();
 maxSdk = config.maxSdk();
 manifest = config.manifest();
 qualifiers = config.qualifiers();
 packageName = config.packageName();
 resourceDir = config.resourceDir();
 assetDir = config.assetDir();
 shadows = config.shadows();
 instrumentedPackages = config.instrumentedPackages();
 application = config.application();
 libraries = config.libraries();
}

代码示例来源:origin: robolectric/robolectric

private static void assertConfig(
  Config config,
  int[] sdk,
  String manifest,
  Class<? extends Application> application,
  String packageName,
  String qualifiers,
  String resourceDir,
  String assetsDir,
  Class<?>[] shadows,
  String[] instrumentedPackages,
  String[] libraries) {
 assertThat(config.sdk()).isEqualTo(sdk);
 assertThat(config.manifest()).isEqualTo(manifest);
 assertThat(config.application()).isEqualTo(application);
 assertThat(config.packageName()).isEqualTo(packageName);
 assertThat(config.qualifiers()).isEqualTo(qualifiers);
 assertThat(config.resourceDir()).isEqualTo(resourceDir);
 assertThat(config.assetDir()).isEqualTo(assetsDir);
 assertThat(config.shadows()).asList().containsAllIn(shadows).inOrder();
 assertThat(config.instrumentedPackages()).asList().containsAllIn(instrumentedPackages);
 assertThat(config.libraries()).asList().containsAllIn(libraries);
}

代码示例来源:origin: org.robolectric/robolectric

@Override @Nonnull
protected Class<?>[] getExtraShadows(FrameworkMethod frameworkMethod) {
 Config config = ((RobolectricFrameworkMethod) frameworkMethod).config;
 return config.shadows();
}

代码示例来源:origin: org.robolectric/robolectric

public static void withConfig(InstrumentationConfiguration.Builder builder, Config config) {
 for (Class<?> clazz : config.shadows()) {
  Implements annotation = clazz.getAnnotation(Implements.class);
  if (annotation == null) {
   throw new IllegalArgumentException(clazz + " is not annotated with @Implements");
  }
  String className = annotation.className();
  if (className.isEmpty()) {
   className = annotation.value().getName();
  }
  if (!className.isEmpty()) {
   builder.addInstrumentedClass(className);
  }
 }
 for (String packageName : config.instrumentedPackages()) {
  builder.addInstrumentedPackage(packageName);
 }
}

代码示例来源:origin: org.robolectric/annotations

shadows.addAll(Arrays.asList(overlayConfig.shadows()));
this.shadows = shadows.toArray(new Class[shadows.size()]);

代码示例来源:origin: robospock/RoboSpock

protected void configureShadows(SdkEnvironment sdkEnvironment, Config config) {
  ShadowMap shadowMap = createShadowMap();
  if (config != null) {
    Class<?>[] shadows = config.shadows();
    if (shadows.length > 0) {
      shadowMap = shadowMap.newBuilder().addShadowClasses(shadows).build();
    }
  }
  ClassHandler classHandler = getClassHandler(sdkEnvironment, shadowMap);
  injectClassHandler(sdkEnvironment.getRobolectricClassLoader(), classHandler);
}

代码示例来源:origin: org.robolectric/annotations

public Builder(Config config) {
 sdk = config.sdk();
 minSdk = config.minSdk();
 maxSdk = config.maxSdk();
 manifest = config.manifest();
 qualifiers = config.qualifiers();
 packageName = config.packageName();
 resourceDir = config.resourceDir();
 assetDir = config.assetDir();
 shadows = config.shadows();
 instrumentedPackages = config.instrumentedPackages();
 application = config.application();
 libraries = config.libraries();
}

代码示例来源:origin: ImangazalievM/Bubbble

@Override
public Config getConfig(@NonNull Method method) {
  final Config defaultConfig = super.getConfig(method);
  return new Config.Implementation(
      new int[]{SDK_EMULATE_LEVEL},
      defaultConfig.manifest(),
      defaultConfig.qualifiers(),
      defaultConfig.packageName(),
      defaultConfig.abiSplit(),
      defaultConfig.resourceDir(),
      defaultConfig.assetDir(),
      defaultConfig.buildDir(),
      defaultConfig.shadows(),
      defaultConfig.instrumentedPackages(),
      BubbbleTestApplication.class, // Notice that we override real application class for Unit tests.
      defaultConfig.libraries(),
      defaultConfig.constants() == Void.class ? BuildConfig.class : defaultConfig.constants()
  );
}

代码示例来源:origin: ImangazalievM/ReActiveAndroid

@Override
public Config getConfig(@NonNull Method method) {
  final Config defaultConfig = super.getConfig(method);
  return new Config.Implementation(
      new int[]{SDK_EMULATE_LEVEL},
      defaultConfig.manifest(),
      defaultConfig.qualifiers(),
      defaultConfig.packageName(),
      defaultConfig.abiSplit(),
      defaultConfig.resourceDir(),
      defaultConfig.assetDir(),
      defaultConfig.buildDir(),
      defaultConfig.shadows(),
      defaultConfig.instrumentedPackages(),
      TestApp.class, // Notice that we override real application class for Unit tests.
      defaultConfig.libraries(),
      defaultConfig.constants() == Void.class ? BuildConfig.class : defaultConfig.constants()
  );
}

相关文章