Skip to content

Commit

Permalink
Android: Add missing @OverRide annotations
Browse files Browse the repository at this point in the history
This fixes errorprone MissingOverride warnings.

Used '-XepPatchChecks:MissingOverride' and '-XepPatchLocation:IN_PLACE'
to automatically add the annotations.

TBR for cross-repo refactoring.

BUG=775031
TBR=torne@chromium.org,sdefresne@chromium.org,rockot@chromium.org,xunjieli@chromium.org

Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win10_chromium_x64_rel_ng
Change-Id: I2fd028dcf6ab9fdf5ea1e2dab2215a52dffe8b21
Reviewed-on: https://chromium-review.googlesource.com/766516
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: Xi Han <hanxi@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Reviewed-by: Lambros Lambrou <lambroslambrou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516770}
  • Loading branch information
Peter Wen authored and Commit Bot committed Nov 15, 2017
1 parent 798beff commit dd3a51e
Show file tree
Hide file tree
Showing 48 changed files with 104 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,24 @@ public GeoPermissionRequest(String origin, GeolocationPermissions.Callback callb
mCallback = callback;
}

@Override
public Uri getOrigin() {
return Uri.parse(mOrigin);
}

@Override
public String[] getResources() {
return new String[] { WebViewBrowserActivity.RESOURCE_GEO };
}

@Override
public void grant(String[] resources) {
assert resources.length == 1;
assert WebViewBrowserActivity.RESOURCE_GEO.equals(resources[0]);
mCallback.invoke(mOrigin, true, false);
}

@Override
public void deny() {
mCallback.invoke(mOrigin, false, false);
}
Expand All @@ -143,21 +147,25 @@ public FilePermissionRequest(String origin) {
mOrigin = origin;
}

@Override
public Uri getOrigin() {
return Uri.parse(mOrigin);
}

@Override
public String[] getResources() {
return new String[] { WebViewBrowserActivity.RESOURCE_FILE_URL };
}

@Override
public void grant(String[] resources) {
assert resources.length == 1;
assert WebViewBrowserActivity.RESOURCE_FILE_URL.equals(resources[0]);
// Try again now that we have read access.
WebViewBrowserActivity.this.mWebView.loadUrl(mOrigin);
}

@Override
public void deny() {
// womp womp
}
Expand All @@ -172,6 +180,7 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_webview_browser);
mUrlBar = (EditText) findViewById(R.id.url_field);
mUrlBar.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View view, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
loadUrlFromUrlBar(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public Intent getBindIntent() {

private final ChildProcessConnection.ChildServiceConnectionFactory mServiceConnectionFactory =
new ChildProcessConnection.ChildServiceConnectionFactory() {
@Override
public ChildProcessConnection.ChildServiceConnection createConnection(
Intent bindIntent, int bindFlags,
ChildProcessConnection.ChildServiceConnectionDelegate delegate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public BaseActivityInstrumentationTestCase(Class<T> activityClass) {
super(activityClass);
}

@Override
@CallSuper
protected void setUp() throws Exception {
super.setUp();
}

@Override
@CallSuper
protected void tearDown() throws Exception {
super.tearDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

import junit.framework.TestCase;

import org.chromium.testing.local.LocalRobolectricTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;

import org.chromium.testing.local.LocalRobolectricTestRunner;

/** Unit tests for MinAndroidSdkLevelSkipCheck. */
@RunWith(LocalRobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 18)
Expand Down Expand Up @@ -45,13 +46,15 @@ private static class ExtendsMin17Class extends Min17Class {
public ExtendsMin17Class(String name) {
super(name);
}
@Override
public void unannotatedMethod() {}
}

private static class ExtendsMin20Class extends Min20Class {
public ExtendsMin20Class(String name) {
super(name);
}
@Override
public void unannotatedMethod() {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.robolectric.annotation.Config;

import org.chromium.testing.local.LocalRobolectricTestRunner;
Expand All @@ -30,6 +29,7 @@ private static class TestRestrictionSkipCheck extends RestrictionSkipCheck {
public TestRestrictionSkipCheck() {
super(null);
}
@Override
protected boolean restrictionApplies(String restriction) {
return TextUtils.equals(restriction, TEST_RESTRICTION_APPLIES);
}
Expand Down Expand Up @@ -73,13 +73,15 @@ private static class ExtendsRestrictedClass extends RestrictedClass {
public ExtendsRestrictedClass(String name) {
super(name);
}
@Override
public void unannotatedMethod() {}
}

private static class ExtendsUnrestrictedClass extends UnrestrictedClass {
public ExtendsUnrestrictedClass(String name) {
super(name);
}
@Override
public void unannotatedMethod() {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ChromeMediaRouter implements MediaRouteManager {

private static MediaRouteProvider.Factory sRouteProviderFactory =
new MediaRouteProvider.Factory() {
@Override
public void addProviders(MediaRouteManager manager) {
MediaRouteProvider castProvider = CastMediaRouteProvider.create(manager);
manager.addMediaRouteProvider(castProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public IBinder onBind(Intent intent) {
}

private final IDecoderService.Stub mBinder = new IDecoderService.Stub() {
@Override
public void decodeImage(Bundle payload, IDecoderServiceCallback callback) {
Bundle bundle = null;
String filePath = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class DecoderServiceHost extends IDecoderServiceCallback.Stub {

IDecoderService mIRemoteService;
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
mIRemoteService = IDecoderService.Stub.asInterface(service);
mBound = true;
Expand All @@ -52,6 +53,7 @@ public void onServiceConnected(ComponentName className, IBinder service) {
}
}

@Override
public void onServiceDisconnected(ComponentName className) {
Log.e(TAG, "Service has unexpectedly disconnected");
mIRemoteService = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {
.setMessage(R.string.physical_web_share_entry_message)
.setPositiveButton(R.string.continue_button,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
PhysicalWeb.setSharingOptedIn();
PhysicalWebBroadcastService.startBroadcastService(url);
Expand All @@ -46,6 +47,7 @@ public void onClick(DialogInterface dialog, int which) {
})
.setNegativeButton(R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ public class ThumbnailDiskStorage implements ThumbnailGeneratorCallback {
long mSizeBytes;

private class InitTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
initDiskCache();
return null;
}
}

private class ClearTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
clearDiskCache();
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,13 @@ public void testWebShareCancel() throws Exception {
// Set up ShareHelper to ignore the intent (without showing a picker). This simulates the
// user canceling the dialog.
ShareHelper.setFakeIntentReceiverForTesting(new ShareHelper.FakeIntentReceiver() {
@Override
public void setIntentToSendBack(Intent intent) {}

@Override
public void onCustomChooserShown(AlertDialog dialog) {}

@Override
public void fireIntent(Context context, Intent intent) {
// Click again to start another share. This is necessary to work around
// https://crbug.com/636274 (callback is not canceled until next share is
Expand Down Expand Up @@ -161,12 +164,15 @@ public void testWebShareSuccess() throws Exception {
ShareHelper.setFakeIntentReceiverForTesting(new ShareHelper.FakeIntentReceiver() {
private Intent mIntentToSendBack;

@Override
public void setIntentToSendBack(Intent intent) {
mIntentToSendBack = intent;
}

@Override
public void onCustomChooserShown(AlertDialog dialog) {}

@Override
public void fireIntent(Context context, Intent intent) {
mReceivedIntent = intent;

Expand Down Expand Up @@ -210,13 +216,16 @@ public void fireIntent(Context context, Intent intent) {
@Feature({"WebShare"})
public void testWebShareCancelPreLMR1() throws Exception {
ShareHelper.setFakeIntentReceiverForTesting(new ShareHelper.FakeIntentReceiver() {
@Override
public void setIntentToSendBack(Intent intent) {}

@Override
public void onCustomChooserShown(AlertDialog dialog) {
// Cancel the chooser dialog.
dialog.dismiss();
}

@Override
public void fireIntent(Context context, Intent intent) {}
});

Expand All @@ -240,8 +249,10 @@ public void fireIntent(Context context, Intent intent) {}
@Feature({"WebShare"})
public void testWebShareSuccessPreLMR1() throws Exception {
ShareHelper.setFakeIntentReceiverForTesting(new ShareHelper.FakeIntentReceiver() {
@Override
public void setIntentToSendBack(Intent intent) {}

@Override
public void onCustomChooserShown(AlertDialog dialog) {
// Click on an app (it doesn't matter which, because we will hook the intent).
assert dialog.getListView().getCount() > 0;
Expand All @@ -250,6 +261,7 @@ public void onCustomChooserShown(AlertDialog dialog) {
.performItemClick(null, 0, dialog.getListView().getItemIdAtPosition(0));
}

@Override
public void fireIntent(Context context, Intent intent) {
mReceivedIntent = intent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private void attachBaseContextLate(Context base) {

private static class NetworkChangingPermissionManager
extends MockCrashReportingPermissionManager {
@Override
public boolean isNetworkAvailableForCrashUploads() {
return mIsNetworkAvailable;
}
Expand All @@ -81,6 +82,7 @@ public void setIsNetworkAvailableForCrashUploads(boolean networkAvailable) {
}
}

@Override
CrashReportingPermissionManager getCrashReportingPermissionManager() {
return mPermissionManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static class TestScreenshotMonitorDelegate implements ScreenshotMonitorDelegate
// This is modified on the UI thread and accessed on the test thread.
public final AtomicInteger screenshotShowUiCount = new AtomicInteger();

@Override
public void onScreenshotTaken() {
Assert.assertTrue(ThreadUtils.runningOnUiThread());
screenshotShowUiCount.getAndIncrement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private static class StubProfileSyncService extends ProfileSyncService {
mSyncable = syncable;
}

@Override
public Set<Integer> getActiveDataTypes() {
if (mSyncable) {
return CollectionUtil.newHashSet(ModelType.HISTORY_DELETE_DIRECTIVES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
Expand Down Expand Up @@ -61,6 +60,7 @@ public void setUp() {
doReturn("My neat website").when(mTab).getTitle();
doReturn(0L).when(mUtil).getElapsedTime();
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
CopylessPaste.GetEntitiesResponse callback =
(CopylessPaste.GetEntitiesResponse) invocation.getArguments()[0];
Expand Down Expand Up @@ -108,6 +108,7 @@ public void testCacheHit_expired() {
@Test
public void testCacheHit_noEntity() {
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
CopylessPaste.GetEntitiesResponse callback =
(CopylessPaste.GetEntitiesResponse) invocation.getArguments()[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public boolean isValid() {
private int mFormat = PixelFormat.UNKNOWN;
private final MyFakeSurface mSurface = new MyFakeSurface();

@Override
@Implementation
public void setFormat(int format) {
mFormat = format;
Expand All @@ -107,6 +108,7 @@ public MyFakeSurface getFakeSurface() {

public MyShadowSurfaceView() {}

@Override
@Implementation
public SurfaceHolder getHolder() {
return getMyFakeSurfaceHolder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ public void setUp() {
clientIds.add(CLIENT_ID1);
clientIds.add(CLIENT_ID2);
doAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
return clientIds;
}
})
.when(mRouteProvider).getClients();
@Override
public Object answer(InvocationOnMock invocation) {
return clientIds;
}
})
.when(mRouteProvider)
.getClients();
doNothing().when(mRouteProvider).onMessage(anyString(), anyString());
doNothing().when(mRouteProvider).onMessageSentResult(anyBoolean(), anyInt());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
import android.support.v7.media.MediaRouteSelector;
import android.support.v7.media.MediaRouter;

import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.media.router.ChromeMediaRouterTestBase;
import org.chromium.chrome.browser.media.router.DiscoveryDelegate;
import org.chromium.testing.local.LocalRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;

import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.media.router.ChromeMediaRouterTestBase;
import org.chromium.chrome.browser.media.router.DiscoveryDelegate;
import org.chromium.testing.local.LocalRobolectricTestRunner;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -37,6 +38,7 @@
public class DiscoveryCallbackTest extends ChromeMediaRouterTestBase {
protected DiscoveryDelegate mDiscoveryDelegate;

@Override
@Before
public void setUp() {
super.setUp();
Expand Down
Loading

0 comments on commit dd3a51e

Please sign in to comment.