in Android, Long click menus can be found in List items, texts, views, screen.
Robotium supports various functions to handle Long click menus,
project has a list of items and each support a long press functionality. on long press, will open a menu with various options like "Open, Delete, Edit title"
Let us write a test case for this project,
Robotium supports various functions to handle Long click menus,
- clickLongInList(int line)
- clickLongOnText(String text)
- clickLongOnView(android.view.View view)
- clickLongOnScreen(float x, float y)
project has a list of items and each support a long press functionality. on long press, will open a menu with various options like "Open, Delete, Edit title"
Let us write a test case for this project,
Test case for Android Long click menus :
Steps:
Explanation:
- Open notepad application
- press the menu item 'Add note' and add note 'Note 1'
- long click on the 'Note 1' in the list, which will open a menu, select 'Delete' option.
- verify the note is delete or not?
public void testRemoveNote() throws Exception {
solo.clickOnMenuItem("Add note");
//Assert that NoteEditor activity is opened
solo.assertCurrentActivity("Expected NoteEditor activity", "NoteEditor");
//In text field 0, add Note 1
solo.enterText(0, "Note 1");
solo.clickOnMenuItem("Save");
solo.clickLongOnText("Note 1");
//Clicks on Delete in the context menu
solo.clickOnText("Delete");
//Note 1 test should not be found
boolean expected = false;
boolean actual = solo.searchText("Note 1");
//Assert that Note 1 text is not found
assertEquals("Note 1 Text is found", expected, actual);
}
Explanation:
- Add Note : use 'solo.clickOnMenuItem()' to press on the menu item 'Add Note'.
- Long click : 'solo.clickLongOnText()' is used to perform long click operation on the specified text.
- use 'solo.clickOnText()', to select the text from long click menu.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.