Auto-tools/Projects/Robocop/WritingTests

< Auto-tools‎ | Projects‎ | Robocop
Revision as of 18:46, 8 December 2011 by Tfairey (talk | contribs) (Added android IDs)

Setup

Writing a test for Robocop shouldn't be very hard, but there is a very limited API as of yet. Copying a test from the examples is the best way to start. The flow of the test will go from starting the application to killing it. Your test should be in the file test[Case].java.in It will have three methods in the class test[Case]: setUp(), test[Case](), and tearDown(). setUp gets called at the beginning and starts fennec inside what

APIs

The two main interfaces that are used are Driver and Element. Driver finds elements, and has a direct relation to the Gecko. Element represents each of the available UI objects in Fennec including the Awesomebar, the 'tabs' button, and different lists and menus.

Driver
  //This is used to find elements given their id's name.
  Element findElement(String name);
  //This will cause this process to spin until the gecko fires a specific JSON event, such as DOMContentLoaded
  void waitForGeckoEvent(String geckoEvent);
  //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();
Element
  //To click the element.
  void click()
  //Clicks the given Key (Element.SpecialKey.[DOWN|UP|LEFT|RIGHT|ENTER])
  void clickSpecialKey(SpecialKey button)
  //Sends a string of characters to the system. (most have been implemented but not all)
  void sendKeys(String keysToSend);
  //Returns true if the element is currently displayed
  boolean isDisplayed();
  //Returns the text currently displayed on the element, or direct sub-elements.
  String getText();

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)

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