• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ShadowResolveInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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);
}
 
开发者ID:Nilhcem,项目名称:droidconde-2016,代码行数:19,代码来源:IntentsTest.java


示例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);
}
 
开发者ID:Nilhcem,项目名称:droidconde-2016,代码行数:18,代码来源:IntentsTest.java


示例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);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:22,代码来源:BaseListActivityTest.java


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


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


示例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());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:33,代码来源:CustomTabsDelegateTest.java


示例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"));
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:7,代码来源:TestApplication.java


示例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);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:60,代码来源:ItemActivityTest.java


示例9: shadowOf

import org.robolectric.shadows.ShadowResolveInfo; //导入依赖的package包/类
public static ShadowResolveInfo shadowOf(ResolveInfo instance) {
  return (ShadowResolveInfo) shadowOf_(instance);
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:4,代码来源:Robolectric.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AxisDependency类代码示例发布时间:2022-05-22
下一篇:
Java MultiLineLabelUI类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap