: New feature! MozillaWiki is now mobile-friendly. Visit from a mobile device to see new mobile theme + try editing. Release details.


From MozillaWiki
Jump to: navigation, search


make -f client.mk

Robocop needs two different builds of firefox in order for it to work. One is the desktop build, and the other being the fennec build. When making different builds, it is essential that we should use two different .mozconfig files to generate the correct build. Here's some examples of .mozconfig:

# This is an example .mozconfig file for building fennec
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-android
mk_add_options MOZ_MAKE_FLAGS="-s -j10"
ac_add_options --enable-debug
ac_add_options --disable-optimize
ac_add_options --with-ccache
ac_add_options --disable-crashreporter
# Android SDK/NDK
ac_add_options --with-android-ndk="/dir/to/android-tools/android-ndk-r5c"
ac_add_options --with-android-sdk="/dir/to/android-tools/android-sdk-macosx/platforms/android-14"
ac_add_options --with-android-version=5
ac_add_options --with-android-tools="/dir/to/android-tools/android-sdk-macosx/tools"
ac_add_options --with-android-toolchain="/dir/to/android-tools/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86"
ac_add_options --with-android-platform="/dir/to/android-tools/android-ndk-r5c/platforms/android-5/arch-arm"
# Android options
## Native UI:
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi
ac_add_options --with-endian=little
# This is an example for building desktop firefox
ac_add_options --enable-application=browser
mk_add_options MOZ_OBJDIR=./objdir-firefox

After done cloning and building (which takes an awfully long time), we can now package the fennec builds we just created by using this command under the object directory:

make package

When all of the above is completed, we just need to install the fennec package on our device by using adb:

adb install dist/fennec-*.apk

Running Test Cases

We should be following this link for running test cases.

  • Please make sure the MOZ_HOST_BIN environmental variable is set to the correct place. It should point directly to the SOURCE/{objdir}/dist/bin under the DESKTOP build.
  • Then run this command under the object directory from the FENNEC build:
make mochitest-robotium
  • Or this command for individual test cases:
# using testAwesomebar as example
TEST_PATH=testAwesomebar make mochitest-robotium

Creating Test Cases

This link should be used as a guide on how to start writing a robocop test. Here's some examples for some of the actions which may be used in a test case:

        // Loading URL from awesomebar, this should be local files only
        String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
        // Try scrolling across the screen
        // Calculate where we should be dragging.
        int midX = mDriver.getGeckoLeft() + mDriver.getGeckoWidth()/2;
        int midY = mDriver.getGeckoTop() + mDriver.getGeckoHeight()/2;
        int endY = mDriver.getGeckoTop() + mDriver.getGeckoHeight()/10;
        for (int i = 0; i < 10; i++) {
            mActions.drag(midX, midX, midY, endY);
            try {
            } catch (InterruptedException e) {
        // Sending key press, using BACK key as example
        // Wait for some text to appear within awesome screen
        // Assertion within chrome
        mAsserter.ok(mSolo.waitForText("about:home"), "LOG ENTRY GOES HERE", "");
        // Tap on an item within current view
        // Tap on items within current listview
        // Tap on text
        // Store an element for future use
        awesomebar = mDriver.findElement(getActivity(), "awesome_bar");

There are way more commands we can use with robocop. We can find more information here: