本文整理汇总了Java中org.robolectric.res.builder.RobolectricPackageManager.addPackage方法的典型用法代码示例。如果您正苦于以下问题:Java RobolectricPackageManager.addPackage方法的具体用法?Java RobolectricPackageManager.addPackage怎么用?Java RobolectricPackageManager.addPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robolectric.res.builder.RobolectricPackageManager
的用法示例。
在下文中一共展示了RobolectricPackageManager.addPackage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute_whenUberAppInsalled_shouldPointToUberApp
import org.robolectric.res.builder.RobolectricPackageManager; //导入方法依赖的package包/类
@Test
public void execute_whenUberAppInsalled_shouldPointToUberApp() throws IOException {
String expectedUri = readUriResourceWithUserAgentParam("src/test/resources/deeplinkuris/just_client_provided",
USER_AGENT_DEEPLINK);
Activity activity = Robolectric.setupActivity(Activity.class);
ShadowActivity shadowActivity = shadowOf(activity);
RobolectricPackageManager packageManager = RuntimeEnvironment.getRobolectricPackageManager();
PackageInfo uberPackage = new PackageInfo();
uberPackage.packageName = UBER_PACKAGE_NAME;
packageManager.addPackage(uberPackage);
RideParameters rideParameters = new RideParameters.Builder().build();
RequestDeeplink requestDeeplink = new RequestDeeplink.Builder(activity)
.setRideParameters(rideParameters)
.setSessionConfiguration(new SessionConfiguration.Builder().setClientId("clientId").build())
.build();
requestDeeplink.execute();
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertEquals(expectedUri, startedIntent.getData().toString());
}
示例2: simulateAppUpdate
import org.robolectric.res.builder.RobolectricPackageManager; //导入方法依赖的package包/类
static void simulateAppUpdate() {
RobolectricPackageManager rpm = RuntimeEnvironment.getRobolectricPackageManager();
PackageInfo packageInfo = new PackageInfo();
packageInfo.packageName = RuntimeEnvironment.application.getPackageName();
packageInfo.lastUpdateTime = new Date().getTime();
rpm.addPackage(packageInfo);
Once.initialise(RuntimeEnvironment.application);
}
示例3: createApplication
import org.robolectric.res.builder.RobolectricPackageManager; //导入方法依赖的package包/类
@Override
public Application createApplication(Method method, AndroidManifest appManifest, Config config) {
// FIXME If a future version of Robolectric implements "setInstallerPackageName", remove this.
RobolectricPackageManager oldManager = Robolectric.packageManager;
RobolectricPackageManager newManager = new FullEnvPackageManager();
for (PackageInfo pkg : oldManager.getInstalledPackages(0))
newManager.addPackage(pkg);
Robolectric.packageManager = newManager;
return new PiwikTestApplication();
}
示例4: addInstalledPackage
import org.robolectric.res.builder.RobolectricPackageManager; //导入方法依赖的package包/类
private void addInstalledPackage(String packageName) {
RobolectricPackageManager pm = Robolectric.packageManager;
PackageInfo packInfo = new PackageInfo();
packInfo.packageName = packageName;
pm.addPackage(packInfo);
}