当前位置: 首页>>代码示例>>Java>>正文


Java AndroidManifest类代码示例

本文整理汇总了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
        }

    };
}
 
开发者ID:acadet,项目名称:springbok,代码行数:19,代码来源:GradleRobolectricTestRunner.java

示例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;
    }
  };
}
 
开发者ID:glombard,项目名称:so,代码行数:21,代码来源:MyTestRunner.java

示例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;
 }
 
开发者ID:benwilcock,项目名称:android-alltest-gradle-sample,代码行数:18,代码来源:RobolectricGradleTestRunner.java

示例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;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:18,代码来源:ShadowActivity.java

示例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;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:27,代码来源:RobolectricPackageManager.java

示例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;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:26,代码来源:RobolectricPackageManager.java

示例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;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:25,代码来源:RobolectricPackageManager.java

示例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;
    }

  };
}
 
开发者ID:pinicius,项目名称:CAS2016,代码行数:13,代码来源:RosieRobolectricTestRunner.java

示例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);
}
 
开发者ID:josephearl,项目名称:foundry,代码行数:10,代码来源:FoundryTestRunner.java

示例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"));
                }
            };
        }
    }));
}
 
开发者ID:blinkboxbooks,项目名称:android-ePub-Library,代码行数:14,代码来源:Runner.java

示例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);
}
 
开发者ID:evant,项目名称:simplefragment,代码行数:14,代码来源:CustomRobolectricRunner.java

示例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);
}
 
开发者ID:evant,项目名称:simplefragment,代码行数:9,代码来源:CustomRobolectricRunner.java

示例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;
        }
    };
}
 
开发者ID:mahdihijazi,项目名称:interview_tasks,代码行数:11,代码来源:RobojavaTestRunner.java

示例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));
}
 
开发者ID:skoumalcz,项目名称:joogar,代码行数:8,代码来源:RobolectricGradleTestRunner.java


注:本文中的org.robolectric.AndroidManifest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。