本文整理汇总了Java中org.robolectric.shadows.ShadowListView类的典型用法代码示例。如果您正苦于以下问题:Java ShadowListView类的具体用法?Java ShadowListView怎么用?Java ShadowListView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShadowListView类属于org.robolectric.shadows包,在下文中一共展示了ShadowListView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addItems
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
private void addItems(Activity activity, Map<String, Integer> items)
{
ListView list = (ListView)activity.findViewById(R.id.list);
assertNotNull(list);
ShadowListView shadowList = shadowOf(list);
shadowList.populateItems();
int initialCount = list.getCount();
for(Map.Entry<String, Integer> item : items.entrySet())
{
addItem(activity, item.getKey(), item.getValue());
}
assertEquals(initialCount + items.size(), list.getCount());
}
开发者ID:brarcher,项目名称:rental-calc,代码行数:18,代码来源:ItemizationActivityTest.java
示例2: testItemClickLaunchesActivity
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
private void testItemClickLaunchesActivity(int index, String expectedActivity)
{
ActivityController activityController = Robolectric.buildActivity(MainActivity.class).create();
Activity activity = (Activity)activityController.get();
activityController.start();
activityController.resume();
ListView list = (ListView)activity.findViewById(R.id.list);
ShadowListView shadowList = shadowOf(list);
shadowList.populateItems();
// First item should be the Budgets, second should be Transactions
shadowList.performItemClick(index);
testNextStartedActivity(activity, expectedActivity);
}
开发者ID:brarcher,项目名称:budget-watch,代码行数:19,代码来源:MainActivityTest.java
示例3: openASavedForm
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
public static void openASavedForm(int expectedFormCount, int formIndexToSelect) {
Intent savedFormsIntent =
new Intent(RuntimeEnvironment.application, FormRecordListActivity.class);
ShadowActivity homeActivityShadow = prepSavedFormsActivity(savedFormsIntent);
FormRecordListActivity savedFormsActivity =
Robolectric.buildActivity(FormRecordListActivity.class)
.withIntent(savedFormsIntent).create().start()
.resume().get();
// wait for saved forms to load
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
ShadowListView shadowEntityList = assertSavedFormEntries(expectedFormCount, savedFormsActivity);
shadowEntityList.performItemClick(formIndexToSelect);
launchFormEntryForSavedForm(homeActivityShadow, savedFormsIntent, savedFormsActivity);
}
开发者ID:dimagi,项目名称:commcare-android,代码行数:20,代码来源:FormRecordListActivityTest.java
示例4: showTransactionList
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
/**
* test interface redirect {@link #showTransactionList()}
* @param mTransactionList
*/
@Override
public void showTransactionList(List mTransactionList) {
// prepare
List<TransactionFields> list = MockTransaction.fakeTransactionList();
// test
DashboardView dashboardView = getTestObj();
dashboardView.showTransactionList(list);
ListView listView = getField(dashboardView, ReflectionId.listView);
ListAdapter listAdapter = listView.getAdapter();
ShadowListView shadowListView = shadowOf(listView);
shadowListView.populateItems();
// verify
int i = 0;
for (TransactionFields transactionFields : list) {
ViewTransactionFields viewTransactionFields = (ViewTransactionFields) listAdapter.getItem(i);
compareObj(transactionFields, viewTransactionFields.getTransactionFields());
i++;
}
}
开发者ID:HunkD,项目名称:Awwl,代码行数:24,代码来源:DashboardViewImplActivityTest.java
示例5: clickPropertyLaunchesActivity
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
@Test
public void clickPropertyLaunchesActivity()
{
db.insertProperty(new Property());
ActivityController controller = Robolectric.buildActivity(PropertiesListActivity.class).create();
Activity activity = (Activity)controller.get();
controller.start();
controller.visible();
controller.resume();
ListView list = (ListView)activity.findViewById(R.id.list);
ShadowListView shadowList = shadowOf(list);
shadowList.populateItems();
assertEquals(1, list.getCount());
shadowList.performItemClick(0);
assertTrue(activity.isFinishing() == false);
Intent next = shadowOf(activity).getNextStartedActivity();
ComponentName componentName = next.getComponent();
String name = componentName.flattenToShortString();
assertEquals("protect.rentalcalc/.PropertyOverviewActivity", name);
Bundle extras = next.getExtras();
assertNotNull(extras);
assertTrue(extras.containsKey("id"));
assertEquals(DatabaseTestHelper.FIRST_ID, extras.getLong("id"));
}
开发者ID:brarcher,项目名称:rental-calc,代码行数:33,代码来源:PropertiesListActivityTest.java
示例6: doneBlankItem
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
@Test
public void doneBlankItem()
{
HashMap<String, Integer> emptyMap = new HashMap<>();
ActivityController controller = startWithMap(emptyMap);
Activity activity = (Activity)controller.get();
ShadowActivity shadowActivity = shadowOf(activity);
ListView list = (ListView)activity.findViewById(R.id.list);
assertNotNull(list);
ShadowListView shadowList = shadowOf(list);
shadowList.populateItems();
assertEquals(0, list.getCount());
shadowActivity.clickMenuItem(R.id.action_add);
assertEquals(1, list.getCount());
assertTrue(shadowActivity.isFinishing() == false);
shadowActivity.clickMenuItem(R.id.action_done);
assertTrue(shadowActivity.isFinishing());
// Check that can finish out the lifecycle
controller.pause();
controller.stop();
controller.destroy();
checkReturnedMap(activity, emptyMap);
}
开发者ID:brarcher,项目名称:rental-calc,代码行数:30,代码来源:ItemizationActivityTest.java
示例7: clickOnBudget
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
@Test
public void clickOnBudget()
{
ActivityController activityController = Robolectric.buildActivity(BudgetActivity.class).create();
Activity activity = (Activity)activityController.get();
DBHelper db = new DBHelper(activity);
db.insertBudget("name", 100);
db.close();
activityController.start();
activityController.resume();
ListView list = (ListView)activity.findViewById(R.id.list);
ShadowListView shadowList = shadowOf(list);
shadowList.populateItems();
shadowList.performItemClick(0);
ShadowActivity shadowActivity = shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ComponentName name = startedIntent.getComponent();
assertEquals("protect.budgetwatch/.TransactionActivity", name.flattenToShortString());
Bundle bundle = startedIntent.getExtras();
String budget = bundle.getString("budget");
assertEquals("name", budget);
}
开发者ID:brarcher,项目名称:budget-watch,代码行数:29,代码来源:BudgetActivityTest.java
示例8: shouldShowContentInListView
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
@Test
public void shouldShowContentInListView() {
ShadowListView shadowListView = shadowOf(topicFragment.getListView());
int index = shadowListView.findIndexOfItemContainingText("Topic 1 content");
assertThat(index).isEqualTo(0);
}
开发者ID:gongmingqm10,项目名称:tarcle-tdd,代码行数:8,代码来源:TopicFragmentTest.java
示例9: shouldInvokeCallbackWhenItemIsClicked
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
@Test
public void shouldInvokeCallbackWhenItemIsClicked() {
RootActivity spyActivity = spy(Robolectric.buildActivity(RootActivity.class).create().start().resume().get());
fragment.onAttach(spyActivity);
int position = 2;
ShadowListView shadowListView = shadowOf(fragment.mDrawerListView);
shadowListView.performItemClick(position);
verify(spyActivity).onNavigationDrawerItemSelected(eq(position));
}
开发者ID:gongmingqm10,项目名称:tarcle-tdd,代码行数:11,代码来源:NavigationDrawerFragmentTest.java
示例10: shouldShowCircleNameInListItem
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
@Test
public void shouldShowCircleNameInListItem() {
ShadowListView shadowListView = shadowOf(circleFragment.getListView());
int position = shadowListView.findIndexOfItemContainingText("Circle Tang");
assertThat(position).isEqualTo(1);
}
开发者ID:gongmingqm10,项目名称:tarcle-tdd,代码行数:8,代码来源:CircleFragmentTest.java
示例11: assertSavedFormEntries
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
private static ShadowListView assertSavedFormEntries(int expectedFormCount,
FormRecordListActivity savedFormActivity) {
ListView entityList =
(ListView)savedFormActivity.findViewById(R.id.screen_entity_select_list);
IncompleteFormListAdapter adapter =
(IncompleteFormListAdapter)entityList.getAdapter();
adapter.setFormFilter(FormRecordListActivity.FormRecordFilter.Submitted);
adapter.resetRecords();
assertEquals(expectedFormCount, adapter.getCount());
return Shadows.shadowOf(entityList);
}
开发者ID:dimagi,项目名称:commcare-android,代码行数:12,代码来源:FormRecordListActivityTest.java
示例12: loadList
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
public static EntityListAdapter loadList(EntitySelectActivity entitySelectActivity) {
// wait for entities to load
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
ListView entityList =
(ListView)entitySelectActivity.findViewById(R.id.screen_entity_select_list);
EntityListAdapter adapter = (EntityListAdapter)entityList.getAdapter();
ShadowListView shadowListView = Shadows.shadowOf(entityList);
shadowListView.populateItems();
return adapter;
}
开发者ID:dimagi,项目名称:commcare-android,代码行数:14,代码来源:CaseLoadUtils.java
示例13: testListViewClick
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
public static void testListViewClick(ListViewFragment fragment, List<ListItem> items, Class expectedActivity) {
Activity activity = FragmentTestDriver.bindData(fragment, items);
ListView listView = FragmentTestDriver.getListView(fragment);
ShadowListView shadowList = Shadows.shadowOf(listView);
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
shadowList.performItemClick(0);
assertNotNull(shadowActivity.peekNextStartedActivity());
assertEquals(shadowActivity.peekNextStartedActivity().getComponent(),
new ComponentName(activity, expectedActivity));
activity.finish();
}
开发者ID:the-blue-alliance,项目名称:the-blue-alliance-android,代码行数:15,代码来源:FragmentTestDriver.java
示例14: testMenuClick
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
private void testMenuClick(final int index, final Class<?> expected) {
ShadowListView list = shadowOf_(foul.getListView());
assertThat(list.performItemClick(index), is(true));
ShadowActivity activity = shadowOf_(foul);
ShadowIntent intent = shadowOf_(activity.getNextStartedActivity());
assertThat(intent.getIntentClass().getName(), equalTo(expected.getName()));
}
开发者ID:vakuum,项目名称:foul-android,代码行数:9,代码来源:FoulTest.java
示例15: shadowOf
import org.robolectric.shadows.ShadowListView; //导入依赖的package包/类
public static ShadowListView shadowOf(ListView instance) {
return (ShadowListView) shadowOf_(instance);
}
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:4,代码来源:Robolectric.java
注:本文中的org.robolectric.shadows.ShadowListView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论