/** test user can add stall/delete stall US 01.04.01 US 01.05.01 */ public void testStallsList() { solo.clickOnView(solo.getView(R.id.LoginButton)); solo.enterText((EditText) solo.getView(R.id.emailAddress), "__test1"); solo.clickOnView(solo.getView(R.id.email_sign_in_button)); solo.clickOnView(solo.getView(R.id.AccountBtn)); solo.assertCurrentActivity("should be lists of own stalls", AccountActivity.class); solo.clickOnView(solo.getView(R.id.AddBtn)); solo.enterText((EditText) solo.getView(R.id.NamePrompET), "__test1"); solo.enterText((EditText) solo.getView(R.id.DescriptionET), "Test."); solo.clickOnView(solo.getView(R.id.AddInAddBtn)); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } ElasticSearchCtr.GetStall getStall = new ElasticSearchCtr.GetStall(); String[] temp = new String[2]; temp[0] = "__test1"; temp[1] = "Owner"; tempAry = new ArrayList<>(); try { getStall.execute(temp); tempAry = getStall.get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } assertTrue(tempAry.size() >= 1); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } ElasticSearchCtr.DeleteStall deleteStall = new ElasticSearchCtr.DeleteStall(); deleteStall.execute(tempAry.get(0)); Boolean check = false; try { check = deleteStall.get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } assertTrue("didn't delete Stall", check); solo.goBack(); solo.clickOnView(solo.getView(R.id.SignoutBtnHomePg)); }
/** Test adding/deleting a picture to/from a stall US 09.01.01 US 09.02.01 */ public void testPictureStalls() { Bitmap bitmap = Bitmap.createBitmap(new int[] {1, 2, 5, 4}, 2, 2, Bitmap.Config.ARGB_8888); solo.clickOnView(solo.getView(R.id.LoginButton)); solo.enterText((EditText) solo.getView(R.id.emailAddress), "robo"); solo.clickOnView(solo.getView(R.id.email_sign_in_button)); solo.clickOnView(solo.getView(R.id.AccountBtn)); solo.clickOnView(solo.getView(R.id.AddBtn)); solo.enterText((EditText) solo.getView(R.id.NamePrompET), "robo"); solo.enterText((EditText) solo.getView(R.id.DescriptionET), "Test."); solo.clickOnView(solo.getView(R.id.AddInAddBtn)); solo.goBack(); solo.clickOnView(solo.getView(R.id.AccountBtn)); ListView lv = (ListView) solo.getView(R.id.OwnStalls); View element = lv.getChildAt(0); assertNotNull(element); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } ElasticSearchCtr.GetStall getStall = new ElasticSearchCtr.GetStall(); String[] temp = new String[2]; temp[0] = "robo"; temp[1] = "Owner"; tempAry = new ArrayList<>(); try { getStall.execute(temp); tempAry = getStall.get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } assertTrue(tempAry.size() == 1); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } tempAry.get(0).setThumbnail(bitmap); ElasticSearchForTest.updateStallES updateStallES = new ElasticSearchForTest.updateStallES(); updateStallES.execute(tempAry.get(0)); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } assertEquals("Should be the created bitmap", bitmap, tempAry.get(0).getThumbnail()); ListView lv2 = (ListView) solo.getView(R.id.OwnStalls); View listelement = lv2.getChildAt(0); TextView description = (TextView) listelement.findViewById(R.id.DescriptionEditStallV); solo.clickOnView(description); solo.clickOnView(solo.getView(R.id.DelPicEditStallBtn)); solo.clickOnView(solo.getView(R.id.SaveEdit)); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } getStall = new ElasticSearchCtr.GetStall(); try { getStall.execute(temp); tempAry = getStall.get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } assertEquals("Should be a null bitmap", null, tempAry.get(0).getThumbnail()); solo.goBack(); solo.clickOnView(solo.getView(R.id.SignoutBtnHomePg)); solo.clickOnView(solo.getView(R.id.LoginButton)); solo.enterText((EditText) solo.getView(R.id.emailAddress), "robo"); solo.clickOnView(solo.getView(R.id.email_sign_in_button)); solo.clickOnView(solo.getView(R.id.AccountBtn)); solo.clickInList(0); solo.assertCurrentActivity("should be in edit stall", EditStall.class); solo.clickOnView(solo.getView(R.id.EditStallDeleteBtn)); solo.goBack(); solo.clickOnView(solo.getView(R.id.SignoutBtnHomePg)); }