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

Java SupportFragmentTestUtil类代码示例

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

本文整理汇总了Java中org.robolectric.shadows.support.v4.SupportFragmentTestUtil的典型用法代码示例。如果您正苦于以下问题:Java SupportFragmentTestUtil类的具体用法?Java SupportFragmentTestUtil怎么用?Java SupportFragmentTestUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SupportFragmentTestUtil类属于org.robolectric.shadows.support.v4包,在下文中一共展示了SupportFragmentTestUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testPendingItem

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Test
public void testPendingItem() {
    Bundle args = new Bundle();
    args.putParcelable(ItemFragment.EXTRA_ITEM, new TestItem() {
        @Override
        public Item[] getKidItems() {
            return new Item[]{new TestItem() {
                @Override
                public int getLocalRevision() {
                    return -1;
                }
            }};
        }

        @Override
        public int getKidCount() {
            return 1;
        }
    });
    Fragment fragment = Fragment.instantiate(RuntimeEnvironment.application,
            ItemFragment.class.getName(), args);
    SupportFragmentTestUtil.startVisibleFragment(fragment, ItemFragmentMultiPageTest.TestItemActivity.class,
            R.id.content_frame);
    recyclerView = (RecyclerView) fragment.getView().findViewById(R.id.recycler_view);
    adapter = (SinglePageItemRecyclerViewAdapter) recyclerView.getAdapter();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:27,代码来源:ItemFragmentSinglePageTest.java


示例2: setUp

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    DummyDataSet.copyDataSet("ASDB_Tabs.db");
    helper = new SQLChatHelper(context);
    cHelper = new SQLContactHelper(context);
    fragment = ChatTabFragment.createInstance();
    SupportFragmentTestUtil.startFragment(fragment);
    adapter = new ChatTabRecyclerAdapter(fragment);
    presenter = new ChatTabPresenter(fragment, adapter);



    Contact c1 = new Contact("kontakt1");
    Contact c2 = new Contact("kontakt2");
    List<Contact> cList = new ArrayList<>();
    cList.add(c1);
    cList.add(c2);
    Chat chat = new Chat("TestChat", "1", cList);
    helper.insert(chat);
}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:21,代码来源:ChatTabPresenterTest.java


示例3: setupFragment

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
private void setupFragment(int environment) {
    List<EnvironmentModel> environments = Lists.newArrayList(
        newEnvironmentModel(123, "A-environment"),
        newEnvironmentModel(environment, "B-environment"),
        newEnvironmentModel(10, "C-environment"),
        newEnvironmentModel(789, "D-environment"));

    when(environmentService.findAll()).thenReturn(Observable.just(environments));

    DeviceListFragment fragment = new DeviceListFragment();
    Bundle args = new Bundle();
    args.putInt(ARG_ENVIRONMENT, environment);
    fragment.setArguments(args);
    SupportFragmentTestUtil.startFragment(fragment);
    assertNotNull("should not be null", fragment);
}
 
开发者ID:openwebnet,项目名称:openwebnet-android,代码行数:17,代码来源:DeviceListFragmentTest.java


示例4: testProfileImageUpdation_onGlobalAccountEvent

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Test
public void testProfileImageUpdation_onGlobalAccountEvent() {
    final NavigationFragment fragment = new NavigationFragment();
    SupportFragmentTestUtil.startVisibleFragment(fragment);
    final View view = fragment.getView();
    assertNotNull(view);

    final ImageView profileImage = (ImageView) view.findViewById(R.id.profile_image);
    assertNotNull(profileImage);

    // Assert: Profile pic not updated when a non-logged in user's account object is broadcasted
    Drawable previousDrawable = profileImage.getDrawable();
    Account account = configureMockAccount("not_logged_in_user");
    EventBus.getDefault().post(new AccountDataLoadedEvent(account));
    assertEquals(previousDrawable, profileImage.getDrawable());

    // Assert: Profile pic is updated when a logged-in user's account object is broadcasted
    UserPrefs userPrefs = RoboGuice.getInjector(context).getInstance(UserPrefs.class);
    final String loggedInUser = userPrefs.getProfile().username;
    account = configureMockAccount(loggedInUser);
    EventBus.getDefault().post(new AccountDataLoadedEvent(account));
    assertNotEquals(previousDrawable, profileImage.getDrawable());
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:24,代码来源:NavigationFragmentTest.java


示例5: uiLessShouldFail

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Test() public void uiLessShouldFail() {
  try {
    SupportFragmentTestUtil.startVisibleFragment(new UiLessFragment());
    Assert.fail("Exception expected");
  } catch (IllegalStateException e) {
    Assert.assertEquals(
        "It seems that you are using "+UiLessFragment.class.getCanonicalName()+" as headless (UI less) fragment (because onViewCreated() has not been called or maybe delegation misses that part). Having a Presenter without a View (UI) doesn't make sense. Simply use an usual fragment instead of an MvpFragment if you want to use a UI less Fragment",
        e.getMessage());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:FragmentMvpDelegateUiLessMvpFragmentTest.java


示例6: setUpFragment

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
private void setUpFragment() {
    postsFragment = new PostsFragment();
    SupportFragmentTestUtil.startFragment(postsFragment);
    postsFragment.setPresenter(postsPresenterMock);
    postsFragment.postsRecyclerView = postsRecyclerViewMock;
    postsFragment.postRecyclerViewAdapter = postRecyclerViewAdapterMock;
    postsFragment.progressDialog = progressDialogMock;
}
 
开发者ID:ParaskP7,项目名称:sample-code-posts,代码行数:9,代码来源:PostsFragmentTest.java


示例7: testOnSaveInstanceStateDelegated

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Test
public void testOnSaveInstanceStateDelegated() {
    SupportFragmentTestUtil.startFragment(fragment);
    final Bundle testBundle = new Bundle();
    fragment.onSaveInstanceState(testBundle);
    verify(fragment.getMvvmDelegate()).onSaveInstanceState(testBundle);
}
 
开发者ID:A-Zaiats,项目名称:android-mvvm,代码行数:8,代码来源:MvvmFragmentTest.java


示例8: testRemoveOnPropertyChangedCallbacksOnActivityDestroy

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Test
public void testRemoveOnPropertyChangedCallbacksOnActivityDestroy() {
    final Observable.OnPropertyChangedCallback firstCallback = mock(Observable.OnPropertyChangedCallback.class);
    final Observable.OnPropertyChangedCallback secondCallback = mock(Observable.OnPropertyChangedCallback.class);
    fragment.setViewModel(fragment.createViewModel());
    fragment.addOnPropertyChangedCallback(firstCallback);
    fragment.addOnPropertyChangedCallback(secondCallback);

    SupportFragmentTestUtil.startFragment(fragment);
    fragment.onDestroy();
    verify(fragment.getViewModel()).removeOnPropertyChangedCallback(firstCallback);
    verify(fragment.getViewModel()).removeOnPropertyChangedCallback(secondCallback);
}
 
开发者ID:A-Zaiats,项目名称:android-mvvm,代码行数:14,代码来源:MvvmFragmentTest.java


示例9: testSwipeCardOrder3

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Test
public void testSwipeCardOrder3() {

    CardFragmentTestClass fragment = new CardFragmentTestClass();
    SupportFragmentTestUtil.startFragment(fragment, EmptyActivity.class);

    ArrayList<Professional> test_data_set = new ArrayList<Professional>(128);
    for (int i = 0; i < 128; ++i)
        test_data_set.add(ProfessionalTestClass.testProfessional("" + Integer.toString(i), "" + Integer.toString(i)));
    fragment.setTestData(test_data_set, CardFragmentTestClass.Test.mix);
    //SearchQueryResult cardSet;
    //    cardSet = fragment.getCurrentSet();

    ShadowLog.stream = System.out;
    ShadowLog.i("", "\n- - - - - - - - - - - - - - - - - - - - - - - - -\n");

    iterator = 50;

    ShadowLog.i("testSwipeCardOrder3", "forward and backward iterations inside same set");
    assert1ForwardIteration(fragment, test_data_set);
    assert1ForwardIteration(fragment, test_data_set);
    assert1BackwardIteration(fragment, test_data_set);
    assert1ForwardIteration(fragment, test_data_set);
    assert1ForwardIteration(fragment, test_data_set);
    assert1ForwardIteration(fragment, test_data_set);
    assert1BackwardIteration(fragment, test_data_set);
    assert1BackwardIteration(fragment, test_data_set);

    ShadowLog.i("testSwipeCardOrder3", "forward and backward iterations alternating sets");
    //iterator=52
    for (int i = 0; i < 30; ++i) assert1ForwardIteration(fragment, test_data_set);
    for (int i = 0; i < 30; ++i) assert1BackwardIteration(fragment, test_data_set);
    for (int i = 0; i < 30; ++i) assert1ForwardIteration(fragment, test_data_set);
    for (int i = 0; i < 30; ++i) assert1BackwardIteration(fragment, test_data_set);

}
 
开发者ID:AoDispor,项目名称:AoDispor-Android,代码行数:37,代码来源:CardFragmentTest.java


示例10: setUp

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Before
public void setUp() {
    DummyDataSet.copyDataSet("ASDB_Tabs.db");
    chatHelper = HelperFactory.getChatHelper(context);
    contactHelper = HelperFactory.getContacHelper(context);
    contacts = contactHelper.getContacts();

    fragment = TestFragment.createInstance(TestFragment.TYPE_CONTACT_TAB);
    SupportFragmentTestUtil.startVisibleFragment(fragment);
    adapter = (ContactTabRecyclerAdapter) fragment.getAdapter();
    manager = fragment.getLayoutManager();
    recyclerView = fragment.getRecyclerView();
}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:14,代码来源:ContactTabAdapterViewholderTest.java


示例11: setUp

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    DummyDataSet.copyDataSet("ASDB_Tabs.db");
    helper = HelperFactory.getFileHelper(context);
    files = helper.getFiles();

    fragment = TestFragment.createInstance(TestFragment.TYPE_FILE_TAB);
    SupportFragmentTestUtil.startVisibleFragment(fragment);

    adapter = (FileTabRecyclerAdapter) fragment.getAdapter();
    manager = fragment.getLayoutManager();
    recyclerView = fragment.getRecyclerView();


}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:16,代码来源:FileTabAdapterViewholderTest.java


示例12: setUp

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Before
public void setUp() {
    DummyDataSet.copyDataSet("ASDB_Tabs.db");
    contactHelper = HelperFactory.getContacHelper(context);
    chatHelper = HelperFactory.getChatHelper(context);
    dataHelper = HelperFactory.getDataHelper(context);
    chats = chatHelper.getChats();

    fragment = TestFragment.createInstance(TestFragment.TYPE_CHAT_TAB);
    SupportFragmentTestUtil.startVisibleFragment(fragment);

    adapter = (ChatTabRecyclerAdapter) fragment.getAdapter();
    manager = fragment.getLayoutManager();
    recyclerView = fragment.getRecyclerView();
}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:16,代码来源:ChatTabAdapterViewholderTest.java


示例13: setUp

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    DummyDataSet.copyDataSet("ASDB_Tabs.db");
    fragment = ContactTabFragment.createInstance();
    SupportFragmentTestUtil.startFragment(fragment);
    adapter = new ContactTabRecyclerAdapter(fragment);
    presenter = new ContactTabPresenter(fragment, adapter);

    contactHelper = HelperFactory.getContacHelper(context);
    chatHelper = HelperFactory.getChatHelper(context);
}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:12,代码来源:ContactTabPresenterTest.java


示例14: setUp

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    DummyDataSet.copyDataSet("ASDB_Tabs.db");
    ShadowLog.stream = System.out;
    fileHelper = new SQLFileHelper(context);
    chatHelper = new SQLChatHelper(context);
    dataHelper = new SQLDataHelper(context);
    fragment = FileTabFragment.createInstance();
    SupportFragmentTestUtil.startFragment(fragment);
    adapter = new FileTabRecyclerAdapter(fragment);
    presenter = new FileTabPresenter(fragment, adapter);


}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:15,代码来源:FileTabPresenterTest.java


示例15: updateProjects_SetsAdapter

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Test public void updateProjects_SetsAdapter() throws Exception {
    fragment = ProjectListFragment.newInstance();
    SupportFragmentTestUtil.startFragment(fragment);

    fragment.updateProjects(getProjects());

    //assertThat(fragment.recyclerView).hasAdapter();
    RecyclerView.Adapter adapter = fragment.recyclerView.getAdapter();
    assertThat(adapter).isNotNull();
    assertThat(adapter.getItemCount()).isEqualTo(2);
}
 
开发者ID:ylogx,项目名称:CCDroid,代码行数:12,代码来源:ProjectListFragmentRoboTest.java


示例16: initializeTest

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
/**
 * Testing initialization
 */
@Test
public void initializeTest() {
    CourseUnitWebViewFragment fragment = CourseUnitWebViewFragment.newInstance(getHtmlUnit());
    SupportFragmentTestUtil.startVisibleFragment(fragment);
    View view = fragment.getView();
    assertNotNull(view);

    View courseUnitWebView = view.findViewById(R.id.webview);
    assertNotNull(courseUnitWebView);
    assertThat(courseUnitWebView).isInstanceOf(WebView.class);
    WebView webView = (WebView) courseUnitWebView;
    assertTrue(webView.getSettings().getJavaScriptEnabled());
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:17,代码来源:CourseUnitWebViewFragmentTest.java


示例17: initializeTest

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
/**
 * Testing initialization
 */
@Test
public void initializeTest() {
    CourseUnitVideoFragment fragment = CourseUnitVideoFragment.newInstance(getVideoUnit(), false, false);
    SupportFragmentTestUtil.startVisibleFragment(fragment, FragmentUtilActivity.class, 1);
    assertTrue(fragment.getRetainInstance());

    View view = fragment.getView();
    assertNotNull(view);
    View messageContainer = view.findViewById(R.id.message_container);
    assertNotNull(messageContainer);
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:15,代码来源:CourseUnitVideoFragmentTest.java


示例18: orientationChangeTest

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
/**
 * Testing orientation changes
 */
@Test
public void orientationChangeTest() {
    CourseUnitVideoFragment fragment = CourseUnitVideoFragment.newInstance(getVideoUnit(), false, false);
    SupportFragmentTestUtil.startVisibleFragment(fragment, FragmentUtilActivity.class, 1);
    assertNotEquals(Configuration.ORIENTATION_LANDSCAPE,
            fragment.getResources().getConfiguration().orientation);

    testOrientationChange(fragment, Configuration.ORIENTATION_LANDSCAPE);
    testOrientationChange(fragment, Configuration.ORIENTATION_PORTRAIT);
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:14,代码来源:CourseUnitVideoFragmentTest.java


示例19: startFragment

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
protected void startFragment(@NonNull final FragmentT fragment) {
    this.presenter = mock(getPresenterType());
    fragment.presenter = presenter;
    SupportFragmentTestUtil.startVisibleFragment(fragment, HostActivity.class, android.R.id.content);
    this.fragment = fragment;
    this.view = fragment.view;
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:8,代码来源:PresenterFragmentTest.java


示例20: testOnCreateView

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入依赖的package包/类
@Test
public void testOnCreateView() throws Exception {
    // execute
    SupportFragmentTestUtil.startFragment(fixture);
    // validate
    assertNotNull(fixture);
    verify(scanner).update();
    verify(scanner).register(fixture.getChannelGraphAdapter());
}
 
开发者ID:VREMSoftwareDevelopment,项目名称:WiFiAnalyzer,代码行数:10,代码来源:ChannelGraphFragmentTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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