Bug 990116 - Part 0: Move UITest.Type to BaseRobocopTest. r=mcomella

This commit is contained in:
Nick Alexander 2014-04-01 22:00:45 -07:00
Родитель b5e3c19e98
Коммит 041d930c2a
57 изменённых файлов: 29 добавлений и 273 удалений

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

@ -16,8 +16,10 @@ import android.app.Activity;
import android.test.ActivityInstrumentationTestCase2;
public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<Activity> {
public static final int TEST_MOCHITEST = 0;
public static final int TEST_TALOS = 1;
public enum Type {
MOCHITEST,
TALOS
}
protected static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";
protected Assert mAsserter;
@ -35,7 +37,15 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
super(targetPackageId, activityClass);
}
protected abstract int getTestType();
/**
* Returns the test type: mochitest or talos.
* <p>
* By default tests are mochitests, but a test can override this method in
* order to change its type. Most Robocop tests are mochitests.
*/
protected Type getTestType() {
return Type.MOCHITEST;
}
@Override
protected void setUp() throws Exception {
@ -46,7 +56,7 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
mLogFile = (String) mConfig.get("logfile");
// Initialize the asserter.
if (getTestType() == TEST_TALOS) {
if (getTestType() == Type.TALOS) {
mAsserter = new FennecTalosAssert();
} else {
mAsserter = new FennecMochitestAssert();

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

@ -19,11 +19,6 @@ public class JavascriptTest extends BaseTest {
this.javascriptUrl = javascriptUrl;
}
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testJavascript() throws Exception {
blockForGeckoReady();

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

@ -14,11 +14,6 @@ import org.json.JSONObject;
public abstract class SessionTest extends BaseTest {
protected Navigation mNavigation;
@Override
final protected int getTestType() {
return TEST_MOCHITEST;
}
@Override
public void setUp() throws Exception {
super.setUp();

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

@ -12,6 +12,7 @@ import org.mozilla.gecko.FennecMochitestAssert;
import org.mozilla.gecko.FennecNativeActions;
import org.mozilla.gecko.FennecNativeDriver;
import org.mozilla.gecko.FennecTalosAssert;
import org.mozilla.gecko.tests.BaseRobocopTest.Type;
import org.mozilla.gecko.tests.components.*;
import org.mozilla.gecko.tests.helpers.HelperInitializer;
@ -36,11 +37,6 @@ import java.util.HashMap;
abstract class UITest extends ActivityInstrumentationTestCase2<Activity>
implements UITestContext {
protected enum Type {
MOCHITEST,
TALOS
}
private static final String LAUNCHER_ACTIVITY = TestConstants.ANDROID_PACKAGE_NAME + ".App";
private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";

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

@ -7,11 +7,6 @@ import org.mozilla.gecko.*;
* - check that about: loads from Settings/About...
*/
public class testAboutPage extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
private void ensureTitleMatches(final String regex) {
Element urlBarTitle = mDriver.findElement(getActivity(), R.id.url_bar_title);
mAsserter.isnot(urlBarTitle, null, "Got the URL bar title");

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

@ -21,11 +21,6 @@ public class testAddSearchEngine extends AboutHomeTest {
private final String SEARCH_TEXT = "Firefox for Android";
private final String ADD_SEARCHENGINE_OPTION_TEXT = "Add Search Engine";
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testAddSearchEngine() {
String blankPageURL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
String searchEngineURL = getAbsoluteUrl(StringHelper.ROBOCOP_SEARCH_URL);

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

@ -7,11 +7,6 @@ import org.json.JSONArray;
import org.json.JSONObject;
public class testAddonManager extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
/* This test will check the behavior of the Addons Manager:
First the test will open the Addons Manager from the Menu and then close it
Then the test will open the Addons Manager by visiting about:addons

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

@ -13,11 +13,6 @@ import org.mozilla.gecko.*;
* - verifies it rendered properly
*/
public class testAdobeFlash extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testLoad() {
// This test only works on ICS and higher
if (Build.VERSION.SDK_INT < 15) {

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

@ -1,11 +1,6 @@
package org.mozilla.gecko.tests;
public class testAwesomebar extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testAwesomebar() {
blockForGeckoReady();

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

@ -11,11 +11,6 @@ import org.mozilla.gecko.*;
* - 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() {
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");

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

@ -12,11 +12,6 @@ public class testBookmark extends AboutHomeTest {
private static String BOOKMARK_URL;
private static int WAIT_FOR_BOOKMARKED_TIMEOUT = 10000;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testBookmark() {
BOOKMARK_URL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
runAboutHomeTest();

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

@ -21,11 +21,6 @@ import java.util.Arrays;
public class testBookmarkFolders extends AboutHomeTest {
private static String DESKTOP_BOOKMARK_URL;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testBookmarkFolders() {
DESKTOP_BOOKMARK_URL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL);

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

@ -3,12 +3,6 @@ package org.mozilla.gecko.tests;
import org.mozilla.gecko.*;
public class testBookmarkKeyword extends AboutHomeTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testBookmarkKeyword() {
blockForGeckoReady();

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

@ -7,11 +7,6 @@ import android.widget.ListView;
public class testBookmarklets extends AboutHomeTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testBookmarklets() {
final String url = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
final String title = "alertBookmarklet";

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

@ -3,11 +3,6 @@ package org.mozilla.gecko.tests;
import org.mozilla.gecko.*;
public class testBookmarksPanel extends AboutHomeTest {
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testBookmarksPanel() {
final String BOOKMARK_URL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);

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

@ -24,11 +24,6 @@ import org.mozilla.gecko.db.BrowserContract;
public class testBrowserProvider extends ContentProviderTest {
private long mMobileFolderId;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
private void loadMobileFolderId() throws Exception {
Cursor c = null;
try {

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

@ -76,8 +76,8 @@ public class testBrowserProviderPerf extends BaseRobocopTest {
}
@Override
protected int getTestType() {
return TEST_TALOS;
protected Type getTestType() {
return Type.TALOS;
}
private void loadMobileFolderId() throws Exception {

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

@ -18,11 +18,6 @@ import java.util.HashMap;
* visibility is correct.
*/
public class testBrowserSearchVisibility extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testSearchSuggestions() {
blockForGeckoReady();

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

@ -1,5 +1,7 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.tests.BaseRobocopTest.Type;
public class testCheck extends PixelTest {
private void pause(int length) {
try {
@ -10,8 +12,8 @@ public class testCheck extends PixelTest {
}
@Override
protected int getTestType() {
return TEST_TALOS;
protected Type getTestType() {
return Type.TALOS;
}
public void testCheck() {

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

@ -1,9 +1,11 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.tests.BaseRobocopTest.Type;
public class testCheck2 extends PixelTest {
@Override
protected int getTestType() {
return TEST_TALOS;
protected Type getTestType() {
return Type.TALOS;
}
public void testCheck2() {

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

@ -15,11 +15,6 @@ import java.util.ArrayList;
public class testClearPrivateData extends PixelTest {
private final int TEST_WAIT_MS = 10000;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testClearPrivateData() {
blockForGeckoReady();
clearHistory();

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

@ -34,11 +34,6 @@ public class testDistribution extends ContentProviderTest {
private Activity mActivity;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
/**
* This is a hack.
*

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

@ -17,12 +17,6 @@ import org.json.JSONObject;
* Password Manager doorhangers - Remember and Not Now options dismiss the doorhanger
*/
public class testDoorHanger extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testDoorHanger() {
String GEO_URL = getAbsoluteUrl("/robocop/robocop_geolocation.html");
String BLANK_URL = getAbsoluteUrl("/robocop/robocop_blank_01.html");

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

@ -9,11 +9,6 @@ public class testFindInPage extends PixelTest {
protected Element next, close;
int height,width;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testFindInPage() {
blockForGeckoReady();
String url = getAbsoluteUrl("/robocop/robocop_text_page.html");

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

@ -9,11 +9,6 @@ import org.mozilla.gecko.*;
* - 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() {
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");

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

@ -18,11 +18,6 @@ import java.io.File;
public class testFormHistory extends BaseTest {
private static final String DB_NAME = "formhistory.sqlite";
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testFormHistory() {
Context context = (Context)getActivity();
ContentResolver cr = context.getContentResolver();

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

@ -7,11 +7,6 @@ import android.hardware.Camera;
import android.os.Build;
public class testGetUserMedia extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testGetUserMedia() {
String GUM_URL = getAbsoluteUrl("/robocop/robocop_getusermedia.html");

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

@ -10,11 +10,6 @@ import android.view.ViewGroup;
public class testHistory extends AboutHomeTest {
private View mFirstChild;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testHistory() {
blockForGeckoReady();

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

@ -19,11 +19,6 @@ public class testHomeListsProvider extends ContentProviderTest {
public static final String URL = null;
}
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
@SuppressWarnings("unused")
private void ensureEmptyDatabase() throws Exception {
// Delete all the list entries.

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

@ -23,11 +23,6 @@ public class testImportFromAndroid extends AboutHomeTest {
ArrayList<String> androidData = new ArrayList<String>();
ArrayList<String> firefoxHistory = new ArrayList<String>();
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testImportFromAndroid() {
ArrayList<String> firefoxBookmarks = new ArrayList<String>();
ArrayList<String> oldFirefoxHistory = new ArrayList<String>();

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

@ -105,11 +105,6 @@ public final class testInputUrlBar extends BaseTest {
mAsserter.ok("yz".equals(yz), "Is the URL bar text \"yz\"?", yz);
}
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
private void startEditingMode() {
focusUrlBar();

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

@ -10,11 +10,6 @@ import org.mozilla.gecko.util.GeckoJarReader;
* as loading some invalid jar urls.
*/
public class testJarReader extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testJarReader() {
String appPath = getActivity().getApplication().getPackageResourcePath();
mAsserter.isnot(appPath, null, "getPackageResourcePath is non-null");

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

@ -10,11 +10,6 @@ public class testLinkContextMenu extends ContentContextMenuTest {
private static final String LINK_PAGE_TITLE = "Big Link";
private static final String linkMenuItems [] = { "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testLinkContextMenu() {
blockForGeckoReady();

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

@ -7,11 +7,6 @@ package org.mozilla.gecko.tests;
* - verifies the displayed url is correct
*/
public class testLoad extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testLoad() {
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");

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

@ -9,11 +9,6 @@ public class testMailToContextMenu extends ContentContextMenuTest {
private static final String MAILTO_PAGE_TITLE = "Big Mailto";
private static final String mailtoMenuItems [] = {"Copy Email Address", "Share Email Address"};
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testMailToContextMenu() {
blockForGeckoReady();

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

@ -7,11 +7,6 @@ then testing it on a login page and finally disabling the password */
public class testMasterPassword extends PixelTest {
Device dev;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testMasterPassword() {
blockForGeckoReady();

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

@ -12,11 +12,6 @@ public class testNewTab extends BaseTest {
private Element closeTab = null;
private int tabCountInt = 0;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testNewTab() {
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");

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

@ -9,11 +9,6 @@ import org.mozilla.gecko.*;
* - 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() {
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");

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

@ -1,5 +1,7 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.tests.BaseRobocopTest.Type;
/**
* A panning performance test.
* Drags the page a bunch of times and measures the frames per second
@ -7,8 +9,8 @@ package org.mozilla.gecko.tests;
*/
public class testPan extends PixelTest {
@Override
protected int getTestType() {
return TEST_TALOS;
protected Type getTestType() {
return Type.TALOS;
}
public void testPan() {

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

@ -9,11 +9,6 @@ import org.mozilla.gecko.*;
* - 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() {
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");

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

@ -14,11 +14,6 @@ import org.json.JSONArray;
import org.json.JSONObject;
public class testPasswordEncrypt extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testPasswordEncrypt() {
Context context = (Context)getActivity();
ContentResolver cr = context.getContentResolver();

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

@ -19,11 +19,6 @@ 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() {
Context context = (Context)getActivity();
ContentResolver cr = context.getContentResolver();

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

@ -6,11 +6,6 @@ import android.widget.CheckBox;
import java.util.ArrayList;
public class testPermissions extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testPermissions() {
blockForGeckoReady();

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

@ -13,11 +13,6 @@ public class testPictureLinkContextMenu extends ContentContextMenuTest {
private static final String linkMenuItems [] = { "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
private static final String linkTitle = "^Link$";
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testPictureLinkContextMenu() {
blockForGeckoReady();

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

@ -20,11 +20,6 @@ public class testPrefsObserver extends BaseTest {
private Actions.RepeatedEventExpecter mExpecter;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void setPref(boolean value) throws JSONException {
mAsserter.dumpLog("Setting pref");

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

@ -15,11 +15,6 @@ import org.json.JSONObject;
*/
public class testPrivateBrowsing extends ContentContextMenuTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testPrivateBrowsing() {
String bigLinkUrl = getAbsoluteUrl(StringHelper.ROBOCOP_BIG_LINK_URL);
String blank1Url = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);

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

@ -14,11 +14,6 @@ import android.util.Log;
import org.json.JSONObject;
public class testPromptGridInput extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
protected int index = 1;
public void testPromptGridInput() {
blockForGeckoReady();

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

@ -22,10 +22,6 @@ public class testReaderMode extends AboutHomeTest {
static final int EVENT_CLEAR_DELAY_MS = 3000;
static final int READER_ICON_MAX_WAIT_MS = 15000;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testReaderMode() {
blockForGeckoReady();

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

@ -58,11 +58,6 @@ public class testReadingListProvider extends ContentProviderTest {
}
};
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
@Override
public void setUp() throws Exception {
super.setUp(sProviderFactory, BrowserContract.READING_LIST_AUTHORITY, DB_NAME);

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

@ -25,11 +25,6 @@ public class testSearchSuggestions extends BaseTest {
private static final String TEST_QUERY = "foo barz";
private static final String SUGGESTION_TEMPLATE = "/robocop/robocop_suggestions.sjs?query=__searchTerms__";
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testSearchSuggestions() {
blockForGeckoReady();

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

@ -97,11 +97,6 @@ public class testSettingsMenuItems extends PixelTest {
settingsMap.put(PATH_MOZILLA, new ArrayList<String[]>(Arrays.asList(OPTIONS_MOZILLA)));
}
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testSettingsMenuItems() {
blockForGeckoReady();
mMidWidth = mDriver.getGeckoWidth()/2;

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

@ -27,11 +27,6 @@ public class testShareLink extends AboutHomeTest {
String url;
String urlTitle = "Big Link";
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testShareLink() {
url = getAbsoluteUrl("/robocop/robocop_big_link.html");
ArrayList<String> shareOptions;

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

@ -9,11 +9,6 @@ public class testSystemPages extends PixelTest {
final int mExpectedTabCount = 1;
private static final int AFTER_BACK_SLEEP_MS = 500;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testSystemPages() {
blockForGeckoReady();

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

@ -14,11 +14,6 @@ import android.graphics.Color;
* - finally, test that BrowserDB.removeThumbnails drops the thumbnails
*/
public class testThumbnails extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testThumbnails() {
final String site1Url = getAbsoluteUrl("/robocop/robocop_404.sjs?type=changeColor");
final String site2Url = getAbsoluteUrl("/robocop/robocop_404.sjs?type=do404");

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

@ -8,11 +8,6 @@ import java.util.ArrayList;
*/
public class testTitleBar extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testTitleBar() {
blockForGeckoReady();
checkOption();

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

@ -15,11 +15,6 @@ public class testVkbOverlap extends PixelTest {
private static final int LESS_THAN_CURSOR_BLINK_PERIOD = CURSOR_BLINK_PERIOD - 50;
private static final int PAGE_SETTLE_TIME = 5000;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testVkbOverlap() {
blockForGeckoReady();
testSetup("initial-scale=1.0, user-scalable=no", false);

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

@ -3,11 +3,6 @@ package org.mozilla.gecko.tests;
import org.mozilla.gecko.*;
public class test_bug720538 extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void test_bug720538() {
String url = getAbsoluteUrl("/robocop/test_bug720538.html");