Java 类org.robolectric.res.FileFsFile 实例源码

项目:mobsoft-lab    文件:RobolectricDaggerTestRunner.java   
@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);
}
项目:materialandroid    文件:LibraryRobolectricTestRunner.java   
@Override
protected AndroidManifest getAppManifest(Config config) {
  AndroidManifest appManifest = super.getAppManifest(config);
  FsFile androidManifestFile = appManifest.getAndroidManifestFile();

  if (androidManifestFile.exists()) {
    return appManifest;
  } else {
    androidManifestFile = FileFsFile.from(appManifest.getAndroidManifestFile().getPath()
        .replace("manifests/full", "manifests/aapt"));
    return new AndroidManifest(androidManifestFile, appManifest.getResDirectory(), appManifest.getAssetsDirectory());
  }
}
项目:markdown-to-spanned    文件:ManifestedRobolectricGradeTestRunner.java   
protected AndroidManifest getAppManifest(Config config) {
    AndroidManifest appManifest = super.getAppManifest(config);
    FsFile androidManifestFile = appManifest.getAndroidManifestFile();

    if (androidManifestFile.exists()) {
        return appManifest;
    } else {
        String moduleRoot = getModuleRootPath(config);
        androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("bundles", "manifests/full"));
        FsFile resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath());
        FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath());
        return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory);
    }
}
项目:MVPAndroidBootstrap    文件:AppRobolectricRunner.java   
protected AndroidManifest getAppManifest(Config config) {
    AndroidManifest appManifest = super.getAppManifest(config);
    FsFile androidManifestFile = appManifest.getAndroidManifestFile();

    if (androidManifestFile.exists()) {
        return appManifest;
    } else {
        String moduleRoot = getModuleRootPath(config);
        androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("bundles", "manifests/full"));
        FsFile resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath());
        FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath());
        return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory);
    }
}
项目:hoko-android    文件:HokoGradleTestRunner.java   
@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 packageName = getPackageName(config);

    final FileFsFile res;
    final FileFsFile assets;
    final FileFsFile manifest;

    if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) {
        res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type);
    } else {
        res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) {
        assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type);
    } else {
        assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) {
        manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "androidTest", flavor, type, "AndroidManifest.xml");
    } else {
        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: " + packageName);
    return new AndroidManifest(manifest, res, assets, packageName);
}
项目:SnackbarBuilder    文件:LibraryRobolectricTestRunner.java   
@Override
protected AndroidManifest getAppManifest(Config config) {
  AndroidManifest appManifest = super.getAppManifest(config);
  FsFile androidManifestFile = appManifest.getAndroidManifestFile();

  if (androidManifestFile.exists()) {
    return appManifest;
  } else {
    androidManifestFile = FileFsFile.from(appManifest.getAndroidManifestFile().getPath()
        .replace("manifests/full", "manifests/aapt"));
    return new AndroidManifest(androidManifestFile, appManifest.getResDirectory(), appManifest.getAssetsDirectory());
  }
}
项目:lasso    文件:CustomRobolectricRunner.java   
protected AndroidManifest getAppManifest(Config config) {
    AndroidManifest appManifest = super.getAppManifest(config);
    FsFile androidManifestFile = appManifest.getAndroidManifestFile();

    if (androidManifestFile.exists()) {
        return appManifest;
    } else {
        String moduleRoot = getModuleRootPath(config);
        androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("bundles", "manifests/full"));
        FsFile resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath().replace("/res", "").replace("bundles", "res"));
        FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath().replace("/assets", "").replace("bundles", "assets"));
        return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory);
    }
}
项目:FullRobolectricTestSample    文件:TemporaryAsset.java   
public File createFile(AndroidManifest manifest, String fileName, String contents) throws Exception {
  File assetBase = ((FileFsFile) manifest.getAssetsDirectory()).getFile();
  File file = new File(assetBase, fileName);
  file.getParentFile().mkdirs();

  FileWriter fileWriter = new FileWriter(file);
  try {
     fileWriter.write(contents);
  } finally {
    fileWriter.close();
  }

  assetsToDelete.add(file);
  return file;
}
项目:tickmate    文件:TickmateTestRunner.java   
protected AndroidManifest getAppManifest(Config config) {
    AndroidManifest appManifest = super.getAppManifest(config);
    FsFile androidManifestFile = appManifest.getAndroidManifestFile();

    if (androidManifestFile.exists()) {
        return appManifest;
    } else {
        androidManifestFile = FileFsFile.from(MODULE_ROOT, "src/main/AndroidManifest.xml");
        FsFile resDirectory = FileFsFile.from(MODULE_ROOT, "src/main/res");
        FsFile assetsDirectory = FileFsFile.from(MODULE_ROOT, "src/main/assets");

        return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory);
    }
}
项目:crom    文件:CustomRobolectricRunner.java   
protected AndroidManifest getAppManifest(Config config) {
    AndroidManifest appManifest = super.getAppManifest(config);
    FsFile androidManifestFile = appManifest.getAndroidManifestFile();

    if (androidManifestFile.exists()) {
        return appManifest;
    } else {
        String moduleRoot = getModuleRootPath(config);
        androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath());
        FsFile resDirectory = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("AndroidManifest.xml", "res"));
        FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("AndroidManifest.xml", "assets"));
        return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory);
    }
}
项目:mobile-sdk-android    文件:RoboelectricTestRunnerWithResources.java   
protected AndroidManifest getAppManifest(Config config) {
    AndroidManifest appManifest = super.getAppManifest(config);
    FsFile androidManifestFile = appManifest.getAndroidManifestFile();
    FsFile resDirectory;
    FsFile assetsDirectory;


    String moduleRoot = getModuleRootPath(config);
    androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("bundles", "manifests/aapt"));

    if(appManifest.getResDirectory().getPath().contains("release")) {
        resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath().replace("release", "default"));
        assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath().replace("release", "default"));
    }else{
        resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath().replace("bundles/debug/res", "res/merged/debug"));
        assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath());
    }


    System.out.print(androidManifestFile.getPath() + '\n');
    System.out.print(resDirectory.getPath() + '\n');
    System.out.print(assetsDirectory.getPath() + '\n');


    return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory);

}
项目:mobile-sdk-android    文件:RoboelectricTestRunnerWithResources.java   
protected AndroidManifest getAppManifest(Config config) {
    AndroidManifest appManifest = super.getAppManifest(config);
    FsFile androidManifestFile = appManifest.getAndroidManifestFile();
    FsFile resDirectory;
    FsFile assetsDirectory;


        String moduleRoot = getModuleRootPath(config);
        androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("bundles", "manifests/aapt"));

        if(appManifest.getResDirectory().getPath().contains("release")) {
            resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath().replace("release", "default"));
            assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath().replace("release", "default"));
        }else{
            resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath());
            assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath());
        }


        System.out.print(androidManifestFile.getPath() + '\n');
        System.out.print(resDirectory.getPath() + '\n');
        System.out.print(assetsDirectory.getPath() + '\n');


        return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory);

}
项目:rx-daggered-robogradler    文件:RoboTestRunner.java   
@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 packageName = getPackageName(config);

    final FileFsFile res;
    final FileFsFile assets;
    final FileFsFile manifest;

    // res/merged added in Android Gradle plugin 1.3-beta1

    // Recognize new name for data binding layouts until later plugin version
    if (FileFsFile.from(BUILD_OUTPUT, "data-binding-layout-out").exists()) {
        res = FileFsFile.from(BUILD_OUTPUT, "data-binding-layout-out", flavor, type);
    } else if (FileFsFile.from(BUILD_OUTPUT, "res", "merged").exists()) {
        res = FileFsFile.from(BUILD_OUTPUT, "res", "merged", flavor, type);
    } else if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) {
        res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type);
    } else {
        res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) {
        assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type);
    } else {
        assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) {
        manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", flavor, type, "AndroidManifest.xml");
    } else {
        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: " + packageName);
    return new AndroidManifest(manifest, res, assets, packageName);
}
项目:android-oss    文件:KSRobolectricGradleTestRunner.java   
@Override
protected AndroidManifest getAppManifest(final 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 packageName = getPackageName(config);

  final FileFsFile res;
  final FileFsFile assets;
  final FileFsFile manifest;

  // res/merged added in Android Gradle plugin 1.3-beta1
  if (FileFsFile.from(BUILD_OUTPUT, "res", "merged").exists()) {
    res = FileFsFile.from(BUILD_OUTPUT, "res", "merged", flavor, type);
  } else if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) {
    res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type);
  } else {
    res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res");
  }

  if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) {
    assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type);
  } else {
    assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets");
  }

  if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) {
    manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", flavor, type, "AndroidManifest.xml");
  } else {
    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: " + packageName);

  return new AndroidManifest(manifest, res, assets) {
    @Override
    public String getRClassName() throws Exception {
      return com.kickstarter.R.class.getName();
    }
  };
}
项目:rokontrol-android    文件:PatchedRobolectricGradleTestRunner.java   
@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 packageName = getPackageName(config);

    final FileFsFile res;
    final FileFsFile assets;
    final FileFsFile manifest;

    // res/merged added in Android Gradle plugin 1.3-beta1
    if (FileFsFile.from(BUILD_OUTPUT, "res", "merged").exists()) {
        res = FileFsFile.from(BUILD_OUTPUT, "res", "merged", flavor, type);
    } else if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) {
        res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type);
    } else {
        res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) {
        assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type);
    } else {
        assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "manifests", "test", flavor, type, "AndroidManifest.xml").exists()) {
        manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "test", flavor, type, "AndroidManifest.xml");
    } else if (FileFsFile.from(BUILD_OUTPUT, "manifests", "full", flavor, type, "AndroidManifest.xml").exists()) {
        manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", flavor, type, "AndroidManifest.xml");
    } else {
        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: " + packageName);
    return new AndroidManifest(manifest, res, assets, packageName);
}
项目:edx-app-android    文件:DataBindingRobolectricGradleTestRunner.java   
@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 packageName = getPackageName(config);

    final FileFsFile res;
    final FileFsFile assets;
    final FileFsFile manifest;

    if (FileFsFile.from(BUILD_OUTPUT, "data-binding-layout-out").exists()) {
        // Android gradle plugin 1.5.0+ puts the merged layouts in data-binding-layout-out.
        // https://github.com/robolectric/robolectric/issues/2143
        res = FileFsFile.from(BUILD_OUTPUT, "data-binding-layout-out", flavor, type);
    } else if (FileFsFile.from(BUILD_OUTPUT, "res", "merged").exists()) {
        // res/merged added in Android Gradle plugin 1.3-beta1
        res = FileFsFile.from(BUILD_OUTPUT, "res", "merged", flavor, type);
    } else if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) {
        res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type);
    } else {
        res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) {
        assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type);
    } else {
        assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) {
        manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", flavor, type, "AndroidManifest.xml");
    } else {
        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: " + packageName);
    return new AndroidManifest(manifest, res, assets, packageName);
}
项目:algoliasearch-client-android    文件:CustomRunner.java   
@Override
protected AndroidManifest getAppManifest(Config config) {
    final String cwd = System.getProperty("user.dir");
    Logger.debug("Current working directory: " + cwd);

    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 packageName = getPackageName(config);

    final FileFsFile res;
    final FileFsFile assets;
    final FileFsFile manifest;

    if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) {
        res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type);
    } else {
        res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) {
        assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type);
    } else {
        assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets");
    }

    if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) {
        // [CUSTOMIZED] The default implementation uses `full` instead of `aapt`.
        manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "aapt", flavor, type, "AndroidManifest.xml");
    } else {
        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: " + packageName);
    return new AndroidManifest(manifest, res, assets, packageName);
}