As it is common that most of the Android developers will use Image Buttons instead Text buttons, it is important criteria to test Image buttons.
Robotium has support for Image Buttons. The following APIs can be used to test Image Button functionalities,
Explanation :
Robotium has support for Image Buttons. The following APIs can be used to test Image Button functionalities,
- getImageButton(int index)
- clickOnImageButton(int index)
Test case for Image Buttons :
Steps :- Click on the Image Button “Alarm”
- go back
- Click on the Image Button “Music”
1: public void testCheckBoxes() throws Exception {
2: solo.waitForActivity("AlarmPlusActivity");
3:
4: //click on Alarm Image Button
5: solo.clickOnImageButton(0);
6: assertTrue(solo.searchText("Add alarm")); //this text appears in the next activity
7: //go to previous screen
8: solo.goBack();
9: //click on Gallery button
10: solo.clickOnImageButton(1);
11:
12: }
Explanation :
- Click on Image Button : ‘solo.clickOnImageButton()’, is used to click on the Image button, which accepts only index number as argument.
- Return to Previous screen, ‘solo.goBack()’, is used to go to Previous screen.
- index of the Image buttons increase from Left to Right. Alarm button has 0, Gallery button has 1 and Home button with index
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.