本文整理汇总了Java中org.robolectric.manifest.AndroidManifest类的典型用法代码示例。如果您正苦于以下问题:Java AndroidManifest类的具体用法?Java AndroidManifest怎么用?Java AndroidManifest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AndroidManifest类属于org.robolectric.manifest包,在下文中一共展示了AndroidManifest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBootReceiverRegistered
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Test
public void testBootReceiverRegistered() {
Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED);
AndroidManifest manifest = ShadowApplication.getInstance().getAppManifest();
List<BroadcastReceiver> receivers = ShadowApplication.getInstance().getReceiversForIntent(intent);
assertThat(receivers, hasItem(isA(JobGcReceiver.class)));
}
示例2: getAppManifest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String appRoot = "src/main/";
String manifestPath = appRoot + "AndroidManifest.xml";
String resDir = appRoot + "res";
String assetsDir = appRoot + "assets";
//return new AndroidManifest(Fs.fileFromPath("src/main/AndroidManifest.xml"), Fs.fileFromPath(resDir), Fs.fileFromPath(assetsDir)) {
return new AndroidManifest(Fs.fileFromPath(manifestPath), Fs.fileFromPath(resDir), Fs.fileFromPath(assetsDir)) {
@Override
public List<ResourcePath> getIncludedResourcePaths() {
List<ResourcePath> paths = super.getIncludedResourcePaths();
paths.add(new ResourcePath(getRClass(), Fs.fileFromPath("src/main/res"), getAssetsDirectory()));
paths.add(new ResourcePath(getRClass(), Fs.fileFromPath("src/test/res"), getAssetsDirectory()));
return paths;
}
};
}
示例3: RoboOleaster
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
public RoboOleaster(Class testClass) throws InitializationError {
super(testClass);
Config config = getConfig(testClass);
AndroidManifest androidManifest = getAppManifest(config);
interceptors = new Interceptors(findInterceptors());
SdkEnvironment sdkEnvironment = getSandbox(config, androidManifest);
// Configure shadows *BEFORE* setting the ClassLoader. This is necessary because
// creating the ShadowMap loads all ShadowProviders via ServiceLoader and this is
// not available once we install the Robolectric class loader.
configureShadows(sdkEnvironment);
Class bootstrappedTestClass = sdkEnvironment.bootstrappedClass(testClass);
try {
this.oleasterRobolectricRunner = sdkEnvironment
.bootstrappedClass(OleasterRobolectricRunner.class)
.getConstructor(Class.class, SdkEnvironment.class, Config.class, AndroidManifest.class)
.newInstance(bootstrappedTestClass, sdkEnvironment, config, androidManifest);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例4: getAppManifest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String path = PATH_MANIFEST;
// android studio has a different execution root for tests than pure gradle
// so we avoid here manual effort to get them running inside android studio
if (!new File(path).exists()) {
path = PATH_PREFIX + path;
}
config = overwriteConfig(config, CONFIG_MANIFEST, path);
config = overwriteConfig(config, CONFIG_ASSET_DIR, PATH_ASSET);
config = overwriteConfig(config, CONFIG_RESOURCE_DIR, PATH_RESOURCE);
config = overwriteConfig(config, CONFIG_PACKAGE_NAME, PACKAGE_NAME);
return super.getAppManifest(config);
}
示例5: getAppManifest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
final String manifestPath = PathResolver.resolveAndroidManifestPath();
final String resourcesPath = PathResolver.resolveResPath();
final String assetsPath = PathResolver.resolveAssetsPath();
AndroidManifest manifest = new AndroidManifest(
Fs.fileFromPath(manifestPath),
Fs.fileFromPath(resourcesPath),
Fs.fileFromPath(assetsPath)) {
@Override
public int getTargetSdkVersion() {
return TARGET_SDK_VERSION;
}
@Override
public int getMinSdkVersion() {
return MIN_SDK_VERSION;
}
};
return manifest;
}
示例6: shouldMatchPermissions
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Test
public void shouldMatchPermissions() {
// Initialize: configure test for current app configuration
FsFile mergedManifestFile;
Object[] expectedPermissions;
if (BuildConfig.DEBUG) {
mergedManifestFile = Fs.fileFromPath(MERGED_DEBUG_MANIFEST_FILE);
expectedPermissions = EXPECTED_DEBUG_PERMISSIONS;
} else {
mergedManifestFile = Fs.fileFromPath(MERGED_RELEASE_MANIFEST_FILE);
expectedPermissions = EXPECTED_RELEASE_PERMISSIONS;
}
// Run: Creates a Robolectric configuration using specified manifest file
AndroidManifest manifest = new AndroidManifest(mergedManifestFile, null, null);
// Check: manifest file should contain only expected permissions
assertThat(manifest.getUsedPermissions())
.containsExactly(expectedPermissions);
}
示例7: getAppManifest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String path = getPathManifest();
// android studio has a different execution root for tests than pure gradle
// so we avoid here manual effort to get them running inside android studio
if (!new File(path).exists()) {
path = PATH_PREFIX + path;
}
config = overwriteConfig(config, CONFIG_MANIFEST, path);
config = overwriteConfig(config, CONFIG_ASSET_DIR, getPathAssets());
config = overwriteConfig(config, CONFIG_RESOURCE_DIR, getPathResources());
if (packageName != null) {
config = overwriteConfig(config, CONFIG_PACKAGE_NAME, packageName);
}
if (applicationClass != null) {
config = overwriteConfig(config, CONFIG_APPLICATION, applicationClass.getCanonicalName());
}
return super.getAppManifest(config);
}
示例8: getAppManifest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String manifestProperty = System.getProperty("android.manifest");
if (config.manifest().equals(Config.DEFAULT) && manifestProperty != null) {
String resProperty = System.getProperty("android.resources");
String assetsProperty = System.getProperty("android.assets");
AndroidManifest androidManifest = new AndroidManifest(
Fs.fileFromPath(manifestProperty),
Fs.fileFromPath(resProperty),
Fs.fileFromPath(assetsProperty)) {
@Override
public int getTargetSdkVersion() {
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
}
};
androidManifest.setPackageName("zenproject.meditation.android");
return androidManifest;
}
return super.getAppManifest(config);
}
示例9: createAppManifest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest createAppManifest(FsFile manifestFile, FsFile resDir, FsFile assetsDir) {
return new AndroidManifest(
Fs.fileFromPath("src/main/AndroidManifest.xml"),
Fs.fileFromPath("src/main/res"),
Fs.fileFromPath("src/main/assets")) {
@Override
public int getTargetSdkVersion() {
return 18;
}
@Override
public String getThemeRef(Class<? extends Activity> activityClass) {
return "@android:style/Theme.Holo.Light.NoActionBar";
}
};
}
示例10: getAppManifest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
final String manifestPath = PathResolver.resolveAndroidManifestPath();
final String resourcesPath = PathResolver.resolveResPath();
final String assetsPath = PathResolver.resolveAssetsPath();
AndroidManifest manifest = new AndroidManifest(
Fs.fileFromPath(manifestPath),
Fs.fileFromPath(resourcesPath),
Fs.fileFromPath(assetsPath)) {
@Override
public int getTargetSdkVersion() {
return TARGET_SDK_VERSION;
}
@Override
public int getMinSdkVersion() {
return MIN_SDK_VERSION;
}
};
manifest.setPackageName("pl.dawidgdanski.bakery");
return manifest;
}
示例11: getAppManifest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String manifestPath = APP_ROOT_DIRECTORY + ANDROID_MANIFEST_FILE_NAME;
String resDir = APP_ROOT_DIRECTORY + RES_DIR;
String assetsDir = APP_ROOT_DIRECTORY + ASSETS_DIR;
AndroidManifest manifest = new AndroidManifest(Fs.fileFromPath(manifestPath),
Fs.fileFromPath(resDir),
Fs.fileFromPath(assetsDir)) {
@Override
public int getTargetSdkVersion() {
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
}
};
return manifest;
}
示例12: getAppManifest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
private AndroidManifest getAppManifest(Config config) {
ManifestFactory manifestFactory = getManifestFactory(config);
ManifestIdentifier identifier = manifestFactory.identify(config);
synchronized (appManifestsCache) {
AndroidManifest appManifest;
appManifest = appManifestsCache.get(identifier);
if (appManifest == null) {
appManifest = manifestFactory.create(identifier);
appManifestsCache.put(identifier, appManifest);
}
return appManifest;
}
}
示例13: pickSdkVersion
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
private int pickSdkVersion(Config config, AndroidManifest manifest) {
if (config != null && config.sdk().length > 1) {
throw new IllegalArgumentException("Robospock does not support multiple values for @Config.sdk");
} else if (config != null && config.sdk().length == 1) {
return config.sdk()[0];
} else if (manifest != null) {
return manifest.getTargetSdkVersion();
} else {
return SdkConfig.FALLBACK_SDK_VERSION;
}
}
示例14: OleasterRobolectricRunner
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
public OleasterRobolectricRunner(
Class<?> testClass,
SdkEnvironment sandbox,
Config config,
AndroidManifest androidManifest)
throws
InitializationError {
super(testClass);
this.sandbox = sandbox;
this.config = config;
this.androidManifest = androidManifest;
}
示例15: beforeTest
import org.robolectric.manifest.AndroidManifest; //导入依赖的package包/类
protected void beforeTest(Sandbox sandbox, Spec spec) throws Throwable {
SdkEnvironment sdkEnvironment = (SdkEnvironment) sandbox;
RoboSpec roboSpec = (RoboSpec) spec;
roboSpec.parallelUniverseInterface = getHooksInterface(sdkEnvironment);
Class<TestLifecycle> cl = sdkEnvironment.bootstrappedClass(getTestLifecycleClass());
roboSpec.testLifecycle = ReflectionHelpers.newInstance(cl);
final Config config = roboSpec.config;
final AndroidManifest appManifest = roboSpec.getAppManifest();
roboSpec.parallelUniverseInterface.setSdkConfig((sdkEnvironment).getSdkConfig());
roboSpec.parallelUniverseInterface.resetStaticState(config);
SdkConfig sdkConfig = roboSpec.sdkConfig;
Class<?> androidBuildVersionClass = (sdkEnvironment).bootstrappedClass(Build.VERSION.class);
ReflectionHelpers.setStaticField(androidBuildVersionClass, "SDK_INT", sdkConfig.getApiLevel());
ReflectionHelpers.setStaticField(androidBuildVersionClass, "RELEASE", sdkConfig.getAndroidVersion());
ReflectionHelpers.setStaticField(androidBuildVersionClass, "CODENAME", sdkConfig.getAndroidCodeName());
PackageResourceTable systemResourceTable = sdkEnvironment.getSystemResourceTable(getJarResolver());
PackageResourceTable appResourceTable = getAppResourceTable(appManifest);
// This will always be non empty since every class has basic methods like toString.
Method randomMethod = getTestClass().getJavaClass().getMethods()[0];
roboSpec.parallelUniverseInterface.setUpApplicationState(
randomMethod,
roboSpec.testLifecycle,
appManifest,
config,
new RoutingResourceTable(getCompiletimeSdkResourceTable(), appResourceTable),
new RoutingResourceTable(systemResourceTable, appResourceTable),
new RoutingResourceTable(systemResourceTable));
roboSpec.testLifecycle.beforeTest(null);
}