Auto-tools/Projects/Robocop

Problem

With advent of NativeFennec, a new framework was needed to test the UI of the Mobile Browser. Robotium was identified as a useful framework to take advantage of, but is not complete. Robocop incorporates all of Activity, Instrumentation, and Robotium Classes to inject events into the new Java front-end of Fennec.

Setup

Look at [this bug] for more information on how to set it up. One or two patches and you should be good to go.

make -f client.mk
cd objdir
make package
adb install dist/fennec-robocop.apk
make package-tests
export TEST_DEVICE = 1.2.3.4
export MOZ_HOST_BIN=~/objdir/dist/bin
make mochitest-robotium

Frequently found Errors

OOM Error. This is an error found after use of Robocop frequently, but once it has happened, Fennec itself continues to crash. To fix it, simply uninstall and reinstall. This does not occur of frequent use of Robocop, as I have run 30 iterations of just robocop without it throwing this error.

InvocationTargetException Error. This is an issue arising when using a Tegra.It looks like the following:

W/System.err( 2610): java.lang.reflect.InvocationTargetException
W/System.err( 2610): at org.mozilla.gecko.GeckoAppShell.unregisterGeckoEventListener(GeckoAppShell.java:1565)
...

Build Error. This is resolved by doing a clean build.

make[7]: Entering directory `/media/sdan/birch/objdir-native-droid/mobile/android/base/locales'
make[7]: Leaving directory `/media/sdan/birch/objdir-native-droid/mobile/android/base/locales'
res/values/strings.xml:1: error: Error parsing XML: no element found
res/layout/awesomebar_search.xml:9: error: Error: No resource found that matches the given name (at 'hint' with value '@string/awesomebar_default_text').
res/layout-v11/awesomebar_search.xml:9: error: Error: No resource found that matches the given name (at 'hint' with value '@string/awesomebar_default_text').
res/layout/browser_toolbar.xml:7: error: Error: No resource found that matches the given name (at 'hint' with value '@string/awesomebar_default_text').
res/layout/crash_reporter.xml:6: error: Error: No resource found that matches the given name (at 'text' with value '@string/crash_message').
res/layout/crash_reporter.xml:14: error: Error: No resource found that matches the given name (at 'text' with value '@string/crash_help_message').
res/layout/crash_reporter.xml:21: error: Error: No resource found that matches the given name (at 'text' with value '@string/crash_send_report_message').
...

Infrequent Runtime Errors. Two have been known to occur: One, where Fennec freezes when loading a page, the other where the page loads, but has 0 content. These are worked around by restarting the test.

Notes

  • If you are writing tests for Robocop, see [Writing Tests] for more API information
  • We are using [NativeUI Messages] to talk between Robocop and gecko
  • There has been interest in using a record/replay tool similar to [testdroid]. Most likely this will allow for people to record something and then we can hand edit it into a proper test case.
  • adb shell am instrument -w org.mozilla.roboexample.test/android.test.InstrumentationTestRunner