Back out 551fb80a2dca (bug 758392) for roboprovider bustage

This commit is contained in:
Phil Ringnalda 2012-05-25 23:18:19 -07:00
parent 5e2750b720
commit 9927ee82ec
26 changed files with 43 additions and 140 deletions

View File

@ -32,12 +32,10 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
protected Assert mAsserter;
protected Actions mActions;
protected String mBaseUrl;
private String mTestType;
private String mLogFile;
protected String mProfile;
protected static final int TEST_MOCHITEST = 0;
protected static final int TEST_TALOS = 1;
static {
try {
mLauncherActivityClass = (Class<Activity>)Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);
@ -50,9 +48,6 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
super(TARGET_PACKAGE_ID, mLauncherActivityClass);
}
// Must return either TEST_MOCHITEST or TEST_TALOS
protected abstract int getTestType();
@Override
protected void setUp() throws Exception {
// Load config file from sdcard (setup by python script)
@ -75,9 +70,12 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
mLogFile = (String)config.get("logfile");
mBaseUrl = ((String)config.get("host")).replaceAll("(/$)", "");
}
// Initialize the asserter
if (getTestType() == TEST_TALOS) {
public void setTestType(String type) {
mTestType = type;
if (mTestType.equals("talos")) {
mAsserter = new FennecTalosAssert();
} else {
mAsserter = new FennecMochitestAssert();

View File

@ -46,9 +46,6 @@ abstract class ContentProviderTest extends AndroidTestCase {
protected IsolatedContext mProviderContext;
protected String mLogFile;
protected static final int TEST_MOCHITEST = 0;
protected static final int TEST_TALOS = 1;
private class ContentProviderMockContext extends MockContext {
@Override
public Resources getResources() {
@ -191,8 +188,16 @@ abstract class ContentProviderTest extends AndroidTestCase {
mAsserter.setTestName(this.getClass().getName() + " - " + testName);
}
// Must return either TEST_MOCHITEST or TEST_TALOS
protected abstract int getTestType();
public void setTestType(String type) {
if (type.equals("talos")) {
mAsserter = new FennecTalosAssert();
} else {
mAsserter = new FennecMochitestAssert();
}
mAsserter.setLogFile(mLogFile);
mAsserter.setTestName(this.getClass().getName());
}
public void setUp() throws Exception {
throw new Exception("You should call setUp(providerClassName, authorityUriField) instead");
@ -207,16 +212,6 @@ abstract class ContentProviderTest extends AndroidTestCase {
loadRobotiumConfig();
setUpProviderClassAndAuthority(providerClassName, authorityUriField);
setUpContentProvider();
// Initialize the asserter
if (getTestType() == TEST_TALOS) {
mAsserter = new FennecTalosAssert();
} else {
mAsserter = new FennecMochitestAssert();
}
mAsserter.setLogFile(mLogFile);
mAsserter.setTestName(this.getClass().getName());
}
public void tearDown() throws Exception {

View File

@ -3,7 +3,7 @@ package @ANDROID_PACKAGE_NAME@.tests;
import @ANDROID_PACKAGE_NAME@.*;
abstract class PixelTest extends BaseTest {
class PixelTest extends BaseTest {
private static final long PAINT_CLEAR_DELAY = 500; // milliseconds
protected final PaintedSurface loadAndPaint(String url) {

View File

@ -6,12 +6,8 @@ import android.app.Activity;
import android.util.Log;
public class testAboutPage extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testAboutPage() {
setTestType("mochitest");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
// Load the about: page

View File

@ -4,12 +4,9 @@ package @ANDROID_PACKAGE_NAME@.tests;
import @ANDROID_PACKAGE_NAME@.*;
public class testAwesomebar extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testAwesomebar() {
setTestType("mochitest");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");

View File

@ -13,12 +13,8 @@ import android.app.Instrumentation;
* - Verify that the 45-degree angle was not thrown out and it dragged diagonally
*/
public class testAxisLocking extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testAxisLocking() {
setTestType("mochitest");
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());

View File

@ -30,12 +30,8 @@ public class testBookmark extends BaseTest {
"https://addons.mozilla.org/en-US/android/"
};
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testBookmark() {
setTestType("mochitest");
BOOKMARK_URL = getAbsoluteUrl(BOOKMARK_URL);
mClassLoader = getActivity().getApplicationContext().getClassLoader();

View File

@ -10,17 +10,13 @@ import android.net.Uri;
import android.provider.Browser;
public class testBookmarklets extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testBookmarklets() {
final String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
final String title = "alertBookmarklet";
final String js = "javascript:alert(12 + .34)";
boolean alerted;
setTestType("mochitest");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
// load a standard page so bookmarklets work

View File

@ -80,11 +80,6 @@ public class testBrowserProvider extends ContentProviderTest {
private String mCombinedFaviconCol;
private String mCombinedThumbnailCol;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
private void loadContractInfo() throws Exception {
mBookmarksUri = getContentUri("Bookmarks");
mHistoryUri = getContentUri("History");
@ -306,6 +301,8 @@ public class testBrowserProvider extends ContentProviderTest {
}
public void testBrowserProvider() throws Exception {
setTestType("mochitest");
loadMobileFolderId();
for (int i = 0; i < mTests.size(); i++) {

View File

@ -58,11 +58,6 @@ public class testBrowserProviderPerf extends ContentProviderTest {
private String mHistoryThumbnailCol;
private String mHistoryLastVisitedCol;
@Override
protected int getTestType() {
return TEST_TALOS;
}
private void loadFilterMethod() throws Exception {
Class browserDBClass = mClassLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
@ -229,6 +224,8 @@ public class testBrowserProviderPerf extends ContentProviderTest {
}
public void testBrowserProviderPerf() throws Exception {
setTestType("talos");
loadMobileFolderId();
addTonsOfUrls();

View File

@ -12,12 +12,8 @@ public class testCheck extends PixelTest {
}
}
@Override
protected int getTestType() {
return TEST_TALOS;
}
public void testCheck() {
setTestType("talos");
String url = getAbsoluteUrl("/startup_test/fennecmark/timecube.html");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();

View File

@ -4,12 +4,8 @@ package @ANDROID_PACKAGE_NAME@.tests;
import @ANDROID_PACKAGE_NAME@.*;
public class testCheck2 extends PixelTest {
@Override
protected int getTestType() {
return TEST_TALOS;
}
public void testCheck2() {
setTestType("talos");
String url = getAbsoluteUrl("/startup_test/fennecmark/cnn/cnn.com/index.html");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();

View File

@ -5,12 +5,8 @@ import @ANDROID_PACKAGE_NAME@.*;
import java.lang.reflect.Method;
public class testCheck3 extends PixelTest {
@Override
protected int getTestType() {
return TEST_TALOS;
}
public void testCheck3() {
setTestType("talos");
String url = getAbsoluteUrl("/startup_test/fennecmark/cnn/cnn.com/index.html");
// Disable Fennec's low-res screenshot for the duration of this test;
// this distinguishes this test from testCheck2, which is otherwise

View File

@ -11,12 +11,8 @@ import android.app.Instrumentation;
* - Fling the page downwards so we get back to the top and verify.
*/
public class testFlingCorrectness extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testFlingCorrectness() {
setTestType("mochitest");
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());

View File

@ -21,13 +21,8 @@ import java.util.ArrayList;
*/
public class testFormHistory extends BaseTest {
private static final String DB_NAME = "formhistory.sqlite";
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testFormHistory() {
setTestType("mochitest");
Context context = (Context)getActivity();
ContentResolver cr = context.getContentResolver();
ContentValues[] cvs = new ContentValues[1];

View File

@ -19,12 +19,8 @@ import java.io.StringWriter;
* as loading some invalid jar urls.
*/
public class testJarReader extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testJarReader() {
setTestType("mochitest");
try {
ClassLoader classLoader = getActivity().getClassLoader();
Class gjrClass = classLoader.loadClass("org.mozilla.gecko.GeckoJarReader");

View File

@ -10,12 +10,8 @@ import @ANDROID_PACKAGE_NAME@.*;
* - verifies the displayed url is correct
*/
public class testLoad extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testLoad() {
setTestType("mochitest");
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();

View File

@ -5,12 +5,8 @@ import @ANDROID_PACKAGE_NAME@.*;
import android.app.Activity;
public class testNewTab extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testNewTab() {
setTestType("mochitest");
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");
String tabCountText = null;

View File

@ -11,12 +11,8 @@ import android.app.Instrumentation;
* - Drag page rightwards by 100 pixels into overscroll, verify it snaps back.
*/
public class testOverscroll extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testOverscroll() {
setTestType("mochitest");
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());

View File

@ -9,12 +9,9 @@ import @ANDROID_PACKAGE_NAME@.*;
* that fennec draws at.
*/
public class testPan extends PixelTest {
@Override
protected int getTestType() {
return TEST_TALOS;
}
public void testPan() {
setTestType("talos");
String url = getAbsoluteUrl("/startup_test/fennecmark/wikipedia.html");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();

View File

@ -11,12 +11,8 @@ import android.app.Instrumentation;
* - drags page leftwards by 100 pixels and verifies it draws
*/
public class testPanCorrectness extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testPanCorrectness() {
setTestType("mochitest");
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());

View File

@ -16,12 +16,8 @@ import org.json.JSONException;
import org.json.JSONObject;
public class testPasswordEncrypt extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testPasswordEncrypt() {
setTestType("mochitest");
Context context = (Context)getActivity();
ContentResolver cr = context.getContentResolver();
mAsserter.isnot(cr, null, "Found a content resolver");

View File

@ -19,13 +19,8 @@ import java.io.File;
*/
public class testPasswordProvider extends BaseTest {
private static final String DB_NAME = "signons.sqlite";
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testPasswordProvider() {
setTestType("mochitest");
Context context = (Context)getActivity();
ContentResolver cr = context.getContentResolver();
ContentValues[] cvs = new ContentValues[1];

View File

@ -10,12 +10,8 @@ public class testPermissions extends PixelTest {
private PaintedSurface mPaintedSurface;
private Actions.RepeatedEventExpecter mPaintExpecter;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testPermissions() {
setTestType("mochitest");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
geolocationTest();

View File

@ -6,12 +6,8 @@ import android.app.Activity;
import android.util.DisplayMetrics;
public class testWebContentContextMenu extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testWebContentContextMenu() {
setTestType("mochitest");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
DisplayMetrics dm = new DisplayMetrics();

View File

@ -5,12 +5,8 @@ import @ANDROID_PACKAGE_NAME@.*;
import android.app.Instrumentation;
public class test_bug720538 extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void test_bug720538() {
setTestType("mochitest");
String url = getAbsoluteUrl("/robocop/test_bug720538.html");
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();