зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1106900 - Move mSolo and other Robocop components into BaseRobocopTest. r=mcomella
--HG-- extra : rebase_source : 35a6002f856dc978f301cf6fc65945cec11c110a
This commit is contained in:
Родитель
701684409e
Коммит
9fc7941275
|
@ -10,20 +10,26 @@ import org.apache.http.HttpResponse;
|
|||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
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;
|
||||
import org.mozilla.gecko.FennecMochitestAssert;
|
||||
import org.mozilla.gecko.FennecNativeActions;
|
||||
import org.mozilla.gecko.FennecNativeDriver;
|
||||
import org.mozilla.gecko.FennecTalosAssert;
|
||||
import org.mozilla.gecko.updater.UpdateServiceHelper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.PowerManager;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jayway.android.robotium.solo.Solo;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
public enum Type {
|
||||
|
@ -61,6 +67,15 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
|
|||
protected Map<String, String> mConfig;
|
||||
protected String mRootPath;
|
||||
|
||||
protected Solo mSolo;
|
||||
protected Driver mDriver;
|
||||
protected Actions mActions;
|
||||
|
||||
protected Activity mActivity;
|
||||
protected String mProfile;
|
||||
|
||||
protected abstract Intent createActivityIntent();
|
||||
|
||||
/**
|
||||
* The browser is started at the beginning of this test. A single test is a
|
||||
* class inheriting from <code>BaseRobocopTest</code> that contains test
|
||||
|
@ -109,6 +124,9 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
|
|||
String configFile = FennecNativeDriver.getFile(mRootPath + "/robotium.config");
|
||||
mConfig = FennecNativeDriver.convertTextToTable(configFile);
|
||||
mLogFile = mConfig.get("logfile");
|
||||
mProfile = mConfig.get("profile");
|
||||
mBaseHostnameUrl = mConfig.get("host").replaceAll("(/$)", "");
|
||||
mBaseIpUrl = mConfig.get("rawhost").replaceAll("(/$)", "");
|
||||
|
||||
// Initialize the asserter.
|
||||
if (getTestType() == Type.TALOS) {
|
||||
|
@ -119,8 +137,15 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
|
|||
mAsserter.setLogFile(mLogFile);
|
||||
mAsserter.setTestName(getClass().getName());
|
||||
|
||||
mBaseHostnameUrl = mConfig.get("host").replaceAll("(/$)", "");
|
||||
mBaseIpUrl = mConfig.get("rawhost").replaceAll("(/$)", "");
|
||||
// Start the activity.
|
||||
final Intent intent = createActivityIntent();
|
||||
setActivityIntent(intent);
|
||||
mActivity = getActivity();
|
||||
|
||||
// Set up Robotium.solo and Driver objects
|
||||
mSolo = new Solo(getInstrumentation(), mActivity);
|
||||
mDriver = new FennecNativeDriver(mActivity, mSolo, mRootPath);
|
||||
mActions = new FennecNativeActions(mActivity, mSolo, getInstrumentation(), mAsserter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,12 +15,9 @@ import java.util.HashSet;
|
|||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import org.mozilla.gecko.Actions;
|
||||
import org.mozilla.gecko.BrowserApp;
|
||||
import org.mozilla.gecko.Driver;
|
||||
import org.mozilla.gecko.Element;
|
||||
import org.mozilla.gecko.FennecNativeActions;
|
||||
import org.mozilla.gecko.FennecNativeDriver;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.GeckoProfile;
|
||||
|
@ -72,12 +69,7 @@ abstract class BaseTest extends BaseRobocopTest {
|
|||
|
||||
protected static final String URL_HTTP_PREFIX = "http://";
|
||||
|
||||
private Activity mActivity;
|
||||
private int mPreferenceRequestID = 0;
|
||||
protected Solo mSolo;
|
||||
protected Driver mDriver;
|
||||
protected Actions mActions;
|
||||
protected String mProfile;
|
||||
public Device mDevice;
|
||||
protected DatabaseHelper mDatabaseHelper;
|
||||
protected int mScreenMidWidth;
|
||||
|
@ -110,30 +102,6 @@ abstract class BaseTest extends BaseRobocopTest {
|
|||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// Create the intent to be used with all the important arguments.
|
||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
||||
mProfile = mConfig.get("profile");
|
||||
|
||||
// Don't show the first run experience.
|
||||
i.putExtra(BrowserApp.EXTRA_SKIP_STARTPANE, true);
|
||||
|
||||
i.putExtra("args", "-no-remote -profile " + mProfile);
|
||||
|
||||
String envString = mConfig.get("envvars");
|
||||
if (envString != "") {
|
||||
String[] envStrings = envString.split(",");
|
||||
for (int iter = 0; iter < envStrings.length; iter++) {
|
||||
i.putExtra("env" + iter, envStrings[iter]);
|
||||
}
|
||||
}
|
||||
|
||||
// Start the activity.
|
||||
setActivityIntent(i);
|
||||
mActivity = getActivity();
|
||||
// Set up Robotium.solo and Driver objects
|
||||
mSolo = new Solo(getInstrumentation(), mActivity);
|
||||
mDriver = new FennecNativeDriver(mActivity, mSolo, mRootPath);
|
||||
mActions = new FennecNativeActions(mActivity, mSolo, getInstrumentation(), mAsserter);
|
||||
mDevice = new Device();
|
||||
mDatabaseHelper = new DatabaseHelper(mActivity, mAsserter);
|
||||
|
||||
|
@ -190,6 +158,23 @@ abstract class BaseTest extends BaseRobocopTest {
|
|||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Intent createActivityIntent() {
|
||||
final Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.putExtra("args", "-no-remote -profile " + mProfile);
|
||||
|
||||
final String envString = mConfig.get("envvars");
|
||||
if (!TextUtils.isEmpty(envString)) {
|
||||
final String[] envStrings = envString.split(",");
|
||||
|
||||
for (int iter = 0; iter < envStrings.length; iter++) {
|
||||
intent.putExtra("env" + iter, envStrings[iter]);
|
||||
}
|
||||
}
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
public void assertMatches(String value, String regex, String name) {
|
||||
if (value == null) {
|
||||
mAsserter.ok(false, name, "Expected /" + regex + "/, got null");
|
||||
|
|
|
@ -4,14 +4,10 @@
|
|||
|
||||
package org.mozilla.gecko.tests;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.mozilla.gecko.Actions;
|
||||
import org.mozilla.gecko.Assert;
|
||||
import org.mozilla.gecko.BrowserApp;
|
||||
import org.mozilla.gecko.Driver;
|
||||
import org.mozilla.gecko.FennecNativeActions;
|
||||
import org.mozilla.gecko.FennecNativeDriver;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.tests.components.AboutHomeComponent;
|
||||
|
@ -21,7 +17,6 @@ import org.mozilla.gecko.tests.components.GeckoViewComponent;
|
|||
import org.mozilla.gecko.tests.components.ToolbarComponent;
|
||||
import org.mozilla.gecko.tests.helpers.HelperInitializer;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
|
@ -42,10 +37,6 @@ abstract class UITest extends BaseRobocopTest
|
|||
private static final String JUNIT_FAILURE_MSG = "A JUnit method was called. Make sure " +
|
||||
"you are using AssertionHelper to make assertions. Try `fAssert*(...);`";
|
||||
|
||||
private Solo mSolo;
|
||||
private Driver mDriver;
|
||||
private Actions mActions;
|
||||
|
||||
protected AboutHomeComponent mAboutHome;
|
||||
protected AppMenuComponent mAppMenu;
|
||||
protected GeckoViewComponent mGeckoView;
|
||||
|
@ -55,15 +46,6 @@ abstract class UITest extends BaseRobocopTest
|
|||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// Start the activity.
|
||||
final Intent intent = createActivityIntent(mConfig);
|
||||
setActivityIntent(intent);
|
||||
final Activity activity = getActivity();
|
||||
|
||||
mSolo = new Solo(getInstrumentation(), activity);
|
||||
mDriver = new FennecNativeDriver(activity, mSolo, mRootPath);
|
||||
mActions = new FennecNativeActions(activity, mSolo, getInstrumentation(), mAsserter);
|
||||
|
||||
// Helpers depend on components so initialize them first.
|
||||
initComponents();
|
||||
initHelpers();
|
||||
|
@ -191,16 +173,15 @@ abstract class UITest extends BaseRobocopTest
|
|||
return baseUrl + "/" + url.replaceAll("(^/)", "");
|
||||
}
|
||||
|
||||
private static Intent createActivityIntent(final Map<String, String> config) {
|
||||
@Override
|
||||
protected Intent createActivityIntent() {
|
||||
final Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
|
||||
// Don't show the first run experience.
|
||||
intent.putExtra(BrowserApp.EXTRA_SKIP_STARTPANE, true);
|
||||
intent.putExtra("args", "-no-remote -profile " + mProfile);
|
||||
|
||||
final String profile = config.get("profile");
|
||||
intent.putExtra("args", "-no-remote -profile " + profile);
|
||||
|
||||
final String envString = config.get("envvars");
|
||||
final String envString = mConfig.get("envvars");
|
||||
if (!TextUtils.isEmpty(envString)) {
|
||||
final String[] envStrings = envString.split(",");
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import android.content.ContentProvider;
|
|||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.net.Uri;
|
||||
|
@ -313,4 +314,11 @@ public class testBrowserProviderPerf extends BaseRobocopTest {
|
|||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Returning null here refers to the default intent and it shouldn't
|
||||
// impede activity launch.
|
||||
@Override
|
||||
protected Intent createActivityIntent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче