mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1067060: Remove redundant typecasts, add final and some override annotations. r=mcomella
This commit is contained in:
parent
0809969f77
commit
c0119e5330
@ -33,11 +33,11 @@ import com.jayway.android.robotium.solo.Solo;
|
||||
public class FennecNativeDriver implements Driver {
|
||||
private static final int FRAME_TIME_THRESHOLD = 25; // allow 25ms per frame (40fps)
|
||||
|
||||
private Activity mActivity;
|
||||
private Solo mSolo;
|
||||
private String mRootPath;
|
||||
private final Activity mActivity;
|
||||
private final Solo mSolo;
|
||||
private final String mRootPath;
|
||||
|
||||
private static String mLogFile = null;
|
||||
private static String mLogFile;
|
||||
private static LogLevel mLogLevel = LogLevel.INFO;
|
||||
|
||||
public enum LogLevel {
|
||||
@ -46,7 +46,7 @@ public class FennecNativeDriver implements Driver {
|
||||
WARN(3),
|
||||
ERROR(4);
|
||||
|
||||
private int mValue;
|
||||
private final int mValue;
|
||||
LogLevel(int value) {
|
||||
mValue = value;
|
||||
}
|
||||
@ -86,6 +86,7 @@ public class FennecNativeDriver implements Driver {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGeckoTop() {
|
||||
if (!mGeckoInfo) {
|
||||
getGeckoInfo();
|
||||
@ -93,6 +94,7 @@ public class FennecNativeDriver implements Driver {
|
||||
return mGeckoTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGeckoLeft() {
|
||||
if (!mGeckoInfo) {
|
||||
getGeckoInfo();
|
||||
@ -100,6 +102,7 @@ public class FennecNativeDriver implements Driver {
|
||||
return mGeckoLeft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGeckoHeight() {
|
||||
if (!mGeckoInfo) {
|
||||
getGeckoInfo();
|
||||
@ -107,6 +110,7 @@ public class FennecNativeDriver implements Driver {
|
||||
return mGeckoHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGeckoWidth() {
|
||||
if (!mGeckoInfo) {
|
||||
getGeckoInfo();
|
||||
@ -118,14 +122,17 @@ public class FennecNativeDriver implements Driver {
|
||||
*
|
||||
* @return An Element representing the view, or null if the view is not found.
|
||||
*/
|
||||
@Override
|
||||
public Element findElement(Activity activity, int id) {
|
||||
return new FennecNativeElement(id, activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startFrameRecording() {
|
||||
PanningPerfAPI.startFrameTimeRecording();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stopFrameRecording() {
|
||||
final List<Long> frames = PanningPerfAPI.stopFrameTimeRecording();
|
||||
int badness = 0;
|
||||
@ -144,10 +151,12 @@ public class FennecNativeDriver implements Driver {
|
||||
return badness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startCheckerboardRecording() {
|
||||
PanningPerfAPI.startCheckerboardRecording();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float stopCheckerboardRecording() {
|
||||
final List<Float> checkerboard = PanningPerfAPI.stopCheckerboardRecording();
|
||||
float total = 0;
|
||||
@ -169,6 +178,7 @@ public class FennecNativeDriver implements Driver {
|
||||
return layerView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaintedSurface getPaintedSurface() {
|
||||
final LayerView view = getSurfaceView();
|
||||
if (view == null) {
|
||||
@ -223,16 +233,20 @@ public class FennecNativeDriver implements Driver {
|
||||
public int mScrollHeight=0;
|
||||
public int mPageHeight=10;
|
||||
|
||||
@Override
|
||||
public int getScrollHeight() {
|
||||
return mScrollHeight;
|
||||
}
|
||||
@Override
|
||||
public int getPageHeight() {
|
||||
return mPageHeight;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupScrollHandling() {
|
||||
EventDispatcher.getInstance().registerGeckoThreadListener(new GeckoEventListener() {
|
||||
@Override
|
||||
|
@ -13,25 +13,28 @@ import android.widget.TextView;
|
||||
|
||||
public class FennecNativeElement implements Element {
|
||||
private final Activity mActivity;
|
||||
private Integer mId;
|
||||
private final Integer mId;
|
||||
|
||||
public FennecNativeElement(Integer id, Activity activity) {
|
||||
mId = id;
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
private boolean mClickSuccess;
|
||||
|
||||
@Override
|
||||
public boolean click() {
|
||||
mClickSuccess = false;
|
||||
RobocopUtils.runOnUiThreadSync(mActivity,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
View view = (View)mActivity.findViewById(mId);
|
||||
View view = mActivity.findViewById(mId);
|
||||
if (view != null) {
|
||||
if (view.performClick()) {
|
||||
mClickSuccess = true;
|
||||
@ -50,10 +53,12 @@ public class FennecNativeElement implements Element {
|
||||
|
||||
private Object mText;
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
mText = null;
|
||||
RobocopUtils.runOnUiThreadSync(mActivity,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
View v = mActivity.findViewById(mId);
|
||||
if (v instanceof EditText) {
|
||||
@ -92,12 +97,14 @@ public class FennecNativeElement implements Element {
|
||||
|
||||
private boolean mDisplayed;
|
||||
|
||||
@Override
|
||||
public boolean isDisplayed() {
|
||||
mDisplayed = false;
|
||||
RobocopUtils.runOnUiThreadSync(mActivity,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
View view = (View)mActivity.findViewById(mId);
|
||||
View view = mActivity.findViewById(mId);
|
||||
if (view != null) {
|
||||
mDisplayed = true;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ abstract class AboutHomeTest extends PixelTest {
|
||||
boolean correctTab = waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
|
||||
ViewPager pager = mSolo.getView(ViewPager.class, 0);
|
||||
return (pager.getCurrentItem() == tabIndex);
|
||||
}
|
||||
}, MAX_WAIT_MS);
|
||||
@ -237,7 +237,7 @@ abstract class AboutHomeTest extends PixelTest {
|
||||
*/
|
||||
protected void openAboutHomeTab(AboutHomeTabs tab) {
|
||||
focusUrlBar();
|
||||
ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
|
||||
ViewPager pager = mSolo.getView(ViewPager.class, 0);
|
||||
final int currentTabIndex = pager.getCurrentItem();
|
||||
int tabOffset;
|
||||
|
||||
|
@ -96,7 +96,7 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
|
||||
}
|
||||
String configFile = FennecNativeDriver.getFile(mRootPath + "/robotium.config");
|
||||
mConfig = FennecNativeDriver.convertTextToTable(configFile);
|
||||
mLogFile = (String) mConfig.get("logfile");
|
||||
mLogFile = mConfig.get("logfile");
|
||||
|
||||
// Initialize the asserter.
|
||||
if (getTestType() == Type.TALOS) {
|
||||
@ -105,6 +105,6 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
|
||||
mAsserter = new FennecMochitestAssert();
|
||||
}
|
||||
mAsserter.setLogFile(mLogFile);
|
||||
mAsserter.setTestName(this.getClass().getName());
|
||||
mAsserter.setTestName(getClass().getName());
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ abstract class BaseTest extends BaseRobocopTest {
|
||||
protected StringHelper mStringHelper;
|
||||
protected int mScreenMidWidth;
|
||||
protected int mScreenMidHeight;
|
||||
private HashSet<Integer> mKnownTabIDs = new HashSet<Integer>();
|
||||
private final HashSet<Integer> mKnownTabIDs = new HashSet<Integer>();
|
||||
|
||||
protected void blockForGeckoReady() {
|
||||
try {
|
||||
@ -100,12 +100,12 @@ abstract class BaseTest extends BaseRobocopTest {
|
||||
super.setUp();
|
||||
|
||||
// Create the intent to be used with all the important arguments.
|
||||
mBaseUrl = ((String) mConfig.get("host")).replaceAll("(/$)", "");
|
||||
mRawBaseUrl = ((String) mConfig.get("rawhost")).replaceAll("(/$)", "");
|
||||
mBaseUrl = mConfig.get("host").replaceAll("(/$)", "");
|
||||
mRawBaseUrl = mConfig.get("rawhost").replaceAll("(/$)", "");
|
||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
||||
mProfile = (String) mConfig.get("profile");
|
||||
mProfile = mConfig.get("profile");
|
||||
i.putExtra("args", "-no-remote -profile " + mProfile);
|
||||
String envString = (String) mConfig.get("envvars");
|
||||
String envString = mConfig.get("envvars");
|
||||
if (envString != "") {
|
||||
String[] envStrings = envString.split(",");
|
||||
for (int iter = 0; iter < envStrings.length; iter++) {
|
||||
@ -275,8 +275,8 @@ abstract class BaseTest extends BaseRobocopTest {
|
||||
}
|
||||
|
||||
class VerifyTextViewText implements Condition {
|
||||
private TextView mTextView;
|
||||
private String mExpected;
|
||||
private final TextView mTextView;
|
||||
private final String mExpected;
|
||||
public VerifyTextViewText(TextView textView, String expected) {
|
||||
mTextView = textView;
|
||||
mExpected = expected;
|
||||
@ -304,7 +304,7 @@ abstract class BaseTest extends BaseRobocopTest {
|
||||
boolean result = mSolo.waitForCondition(condition, timeout);
|
||||
if (!result) {
|
||||
// Log timeout failure for diagnostic purposes only; a failed wait may
|
||||
// be normal and does not necessarily warrant a test asssertion/failure.
|
||||
// be normal and does not necessarily warrant a test assertion/failure.
|
||||
mAsserter.dumpLog("waitForCondition timeout after " + timeout + " ms.");
|
||||
}
|
||||
return result;
|
||||
@ -757,8 +757,8 @@ abstract class BaseTest extends BaseRobocopTest {
|
||||
}
|
||||
|
||||
class Navigation {
|
||||
private String devType;
|
||||
private String osVersion;
|
||||
private final String devType;
|
||||
private final String osVersion;
|
||||
|
||||
public Navigation(Device mDevice) {
|
||||
devType = mDevice.type;
|
||||
@ -862,8 +862,8 @@ abstract class BaseTest extends BaseRobocopTest {
|
||||
*/
|
||||
private class DescriptionCondition<T extends View> implements Condition {
|
||||
public T mView;
|
||||
private String mDescr;
|
||||
private Class<T> mCls;
|
||||
private final String mDescr;
|
||||
private final Class<T> mCls;
|
||||
|
||||
public DescriptionCondition(Class<T> cls, String descr) {
|
||||
mDescr = descr;
|
||||
|
@ -68,8 +68,8 @@ abstract class UITest extends BaseRobocopTest
|
||||
mDriver = new FennecNativeDriver(activity, mSolo, mRootPath);
|
||||
mActions = new FennecNativeActions(activity, mSolo, getInstrumentation(), mAsserter);
|
||||
|
||||
mBaseHostnameUrl = ((String) mConfig.get("host")).replaceAll("(/$)", "");
|
||||
mBaseIpUrl = ((String) mConfig.get("rawhost")).replaceAll("(/$)", "");
|
||||
mBaseHostnameUrl = mConfig.get("host").replaceAll("(/$)", "");
|
||||
mBaseIpUrl = mConfig.get("rawhost").replaceAll("(/$)", "");
|
||||
|
||||
// Helpers depend on components so initialize them first.
|
||||
initComponents();
|
||||
@ -158,6 +158,7 @@ abstract class UITest extends BaseRobocopTest
|
||||
* Returns the test type. By default this returns MOCHITEST, but tests can override this
|
||||
* method in order to change the type of the test.
|
||||
*/
|
||||
@Override
|
||||
protected Type getTestType() {
|
||||
return Type.MOCHITEST;
|
||||
}
|
||||
@ -179,10 +180,10 @@ abstract class UITest extends BaseRobocopTest
|
||||
private static Intent createActivityIntent(final Map<String, String> config) {
|
||||
final Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
|
||||
final String profile = (String) config.get("profile");
|
||||
final String profile = config.get("profile");
|
||||
intent.putExtra("args", "-no-remote -profile " + profile);
|
||||
|
||||
final String envString = (String) config.get("envvars");
|
||||
final String envString = config.get("envvars");
|
||||
if (!TextUtils.isEmpty(envString)) {
|
||||
final String[] envStrings = envString.split(",");
|
||||
|
||||
|
@ -34,25 +34,25 @@ public class testJavascriptBridge extends UITest {
|
||||
GeckoHelper.blockForReady();
|
||||
NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_JS_HARNESS_URL +
|
||||
"?path=" + TEST_JS);
|
||||
js.syncCall("check_js_int_arg", (int) 1);
|
||||
js.syncCall("check_js_int_arg", 1);
|
||||
}
|
||||
|
||||
public void checkJavaIntArg(final int int2) {
|
||||
// Async call from JS
|
||||
fAssertEquals("Integer argument matches", 2, int2);
|
||||
js.syncCall("check_js_double_arg", (double) 3.0);
|
||||
js.syncCall("check_js_double_arg", 3.0D);
|
||||
}
|
||||
|
||||
public void checkJavaDoubleArg(final double double4) {
|
||||
// Async call from JS
|
||||
fAssertEquals("Double argument matches", 4.0, double4);
|
||||
js.syncCall("check_js_boolean_arg", (boolean) false);
|
||||
js.syncCall("check_js_boolean_arg", false);
|
||||
}
|
||||
|
||||
public void checkJavaBooleanArg(final boolean booltrue) {
|
||||
// Async call from JS
|
||||
fAssertEquals("Boolean argument matches", true, booltrue);
|
||||
js.syncCall("check_js_string_arg", (String) "foo");
|
||||
js.syncCall("check_js_string_arg", "foo");
|
||||
}
|
||||
|
||||
public void checkJavaStringArg(final String stringbar) throws JSONException {
|
||||
|
Loading…
Reference in New Issue
Block a user