本文整理汇总了Java中org.robolectric.annotation.Config.constants方法的典型用法代码示例。如果您正苦于以下问题:Java Config.constants方法的具体用法?Java Config.constants怎么用?Java Config.constants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robolectric.annotation.Config
的用法示例。
在下文中一共展示了Config.constants方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConfig
import org.robolectric.annotation.Config; //导入方法依赖的package包/类
@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.resourceDir(),
defaultConfig.assetDir(),
defaultConfig.shadows(),
defaultConfig.instrumentedPackages(),
defaultConfig.application(),
defaultConfig.libraries(),
defaultConfig.constants() == Void.class ? BuildConfig.class : defaultConfig.constants()
);
}
示例2: getManifestFactory
import org.robolectric.annotation.Config; //导入方法依赖的package包/类
/**
* Detects which build system is in use and returns the appropriate ManifestFactory implementation.
*
* Custom TestRunner subclasses may wish to override this method to provide alternate configuration.
*
* @param config Specification of the SDK version, manifest file, package name, etc.
*/
private ManifestFactory getManifestFactory(Config config) {
Properties buildSystemApiProperties = getBuildSystemApiProperties();
if (buildSystemApiProperties != null) {
return new DefaultManifestFactory(buildSystemApiProperties);
}
Class<?> buildConstants = config.constants();
//noinspection ConstantConditions
if (BuckManifestFactory.isBuck()) {
return new BuckManifestFactory();
} else if (buildConstants != Void.class) {
return new GradleManifestFactory();
} else {
return new MavenManifestFactory();
}
}
示例3: getConfig
import org.robolectric.annotation.Config; //导入方法依赖的package包/类
@Override
public Config getConfig(Method method) {
Config c = super.getConfig(method);
int[] sdkLevel = c.sdk().length == 0 ? SDK : c.sdk();
Class<?> constants = c.constants() == Void.class ? BuildConfig.class : c.constants();
Class<? extends Application> application = c.constants() == Application.class ? TestApp.class : c.application();
return new Config.Builder(c)
.setSdk(sdkLevel)
.setConstants(constants)
.setApplication(application)
.build();
}
示例4: getAppManifest
import org.robolectric.annotation.Config; //导入方法依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
if (config.constants() == Void.class) {
Logger.error("Field 'constants' not specified in @Config annotation");
Logger.error("This is required when using RobolectricGradleTestRunner!");
throw new RuntimeException("No 'constants' field in @Config annotation!");
}
final String type = getType(config);
final String flavor = getFlavor(config);
final String applicationId = getApplicationId(config);
final FileFsFile res;
if (FileFsFile.from(BUILD_OUTPUT, "res", flavor, type).exists()) {
res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type);
} else {
// Use res/merged if the output directory doesn't exist for Data Binding compatibility
res = FileFsFile.from(BUILD_OUTPUT, "res/merged", flavor, type);
}
final FileFsFile assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type);
final FileFsFile manifest;
if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) {
manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", flavor, type, "AndroidManifest.xml");
} else {
// Fallback to the location for library manifests
manifest = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "AndroidManifest.xml");
}
Logger.debug("Robolectric assets directory: " + assets.getPath());
Logger.debug(" Robolectric res directory: " + res.getPath());
Logger.debug(" Robolectric manifest path: " + manifest.getPath());
Logger.debug(" Robolectric package name: " + applicationId);
return new AndroidManifest(manifest, res, assets, applicationId);
}