0
我在一個Activity中使用DrawerLayout,我必須爲Robotium編寫測試用例: 1)如何檢查drawerlaout是打開還是關閉我嘗試過,但它不工作下面是我寫在Robotium代碼:如何編寫測試用例Robotium中的抽屜佈局
public void testOpenAndCloseNavigationDrawer() {
/* DrawerLayout drawerlayout = (DrawerLayout)getActivity().findViewById(R.id.drawer_layout);*/
DrawerLayout drawer = ((BalanceActivity)activity).mDrawerLayout;
assertFalse(drawer.isActionbarDrawerOpened());
solo.clickOnActionBarHomeButton();
assertTrue(drawer.isActionbarDrawerOpened());
solo.clickOnActionBarHomeButton();
assertFalse(drawer.isActionbarDrawerOpened());
}
2)我在活動二合一的列表視圖是主列表視圖另一個是drawerlayout列表視圖,我能夠測試低於主列表視圖產品測試代碼我已經寫在Robotium主要列表視圖:
public void testNavigationToSubScreens() throws Exception {
this.solo.waitForActivity(DetailActivity.class);
assertEquals(DetailActivity.class, solo.getCurrentActivity().getClass());
solo.clickInList(1);
solo.goBack();
solo.clickInList(2);
solo.goBack();
solo.clickInList(3);
solo.goBack();
solo.clickInList(4);
solo.goBack();
}
3)如何測試listView項目,如果我們不知道listView中有多少項目