本文整理匯總了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);
}