當前位置: 首頁>>代碼示例>>Java>>正文


Java Config.constants方法代碼示例

本文整理匯總了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()
	);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:GithubSampleTestRunner.java

示例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();
    }
}
 
開發者ID:bangarharshit,項目名稱:Oleaster,代碼行數:24,代碼來源:RoboOleaster.java

示例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();
}
 
開發者ID:yshrsmz,項目名稱:historian,代碼行數:15,代碼來源:ConfiguredRobolectricTestRunner.java

示例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);
}
 
開發者ID:bpatrik,項目名稱:mobsoft-lab,代碼行數:36,代碼來源:RobolectricDaggerTestRunner.java


注:本文中的org.robolectric.annotation.Config.constants方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。