本文整理汇总了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!");
}
}
示例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;
}
示例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);
}
示例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);
}