本文整理汇总了Java中org.robolectric.shadows.support.v4.SupportFragmentTestUtil.startVisibleFragment方法的典型用法代码示例。如果您正苦于以下问题:Java SupportFragmentTestUtil.startVisibleFragment方法的具体用法?Java SupportFragmentTestUtil.startVisibleFragment怎么用?Java SupportFragmentTestUtil.startVisibleFragment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robolectric.shadows.support.v4.SupportFragmentTestUtil
的用法示例。
在下文中一共展示了SupportFragmentTestUtil.startVisibleFragment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: 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());
}
示例3: 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());
}
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: 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());
}
示例8: 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);
}
示例9: 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);
}
示例10: 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;
}
示例11: correctUi
import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入方法依赖的package包/类
@Test public void correctUi() {
SupportFragmentTestUtil.startVisibleFragment(new CorrectUiFragment());
}
示例12: testFragment
import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入方法依赖的package包/类
@Test
public void testFragment() {
Assert.assertNotNull(mPresenter);
SupportFragmentTestUtil.startVisibleFragment(mFragment);
verify(mPresenter).onViewCreated();
}
示例13: setup
import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入方法依赖的package包/类
@Before
public void setup() {
fragment = MeasuringFragment.newInstance();
SupportFragmentTestUtil.startVisibleFragment(fragment);
}
示例14: setup
import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入方法依赖的package包/类
@Before
public void setup() {
fragment = MeasuredRRFragment.newInstance(parameter);
SupportFragmentTestUtil.startVisibleFragment(fragment);
}
示例15: setup
import org.robolectric.shadows.support.v4.SupportFragmentTestUtil; //导入方法依赖的package包/类
@Before
public void setup() {
fragment = MeasuredDetailsEditFragment.newInstance();
SupportFragmentTestUtil.startVisibleFragment(fragment);
}