Bug 715443 - [1/2] Robotium cleanup. r=jmaher
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 05 Jan 2012 10:20:22 -0500
changeset 86331 262123f588e0061d2ec720f55e2117a0743d11aa
parent 86330 e20434400f0c68562daca89630bc101daff96a32
child 86332 e4c773d0f228232e8a022746285f1aa52636bdd0
push idunknown
push userunknown
push dateunknown
reviewersjmaher
bugs715443
milestone12.0a1
Bug 715443 - [1/2] Robotium cleanup. r=jmaher - Extract a common BaseTest class to hold the duplicated setup/tearDown stuff - Convert 2-space indent to 4-space indent in keeping with rest of android code - Prefix class member variables with 'm' - Convert tabs to spaces, remove trailing whitespace - Remove unused imports - Use generics to reduce unchecked warnings
mobile/android/base/tests/BaseTest.java.in
mobile/android/base/tests/testAwesomebar.java.in
mobile/android/base/tests/testBookmark.java.in
mobile/android/base/tests/testLoad.java.in
mobile/android/base/tests/testNewTab.java.in
mobile/android/base/tests/testPan.java.in
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tests/BaseTest.java.in
@@ -0,0 +1,69 @@
+#filter substitution
+package @ANDROID_PACKAGE_NAME@.tests;
+
+import com.jayway.android.robotium.solo.Solo;
+import @ANDROID_PACKAGE_NAME@.*;
+
+import android.app.Activity;
+import android.test.ActivityInstrumentationTestCase2;
+import android.content.Intent;
+import java.util.HashMap;
+
+abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
+    private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";
+    private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
+
+    private static Class<Activity> mLauncherActivityClass;
+    private Activity mActivity;
+    private Solo mSolo;
+    protected Driver mDriver;
+    protected Assert mAsserter;
+    protected Actions mActions;
+
+    static {
+        try {
+            mLauncherActivityClass = (Class<Activity>)Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public BaseTest() {
+        super(TARGET_PACKAGE_ID, mLauncherActivityClass);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        // Load config file from sdcard (setup by python script)
+        String configFile = FennecNativeDriver.getFile("/mnt/sdcard/robotium.config");
+        HashMap config = FennecNativeDriver.convertTextToTable(configFile);
+
+        // Create the intent to be used with all the important arguments.
+        Intent i = new Intent(Intent.ACTION_MAIN);
+        i.putExtra("args", "-no-remote -profile " + (String)config.get("profile"));
+
+        // Start the activity
+        setActivityIntent(i);
+        mActivity = getActivity();
+
+        // Set up Robotium.solo and Driver objects
+        mSolo = new Solo(getInstrumentation(), getActivity());
+        mDriver = new FennecNativeDriver(mActivity, mSolo);
+        mActions = new FennecNativeActions(mActivity, mSolo, getInstrumentation());
+        mDriver.setLogFile((String)config.get("logfile"));
+
+        mAsserter = new FennecNativeAssert();
+        mAsserter.setLogFile((String)config.get("logfile"));
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        try {
+            mSolo.finalize();
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+        getActivity().finish();
+        super.tearDown();
+    }
+}
--- a/mobile/android/base/tests/testAwesomebar.java.in
+++ b/mobile/android/base/tests/testAwesomebar.java.in
@@ -1,115 +1,40 @@
 #filter substitution
 package @ANDROID_PACKAGE_NAME@.tests;
 
-import com.jayway.android.robotium.solo.Solo;	
 import @ANDROID_PACKAGE_NAME@.*;
 
-import android.app.Activity;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.PerformanceTestCase;
-import android.util.Log;
-import android.widget.Button;
-import android.content.Intent;
-import java.util.HashMap;
-
-@SuppressWarnings("unused")
-public class testAwesomebar extends ActivityInstrumentationTestCase2 {
-
-  @SuppressWarnings("unchecked")
-  public testAwesomebar(Class activityClass) {
-    super(activityClass);
-    // TODO Auto-generated constructor stub
-  }
-  private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";	
-  private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
-  private Solo solo;    
-  private Activity activity;
-  private Driver driver;
-  private Assert asserter;
-  private Actions actions;
-  private static Class<?> launcherActivityClass;
+public class testAwesomebar extends BaseTest {
+    public void testAwesomebar() {
+        String url = "http://mochi.test:8888/tests/robocop/robocop_blank_01.html";
+        mActions.waitForGeckoEvent("Gecko:Ready");
+        Element awesomebar = mDriver.findElement("awesome_bar");
+        awesomebar.click();
 
-  static{
-    try{
-      launcherActivityClass = Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);	
-    } catch (ClassNotFoundException e){
-      throw new RuntimeException(e);	
-    }	
-  }	
-
-  @SuppressWarnings("unchecked")	
-  public testAwesomebar() throws ClassNotFoundException {
-    super(TARGET_PACKAGE_ID, launcherActivityClass);	
-  }	
+        Element urlbar = mDriver.findElement("awesomebar_text");
+        getInstrumentation().waitForIdleSync();
+        mActions.sendKeys(url);
+        mAsserter.is(urlbar.getText(), url, "Awesomebar URL Typed Properly");
 
-  @Override 
-  protected void setUp() throws Exception
-  {
-    // Load config file from sdcard (setup by python script)
-    String configFile = FennecNativeDriver.getFile("/mnt/sdcard/robotium.config");
-    HashMap config = FennecNativeDriver.convertTextToTable(configFile);
-
-    // Create the intent to be used with all the important arguments.
-    Intent i = new Intent(Intent.ACTION_MAIN);
-    String argsList = "-no-remote -profile " + (String)config.get("profile");
-    i.putExtra("args", argsList);
-
-    //Start the activity
-    setActivityIntent(i);
-    activity = getActivity();
+        mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
+        // wait for screen to load
+        mActions.waitForGeckoEvent("DOMContentLoaded");
+        mDriver.setupScrollHandling();
 
-    //Set up Robotium.solo and Driver objects
-    solo = new Solo(getInstrumentation(), getActivity());
-    driver = new FennecNativeDriver(activity, solo);
-    actions = new FennecNativeActions(activity, solo, getInstrumentation());
-    driver.setLogFile((String)config.get("logfile"));
-    
-    asserter = new FennecNativeAssert();
-    asserter.setLogFile((String)config.get("logfile"));
-  }
-
-  public void testAwesomebar() {
-    String url = "http://mochi.test:8888/tests/robocop/robocop_blank_01.html";
-    actions.waitForGeckoEvent("Gecko:Ready");
-    Element awesomebar = driver.findElement("awesome_bar");
-    awesomebar.click();
-
-    Element urlbar = driver.findElement("awesomebar_text");
-    getInstrumentation().waitForIdleSync();
-    actions.sendKeys(url);
-    asserter.is(urlbar.getText(), url, "Awesomebar URL Typed Properly");
-
-    actions.sendSpecialKey(Actions.SpecialKey.ENTER);
-    //wait for screen to load
-    actions.waitForGeckoEvent("DOMContentLoaded");
-    driver.setupScrollHandling();
-
-    //Calculate where we should be dragging.
-    int midX = driver.getGeckoLeft() + driver.getGeckoWidth()/2;
-    int midY = driver.getGeckoTop() + driver.getGeckoHeight()/2;
-    int endY = driver.getGeckoTop() + driver.getGeckoHeight()/10;
-    for(int i = 0; i < 10; i++) {
-      actions.drag(midX,midX,midY,endY);
-      try {
-        Thread.sleep(200);
-      } catch (InterruptedException e) {
-        e.printStackTrace();
-      }
+        // 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 {
+                Thread.sleep(200);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+        // Click the awesomebar again
+        awesomebar.click();
+        getInstrumentation().waitForIdleSync();
+        mAsserter.is(urlbar.getText(), url, "Awesomebar URL stayed the same");
     }
-    //Click the awesomebar again 
-    awesomebar.click();
-    getInstrumentation().waitForIdleSync();
-    asserter.is(urlbar.getText(), url, "Awesomebar URL stayed the same");
-  }	
-  
-  @Override	
-  public void tearDown() throws Exception {	
-    try	{
-      solo.finalize();	
-    }catch (Throwable e){	
-      e.printStackTrace();	
-    }	
-    getActivity().finish();	
-    super.tearDown();	
-  }
 }
--- a/mobile/android/base/tests/testBookmark.java.in
+++ b/mobile/android/base/tests/testBookmark.java.in
@@ -1,119 +1,44 @@
 #filter substitution
 package @ANDROID_PACKAGE_NAME@.tests;
 
-import com.jayway.android.robotium.solo.Solo;	
 import @ANDROID_PACKAGE_NAME@.*;
 
-import android.app.Activity;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.PerformanceTestCase;
-import android.util.Log;
-import android.widget.Button;
-import android.content.Intent;
-import java.util.HashMap;
-
-@SuppressWarnings("unused")
-public class testBookmark extends ActivityInstrumentationTestCase2 {
+public class testBookmark extends BaseTest {
+    public void testBookmark() {
+        // TODO: find a better way to not hardcode this url
+        String url = "http://mochi.test:8888/tests/robocop/robocop_blank_02.html";
 
-  @SuppressWarnings("unchecked")
-  public testBookmark(Class activityClass) {
-    super(activityClass);
-    // TODO Auto-generated constructor stub
-  }
-  private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";	
-  private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
-  private Solo solo;    
-  private Activity activity;
-  private Driver driver;
-  private Assert asserter;
-  private Actions actions;
-  private static Class<?> launcherActivityClass;
+        mActions.waitForGeckoEvent("Gecko:Ready");
+        Element awesomebar = mDriver.findElement("awesome_bar");
+        awesomebar.click();
 
-  static{
-    try{
-      launcherActivityClass = Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);	
-    } catch (ClassNotFoundException e){
-      throw new RuntimeException(e);	
-    }	
-  }	
+        Element urlbar = mDriver.findElement("awesomebar_text");
+        getInstrumentation().waitForIdleSync();
+        mActions.sendKeys(url);
+        mAsserter.is(urlbar.getText(), url, "Awesomebar url typed properly");
 
-  @SuppressWarnings("unchecked")	
-  public testBookmark() throws ClassNotFoundException {
-    super(TARGET_PACKAGE_ID, launcherActivityClass);	
-  }	
-  
-  @Override 
-  protected void setUp() throws Exception
-  {
-    //Load config file
-    String configFile = FennecNativeDriver.getFile("/mnt/sdcard/robotium.config");
-    HashMap config = FennecNativeDriver.convertTextToTable(configFile);
-
-    //Create the intent to be used with all the important arguments
-    Intent i = new Intent(Intent.ACTION_MAIN);
-    String argsList = "-no-remote -profile " + (String)config.get("profile");
-    i.putExtra("args", argsList);
+        //Click the top item in the list.
+        mActions.sendSpecialKey(Actions.SpecialKey.DOWN);
+        mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
+        mActions.waitForGeckoEvent("DOMContentLoaded");
 
-    //Start the activity
-    setActivityIntent(i);
-    activity = getActivity();
-    
-    //Set up Robotium.solo and Driver objects
-    solo = new Solo(getInstrumentation(), getActivity());	
-    driver = new FennecNativeDriver(activity, solo);
-    actions = new FennecNativeActions(activity, solo, getInstrumentation());
-    driver.setLogFile((String)config.get("logfile"));
-    
-    asserter = new FennecNativeAssert();
-    asserter.setLogFile((String)config.get("logfile"));
-  } 	
-
-  public void testBookmark(){
-    // TODO: find a better way to not hardcode this url
-    String url = "http://mochi.test:8888/tests/robocop/robocop_blank_02.html";
-
-    actions.waitForGeckoEvent("Gecko:Ready");
-    Element awesomebar = driver.findElement("awesome_bar");
-    awesomebar.click();
-
-    Element urlbar = driver.findElement("awesomebar_text");
-    getInstrumentation().waitForIdleSync();
-    actions.sendKeys(url);
-    asserter.is(urlbar.getText(), url, "Awesomebar url typed properly");
-
-    //Click the top item in the list.
-    actions.sendSpecialKey(Actions.SpecialKey.DOWN);
-    actions.sendSpecialKey(Actions.SpecialKey.ENTER);    
-    actions.waitForGeckoEvent("DOMContentLoaded");
+        getInstrumentation().waitForIdleSync();
+        awesomebar.click();
+        mAsserter.is(urlbar.getText(), url, "Awesomebar URL still on");
 
-    getInstrumentation().waitForIdleSync();
-    awesomebar.click();
-    asserter.is(urlbar.getText(), url, "Awesomebar URL still on");
-
-    //Click the Top item in the history list.
-    getInstrumentation().waitForIdleSync();
-    actions.sendSpecialKey(Actions.SpecialKey.RIGHT);
-    actions.sendSpecialKey(Actions.SpecialKey.RIGHT);
-    getInstrumentation().waitForIdleSync();
-    actions.sendSpecialKey(Actions.SpecialKey.DOWN);
-    actions.sendSpecialKey(Actions.SpecialKey.DOWN);
-    actions.sendSpecialKey(Actions.SpecialKey.ENTER);
-    actions.waitForGeckoEvent("DOMContentLoaded");
+        //Click the Top item in the history list.
+        getInstrumentation().waitForIdleSync();
+        mActions.sendSpecialKey(Actions.SpecialKey.RIGHT);
+        mActions.sendSpecialKey(Actions.SpecialKey.RIGHT);
+        getInstrumentation().waitForIdleSync();
+        mActions.sendSpecialKey(Actions.SpecialKey.DOWN);
+        mActions.sendSpecialKey(Actions.SpecialKey.DOWN);
+        mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
+        mActions.waitForGeckoEvent("DOMContentLoaded");
 
-    getInstrumentation().waitForIdleSync();
-    awesomebar.click();
-    //Unfortunately, the item isn't constant so can't be tested.
-    //asserter.is(url, urlbar.getText(),"Shouldn't this be the last url in the history?");
-  }
-  
-  @Override	
-  public void tearDown() throws Exception {	
-    try	{
-      solo.finalize();	
-    }catch (Throwable e){	
-      e.printStackTrace();	
-    }	
-    getActivity().finish();	
-    super.tearDown();	
-  }
+        getInstrumentation().waitForIdleSync();
+        awesomebar.click();
+        //Unfortunately, the item isn't constant so can't be tested.
+        //asserter.is(url, urlbar.getText(),"Shouldn't this be the last url in the history?");
+    }
 }
--- a/mobile/android/base/tests/testLoad.java.in
+++ b/mobile/android/base/tests/testLoad.java.in
@@ -1,105 +1,30 @@
 #filter substitution
 package @ANDROID_PACKAGE_NAME@.tests;
 
-import com.jayway.android.robotium.solo.Solo;	
 import @ANDROID_PACKAGE_NAME@.*;
 
-import android.app.Activity;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.PerformanceTestCase;
-import android.util.Log;
-import android.widget.Button;
-import android.content.Intent;
-import java.util.HashMap;
-
-@SuppressWarnings("unused")
-public class testLoad extends ActivityInstrumentationTestCase2 {
-
-  @SuppressWarnings("unchecked")
-  public testLoad(Class activityClass) {
-    super(activityClass);
-    // TODO Auto-generated constructor stub
-  }
-  private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";	
-  private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
-  private Solo solo;    
-  private Activity activity;
-  private Driver driver;
-  private Assert asserter;
-  private Actions actions;
-  private static Class<?> launcherActivityClass;
+public class testLoad extends BaseTest {
+    public void testLoad() {
+        // TODO: find a better way to not hardcode this url
+        String url = "http://mochi.test:8888/tests/robocop/robocop_blank_03.html";
 
-  static{
-    try{
-      launcherActivityClass = Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);	
-    } catch (ClassNotFoundException e){
-      throw new RuntimeException(e);	
-    }	
-  }	
-
-  @SuppressWarnings("unchecked")	
-  public testLoad() throws ClassNotFoundException {
-    super(TARGET_PACKAGE_ID, launcherActivityClass);	
-  }	
-  
-  @Override 
-  protected void setUp() throws Exception
-  {
-    //Load config file
-    String configFile = FennecNativeDriver.getFile("/mnt/sdcard/robotium.config");
-    HashMap config = FennecNativeDriver.convertTextToTable(configFile);
-    
-    //Create the intent to be used with all the important arguments
-    Intent i = new Intent(Intent.ACTION_MAIN);
-    String argsList = "-no-remote -profile " + (String)config.get("profile");
-    i.putExtra("args", argsList);
+        mActions.waitForGeckoEvent("Gecko:Ready");
+        Element awesomebar = mDriver.findElement("awesome_bar");
+        awesomebar.click();
 
-    //Start the activity
-    setActivityIntent(i);
-    activity = getActivity();
-
-    //Set up Robotium.solo and Driver objects
-    solo = new Solo(getInstrumentation(), getActivity());	
-    driver = new FennecNativeDriver(activity, solo);
-    actions = new FennecNativeActions(activity, solo, getInstrumentation());
-    driver.setLogFile((String)config.get("logfile"));
-    
-    asserter = new FennecNativeAssert();
-    asserter.setLogFile((String)config.get("logfile"));
-  } 	
-
-  public void testLoad(){
-    // TODO: find a better way to not hardcode this url
-    String url = "http://mochi.test:8888/tests/robocop/robocop_blank_03.html";
-
-    actions.waitForGeckoEvent("Gecko:Ready");
-    Element awesomebar = driver.findElement("awesome_bar");
-    awesomebar.click();
+        Element urlbar = mDriver.findElement("awesomebar_text");
+        getInstrumentation().waitForIdleSync();
+        mActions.sendKeys(url);
+        getInstrumentation().waitForIdleSync();
+        mAsserter.is(urlbar.getText(), url, "Awesomebar URL Correct");
 
-    Element urlbar = driver.findElement("awesomebar_text");
-    getInstrumentation().waitForIdleSync();
-    actions.sendKeys(url);
-    getInstrumentation().waitForIdleSync();
-    asserter.is(urlbar.getText(), url, "Awesomebar URL Correct");
-
-    //Select top item in the list.
-    actions.sendSpecialKey(Actions.SpecialKey.DOWN);
-    actions.sendSpecialKey(Actions.SpecialKey.ENTER);
-    actions.waitForGeckoEvent("DOMContentLoaded");
+        // Select top item in the list.
+        mActions.sendSpecialKey(Actions.SpecialKey.DOWN);
+        mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
+        mActions.waitForGeckoEvent("DOMContentLoaded");
 
-    awesomebar.click();
-    getInstrumentation().waitForIdleSync();
-    asserter.is(urlbar.getText(), url, "Awesomebar URL is still correct");
-  }
-
-  @Override	
-  public void tearDown() throws Exception {	
-    try	{
-      solo.finalize();	
-    }catch (Throwable e){	
-      e.printStackTrace();	
-    }	
-    getActivity().finish();	
-    super.tearDown();	
-  }
+        awesomebar.click();
+        getInstrumentation().waitForIdleSync();
+        mAsserter.is(urlbar.getText(), url, "Awesomebar URL is still correct");
+    }
 }
--- a/mobile/android/base/tests/testNewTab.java.in
+++ b/mobile/android/base/tests/testNewTab.java.in
@@ -1,120 +1,48 @@
 #filter substitution
 package @ANDROID_PACKAGE_NAME@.tests;
 
-import com.jayway.android.robotium.solo.Solo;
 import @ANDROID_PACKAGE_NAME@.*;
 
-import android.app.Activity;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.PerformanceTestCase;
-import android.util.Log;
-import android.widget.Button;
-import android.content.Intent;
-import java.util.HashMap;
-
-@SuppressWarnings("unused")
-public class testNewTab extends ActivityInstrumentationTestCase2 {
-
-  @SuppressWarnings("unchecked")
-  public testNewTab(Class activityClass) {
-    super(activityClass);
-    // TODO Auto-generated constructor stub
-  }
-  private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";	
-  private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
-  private Solo solo;    
-  private Activity activity;
-  private Actions actions;
-  private Driver driver;
-  private Assert asserter;
-  private static Class<?> launcherActivityClass;
+public class testNewTab extends BaseTest {
+    public void testNewTab() {
+        // TODO: find a better way to not hardcode this url
+        String url = "http://mochi.test:8888/tests/robocop/robocop_blank_01.html";
+        String url2 = "http://mochi.test:8888/tests/robocop/robocop_blank_02.html";
+        mActions.waitForGeckoEvent("Gecko:Ready");
+        Element tabs = mDriver.findElement("tabs");
+        // Add one tab
+        tabs.click();
 
-  static{
-    try{
-      launcherActivityClass = Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);	
-    } catch (ClassNotFoundException e){
-      throw new RuntimeException(e);	
-    }	
-  }	
+        Element urlbar = mDriver.findElement("awesomebar_text");
+        getInstrumentation().waitForIdleSync();
+        mActions.sendKeys(url);
+        mAsserter.is(urlbar.getText(), url, "Awesomebar url is fine");
+        mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
+        mActions.waitForGeckoEvent("DOMContentLoaded");
 
-  @SuppressWarnings("unchecked")	
-  public testNewTab() throws ClassNotFoundException {
-    super(TARGET_PACKAGE_ID, launcherActivityClass);	
-  }	
-  
-  @Override 
-  protected void setUp() throws Exception
-  {
-    // Load config file from sdcard (setup by python script)
-    String configFile = FennecNativeDriver.getFile("/mnt/sdcard/robotium.config");
-    HashMap config = FennecNativeDriver.convertTextToTable(configFile);
-
-    // Create the intent to be used with all the important arguments.
-    Intent i = new Intent(Intent.ACTION_MAIN);
-    String argsList = "-no-remote -profile " + (String)config.get("profile");
-    i.putExtra("args", argsList);
-
-    //Start the activity
-    setActivityIntent(i);
-    activity = getActivity();
+        try {
+            Thread.sleep(5000);
+        } catch (Throwable e) {
+        }
 
-    //Set up Robotium.solo and Driver objects
-    solo = new Solo(getInstrumentation(), getActivity());
-    driver = new FennecNativeDriver(activity, solo);
-    actions = new FennecNativeActions(activity, solo, getInstrumentation());
-    driver.setLogFile((String)config.get("logfile"));
-    
-    asserter = new FennecNativeAssert();
-    asserter.setLogFile((String)config.get("logfile"));
-  }
+        // See tab count
+        Element tabCount = mDriver.findElement("tabs_count");
+        mAsserter.is(tabCount.getText(), "2", "Number of tabs has increased");
 
-  public void testNewTab(){
-    // TODO: find a better way to not hardcode this url
-    String url = "http://mochi.test:8888/tests/robocop/robocop_blank_01.html";
-    String url2 = "http://mochi.test:8888/tests/robocop/robocop_blank_02.html";
-    actions.waitForGeckoEvent("Gecko:Ready");
-    Element tabs = driver.findElement("tabs");
-    //Add one tab
-    tabs.click();
-
-    Element urlbar = driver.findElement("awesomebar_text");
-    getInstrumentation().waitForIdleSync();
-    actions.sendKeys(url);
-    asserter.is(urlbar.getText(), url, "Awesomebar url is fine");
-    actions.sendSpecialKey(Actions.SpecialKey.ENTER);
-    actions.waitForGeckoEvent("DOMContentLoaded");
+        // Click tab list
+        tabs.click();
+        Element addTab = mDriver.findElement("add_tab");
 
-    try{Thread.sleep(5000);}catch(Throwable e){};
-    //See tab count
-    Element tabCount = driver.findElement("tabs_count");
-    asserter.is(tabCount.getText(), "2", "Number of tabs has increased");
-
-    //Click tab list
-    tabs.click();
-    Element addTab = driver.findElement("add_tab");
-
-    //Add another tab
-    addTab.click();
-    getInstrumentation().waitForIdleSync();
-    actions.sendKeys(url2);
-    getInstrumentation().waitForIdleSync();
-    asserter.is(urlbar.getText(), url2, "URL is still fine");
+        //Add another tab
+        addTab.click();
+        getInstrumentation().waitForIdleSync();
+        mActions.sendKeys(url2);
+        getInstrumentation().waitForIdleSync();
+        mAsserter.is(urlbar.getText(), url2, "URL is still fine");
 
-    actions.sendSpecialKey(Actions.SpecialKey.ENTER);
-    actions.waitForGeckoEvent("DOMContentLoaded");
-    //Check tab count another time.
-    asserter.is(tabCount.getText(), "3", "Number of tabs has increased");
-
-  }
-
-  @Override	
-  public void tearDown() throws Exception {	
-    try	{
-      solo.finalize();	
-    }catch (Throwable e){	
-      e.printStackTrace();	
-    }	
-    getActivity().finish();	
-    super.tearDown();	
-  }
+        mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
+        mActions.waitForGeckoEvent("DOMContentLoaded");
+        //Check tab count another time.
+        mAsserter.is(tabCount.getText(), "3", "Number of tabs has increased");
+    }
 }
--- a/mobile/android/base/tests/testPan.java.in
+++ b/mobile/android/base/tests/testPan.java.in
@@ -1,126 +1,48 @@
 #filter substitution
 package @ANDROID_PACKAGE_NAME@.tests;
 
-
-import com.jayway.android.robotium.solo.Solo;	
 import @ANDROID_PACKAGE_NAME@.*;
 
-import android.app.Activity;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.PerformanceTestCase;
-import android.util.Log;
-import android.widget.Button;
-import android.content.Intent;
-import java.util.HashMap;
-import java.util.List;
-
-@SuppressWarnings("unused")
-public class testPan extends ActivityInstrumentationTestCase2 {
-
-  @SuppressWarnings("unchecked")
-  public testPan(Class activityClass) {
-    super(activityClass);
-    // TODO Auto-generated constructor stub
-  }
-  private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";	
-  private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
-  private Solo solo;    
-  private Activity activity;
-  private Driver driver;
-  private Actions actions;
-  private Assert asserter;
-  private static Class<?> launcherActivityClass;
+public class testPan extends BaseTest {
+    public void testPan() {
+        // TODO: find a better way to not hardcode this url
+        String url = "http://mochi.test:8888/startup_test/fenncmark/wikipedia.html";
+        mActions.waitForGeckoEvent("Gecko:Ready");
+        Element awesomebar = mDriver.findElement("awesome_bar");
+        awesomebar.click();
 
-  static{
-    try{
-      launcherActivityClass = Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);	
-    } catch (ClassNotFoundException e){
-      throw new RuntimeException(e);	
-    }	
-  }	
+        Element urlbar = mDriver.findElement("awesomebar_text");
+        getInstrumentation().waitForIdleSync();
+        mActions.sendKeys(url);
+        mAsserter.is(url, urlbar.getText(),"Asserting Awesomebar typing works");
 
-  @SuppressWarnings("unchecked")	
-  public testPan() throws ClassNotFoundException {
-    super(TARGET_PACKAGE_ID, launcherActivityClass);	
-  }	
-  
-  @Override 
-  protected void setUp() throws Exception
-  {
-    // Load config file from sdcard (setup by python script)
-    String configFile = FennecNativeDriver.getFile("/mnt/sdcard/robotium.config");
-    HashMap config = FennecNativeDriver.convertTextToTable(configFile);
+        mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
+        mActions.waitForGeckoEvent("DOMContentLoaded");
+        mDriver.setupScrollHandling();
 
-    // Create the intent to be used with all the important arguments.
-    Intent i = new Intent(Intent.ACTION_MAIN);
-    String argsList = "-no-remote -profile " + (String)config.get("profile");
-    i.putExtra("args", argsList);
-
-    //Start the activity
-    setActivityIntent(i);
-    activity = getActivity();
+        // Setup scrolling coordinates.
+        int midX = mDriver.getGeckoLeft() + mDriver.getGeckoWidth()/2;
+        int midY = mDriver.getGeckoTop() + mDriver.getGeckoHeight()/2;
+        int endY = mDriver.getGeckoTop() + mDriver.getGeckoHeight()/10;
 
-    //Set up Robotium.solo and Driver objects
-    solo = new Solo(getInstrumentation(), getActivity());
-    driver = new FennecNativeDriver(activity, solo);
-    actions = new FennecNativeActions(activity, solo, getInstrumentation());
-    driver.setLogFile((String)config.get("logfile"));
-
-    asserter = new FennecNativeAssert();
-    asserter.setLogFile((String)config.get("logfile"));
-  }
-
-  public void testPan() {
-    // TODO: find a better way to not hardcode this url
-    String url = "http://mochi.test:8888/startup_test/fenncmark/wikipedia.html";
-    actions.waitForGeckoEvent("Gecko:Ready");
-    Element awesomebar = driver.findElement("awesome_bar");
-    awesomebar.click();
-
-    Element urlbar = driver.findElement("awesomebar_text");
-    getInstrumentation().waitForIdleSync();
-    actions.sendKeys(url);
-    asserter.is(url, urlbar.getText(),"Asserting Awesomebar typing works");
-
-    actions.sendSpecialKey(Actions.SpecialKey.ENTER);
-    actions.waitForGeckoEvent("DOMContentLoaded");
-    driver.setupScrollHandling();
-
-    // Setup scrolling coordinates.
-    int midX = driver.getGeckoLeft() + driver.getGeckoWidth()/2;
-    int midY = driver.getGeckoTop() + driver.getGeckoHeight()/2;
-    int endY = driver.getGeckoTop() + driver.getGeckoHeight()/10;
+        mDriver.startFrameRecording();
 
-    driver.startFrameRecording();
-
-    int i = 0;
-    // Scroll a thousand times or until the end of the page.
-    do {
-      actions.drag(midX, midX, midY, endY);
-      try {
-        Thread.sleep(200);
-      }
-      catch (InterruptedException e) {
-        e.printStackTrace();
-      }
-      i++;
-    } while( i < 1000 && driver.getScrollHeight() + 2*driver.getHeight() < driver.getPageHeight() );
-//    asserter.ok(i < 1000, "Less than 1000", "Should take less than 1000 drags to get to bottom of the page.");
+        int i = 0;
+        // Scroll a thousand times or until the end of the page.
+        do {
+            mActions.drag(midX, midX, midY, endY);
+            try {
+                Thread.sleep(200);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            i++;
+        } while (i < 1000 && mDriver.getScrollHeight() + 2 * mDriver.getHeight() < mDriver.getPageHeight());
+        // asserter.ok(i < 1000, "Less than 1000", "Should take less than 1000 drags to get to bottom of the page.");
 
-    int frames = driver.stopFrameRecording();
-    driver.dumpLog("__start_report" + Integer.toString(frames) + "__end_report");
-    Long msecs = System.currentTimeMillis();
-    driver.dumpLog("__startTimestamp" + msecs.toString() + "__endTimestamp");
-  }	
-
-  @Override	
-  public void tearDown() throws Exception {	
-    try	{
-      solo.finalize();	
-    }catch (Throwable e){	
-      e.printStackTrace();	
+        int frames = mDriver.stopFrameRecording();
+        mDriver.dumpLog("__start_report" + Integer.toString(frames) + "__end_report");
+        Long msecs = System.currentTimeMillis();
+        mDriver.dumpLog("__startTimestamp" + msecs.toString() + "__endTimestamp");
     }	
-    getActivity().finish();	
-    super.tearDown();	
-  }
 }