项目:lex
文件:LexTestRunner.java
@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(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;
}
};
}
项目:schulcloud-mobile-android
文件:ApplicationRobolectricTestRunner.java
@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;
}
项目:MVP-Boilerplate
文件:PermissionsTest.java
@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);
}
项目:dora
文件:DoraTestRunner.java
@Override
protected Properties getConfigProperties() {
Properties configProperties = super.getConfigProperties();
if (configProperties == null) {
configProperties = new Properties();
}
String manifestPath = "src/test/AndroidManifest.xml";
FsFile manifestFile = Fs.newFile(new File(manifestPath));
if (manifestFile.exists()) {
configProperties.put("manifest",manifestPath);
} else {
configProperties.put("manifest","LikeOrmExample/" + manifestPath);
}
configProperties.put("emulateSdk","16");
return configProperties;
}
项目:Zen
文件:RobolectricLauncherGradleTestRunner.java
@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);
}
项目:stack-overflow-android
文件:MyRobolectricTestRunner.java
@Override
protected AndroidManifest createAppManifest(FsFile manifestFile,FsFile resDir,FsFile assetsDir) {
return new AndroidManifest(
Fs.fileFromPath("src/main/AndroidManifest.xml"),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";
}
};
}
项目:android-couchbase-dagger-robolectric
文件:RobolectricGradleTestRunner.java
@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(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;
}
项目:Bakery
文件:AppRobolectricTestRunner.java
@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(assetsPath)) {
@Override
public int getTargetSdkVersion() {
return TARGET_SDK_VERSION;
}
@Override
public int getMinSdkVersion() {
return MIN_SDK_VERSION;
}
};
manifest.setPackageName("pl.dawidgdanski.bakery");
return manifest;
}
项目:springbok
文件:GradleRobolectricTestRunner.java
@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
}
};
}
项目:so
文件:MyTestRunner.java
@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;
}
};
}
项目:android-alltest-gradle-sample
文件:RobolectricGradleTestRunner.java
@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(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;
}
@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(assetsDir)) {
@Override
public int getTargetSdkVersion() {
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
}
};
return manifest;
}
项目:Forage
文件:PermissionsTest.java
/**
* Test to check if libraries are adding extra permissions to the app manifest.
*/
@Test
public void shouldMatchPermissions() {
AndroidManifest manifest = new AndroidManifest(
Fs.fileFromPath(MERGED_MANIFEST),null
);
assertthat(new HashSet<>(manifest.getUsedPermissions())).
containsExactly((Object[]) EXPECTED_PERMISSIONS);
}
项目:MediaMonkey
文件:MyRobolectricGradleTestRunner.java
@Override
protected AndroidManifest getAppManifest(Config config) {
String basePath = new File(".").getAbsolutePath();
String manifest = basePath + "/src/main/AndroidManifest.xml";
String res = basePath + String.format("/build/intermediates/res/merged/%1$s/%2$s",BuildConfig.FLAVOR,BuildConfig.BUILD_TYPE);
String asset = basePath + "/src/test/assets";
return new AndroidManifest(Fs.fileFromPath(manifest),Fs.fileFromPath(res),Fs.fileFromPath(asset));
}
项目:CAS2016
文件:RosieRobolectricTestRunner.java
@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;
}
};
}
项目:BaseUtil
文件:TestClient.java
@Test
public void testPermissions() {
String MERGED_MANIFEST = "build/intermediates/manifests/full/debug/AndroidManifest.xml";
String EXPECTED_PERMISSIONS = "android.permission.INTERNET";
AndroidManifest manifest = new AndroidManifest(Fs.fileFromPath(MERGED_MANIFEST),null);
LogUtil.print(manifest.getUsedPermissions().toString());
assertthat(manifest.getUsedPermissions()).contains(EXPECTED_PERMISSIONS);
}
@Override
protected AndroidManifest getAppManifest(Config config) {
String buildVariant = (BuildConfig.FLAVOR.isEmpty() ? "" : BuildConfig.FLAVOR + "/")
+ BuildConfig.BUILD_TYPE;
return new AndroidManifest(
Fs.fileFromPath("src/test/AndroidManifest.xml"),Fs.fileFromPath("build/intermediates/res/" + buildVariant),Fs.fileFromPath("src/test/assets")
);
}
项目:interview_tasks
文件:RobojavaTestRunner.java
private static AndroidManifest getAndroidManifest() {
return new AndroidManifest(Fs.fileFromPath(MANIFEST),Fs.fileFromPath(RESOURCES),Fs.fileFromPath(ASSETS)) {
@Override
public int getTargetSdkVersion() {
return TARGET_SDK_VERSION;
}
};
}
项目:MyConference
文件:RobolectricManifestTestRunner.java
@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(assetsDir));
manifest.setPackageName("com.nhpatt.myconference");
return manifest;
}
项目:joogar
文件:RobolectricGradleTestRunner.java
@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));
}
项目:Nox
文件:NoxRobolectricTestRunner.java
@Override protected AndroidManifest getAppManifest(Config config) {
String manifestProperty = "../nox/src/test/AndroidManifest.xml";
String resProperty = "../nox/src/main/res";
return new AndroidManifest(Fs.fileFromPath(manifestProperty),Fs.fileFromPath(resProperty)) {
@Override public int getTargetSdkVersion() {
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
}
};
}
项目:okbuck
文件:BuckRobolectricTestRunner.java
@Override
protected AndroidManifest getAppManifest(Config config) {
String buckManifest = System.getProperty(ROBOLECTRIC_MANIFEST);
String buckResourcesProperty = System.getProperty(ROBOLECTRIC_RESOURCE_DIRECTORIES);
if (buckManifest != null && buckResourcesProperty != null) {
final List<String> buckResources = Arrays.asList(buckResourcesProperty.split(File.pathSeparator));
final FsFile res = Fs.fileFromPath(buckResources.get(buckResources.size() - 1));
final FsFile assets = Fs.fileFromPath(buckResources.get(buckResources.size() - 1));
final FsFile manifest = Fs.fileFromPath(buckManifest);
return new AndroidManifest(manifest,res,assets,config.packageName()) {
@Override
public List<ResourcePath> getIncludedResourcePaths() {
Collection<ResourcePath> resourcePaths = new LinkedHashSet<>();
resourcePaths.add(super.getResourcePath());
ListIterator<String> it = buckResources.listIterator(buckResources.size());
while (it.hasPrevIoUs()) {
resourcePaths.add(new ResourcePath(
getRClass(),getPackageName(),Fs.fileFromPath(it.prevIoUs()),getAssetsDirectory()));
}
return new ArrayList<>(resourcePaths);
}
};
} else {
return null;
}
}
项目:FullRobolectricTestSample
文件:RobolectricTestRunner.java
protected AndroidManifest getAppManifest(Config config) {
if (config.manifest().equals(Config.NONE)) {
return null;
}
String manifestProperty = System.getProperty("android.manifest");
String resourcesProperty = System.getProperty("android.resources");
String assetsProperty = System.getProperty("android.assets");
FsFile fsFile = getBaseDir();
FsFile manifestFile;
FsFile resDir;
FsFile assetsDir;
boolean defaultManifest = config.manifest().equals(Config.DEFAULT);
if (defaultManifest && manifestProperty != null) {
manifestFile = Fs.fileFromPath(manifestProperty);
resDir = Fs.fileFromPath(resourcesProperty);
assetsDir = Fs.fileFromPath(assetsProperty);
} else {
manifestFile = fsFile.join(defaultManifest ? "AndroidManifest.xml" : config.manifest());
resDir = manifestFile.getParent().join(config.resourceDir());
assetsDir = manifestFile.getParent().join("assets");
}
synchronized (envHolder) {
AndroidManifest appManifest;
appManifest = envHolder.appManifestsByFile.get(manifestFile);
if (appManifest == null) {
long startTime = System.currentTimeMillis();
appManifest = createAppManifest(manifestFile,resDir,assetsDir);
if (DocumentLoader.DEBUG_PERF)
System.out.println(String.format("%4dms spent in %s",System.currentTimeMillis() - startTime,manifestFile));
envHolder.appManifestsByFile.put(manifestFile,appManifest);
}
return appManifest;
}
}
项目:FullRobolectricTestSample
文件:SdkEnvironment.java
public PackageResourceLoader createSystemResourceLoader(MavenCentral mavenCentral,RobolectricTestRunner robolectricTestRunner) {
URL url = mavenCentral.getLocalArtifactUrl(robolectricTestRunner,sdkConfig.getSystemResourceDependency());
Fs systemResFs = Fs.fromJar(url);
ResourceExtractor resourceExtractor = new ResourceExtractor(getRobolectricclassLoader());
ResourcePath resourcePath = new ResourcePath(resourceExtractor.getProcessedRFile(),resourceExtractor.getPackageName(),systemResFs.join("res"),systemResFs.join("assets"));
return new PackageResourceLoader(resourcePath,resourceExtractor);
}
项目:FullRobolectricTestSample
文件:XmlFileBuilder.java
public static XmlResourceParser getXmlResourceParser(String file,String packageName,ResourceIndex resourceIndex) {
FsFile fsFile = Fs.fileFromPath(file);
Document document = new XmlFileLoader(null,"xml").parse(fsFile);
if (document == null) {
throw new Resources.NotFoundException("Couldn't find resource " + fsFile.getPath());
}
return new XmlFileBuilder().getXml(document,fsFile.getPath(),packageName,resourceIndex);
}
protected File getNativeLibraryPath() {
String tempPath = System.getProperty("java.io.tmpdir");
if (tempPath == null) {
throw new IllegalStateException("Java temporary directory is not defined (java.io.tmpdir)");
}
return new File(Fs.fileFromPath(tempPath).join("robolectric-libs",getLibName()).getPath());
}
项目:FullRobolectricTestSample
文件:DefaultTestLifecycleTest.java
private AndroidManifest newConfigWith(String packageName,String contents) throws IOException {
File f = temporaryFolder.newFile("whatever.xml","<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
" package=\"" + packageName + "\">\n" +
" " + contents + "\n" +
"</manifest>\n");
return new AndroidManifest(Fs.newFile(f),null);
}
项目:FullRobolectricTestSample
文件:ApplicationTest.java
private AndroidManifest newConfigWith(String packageName,null);
}
项目:FullRobolectricTestSample
文件:ActivityTest.java
private AndroidManifest newConfigWith(String packageName,null);
}
项目:FullRobolectricTestSample
文件:AndroidManifestTest.java
public AndroidManifest newConfigWith(String usesSdkAttrs) throws IOException {
File f = temporaryFolder.newFile("whatever.xml","<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
" package=\"org.robolectric\">\n" +
" <uses-sdk " + usesSdkAttrs + "/>\n" +
"</manifest>\n");
return new AndroidManifest(Fs.newFile(f),null);
}
项目:generator-android
文件:RobolectricGradleTestRunner.java
@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");
return new AndroidManifest(Fs.fileFromPath(manifestProperty),Fs.fileFromPath(assetsProperty));
}
return super.getAppManifest(config);
}
项目:android-unittesting
文件:RobolectricGradleTestRunner.java
@Override
protected AndroidManifest getAppManifest(Config config) {
String manifestProperty = "../app/src/main/AndroidManifest.xml";
String resProperty = "../app/src/main/res";
String assetsProperty = "../app/src/main/assets";
return new AndroidManifest(Fs.fileFromPath(manifestProperty),Fs.fileFromPath(assetsProperty)) {
@Override
public int getTargetSdkVersion() {
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
}
};
}
@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");
return new AndroidManifest(Fs.fileFromPath(manifestProperty),Fs.fileFromPath(assetsProperty));
}
AndroidManifest appManifest = super.getAppManifest(config);
return appManifest;
}
项目:android-uploader
文件:RobolectricGradleRunner.java
@Override
protected AndroidManifest getAppManifest(Config config) {
String manifestProperty = "src/main/AndroidManifest.xml";
String resProperty = "src/main/res";
return new AndroidManifest(Fs.fileFromPath(manifestProperty),Fs.fileFromPath(resProperty)) {
@Override
public int getTargetSdkVersion() {
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
}
};
}
项目:droidxing
文件:TestRunner.java
项目:TruckMuncher-Android
文件:ReadableRobolectricTestRunner.java
@Override
protected AndroidManifest getAppManifest(Config config) {
String manifestProperty = "src/main/AndroidManifest.xml";
String resProperty = "src/main/res";
return new AndroidManifest(Fs.fileFromPath(manifestProperty),Fs.fileFromPath(resProperty)) {
@Override
public int getTargetSdkVersion() {
return 18;
}
};
}
@Test
public void shouldMatchPermissions() {
AndroidManifest manifest = new AndroidManifest(
Fs.fileFromPath(MERGED_MANIFEST),null
);
assertthat(new HashSet<>(manifest.getUsedPermissions())).
containsOnly(EXPECTED_PERMISSIONS);
}
项目:osmdroid
文件:CustomTestRunner.java
@Override
protected AndroidManifest getAppManifest(Config config) {
String manifestPath = "AndroidManifest.xml";
String resPath = "src/main/res/";
String assets = "src/main/assets/";
return new AndroidManifest(Fs.fileFromPath(manifestPath),Fs.fileFromPath(assets)) {
@Override
public int getTargetSdkVersion() {
return 18;
}
};
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。