Bug 758392 - Create abstract getTestType() method in BaseTest. r=gbrown f=jmaher

This commit is contained in:
Brian Nicholson 2012-05-25 17:26:04 -07:00
Родитель 12313fb4bf
Коммит c0b5df4e97
26 изменённых файлов: 140 добавлений и 43 удалений

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

@ -32,10 +32,12 @@ 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);
@ -48,6 +50,9 @@ 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)
@ -70,12 +75,9 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
mLogFile = (String)config.get("logfile");
mBaseUrl = ((String)config.get("host")).replaceAll("(/$)", "");
}
public void setTestType(String type) {
mTestType = type;
if (mTestType.equals("talos")) {
// Initialize the asserter
if (getTestType() == TEST_TALOS) {
mAsserter = new FennecTalosAssert();
} else {
mAsserter = new FennecMochitestAssert();

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

@ -46,6 +46,9 @@ 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() {
@ -188,16 +191,8 @@ abstract class ContentProviderTest extends AndroidTestCase {
mAsserter.setTestName(this.getClass().getName() + " - " + testName);
}
public void setTestType(String type) {
if (type.equals("talos")) {
mAsserter = new FennecTalosAssert();
} else {
mAsserter = new FennecMochitestAssert();
}
mAsserter.setLogFile(mLogFile);
mAsserter.setTestName(this.getClass().getName());
}
// Must return either TEST_MOCHITEST or TEST_TALOS
protected abstract int getTestType();
public void setUp() throws Exception {
throw new Exception("You should call setUp(providerClassName, authorityUriField) instead");
@ -212,6 +207,16 @@ 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 {

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

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

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

@ -6,8 +6,12 @@ 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

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

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

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

@ -13,8 +13,12 @@ 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());

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

@ -30,8 +30,12 @@ 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();

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

@ -10,13 +10,17 @@ 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

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

@ -80,6 +80,11 @@ 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");
@ -301,8 +306,6 @@ public class testBrowserProvider extends ContentProviderTest {
}
public void testBrowserProvider() throws Exception {
setTestType("mochitest");
loadMobileFolderId();
for (int i = 0; i < mTests.size(); i++) {

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

@ -58,6 +58,11 @@ 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");
@ -224,8 +229,6 @@ public class testBrowserProviderPerf extends ContentProviderTest {
}
public void testBrowserProviderPerf() throws Exception {
setTestType("talos");
loadMobileFolderId();
addTonsOfUrls();

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

@ -12,8 +12,12 @@ 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();

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

@ -4,8 +4,12 @@ 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();

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

@ -5,8 +5,12 @@ 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

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

@ -11,8 +11,12 @@ 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());

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

@ -21,8 +21,13 @@ 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];

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

@ -19,8 +19,12 @@ 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");

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

@ -10,8 +10,12 @@ 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();

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

@ -5,8 +5,12 @@ 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;

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

@ -11,8 +11,12 @@ 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());

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

@ -9,9 +9,12 @@ 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();

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

@ -11,8 +11,12 @@ 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());

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

@ -16,8 +16,12 @@ 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");

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

@ -19,8 +19,13 @@ 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];

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

@ -10,8 +10,12 @@ 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();

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

@ -6,8 +6,12 @@ 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();

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

@ -5,8 +5,12 @@ 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();