ListEmptyViewTestpublic class ListEmptyViewTest extends android.test.ActivityInstrumentationTestCase
Fields Summary |
---|
private ListWithEmptyView | mActivity | private android.widget.ListView | mListView |
Constructors Summary |
---|
public ListEmptyViewTest()
super("com.android.frameworks.coretests", ListWithEmptyView.class);
|
Methods Summary |
---|
protected void | setUp()
super.setUp();
mActivity = getActivity();
mListView = getActivity().getListView();
| public void | testPreconditions()
assertNotNull(mActivity);
assertNotNull(mListView);
assertTrue("Empty view not shown", mListView.getVisibility() == View.GONE);
| public void | testZeroToManyToZero()
Instrumentation inst = getInstrumentation();
int i;
for (i = 0; i < 10; i++) {
inst.invokeMenuActionSync(mActivity, mActivity.MENU_ADD, 0);
inst.waitForIdleSync();
assertTrue("Empty view still shown",
mActivity.getEmptyView().getVisibility() == View.GONE);
assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
}
for (i = 0; i < 10; i++) {
inst.invokeMenuActionSync(mActivity, mActivity.MENU_REMOVE, 0);
inst.waitForIdleSync();
if (i < 9) {
assertTrue("Empty view still shown",
mActivity.getEmptyView().getVisibility() == View.GONE);
assertTrue("List not shown",
mActivity.getListView().getVisibility() == View.VISIBLE);
} else {
assertTrue("Empty view not shown",
mActivity.getEmptyView().getVisibility() == View.VISIBLE);
assertTrue("List still shown",
mActivity.getListView().getVisibility() == View.GONE);
}
}
// Navigate forward
Intent intent = new Intent();
intent.setClass(mActivity, ListWithEmptyView.class);
mActivity.startActivity(intent);
// Navigate backward
inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
inst.waitForIdleSync();
assertTrue("Empty view not shown", mActivity.getEmptyView().getVisibility() == View.VISIBLE);
assertTrue("List still shown", mActivity.getListView().getVisibility() == View.GONE);
| public void | testZeroToOne()
Instrumentation inst = getInstrumentation();
inst.invokeMenuActionSync(mActivity, mActivity.MENU_ADD, 0);
inst.waitForIdleSync();
assertTrue("Empty view still shown", mActivity.getEmptyView().getVisibility() == View.GONE);
assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
| public void | testZeroToOneForwardBack()
Instrumentation inst = getInstrumentation();
inst.invokeMenuActionSync(mActivity, mActivity.MENU_ADD, 0);
inst.waitForIdleSync();
assertTrue("Empty view still shown", mActivity.getEmptyView().getVisibility() == View.GONE);
assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
// Navigate forward
Intent intent = new Intent();
intent.setClass(mActivity, ListWithEmptyView.class);
mActivity.startActivity(intent);
// Navigate backward
inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
inst.waitForIdleSync();
assertTrue("Empty view still shown", mActivity.getEmptyView().getVisibility() == View.GONE);
assertTrue("List not shown", mActivity.getListView().getVisibility() == View.VISIBLE);
|
|