Confirmed users
905
edits
No edit summary |
|||
| Line 58: | Line 58: | ||
* If your tests extends BaseTest then you will not need to add the methods setUp() and tearDown() as they are already defined in BaseTest | * If your tests extends BaseTest then you will not need to add the methods setUp() and tearDown() as they are already defined in BaseTest | ||
* If you need to do extra clean-up, like removing entries you added in a database for e.g., the tearDown() method can be overwrittern but make sure to call '''super.tearDown()''' as needed in the method. The same is applicable for setUp(). | * If you need to do extra clean-up, like removing entries you added in a database for e.g., the tearDown() method can be overwrittern but make sure to call '''super.tearDown()''' as needed in the method. The same is applicable for setUp(). | ||
= APIs = | |||
Robotium itself provides a rich API through the Solo class - javadocs for Solo are available at [1]. | |||
"Robocop" provides an additional API to make common tasks easier. The main interfaces are Actions, Elements, and Driver. | |||
Actions provides commonly used non-element specific actions that can be taken on the application, such as dragging and sending key events. | |||
<pre> | |||
Actions | |||
//This will cause this process to spin until the gecko fires a specific JSON event, such as DOMContentLoaded | |||
void waitForGeckoEvent(String geckoEvent); | |||
//Clicks the given Key (Actions.SpecialKey.[DOWN|UP|LEFT|RIGHT|ENTER]) | |||
void sendSpecialKey(SpecialKey button) | |||
//Sends a string of characters to the system. (most have been implemented but not all) | |||
void sendKeys(String keysToSend); | |||
//Sends a drag action across the screen | |||
void drag(int startingX, int endingX, int startingY, int endingY) | |||
// Run a sql query on the specified database | |||
public Cursor querySql(String dbPath, String sql); | |||
</pre> | |||
Element represents each of the available UI objects in Fennec including the Awesomebar, the 'tabs' button, and different lists and menus. | |||
<pre> | |||
Element | |||
//To click the element. | |||
void click() | |||
//Returns true if the element is currently displayed | |||
boolean isDisplayed(); | |||
//Returns the text currently displayed on the element, or direct sub-elements. | |||
String getText(); | |||
</pre> | |||
Driver finds elements and provides info about the UI. | |||
<pre> | |||
Driver | |||
//This is used to find elements given their id's name. | |||
Element findElement(String name); | |||
//This is used for getting information on scrolls. NOTE: It must be used for the next three methods to return useful information | |||
void setupScrollHandling(); | |||
int getPageHeight(); //The total height of the page. | |||
int getScrollHeight(); //How far down the screen the client has scrolled. | |||
int getHeight(); //The height of the client's view. | |||
//The following are used to give information on the graphical location of the Gecko view on the screen. | |||
int getGeckoTop(); | |||
int getGeckoLeft(); | |||
int getGeckoHeight(); | |||
int getGeckoWidth(); | |||
</pre> | |||
Finally, an evolving set of test base classes - BaseTest, PixelTest, etc - can be leveraged for some types of tests. | |||
= Usable IDs = | |||
The following is a list of ids that can be used with Driver.findElement(). Most of the following ids have not been tested, so might have unexpeced results, or require increased APIs for them. To know how a given object is used, in mobile/android/base, grep R.id.[id-name] * | |||
(from Objdir/mobile/android/base/R.java#id) | |||
<pre> | |||
abouthome_content | |||
add_tab | |||
addons | |||
address_bar | |||
agent_mode | |||
all_pages_list | |||
awesome_bar | |||
awesome_screen | |||
awesomebar_button | |||
awesomebar_tabs | |||
awesomebar_text | |||
background | |||
bookmark | |||
bookmark_icon | |||
bookmark_title | |||
bookmark_url | |||
bookmarks_list | |||
browser_toolbar | |||
close | |||
container | |||
doorhanger_choices | |||
doorhanger_container | |||
doorhanger_title | |||
favicon | |||
forward | |||
gecko_layout | |||
grid | |||
history_list | |||
info | |||
list | |||
main_layout | |||
notification_image | |||
notification_progressbar | |||
notification_text | |||
notification_title | |||
outline | |||
plugin_container | |||
preferences | |||
quit | |||
recommended_addon_list | |||
reload | |||
save_as_pdf | |||
screenshot | |||
select_list | |||
share | |||
site_security | |||
stop | |||
tabs | |||
tabs_count | |||
title | |||
url | |||
</pre> | |||
= Basic code sequences to do different actions = | = Basic code sequences to do different actions = | ||