Bug 970176 - Part 0: remove AppConstants dependency on .App by moving things to TestConstants. r=nalexander

This commit is contained in:
Richard Newman 2014-04-10 10:09:34 -07:00
Родитель c0dec6808f
Коммит 0737bf6e03
6 изменённых файлов: 37 добавлений и 14 удалений

Просмотреть файл

@ -24,16 +24,10 @@ public class AppConstants {
public static final String ANDROID_PACKAGE_NAME = "@ANDROID_PACKAGE_NAME@";
public static final String MANGLED_ANDROID_PACKAGE_NAME = "@MANGLED_ANDROID_PACKAGE_NAME@";
/**
* The Java Class instance that launches the browser.
* <p>
* This should always agree with <code>BROWSER_INTENT_CLASS_NAME</code>.
*/
public static final Class<? extends Activity> BROWSER_INTENT_CLASS = @ANDROID_PACKAGE_NAME@.App.class;
/**
* The name of the Java class that launches the browser.
*/
public static final String BROWSER_INTENT_CLASS_NAME = BROWSER_INTENT_CLASS.getName();
public static final String BROWSER_INTENT_CLASS_NAME = ANDROID_PACKAGE_NAME + ".App";
public static final String GRE_MILESTONE = "@GRE_MILESTONE@";

Просмотреть файл

@ -6,7 +6,6 @@ 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;
@ -39,7 +38,7 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
*/
@SuppressWarnings("unchecked")
public BaseRobocopTest() {
this((Class<Activity>) AppConstants.BROWSER_INTENT_CLASS);
this((Class<Activity>) TestConstants.BROWSER_INTENT_CLASS);
}
/**

Просмотреть файл

@ -2,6 +2,7 @@ package org.mozilla.gecko.tests;
import java.util.ArrayList;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.Assert;
import org.mozilla.gecko.GeckoProfile;
import org.mozilla.gecko.db.BrowserDB;
@ -31,7 +32,7 @@ class DatabaseHelper {
protected Uri buildUri(BrowserDataType dataType) {
Uri uri = null;
if (dataType == BrowserDataType.BOOKMARKS || dataType == BrowserDataType.HISTORY) {
uri = Uri.parse("content://" + TestConstants.ANDROID_PACKAGE_NAME + ".db.browser/" + dataType.toString().toLowerCase());
uri = Uri.parse("content://" + AppConstants.ANDROID_PACKAGE_NAME + ".db.browser/" + dataType.toString().toLowerCase());
} else {
mAsserter.ok(false, "The wrong data type has been provided = " + dataType.toString(), "Please provide the correct data type");
}

Просмотреть файл

@ -6,6 +6,13 @@
package org.mozilla.gecko.tests;
import android.app.Activity;
public class TestConstants {
public static final String ANDROID_PACKAGE_NAME = "@ANDROID_PACKAGE_NAME@";
/**
* The Java Class instance that launches the browser.
* <p>
* This should always agree with {@link AppConstants#BROWSER_INTENT_CLASS_NAME}.
*/
public static final Class<? extends Activity> BROWSER_INTENT_CLASS = @ANDROID_PACKAGE_NAME@.App.class;
}

Просмотреть файл

@ -3,6 +3,7 @@ package org.mozilla.gecko.tests;
import java.util.ArrayList;
import org.mozilla.gecko.Actions;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.GeckoProfile;
import android.content.ContentResolver;
@ -112,7 +113,7 @@ public class testImportFromAndroid extends AboutHomeTest {
// Add a few history items in Firefox Mobile
ContentResolver resolver = getActivity().getContentResolver();
Uri uri = Uri.parse("content://" + TestConstants.ANDROID_PACKAGE_NAME + ".db.browser/history");
Uri uri = Uri.parse("content://" + AppConstants.ANDROID_PACKAGE_NAME + ".db.browser/history");
uri = uri.buildUpon().appendQueryParameter("profile", GeckoProfile.DEFAULT_PROFILE)
.appendQueryParameter("sync", "true").build();
for (String url:androidData) {

Просмотреть файл

@ -12,13 +12,34 @@ import android.test.ActivityInstrumentationTestCase2;
/**
* BrowserTestCase provides helper methods for testing.
*/
@SuppressWarnings("unchecked")
public class BrowserTestCase extends ActivityInstrumentationTestCase2<Activity> {
@SuppressWarnings("unused")
private static String LOG_TAG = "BrowserTestCase";
@SuppressWarnings("unchecked")
/**
* The Java Class instance that launches the browser.
* <p>
* This should always agree with {@link AppConstants#BROWSER_INTENT_CLASS_NAME}.
*/
public static final Class<? extends Activity> BROWSER_INTENT_CLASS;
// Use reflection here so we don't have to either (a) preprocess this
// file, or (b) get access to Robocop's TestConstants class from these
// instrumentation tests.
static {
Class<? extends Activity> cl;
try {
cl = (Class<? extends Activity>) Class.forName(AppConstants.BROWSER_INTENT_CLASS_NAME);
} catch (ClassNotFoundException e) {
// Oh well.
cl = Activity.class;
}
BROWSER_INTENT_CLASS = cl;
}
public BrowserTestCase() {
super((Class<Activity>) AppConstants.BROWSER_INTENT_CLASS);
super((Class<Activity>) BROWSER_INTENT_CLASS);
}
public Context getApplicationContext() {