diff options
author | yfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-15 19:24:17 +0000 |
---|---|---|
committer | yfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-15 19:24:17 +0000 |
commit | f13187d0c386be484d2e84abb3d0d31e157cd83d (patch) | |
tree | 20ca8d4e740ccd5da0f4e8674c72d00c0b504a26 | |
parent | 9aec60629ceb5924528606a851b157d0cc9f0e76 (diff) | |
download | chromium_src-f13187d0c386be484d2e84abb3d0d31e157cd83d.zip chromium_src-f13187d0c386be484d2e84abb3d0d31e157cd83d.tar.gz chromium_src-f13187d0c386be484d2e84abb3d0d31e157cd83d.tar.bz2 |
Fix several findbugs issues
This addresses the following classes of findbugs issues:
- ST, MS, SS, DLS, SIC
Also sprinkled in are eclipse auto-corrects of final, @Override and
import fixes.
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/12545043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188447 0039d316-1c4b-4281-b951-d872f2087c98
17 files changed, 68 insertions, 97 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java index 3c11ae6..03f8d20 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java @@ -8,8 +8,6 @@ import android.app.Instrumentation; import android.content.Context; import android.test.ActivityInstrumentationTestCase2; -import junit.framework.Assert; - import org.chromium.android_webview.AwBrowserContext; import org.chromium.android_webview.AwBrowserProcess; import org.chromium.android_webview.AwContents; @@ -18,28 +16,22 @@ import org.chromium.android_webview.AwSettings; import org.chromium.android_webview.test.util.JSUtils; import org.chromium.base.test.util.InMemorySharedPreferences; import org.chromium.content.browser.ContentSettings; -import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.LoadUrlParams; import org.chromium.content.browser.test.util.CallbackHelper; import org.chromium.content.browser.test.util.Criteria; import org.chromium.content.browser.test.util.CriteriaHelper; -import org.chromium.content.browser.test.util.TestCallbackHelperContainer; -import org.chromium.content.common.ProcessInitException; -import org.chromium.ui.gfx.ActivityNativeWindow; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; import java.util.concurrent.FutureTask; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; /** * A base class for android_webview tests. */ public class AndroidWebViewTestBase extends ActivityInstrumentationTestCase2<AndroidWebViewTestRunnerActivity> { - protected static int WAIT_TIMEOUT_SECONDS = 15; + protected final static int WAIT_TIMEOUT_SECONDS = 15; private static final int CHECK_INTERVAL = 100; public AndroidWebViewTestBase() { diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/ClientOnPageFinishedTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/ClientOnPageFinishedTest.java index 64a2596..833de63 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/ClientOnPageFinishedTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/ClientOnPageFinishedTest.java @@ -4,7 +4,6 @@ package org.chromium.android_webview.test; -import android.test.FlakyTest; import android.test.suitebuilder.annotation.MediumTest; import org.chromium.android_webview.AwContents; @@ -85,7 +84,7 @@ public class ClientOnPageFinishedTest extends AndroidWebViewTestBase { final String testPath = "/test.html"; final String syncPath = "/sync.html"; - final String testUrl = webServer.setResponse(testPath, testHtml, null); + webServer.setResponse(testPath, testHtml, null); final String syncUrl = webServer.setResponse(syncPath, testHtml, null); assertEquals(0, onPageFinishedHelper.getCallCount()); diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java index 5a06656..fd79a5d 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java @@ -12,12 +12,11 @@ import org.chromium.android_webview.AwContents; import org.chromium.android_webview.test.util.CommonResources; import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; -import org.chromium.base.test.util.UrlUtils; -import org.chromium.content.browser.test.util.Criteria; -import org.chromium.content.browser.test.util.CriteriaHelper; import org.chromium.content.browser.ContentSettings; import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.LoadUrlParams; +import org.chromium.content.browser.test.util.Criteria; +import org.chromium.content.browser.test.util.CriteriaHelper; import org.chromium.content.browser.test.util.HistoryUtils; import org.chromium.content.browser.test.util.TestCallbackHelperContainer; import org.chromium.net.test.util.TestWebServer; @@ -28,8 +27,6 @@ import java.util.concurrent.TimeUnit; public class LoadDataWithBaseUrlTest extends AndroidWebViewTestBase { - protected static int WAIT_TIMEOUT_SECONDS = 15; - private TestAwContentsClient mContentsClient; private AwContents mAwContents; private ContentViewCore mContentViewCore; diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/TestAwContentsClient.java b/android_webview/javatests/src/org/chromium/android_webview/test/TestAwContentsClient.java index 66b5f62..12c1f14 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/TestAwContentsClient.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/TestAwContentsClient.java @@ -7,19 +7,19 @@ package org.chromium.android_webview.test; import android.webkit.ConsoleMessage; import org.chromium.content.browser.test.util.CallbackHelper; -import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageStartedHelper; +import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnEvaluateJavaScriptResultHelper; import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper; +import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageStartedHelper; import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnReceivedErrorHelper; -import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnEvaluateJavaScriptResultHelper; class TestAwContentsClient extends NullContentsClient { private String mUpdatedTitle; - private OnPageStartedHelper mOnPageStartedHelper; - private OnPageFinishedHelper mOnPageFinishedHelper; - private OnReceivedErrorHelper mOnReceivedErrorHelper; - private OnEvaluateJavaScriptResultHelper mOnEvaluateJavaScriptResultHelper; - private AddMessageToConsoleHelper mAddMessageToConsoleHelper; - private OnScaleChangedHelper mOnScaleChangedHelper; + private final OnPageStartedHelper mOnPageStartedHelper; + private final OnPageFinishedHelper mOnPageFinishedHelper; + private final OnReceivedErrorHelper mOnReceivedErrorHelper; + private final OnEvaluateJavaScriptResultHelper mOnEvaluateJavaScriptResultHelper; + private final AddMessageToConsoleHelper mAddMessageToConsoleHelper; + private final OnScaleChangedHelper mOnScaleChangedHelper; public TestAwContentsClient() { mOnPageStartedHelper = new OnPageStartedHelper(); @@ -99,7 +99,7 @@ class TestAwContentsClient extends NullContentsClient { return false; } - public class AddMessageToConsoleHelper extends CallbackHelper { + public static class AddMessageToConsoleHelper extends CallbackHelper { private int mLevel; private String mMessage; private int mLineNumber; diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/TestContentProvider.java b/android_webview/javatests/src/org/chromium/android_webview/test/TestContentProvider.java index b4581dd..87a08b7 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/TestContentProvider.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/TestContentProvider.java @@ -12,8 +12,8 @@ import android.content.ContentProvider; import android.content.ContentValues; import android.content.Context; import android.content.res.AssetFileDescriptor; -import android.database.Cursor; import android.database.AbstractCursor; +import android.database.Cursor; import android.net.Uri; import android.os.ParcelFileDescriptor; import android.util.Log; @@ -35,7 +35,7 @@ public class TestContentProvider extends ContentProvider { private enum ColumnIndex { RESOURCE_REQUEST_COUNT_COLUMN, }; - private Map<String, Integer> mResourceRequestCount; + private final Map<String, Integer> mResourceRequestCount; public static String createContentUrl(String target) { return CONTENT_SCHEME + AUTHORITY + "/" + target; @@ -107,8 +107,8 @@ public class TestContentProvider extends ContentProvider { /** * Cursor object for retrieving resource request counters. */ - private class ProviderStateCursor extends AbstractCursor { - private int mResourceRequestCount; + private static class ProviderStateCursor extends AbstractCursor { + private final int mResourceRequestCount; public ProviderStateCursor(int resourceRequestCount) { mResourceRequestCount = resourceRequestCount; diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/util/ImagePageGenerator.java b/android_webview/javatests/src/org/chromium/android_webview/test/util/ImagePageGenerator.java index 73ee1ee..504eb05 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/util/ImagePageGenerator.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/util/ImagePageGenerator.java @@ -13,7 +13,7 @@ public class ImagePageGenerator { public static final String IMAGE_LOADED_STRING = "1"; public static final String IMAGE_NOT_LOADED_STRING = "0"; - private final String[] COLORS = { + private final static String[] COLORS = { "AAAAIAAc3j0Ss", "AQABIAEayS9b0", "AgACIAIQ8BmAc", "AwADIAMW5wvJE", "BAAEIAQZNWRTI", "BQAFIAUfInYaQ", "BgAGIAYVG0DB4", "BwAHIAcTDFKIg", "CAAIIAgXCI+Rk", "CQAJIAkRH53Y8", "CgAKIAobJqsDU", "CwALIAsdMblKM", @@ -21,13 +21,13 @@ public class ImagePageGenerator { "D+AQAA/9vaUwc", "D/AQEBANNhzkw" }; - private final String IMAGE_PREFIX = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA" + + private final static String IMAGE_PREFIX = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA" + "6fptVAAAAAXNSR0IArs4c6QAAAA1JREFUCB0BAgD9/w"; - private final String IMAGE_SUFFIX = "AAAAASUVORK5CYII="; + private final static String IMAGE_SUFFIX = "AAAAASUVORK5CYII="; private int mIndex; - private boolean mAdvance; + private final boolean mAdvance; public ImagePageGenerator(int startIndex, boolean advance) { mIndex = startIndex; diff --git a/build/android/findbugs_filter/findbugs_known_bugs.txt b/build/android/findbugs_filter/findbugs_known_bugs.txt index be14eaf..5f5f259 100644 --- a/build/android/findbugs_filter/findbugs_known_bugs.txt +++ b/build/android/findbugs_filter/findbugs_known_bugs.txt @@ -1,10 +1,5 @@ H C EC: Using pointer equality to compare a JavaBridgeCoercionTest$CustomType with a JavaBridgeCoercionTest$CustomType2 in org.chromium.content.browser.JavaBridgeCoercionTest.testPassJavaObject() At JavaBridgeCoercionTest.java H D RCN: Redundant nullcheck of org.chromium.content.browser.SandboxedProcessConnection.mConnectionParams, which is known to be non-null in org.chromium.content.browser.SandboxedProcessConnection.doConnectionSetup() Redundant null check at SandboxedProcessConnection.java -H D ST: Write to static field org.chromium.net.test.util.TestWebServer.sInstance from instance method org.chromium.net.test.util.TestWebServer.shutdown() At TestWebServer.java -H V MS: org.chromium.android_webview.test.AndroidWebViewTestBase.WAIT_TIMEOUT_SECONDS isn't final but should be At AndroidWebViewTestBase.java -H V MS: org.chromium.android_webview.test.LoadDataWithBaseUrlTest.WAIT_TIMEOUT_SECONDS isn't final but should be At LoadDataWithBaseUrlTest.java -H V MS: org.chromium.content.browser.test.util.CallbackHelper.WAIT_TIMEOUT_SECONDS isn't final but should be At CallbackHelper.java -H V MS: org.chromium.content.browser.test.util.HistoryUtils.WAIT_TIMEOUT_SECONDS isn't final but should be At HistoryUtils.java M B DE: org.chromium.net.X509Util.clearTestRootCertificates() might ignore java.io.IOException At X509Util.java M B Nm: The method name org.chromium.base.test.util.ScalableTimeout.ScaleTimeout(long) doesn't start with a lower case letter At ScalableTimeout.java M B RV: exceptional return value of java.io.File.delete() ignored in org.chromium.android_webview.test.ArchiveTest.doArchiveTest(AwContents, String, boolean, String) At ArchiveTest.java @@ -59,10 +54,6 @@ M C UMAC: Uncallable method org.chromium.content.browser.JavaBridgeBasicsTest$7. M C UMAC: Uncallable method org.chromium.content.browser.JavaBridgeBasicsTest$8.method2() defined in anonymous class At JavaBridgeBasicsTest.java M C UMAC: Uncallable method org.chromium.content.browser.JavaBridgeBasicsTest$9.method() defined in anonymous class At JavaBridgeBasicsTest.java M C USELESS_STRING: Invocation of toString on certChain in org.chromium.net.X509Util.verifyServerCertificates(byte[][], String) At X509Util.java -M D DLS: Dead store to eventTime in org.chromium.content.browser.LongPressDetectorTest$1.run() At LongPressDetectorTest.java -M D DLS: Dead store to prevEditableLength in org.chromium.content.browser.ImeAdapter$AdapterInputConnection.setEditableText(String, int, int, int, int) At ImeAdapter.java -M D DLS: Dead store to testUrl in org.chromium.android_webview.test.ClientOnPageFinishedTest.testOnPageFinishedNotCalledForValidSubresources() At ClientOnPageFinishedTest.java -M D DLS: Dead store to time in org.chromium.net.test.util.TestWebServer.setDateHeaders(HttpResponse) At TestWebServer.java M D DMI: Hard coded reference to an absolute pathname in org.chromium.android_webview.test.ArchiveTest.testAutoBadPath() At ArchiveTest.java M D DMI: Hard coded reference to an absolute pathname in org.chromium.android_webview.test.ArchiveTest.testExplicitBadPath() At ArchiveTest.java M D ICAST: integral division result cast to double or float in org.chromium.content.browser.HandleView.setOrientation(int) At HandleView.java @@ -74,7 +65,6 @@ M D SF: Switch statement found in org.chromium.content.browser.HandleView.onTouc M D SF: Switch statement found in org.chromium.content.browser.third_party.GestureDetector.onTouchEvent(MotionEvent) where default case is missing At GestureDetector.java M D ST: Write to static field org.chromium.content.app.SandboxedProcessService.sContext from instance method org.chromium.content.app.SandboxedProcessService.onCreate() At SandboxedProcessService.java M D ST: Write to static field org.chromium.content.browser.ContentSettings.sAppCachePathIsSet from instance method org.chromium.content.browser.ContentSettings.setAppCachePath(String) At ContentSettings.java -M D ST: Write to static field org.chromium.net.test.util.TestWebServer.sInstance from instance method new org.chromium.net.test.util.TestWebServer(boolean) At TestWebServer.java M D UrF: Unread public/protected field: org.chromium.content.browser.JavaBridgeBasicsTest$21.field At JavaBridgeBasicsTest.java M D UrF: Unread public/protected field: org.chromium.content.browser.JavaBridgeFieldsTest$TestObject.booleanField At JavaBridgeFieldsTest.java M D UrF: Unread public/protected field: org.chromium.content.browser.JavaBridgeFieldsTest$TestObject.byteField At JavaBridgeFieldsTest.java @@ -95,15 +85,6 @@ M M LI: Incorrect lazy initialization and update of static field org.chromium.ba M M LI: Incorrect lazy initialization and update of static field org.chromium.content.browser.ContentVideoView.sContentVideoView in org.chromium.content.browser.ContentVideoView.createContentVideoView(int) At ContentVideoView.java M M UG: org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.getBooleanValue() is unsynchronized, org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.setBooleanValue(boolean) is synchronized At JavaBridgeReturnValuesTest.java M M UG: org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.getStringValue() is unsynchronized, org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.setStringValue(String) is synchronized At JavaBridgeReturnValuesTest.java -M P SIC: Should org.chromium.android_webview.test.TestAwContentsClient$AddMessageToConsoleHelper be a _static_ inner class? At TestAwContentsClient.java -M P SIC: Should org.chromium.android_webview.test.TestContentProvider$ProviderStateCursor be a _static_ inner class? At TestContentProvider.java -M P SIC: Should org.chromium.content.browser.ContentViewGestureHandlerTest$GestureRecordingMotionEventDelegate$GestureEvent be a _static_ inner class? At ContentViewGestureHandlerTest.java -M P SIC: Should org.chromium.content.browser.JavaBridgeArrayCoercionTest$CustomType be a _static_ inner class? At JavaBridgeArrayCoercionTest.java -M P SIC: Should org.chromium.content.browser.JavaBridgeFieldsTest$CustomType be a _static_ inner class? At JavaBridgeFieldsTest.java -M P SIC: Should org.chromium.content.browser.JavaBridgeReturnValuesTest$CustomType be a _static_ inner class? At JavaBridgeReturnValuesTest.java -M P SIC: Should org.chromium.content.browser.PopupZoomerTest$CustomCanvasPopupZoomer be a _static_ inner class? At PopupZoomerTest.java -M P SS: Unread field: org.chromium.android_webview.test.util.ImagePageGenerator.IMAGE_PREFIX; should this field be static? At ImagePageGenerator.java -M P SS: Unread field: org.chromium.android_webview.test.util.ImagePageGenerator.IMAGE_SUFFIX; should this field be static? At ImagePageGenerator.java M P UuF: Unused field: org.chromium.content.browser.JavaBridgeBasicsTest$19.privateField In JavaBridgeBasicsTest.java M P UuF: Unused field: org.chromium.content.browser.JavaBridgeBasicsTest$23.field In JavaBridgeBasicsTest.java M V EI2: new org.chromium.chrome.browser.FindMatchRectsDetails(int, RectF[], RectF) may expose internal representation by storing an externally mutable object into FindMatchRectsDetails.rects At FindMatchRectsDetails.java diff --git a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java index f80b259..224f070 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java +++ b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java @@ -111,16 +111,16 @@ class ImeAdapter { private int mNativeImeAdapterAndroid; private int mTextInputType; - private Context mContext; + private final Context mContext; private InputMethodManagerWrapper mInputMethodManagerWrapper; - private SelectionHandleController mSelectionHandleController; - private InsertionHandleController mInsertionHandleController; + private final SelectionHandleController mSelectionHandleController; + private final InsertionHandleController mInsertionHandleController; private AdapterInputConnection mInputConnection; - private ViewEmbedder mViewEmbedder; - private Handler mHandler; + private final ViewEmbedder mViewEmbedder; + private final Handler mHandler; private class DelayedDismissInput implements Runnable { - private int mNativeImeAdapter; + private final int mNativeImeAdapter; DelayedDismissInput(int nativeImeAdapter) { mNativeImeAdapter = nativeImeAdapter; @@ -471,8 +471,8 @@ class ImeAdapter { // It then adapts android's IME to chrome's RenderWidgetHostView using the // native ImeAdapterAndroid via the outer class ImeAdapter. public static class AdapterInputConnection extends BaseInputConnection { - private View mInternalView; - private ImeAdapter mImeAdapter; + private final View mInternalView; + private final ImeAdapter mImeAdapter; private boolean mSingleLine; private int mNumNestedBatchEdits = 0; private boolean mIgnoreTextInputStateUpdates = false; @@ -498,7 +498,6 @@ class ImeAdapter { int prevSelectionStart = Selection.getSelectionStart(editable); int prevSelectionEnd = Selection.getSelectionEnd(editable); - int prevEditableLength = editable.length(); int prevCompositionStart = getComposingSpanStart(editable); int prevCompositionEnd = getComposingSpanEnd(editable); String prevText = editable.toString(); diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java index b0e7089..0969efb 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java @@ -12,15 +12,12 @@ import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; import android.view.MotionEvent; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Deque; -import java.util.concurrent.CountDownLatch; - import org.chromium.base.test.util.Feature; import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegate; import org.chromium.content.browser.third_party.GestureDetector; -import org.chromium.content.browser.third_party.GestureDetector.SimpleOnGestureListener; + +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; /** * Test suite for ContentViewGestureHandler. @@ -613,12 +610,12 @@ public class ContentViewGestureHandlerTest extends InstrumentationTestCase { * Mock MotionEventDelegate that remembers the most recent gesture event. */ static class GestureRecordingMotionEventDelegate implements MotionEventDelegate { - public class GestureEvent { - private int mType; - private long mTimeMs; - private int mX; - private int mY; - private Bundle mExtraParams; + static class GestureEvent { + private final int mType; + private final long mTimeMs; + private final int mX; + private final int mY; + private final Bundle mExtraParams; public GestureEvent(int type, long timeMs, int x, int y, Bundle extraParams) { mType = type; @@ -649,7 +646,7 @@ public class ContentViewGestureHandlerTest extends InstrumentationTestCase { } }; private GestureEvent mMostRecentGestureEvent; - private ArrayList<Integer> mGestureTypeList = new ArrayList<Integer>(); + private final ArrayList<Integer> mGestureTypeList = new ArrayList<Integer>(); @Override public boolean sendTouchEvent(long timeMs, int action, TouchPoint[] pts) { diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeArrayCoercionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeArrayCoercionTest.java index 81c7742..9c737f2 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeArrayCoercionTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeArrayCoercionTest.java @@ -6,8 +6,8 @@ package org.chromium.content.browser; import android.test.suitebuilder.annotation.SmallTest; -import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.DisabledTest; +import org.chromium.base.test.util.Feature; /** * Part of the test suite for the Java Bridge. This class tests that we correctly convert @@ -22,8 +22,8 @@ import org.chromium.base.test.util.DisabledTest; */ public class JavaBridgeArrayCoercionTest extends JavaBridgeTestBase { private class TestObject extends Controller { - private Object mObjectInstance; - private CustomType mCustomTypeInstance; + private final Object mObjectInstance; + private final CustomType mCustomTypeInstance; private boolean[] mBooleanArray; private byte[] mByteArray; @@ -141,7 +141,7 @@ public class JavaBridgeArrayCoercionTest extends JavaBridgeTestBase { } // Two custom types used when testing passing objects. - private class CustomType { + private static class CustomType { } private TestObject mTestObject; diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java index 9b89984..f8322f0 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java @@ -40,7 +40,7 @@ public class JavaBridgeFieldsTest extends JavaBridgeTestBase { } // A custom type used when testing passing objects. - private class CustomType { + private static class CustomType { } TestObject mTestObject; diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeReturnValuesTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeReturnValuesTest.java index 29fb7df..8afcb3a 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeReturnValuesTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeReturnValuesTest.java @@ -97,7 +97,7 @@ public class JavaBridgeReturnValuesTest extends JavaBridgeTestBase { } // A custom type used when testing passing objects. - private class CustomType { + private static class CustomType { } TestObject mTestObject; diff --git a/content/public/android/javatests/src/org/chromium/content/browser/LongPressDetectorTest.java b/content/public/android/javatests/src/org/chromium/content/browser/LongPressDetectorTest.java index f334817..9fd2ca1 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/LongPressDetectorTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/LongPressDetectorTest.java @@ -11,12 +11,12 @@ import android.test.suitebuilder.annotation.SmallTest; import android.view.MotionEvent; import android.view.ViewConfiguration; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.ScalableTimeout; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + /** * Test suite for LongPressDetector. */ @@ -159,6 +159,7 @@ public class LongPressDetectorTest extends InstrumentationTestCase { LongPressDetector longPressDetector = new LongPressDetector( getInstrumentation().getTargetContext(), new LongPressDetector.LongPressDelegate() { + @Override public void onLongPress(MotionEvent event) { longPressCalled.countDown(); } @@ -166,7 +167,7 @@ public class LongPressDetectorTest extends InstrumentationTestCase { final long downTime = SystemClock.uptimeMillis(); final long eventTime = SystemClock.uptimeMillis(); - MotionEvent event = motionEvent(MotionEvent.ACTION_DOWN, downTime, downTime); + MotionEvent event = motionEvent(MotionEvent.ACTION_DOWN, downTime, eventTime); longPressDetector.startLongPressTimerIfNeeded(event); } }); diff --git a/content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java b/content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java index c5d834d..29eeccd 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java @@ -22,7 +22,7 @@ import org.chromium.base.test.util.Feature; public class PopupZoomerTest extends InstrumentationTestCase { private CustomCanvasPopupZoomer mPopupZoomer; - private class CustomCanvasPopupZoomer extends PopupZoomer { + private static class CustomCanvasPopupZoomer extends PopupZoomer { Canvas mCanvas; long mPendingDraws = 0; @@ -44,6 +44,7 @@ public class PopupZoomerTest extends InstrumentationTestCase { // Test doesn't attach PopupZoomer to the view hierarchy, // but onDraw() should still go on. + @Override protected boolean acceptZeroSizeView() { return true; } diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CallbackHelper.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CallbackHelper.java index f2e9a292..95e4b62 100644 --- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CallbackHelper.java +++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CallbackHelper.java @@ -121,7 +121,7 @@ import java.util.concurrent.TimeoutException; * */ public class CallbackHelper { - protected static int WAIT_TIMEOUT_SECONDS = 5; + protected static final int WAIT_TIMEOUT_SECONDS = 5; private final Object mLock = new Object(); private int mCallCount = 0; diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java index 59cd508..db557e3 100644 --- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java +++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java @@ -7,6 +7,7 @@ package org.chromium.content.browser.test.util; import android.app.Instrumentation; import org.chromium.base.test.util.InstrumentationUtils; +import org.chromium.content.browser.ContentView; import org.chromium.content.browser.ContentViewCore; import java.util.concurrent.Callable; @@ -18,7 +19,7 @@ import java.util.concurrent.TimeUnit; */ public class HistoryUtils { - protected static int WAIT_TIMEOUT_SECONDS = 15; + protected final static int WAIT_TIMEOUT_SECONDS = 15; /** * Calls {@link ContentView#canGoBack()} on UI thread. diff --git a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java index c892afe..9e60a43 100644 --- a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java +++ b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java @@ -70,9 +70,9 @@ public class TestWebServer { private static TestWebServer sInstance; private static Hashtable<Integer, String> sReasons; - private ServerThread mServerThread; + private final ServerThread mServerThread; private String mServerUri; - private boolean mSsl; + private final boolean mSsl; private static class Response { final byte[] mResponseData; @@ -91,9 +91,9 @@ public class TestWebServer { // The Maps below are modified on both the client thread and the internal server thread, so // need to use a lock when accessing them. private final Object mLock = new Object(); - private Map<String, Response> mResponseMap = new HashMap<String, Response>(); - private Map<String, Integer> mResponseCountMap = new HashMap<String, Integer>(); - private Map<String, HttpRequest> mLastRequestMap = new HashMap<String, HttpRequest>(); + private final Map<String, Response> mResponseMap = new HashMap<String, Response>(); + private final Map<String, Integer> mResponseCountMap = new HashMap<String, Integer>(); + private final Map<String, HttpRequest> mLastRequestMap = new HashMap<String, HttpRequest>(); /** * Create and start a local HTTP server instance. @@ -106,7 +106,7 @@ public class TestWebServer { // shut down the old instance first sInstance.shutdown(); } - sInstance = this; + setStaticInstance(this); mSsl = ssl; if (mSsl) { mServerUri = "https://localhost:" + SSL_SERVER_PORT; @@ -117,6 +117,10 @@ public class TestWebServer { mServerThread.start(); } + private static void setStaticInstance(TestWebServer instance) { + sInstance = instance; + } + /** * Terminate the http server. */ @@ -149,7 +153,7 @@ public class TestWebServer { throw new IllegalStateException(e); } - TestWebServer.sInstance = null; + setStaticInstance(null); } private final static int RESPONSE_STATUS_NORMAL = 0; @@ -369,7 +373,6 @@ public class TestWebServer { } private void setDateHeaders(HttpResponse response) { - long time = System.currentTimeMillis(); response.addHeader("Date", DateUtils.formatDate(new Date(), DateUtils.PATTERN_RFC1123)); } @@ -451,7 +454,7 @@ public class TestWebServer { "1gaEjsC/0wGmmBDg1dTDH+F1p9TInzr3EFuYD0YiQ7YlAHq3cPuyGoLXJ5dXYuSBfhDXJSeddUkl" + "k1ufZyOOcskeInQge7jzaRfmKg3U94r+spMEvb0AzDQVOKvjjo1ivxMSgFRZaDb/4qw="; - private String PASSWORD = "android"; + private static final String PASSWORD = "android"; /** * Loads a keystore from a base64-encoded String. Returns the KeyManager[] |