Bug 990116 - Part 2: Use BROWSER_INTENT_CLASS in Robocop tests. r=mcomella

This commit is contained in:
Nick Alexander 2014-04-01 22:00:46 -07:00
parent f5f1d5757e
commit 5b100506b2
4 changed files with 26 additions and 53 deletions

View File

@ -6,6 +6,7 @@ package org.mozilla.gecko.tests;
import java.util.Map;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.Assert;
import org.mozilla.gecko.FennecInstrumentationTestRunner;
import org.mozilla.gecko.FennecMochitestAssert;
@ -21,20 +22,35 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
TALOS
}
protected static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";
protected Assert mAsserter;
protected String mLogFile;
protected Map<?, ?> mConfig;
protected String mRootPath;
public BaseRobocopTest(Class<Activity> activityClass) {
super(activityClass);
/**
* The browser is started at the beginning of this test. A single test is a
* class inheriting from <code>BaseRobocopTest</code> that contains test
* methods.
* <p>
* If a test should not start the browser at the beginning of a test,
* specify a different activity class to the one-argument constructor. To do
* as little as possible, specify <code>Activity.class</code>.
*/
@SuppressWarnings("unchecked")
public BaseRobocopTest() {
this((Class<Activity>) AppConstants.BROWSER_INTENT_CLASS);
}
@SuppressWarnings("deprecation")
public BaseRobocopTest(String targetPackageId, Class<Activity> activityClass) {
super(targetPackageId, activityClass);
/**
* Start the given activity class at the beginning of this test.
* <p>
* <b>You should use the no-argument constructor in almost all cases.</b>
*
* @param activityClass to start before this test.
*/
protected BaseRobocopTest(Class<Activity> activityClass) {
super(activityClass);
}
/**
@ -64,4 +80,4 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
mAsserter.setLogFile(mLogFile);
mAsserter.setTestName(this.getClass().getName());
}
}
}

View File

@ -55,7 +55,6 @@ import com.jayway.android.robotium.solo.Solo;
*/
@SuppressWarnings("unchecked")
abstract class BaseTest extends BaseRobocopTest {
private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME = TestConstants.ANDROID_PACKAGE_NAME + ".App";
private static final int VERIFY_URL_TIMEOUT = 2000;
private static final int MAX_WAIT_ENABLED_TEXT_MS = 10000;
private static final int MAX_WAIT_HOME_PAGER_HIDDEN_MS = 15000;
@ -64,7 +63,6 @@ abstract class BaseTest extends BaseRobocopTest {
private static final int GECKO_READY_WAIT_MS = 180000;
public static final int MAX_WAIT_BLOCK_FOR_EVENT_DATA_MS = 90000;
private static Class<Activity> mLauncherActivityClass;
private Activity mActivity;
private int mPreferenceRequestID = 0;
protected Solo mSolo;
@ -89,18 +87,6 @@ abstract class BaseTest extends BaseRobocopTest {
}
}
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
public void setUp() throws Exception {
super.setUp();

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.Actions;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.Assert;
import org.mozilla.gecko.Driver;
import org.mozilla.gecko.FennecInstrumentationTestRunner;
@ -37,14 +38,9 @@ import java.util.HashMap;
abstract class UITest extends ActivityInstrumentationTestCase2<Activity>
implements UITestContext {
private static final String LAUNCHER_ACTIVITY = TestConstants.ANDROID_PACKAGE_NAME + ".App";
private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";
private static final String JUNIT_FAILURE_MSG = "A JUnit method was called. Make sure " +
"you are using AssertionHelper to make assertions. Try `fAssert*(...);`";
private final static Class<Activity> sLauncherActivityClass;
private Solo mSolo;
private Driver mDriver;
private Actions mActions;
@ -60,16 +56,9 @@ abstract class UITest extends ActivityInstrumentationTestCase2<Activity>
protected GeckoViewComponent mGeckoView;
protected ToolbarComponent mToolbar;
static {
try {
sLauncherActivityClass = (Class<Activity>) Class.forName(LAUNCHER_ACTIVITY);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@SuppressWarnings("unchecked")
public UITest() {
super(sLauncherActivityClass);
super((Class<Activity>) AppConstants.BROWSER_INTENT_CLASS);
}
@Override

View File

@ -13,7 +13,6 @@ import org.mozilla.gecko.db.BrowserProvider;
import org.mozilla.gecko.db.LocalBrowserDB;
import org.mozilla.gecko.util.FileUtils;
import android.app.Activity;
import android.content.ContentProvider;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
@ -36,12 +35,7 @@ import android.util.Log;
* Instead, we directly use the existing ContentProvider, accessing a new
* profile directory that we initialize via BrowserDB.
*/
@SuppressWarnings("unchecked")
public class testBrowserProviderPerf extends BaseRobocopTest {
private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME = TestConstants.ANDROID_PACKAGE_NAME + ".App";
private static Class<Activity> mLauncherActivityClass;
private final int NUMBER_OF_BASIC_HISTORY_URLS = 10000;
private final int NUMBER_OF_BASIC_BOOKMARK_URLS = 500;
private final int NUMBER_OF_COMBINED_URLS = 500;
@ -63,18 +57,6 @@ public class testBrowserProviderPerf extends BaseRobocopTest {
private Uri mBookmarksURI;
private Uri mFaviconsURI;
static {
try {
mLauncherActivityClass = (Class<Activity>) Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
public testBrowserProviderPerf() {
super(TARGET_PACKAGE_ID, mLauncherActivityClass);
}
@Override
protected Type getTestType() {
return Type.TALOS;