本文整理汇总了Java中org.robolectric.AndroidManifest类的典型用法代码示例。如果您正苦于以下问题:Java AndroidManifest类的具体用法?Java AndroidManifest怎么用?Java AndroidManifest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AndroidManifest类属于org.robolectric包,在下文中一共展示了AndroidManifest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAppManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String appRoot = "../app/src/main/";
String manifestPath = appRoot + "AndroidManifest.xml";
String resDir = appRoot + "res";
String assetsDir = appRoot + "assets";
AndroidManifest manifest = createAppManifest(Fs.fileFromPath(manifestPath),
Fs.fileFromPath(resDir),
Fs.fileFromPath(assetsDir));
// If you change the package - don't forget to change the build.gradle and the AndroidManifest.xml
manifest.setPackageName("com.soagrowers.android");
// Robolectric is already going to look in the 'app' dir ...
// so no need to add to package name
return manifest;
}
开发者ID:benwilcock,项目名称:android-couchbase-dagger-robolectric,代码行数:19,代码来源:RobolectricGradleTestRunner.java
示例2: getAppManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override
public AndroidManifest getAppManifest(Config config) {
return new AndroidManifest(
Fs.fileFromPath(MANIFEST_PROPERTY),
Fs.fileFromPath(RES_PROPERTY)
) {
@Override
public int getTargetSdkVersion() {
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
}
@Override
public String getThemeRef(Class<? extends Activity> activityClass) {
return "@style/AppTheme"; // Needs to define default theme
}
};
}
示例3: getAppManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String path = "src/main";
if (!new File(path).exists()) {
path = "app/" + path;
}
final String manifestProperty = path + "/AndroidManifest.xml";
final String resProperty = path + "/res";
return new AndroidManifest(Fs.fileFromPath(manifestProperty), Fs.fileFromPath(resProperty)) {
@Override
public int getTargetSdkVersion() {
return ROBOLECTRIC_SDK_VERSION;
}
@Override
public String getThemeRef(Class<? extends Activity> activityClass) {
return ROBOLECTRIC_THEME;
}
};
}
示例4: getAppManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
//String appRoot = "D:\\TmpCodingProjects\\TripComputer\\app\\src\\main\\";
String appRoot = "../app/src/main/";
String manifestPath = appRoot + "AndroidManifest.xml";
String resDir = appRoot + "res";
String assetsDir = appRoot + "assets";
AndroidManifest manifest = createAppManifest(Fs.fileFromPath(manifestPath),
Fs.fileFromPath(resDir),
Fs.fileFromPath(assetsDir));
// If you change the package - don't forget to change the build.gradle and the AndroidManifest.xml
manifest.setPackageName("com.soagrowers.android");
// Robolectric is already going to look in the 'app' dir ...
// so no need to add to package name
return manifest;
}
示例5: setThemeFromManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
public boolean setThemeFromManifest() {
ShadowApplication shadowApplication = shadowOf(realActivity.getApplication());
AndroidManifest appManifest = shadowApplication.getAppManifest();
if (appManifest == null) return false;
String themeRef = appManifest.getThemeRef(realActivity.getClass());
if (themeRef != null) {
ResName style = ResName.qualifyResName(themeRef.replace("@", ""), appManifest.getPackageName(), "style");
Integer themeRes = shadowApplication.getResourceLoader().getResourceIndex().getResourceId(style);
if (themeRes == null)
throw new Resources.NotFoundException("no such theme " + style.getFullyQualifiedName());
realActivity.setTheme(themeRes);
return true;
}
return false;
}
示例6: getActivityInfo
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override public ActivityInfo getActivityInfo(ComponentName className, int flags) throws NameNotFoundException {
String packageName = className.getPackageName();
AndroidManifest androidManifest = androidManifests.get(packageName);
String activityName = className.getClassName();
ActivityData activityData = androidManifest.getActivityData(activityName);
ActivityInfo activityInfo = new ActivityInfo();
activityInfo.packageName = packageName;
activityInfo.name = activityName;
if (activityData != null) {
ResourceIndex resourceIndex = Robolectric.getShadowApplication().getResourceLoader().getResourceIndex();
String themeRef;
// Based on ShadowActivity
if (activityData.getThemeRef() != null) {
themeRef = activityData.getThemeRef();
} else {
themeRef = androidManifest.getThemeRef();
}
if (themeRef != null) {
ResName style = ResName.qualifyResName(themeRef.replace("@", ""), packageName, "style");
activityInfo.theme = resourceIndex.getResourceId(style);
}
}
activityInfo.applicationInfo = getApplicationInfo(packageName, flags);
return activityInfo;
}
示例7: getReceiverInfo
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override
public ActivityInfo getReceiverInfo(ComponentName className, int flags) throws NameNotFoundException {
String packageName = className.getPackageName();
AndroidManifest androidManifest = androidManifests.get(packageName);
String classString = className.getClassName();
int index = classString.indexOf('.');
if (index == -1) {
classString = packageName + "." + classString;
} else if (index == 0) {
classString = packageName + classString;
}
ActivityInfo activityInfo = new ActivityInfo();
activityInfo.packageName = packageName;
activityInfo.name = classString;
if ((flags & GET_META_DATA) != 0) {
for (int i = 0; i < androidManifest.getReceiverCount(); ++i) {
if (androidManifest.getReceiverClassName(i).equals(classString)) {
activityInfo.metaData = metaDataToBundle(androidManifest.getReceiverMetaData(i));
break;
}
}
}
return activityInfo;
}
示例8: queryImplicitIntent
import org.robolectric.AndroidManifest; //导入依赖的package包/类
private List<ResolveInfo> queryImplicitIntent(Intent intent, int flags) {
List<ResolveInfo> resolveInfoList = new ArrayList<ResolveInfo>();
for (Map.Entry<String, AndroidManifest> androidManifest : androidManifests.entrySet()) {
String packageName = androidManifest.getKey();
AndroidManifest appManifest = androidManifest.getValue();
for (Map.Entry<String, ActivityData> activity : appManifest.getActivityDatas().entrySet()) {
String activityName = activity.getKey();
ActivityData activityData = activity.getValue();
if (matchIntentFilter(activityData, intent)) {
ResolveInfo resolveInfo = new ResolveInfo();
resolveInfo.resolvePackageName = packageName;
resolveInfo.activityInfo = new ActivityInfo();
resolveInfo.activityInfo.targetActivity = activityName;
resolveInfoList.add(resolveInfo);
}
}
}
return resolveInfoList;
}
示例9: getAppManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String manifestProperty = "../rosie/src/test/AndroidManifest.xml";
String resProperty = "../rosie/src/main/res";
return new AndroidManifest(Fs.fileFromPath(manifestProperty), Fs.fileFromPath(resProperty)) {
@Override
public int getTargetSdkVersion() {
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
}
};
}
示例10: createAppManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest createAppManifest(final FsFile manifestFile, final FsFile resDir,
final FsFile assetsDir) {
FsFile moduleManifestFile = fixModuleDirectoryPathIfNeeded(manifestFile);
FsFile moduleResDir = fixModuleDirectoryPathIfNeeded(resDir);
FsFile moduleAssetsDir = fixModuleDirectoryPathIfNeeded(assetsDir);
return super.createAppManifest(moduleManifestFile, moduleResDir, moduleAssetsDir);
}
示例11: Runner
import org.robolectric.AndroidManifest; //导入依赖的package包/类
public Runner(final Class<?> testClass) throws InitializationError {
super(RobolectricContext.bootstrap(Runner.class, testClass, new RobolectricContext.Factory() {
@Override
public RobolectricContext create() {
return new RobolectricContext() {
@Override
protected AndroidManifest createAppManifest() {
return new AndroidManifest(new File("build/tmp/android"));
}
};
}
}));
}
示例12: getAppManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String path = "src/main/AndroidManifest.xml";
// 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 = "app/" + path;
}
config = overwriteConfig(config, "manifest", path);
return super.getAppManifest(config);
}
示例13: pickSdkVersion
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override
protected SdkConfig pickSdkVersion(
AndroidManifest appManifest, Config config) {
// current Robolectric supports not the latest android SDK version
// so we must downgrade to simulate the latest supported version.
config = overwriteConfig(config, "emulateSdk", "18");
return super.pickSdkVersion(appManifest, config);
}
示例14: getAndroidManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
private static AndroidManifest getAndroidManifest() {
return new AndroidManifest(Fs.fileFromPath(MANIFEST),
Fs.fileFromPath(RESOURCES),
Fs.fileFromPath(ASSETS)) {
@Override
public int getTargetSdkVersion() {
return TARGET_SDK_VERSION;
}
};
}
示例15: getAppManifest
import org.robolectric.AndroidManifest; //导入依赖的package包/类
@Override protected AndroidManifest getAppManifest(Config config) {
String myAppPath = ClientApp.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String manifestPath = myAppPath + "../../../../src/main/AndroidManifest.xml";
String resPath = myAppPath + "../../../../src/main/res";
String assetPath = myAppPath + "../../../../src/main/assets";
return createAppManifest(Fs.fileFromPath(manifestPath), Fs.fileFromPath(resPath), Fs.fileFromPath(assetPath));
}