本文整理了Java中org.robolectric.annotation.Config.packageName()
方法的一些代码示例,展示了Config.packageName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.packageName()
方法的具体详情如下:
包路径:org.robolectric.annotation.Config
类名称:Config
方法名:packageName
暂无
代码示例来源:origin: robolectric/robolectric
@Override
public ManifestIdentifier identify(Config config) {
String buckManifest = System.getProperty(BUCK_ROBOLECTRIC_MANIFEST);
Path manifestFile = Paths.get(buckManifest);
String buckResDirs = System.getProperty(BUCK_ROBOLECTRIC_RES_DIRECTORIES);
String buckAssetsDirs = System.getProperty(BUCK_ROBOLECTRIC_ASSETS_DIRECTORIES);
String packageName = config.packageName();
final List<Path> buckResources = getDirectoriesFromProperty(buckResDirs);
final List<Path> buckAssets = getDirectoriesFromProperty(buckAssetsDirs);
final Path resDir =
buckResources.isEmpty() ? null : buckResources.get(buckResources.size() - 1);
final Path assetsDir = buckAssets.isEmpty() ? null : buckAssets.get(buckAssets.size() - 1);
final List<ManifestIdentifier> libraries;
if (resDir == null && assetsDir == null) {
libraries = null;
} else {
libraries = new ArrayList<>();
for (int i = 0; i < buckResources.size() - 1; i++) {
libraries.add(new ManifestIdentifier((String) null, null, buckResources.get(i), null, null));
}
for (int i = 0; i < buckAssets.size() - 1; i++) {
libraries.add(new ManifestIdentifier(null, null, null, buckAssets.get(i), null));
}
}
return new ManifestIdentifier(packageName, manifestFile, resDir, assetsDir, libraries);
}
代码示例来源:origin: robolectric/robolectric
return new ManifestIdentifier(config.packageName(), manifestFile, resDir, assetDir, libraries);
代码示例来源:origin: robolectric/robolectric
this.packageName = pick(this.packageName, overlayConfig.packageName(), "");
this.resourceDir = pick(this.resourceDir, overlayConfig.resourceDir(), Config.DEFAULT_RES_FOLDER);
this.assetDir = pick(this.assetDir, overlayConfig.assetDir(), Config.DEFAULT_ASSET_FOLDER);
代码示例来源:origin: robolectric/robolectric
@Override
public ManifestIdentifier identify(Config config) {
Path manifestFile = getFileFromProperty("android_merged_manifest");
Path resourcesDir = getFileFromProperty("android_merged_resources");
Path assetsDir = getFileFromProperty("android_merged_assets");
Path apkFile = getFileFromProperty("android_resource_apk");
String packageName = properties.getProperty("android_custom_package");
String manifestConfig = config.manifest();
if (Config.NONE.equals(manifestConfig)) {
Logger.info("@Config(manifest = Config.NONE) specified while using Build System API, ignoring");
} else if (!Config.DEFAULT_MANIFEST_NAME.equals(manifestConfig)) {
manifestFile = getResource(manifestConfig);
}
if (!Config.DEFAULT_RES_FOLDER.equals(config.resourceDir())) {
resourcesDir = getResource(config.resourceDir());
}
if (!Config.DEFAULT_ASSET_FOLDER.equals(config.assetDir())) {
assetsDir = getResource(config.assetDir());
}
if (!Config.DEFAULT_PACKAGE_NAME.equals(config.packageName())) {
packageName = config.packageName();
}
List<ManifestIdentifier> libraryDirs = emptyList();
if (config.libraries().length > 0) {
Logger.info("@Config(libraries) specified while using Build System API, ignoring");
}
return new ManifestIdentifier(packageName, manifestFile, resourcesDir, assetsDir, libraryDirs,
apkFile);
}
代码示例来源:origin: robolectric/robolectric
private Package loadAppPackage_measured(ApkLoader apkLoader, Config config,
AndroidManifest appManifest, SdkEnvironment sdkEnvironment) {
Package parsedPackage;
if (RuntimeEnvironment.useLegacyResources()) {
injectResourceStuffForLegacy(apkLoader, appManifest, sdkEnvironment);
if (appManifest.getAndroidManifestFile() != null
&& Files.exists(appManifest.getAndroidManifestFile())) {
parsedPackage = LegacyManifestParser.createPackage(appManifest);
} else {
parsedPackage = new Package("org.robolectric.default");
parsedPackage.applicationInfo.targetSdkVersion = appManifest.getTargetSdkVersion();
}
// Support overriding the package name specified in the Manifest.
if (!Config.DEFAULT_PACKAGE_NAME.equals(config.packageName())) {
parsedPackage.packageName = config.packageName();
parsedPackage.applicationInfo.packageName = config.packageName();
} else {
parsedPackage.packageName = appManifest.getPackageName();
parsedPackage.applicationInfo.packageName = appManifest.getPackageName();
}
} else {
RuntimeEnvironment.compileTimeSystemResourcesFile =
sdkEnvironment.getCompileTimeSdk().getJarPath();
RuntimeEnvironment.setAndroidFrameworkJarPath(sdkJarPath);
Path packageFile = appManifest.getApkFile();
parsedPackage = ShadowPackageParser.callParsePackage(packageFile);
}
return parsedPackage;
}
代码示例来源: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
public ManifestIdentifier identify(Config config) {
String buckManifest = System.getProperty(BUCK_ROBOLECTRIC_MANIFEST);
FsFile manifestFile = Fs.fileFromPath(buckManifest);
String buckResDirs = System.getProperty(BUCK_ROBOLECTRIC_RES_DIRECTORIES);
String buckAssetsDirs = System.getProperty(BUCK_ROBOLECTRIC_ASSETS_DIRECTORIES);
String packageName = config.packageName();
final List<FsFile> buckResources = getDirectoriesFromProperty(buckResDirs);
final List<FsFile> buckAssets = getDirectoriesFromProperty(buckAssetsDirs);
final FsFile resDir = buckResources.size() == 0 ? null : buckResources.get(buckResources.size() - 1);
final FsFile assetsDir = buckAssets.size() == 0 ? null : buckAssets.get(buckAssets.size() - 1);
final List<ManifestIdentifier> libraries;
if (resDir == null && assetsDir == null) {
libraries = null;
} else {
libraries = new ArrayList<>();
for (int i = 0; i < buckResources.size() - 1; i++) {
libraries.add(new ManifestIdentifier((String) null, null, buckResources.get(i), null, null));
}
for (int i = 0; i < buckAssets.size() - 1; i++) {
libraries.add(new ManifestIdentifier(null, null, null, buckAssets.get(i), null));
}
}
return new ManifestIdentifier(packageName, manifestFile, resDir, assetsDir, libraries);
}
代码示例来源:origin: org.robolectric/robolectric
@Override
public ManifestIdentifier identify(Config config) {
FsFile manifestFile = getFsFileFromProperty("android_merged_manifest");
FsFile resourcesDir = getFsFileFromProperty("android_merged_resources");
FsFile assetsDir = getFsFileFromProperty("android_merged_assets");
FsFile apkFile = getFsFileFromProperty("android_resource_apk");
String packageName = properties.getProperty("android_custom_package");
String manifestConfig = config.manifest();
if (Config.NONE.equals(manifestConfig)) {
Logger.info("@Config(manifest = Config.NONE) specified while using Build System API, ignoring");
} else if (!Config.DEFAULT_MANIFEST_NAME.equals(manifestConfig)) {
manifestFile = resolveFile(manifestConfig);
}
if (!Config.DEFAULT_RES_FOLDER.equals(config.resourceDir())) {
resourcesDir = resolveFile(config.resourceDir());
}
if (!Config.DEFAULT_ASSET_FOLDER.equals(config.assetDir())) {
assetsDir = resolveFile(config.assetDir());
}
if (!Config.DEFAULT_PACKAGE_NAME.equals(config.packageName())) {
packageName = config.packageName();
}
List<ManifestIdentifier> libraryDirs = emptyList();
if (config.libraries().length > 0) {
Logger.info("@Config(libraries) specified while using Build System API, ignoring");
}
return new ManifestIdentifier(packageName, manifestFile, resourcesDir, assetsDir, libraryDirs,
apkFile);
}
代码示例来源:origin: org.robolectric/robolectric
return new ManifestIdentifier(config.packageName(), manifestFile, resDir, assetDir, libraries);
代码示例来源:origin: org.robolectric/robolectric
if (!Config.DEFAULT_PACKAGE_NAME.equals(config.packageName())) {
parsedPackage.packageName = config.packageName();
parsedPackage.applicationInfo.packageName = config.packageName();
} else {
parsedPackage.packageName = appManifest.getPackageName();
代码示例来源:origin: com.github.gfx.android.robolectricinstrumentation/robolectric-instrumentation
private String getPackageName(Config config) {
try {
final String packageName = config.packageName();
if (!packageName.isEmpty()) {
return packageName;
} else {
return config.constants().getPackage().getName();
}
} catch (Exception e) {
return null;
}
}
代码示例来源:origin: maskarade/Robolectric-Instrumentation
private String getPackageName(Config config) {
try {
final String packageName = config.packageName();
if (!packageName.isEmpty()) {
return packageName;
} else {
return config.constants().getPackage().getName();
}
} catch (Exception e) {
return null;
}
}
代码示例来源:origin: robospock/RoboSpock
private static String getPackageName(Config config) {
// Copied from org.robolectric.RobolectricGradleTestRunner
try {
final String packageName = config.packageName();
if (packageName != null && !packageName.isEmpty()) {
return packageName;
} else {
return ReflectionHelpers.getStaticField(config.constants(), "APPLICATION_ID");
}
} catch (Throwable e) {
return null;
}
}
}
代码示例来源:origin: algolia/algoliasearch-client-android
private String getPackageName(Config config) {
try {
final String packageName = config.packageName();
if (packageName != null && !packageName.isEmpty()) {
return packageName;
} else {
return ReflectionHelpers.getStaticField(config.constants(), "APPLICATION_ID");
}
} catch (Throwable e) {
return null;
}
}
}
代码示例来源:origin: org.robolectric/annotations
this.packageName = pick(this.packageName, overlayConfig.packageName(), "");
this.resourceDir = pick(this.resourceDir, overlayConfig.resourceDir(), Config.DEFAULT_RES_FOLDER);
this.assetDir = pick(this.assetDir, overlayConfig.assetDir(), Config.DEFAULT_ASSET_FOLDER);
代码示例来源:origin: robospock/RoboSpock
String configPackageName = config.packageName();
if (configPackageName != null && !configPackageName.isEmpty()) {
packageName = configPackageName;
代码示例来源: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()
);
}
内容来源于网络,如有侵权,请联系作者删除!