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


Java ReflectionHelpers.setField方法代码示例

本文整理汇总了Java中org.robolectric.util.ReflectionHelpers.setField方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionHelpers.setField方法的具体用法?Java ReflectionHelpers.setField怎么用?Java ReflectionHelpers.setField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robolectric.util.ReflectionHelpers的用法示例。


在下文中一共展示了ReflectionHelpers.setField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldThrowIfNoQueryOrRawQueryIsSet

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
@Test
public void shouldThrowIfNoQueryOrRawQueryIsSet() {
    try {
        final GetCursorStub getStub = GetCursorStub.newInstance();

        final PreparedGetCursor operation = getStub.storIOSQLite
                .get()
                .cursor()
                .withQuery(getStub.query) // will be removed
                .withGetResolver(getStub.getResolverForCursor)
                .prepare();

        ReflectionHelpers.setField(operation, "query", null);
        ReflectionHelpers.setField(operation, "rawQuery", null);
        operation.getData();

        failBecauseExceptionWasNotThrown(IllegalStateException.class);
    } catch (IllegalStateException e) {
        assertThat(e).hasMessage("Either rawQuery or query should be set!");
    }
}
 
开发者ID:pushtorefresh,项目名称:storio,代码行数:22,代码来源:PreparedGetCursorTest.java

示例2: onCreateView

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
@Implementation
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RecyclerView recyclerView = new RecyclerView(container.getContext());
    recyclerView.setId(R.id.list);
    ReflectionHelpers.setField(realObject, "mList", recyclerView);
    return recyclerView;
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:8,代码来源:ShadowPreferenceFragmentCompat.java

示例3: testOnResumeSecondTimeCheckRememberMe

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
/**
 * userManager.rememberMe = true
 * presenter.checkRememberMe = false
 */
@Test
public void testOnResumeSecondTimeCheckRememberMe() {
    when(mMockUDM.isRememberMe()).thenReturn(Observable.just(Boolean.TRUE));
    WelcomePagePresenter presenter = getTestObj();
    ReflectionHelpers.setField(presenter, "mCheckRememberMe", false);
    presenter.onResume();
    verify(mMockView, times(0)).onClickSignIn(null);
}
 
开发者ID:HunkD,项目名称:Awwl,代码行数:13,代码来源:WelcomePagePresenterTest.java

示例4: testOnResumeSecondTimeCheckRememberMe2

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
/**
 * userManager.rememberMe = false
 * presenter.checkRememberMe = false
 */
@Test
public void testOnResumeSecondTimeCheckRememberMe2() {
    when(mMockUDM.isRememberMe()).thenReturn(Observable.just(Boolean.FALSE));
    WelcomePagePresenter presenter = getTestObj();
    ReflectionHelpers.setField(presenter, "mCheckRememberMe", false);
    presenter.onResume();
    verify(mMockView, times(0)).onClickSignIn(null);
}
 
开发者ID:HunkD,项目名称:Awwl,代码行数:13,代码来源:WelcomePagePresenterTest.java


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