本文整理汇总了Java中org.robolectric.shadows.ShadowResolveInfo类的典型用法代码示例。如果您正苦于以下问题:Java ShadowResolveInfo类的具体用法?Java ShadowResolveInfo怎么用?Java ShadowResolveInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShadowResolveInfo类属于org.robolectric.shadows包,在下文中一共展示了ShadowResolveInfo类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: should_start_url_intent
import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
@Test
public void should_start_url_intent() {
// Given
String url = "geo:22.5430883,114.1043205";
RobolectricPackageManager rpm = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
rpm.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), ShadowResolveInfo.newResolveInfo("", "", ""));
// When
boolean result = Intents.startUri(activity, url);
// Then
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertThat(result).isTrue();
assertThat(startedIntent.getAction()).isEqualTo(Intent.ACTION_VIEW);
assertThat(startedIntent.getData().toString()).isEqualTo(url);
}
示例2: should_start_external_uri
import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
@Test
public void should_start_external_uri() {
// Given
String url = "http://www.google.com";
RobolectricPackageManager rpm = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
rpm.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), ShadowResolveInfo.newResolveInfo("", "", ""));
// When
Intents.startExternalUrl(activity, url);
// Then
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertThat(startedIntent.getAction()).isEqualTo(Intent.ACTION_VIEW);
assertThat(startedIntent.getData().toString()).isEqualTo(url);
}
示例3: testSelectItemOpenExternal
import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
@Test
public void testSelectItemOpenExternal() {
RobolectricPackageManager packageManager = (RobolectricPackageManager)
RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(
new Intent(Intent.ACTION_VIEW,
Uri.parse("http://example.com")),
ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
PreferenceManager.getDefaultSharedPreferences(activity)
.edit()
.putBoolean(activity.getString(R.string.pref_external), true)
.commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://example.com";
}
});
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW);
}
示例4: testSelectItemStartActionView
import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
@Test
public void testSelectItemStartActionView() {
RobolectricPackageManager packageManager = (RobolectricPackageManager)
RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(
new Intent(Intent.ACTION_VIEW,
Uri.parse("http://example.com")),
ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
packageManager.addResolveInfoForIntent(
new Intent(Intent.ACTION_VIEW,
Uri.parse("http://example.com")),
ShadowResolveInfo.newResolveInfo("label", "com.android.browser", "DefaultActivity"));
PreferenceManager.getDefaultSharedPreferences(activity)
.edit()
.putBoolean(activity.getString(R.string.pref_external), true)
.commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://example.com";
}
});
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW);
}
示例5: testSelectItemOpenChooser
import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
@Test
public void testSelectItemOpenChooser() {
RobolectricPackageManager packageManager = (RobolectricPackageManager)
RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(
new Intent(Intent.ACTION_VIEW,
Uri.parse("http://news.ycombinator.com/item?id=1")),
ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
packageManager.addResolveInfoForIntent(
new Intent(Intent.ACTION_VIEW,
Uri.parse("http://news.ycombinator.com/item?id=1")),
ShadowResolveInfo.newResolveInfo("label", "com.android.browser", "DefaultActivity"));
PreferenceManager.getDefaultSharedPreferences(activity)
.edit()
.putBoolean(activity.getString(R.string.pref_external), true)
.commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://news.ycombinator.com/item?id=1";
}
});
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_CHOOSER);
}
示例6: testBindService
import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
@Test
public void testBindService() throws RemoteException {
// no chrome installed should not bind service
delegate.bindCustomTabsService(activity);
assertThat(ShadowApplication.getInstance().getBoundServiceConnections()).isEmpty();
// bind service should create connection
RuntimeEnvironment.getRobolectricPackageManager().addResolveInfoForIntent(
new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")),
ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
RuntimeEnvironment.getRobolectricPackageManager().addResolveInfoForIntent(
new Intent("android.support.customtabs.action.CustomTabsService")
.setPackage("com.android.chrome"),
ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
delegate.bindCustomTabsService(activity);
List<ServiceConnection> connections = ShadowApplication.getInstance()
.getBoundServiceConnections();
assertThat(connections).isNotEmpty();
// on service connected should create session and warm up client
verify(service).warmup(anyLong());
assertNotNull(delegate.getSession());
verify(service).newSession(any(ICustomTabsCallback.class));
// may launch url should success
when(service.mayLaunchUrl(any(), any(), any(), any())).thenReturn(true);
assertTrue(delegate.mayLaunchUrl(Uri.parse("http://www.example.com"), null, null));
// on service disconnected should clear session
delegate.unbindCustomTabsService(activity);
assertNull(delegate.getSession());
}
示例7: addResolver
import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
public static void addResolver(Intent intent) {
RobolectricPackageManager packageManager = (RobolectricPackageManager)
RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent( intent,
ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
}
示例8: testOptionExternal
import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
@SuppressLint("NewApi")
@Test
public void testOptionExternal() {
RobolectricPackageManager packageManager = (RobolectricPackageManager)
RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(
new Intent(Intent.ACTION_VIEW,
Uri.parse("http://example.com")),
ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
packageManager.addResolveInfoForIntent(
new Intent(Intent.ACTION_VIEW,
Uri.parse(String.format(HackerNewsClient.WEB_ITEM_PATH, "1"))),
ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
Intent intent = new Intent();
intent.putExtra(ItemActivity.EXTRA_ITEM, new TestItem() {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
@Override
public String getUrl() {
return "http://example.com";
}
@Override
public boolean isStoryType() {
return true;
}
@Override
public String getId() {
return "1";
}
});
controller.withIntent(intent).create().start().resume();
// inflate menu, see https://github.com/robolectric/robolectric/issues/1326
ShadowLooper.pauseMainLooper();
controller.visible();
ShadowApplication.getInstance().getForegroundThreadScheduler().advanceToLastPostedRunnable();
// open article
shadowOf(activity).clickMenuItem(R.id.menu_external);
shadowOf(ShadowPopupMenu.getLatestPopupMenu())
.getOnMenuItemClickListener()
.onMenuItemClick(new RoboMenuItem(R.id.menu_article));
ShadowApplication.getInstance().getForegroundThreadScheduler().advanceToLastPostedRunnable();
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW);
// open item
shadowOf(activity).clickMenuItem(R.id.menu_external);
shadowOf(ShadowPopupMenu.getLatestPopupMenu())
.getOnMenuItemClickListener()
.onMenuItemClick(new RoboMenuItem(R.id.menu_comments));
ShadowApplication.getInstance().getForegroundThreadScheduler().advanceToLastPostedRunnable();
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW);
}
示例9: shadowOf
import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
public static ShadowResolveInfo shadowOf(ResolveInfo instance) {
return (ShadowResolveInfo) shadowOf_(instance);
}