Skip to content

Commit

Permalink
Android: Clean up baseline.xml for downstream
Browse files Browse the repository at this point in the history
Fix lint errors/warnings for all downstream files. This paves the way
for upstream and downstream monochrome bundle targets to generate the
same baseline.xml file.

Add support to ignore @VisibleForTesting(otherwise = ...) annotations
in presubmit and fix a few presubmit errors along the way.

Tbr: No functional changes in components/ and net/
Bug: 1111363
Change-Id: Ia3752c9a775a5ad0dedc10d415376c264d2575fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2330332
Commit-Queue: Peter Wen <wnwen@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795062}
  • Loading branch information
Peter Wen authored and Commit Bot committed Aug 5, 2020
1 parent e17bfbc commit 6367b88
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 998 deletions.
9 changes: 6 additions & 3 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
'^chrome/browser/chromeos/',
'^chrome/browser/component_updater/',
'^chrome/browser/custom_handlers/protocol_handler_registry.cc',
'^chrome/browser/device_identity/chromeos/device_oauth2_token_store_chromeos.cc',
'^chrome/browser/device_identity/chromeos/device_oauth2_token_store_chromeos.cc', # pylint: disable=line-too-long
'^chrome/browser/devtools/',
'^chrome/browser/download/',
'^chrome/browser/extensions/',
Expand All @@ -313,12 +313,12 @@
'^chrome/browser/media/',
'^chrome/browser/metrics/',
'^chrome/browser/nacl_host/test/gdb_debug_stub_browsertest.cc',
'^chrome/browser/nearby_sharing/client/nearby_share_api_call_flow_impl_unittest.cc',
'^chrome/browser/nearby_sharing/client/nearby_share_api_call_flow_impl_unittest.cc', # pylint: disable=line-too-long
'^chrome/browser/net/',
'^chrome/browser/notifications/',
'^chrome/browser/ntp_tiles/ntp_tiles_browsertest.cc',
'^chrome/browser/offline_pages/',
'^chrome/browser/page_load_metrics/observers/data_saver_site_breakdown_metrics_observer_browsertest.cc',
'^chrome/browser/page_load_metrics/observers/data_saver_site_breakdown_metrics_observer_browsertest.cc', # pylint: disable=line-too-long
'^chrome/browser/password_manager/',
'^chrome/browser/payments/payment_manifest_parser_browsertest.cc',
'^chrome/browser/pdf/pdf_extension_test.cc',
Expand Down Expand Up @@ -1492,6 +1492,8 @@ def _CheckNoProductionCodeUsingTestOnlyFunctionsJava(input_api, output_api):
name_pattern = r'ForTest(s|ing)?'
# Describes an occurrence of "ForTest*" inside a // comment.
comment_re = input_api.re.compile(r'//.*%s' % name_pattern)
# Describes @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
annotation_re = input_api.re.compile(r'@VisibleForTesting\(otherwise')
# Catch calls.
inclusion_re = input_api.re.compile(r'(%s)\s*\(' % name_pattern)
# Ignore definitions. (Comments are ignored separately.)
Expand All @@ -1516,6 +1518,7 @@ def _CheckNoProductionCodeUsingTestOnlyFunctionsJava(input_api, output_api):
continue
if (inclusion_re.search(line) and
not comment_re.search(line) and
not annotation_re.search(line) and
not exclusion_re.search(line)):
problems.append(
'%s:%d\n %s' % (local_path, line_number, line.strip()))
Expand Down
2 changes: 0 additions & 2 deletions base/android/java/src/org/chromium/base/IntentUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ public static IBinder safeGetBinder(Bundle bundle, String name) {
* Creates a temporary copy of the extra Bundle, which is required as
* Intent#getBinderExtra() doesn't exist, but Bundle.getBinder() does.
*/
@VisibleForTesting
public static IBinder safeGetBinderExtra(Intent intent, String name) {
if (!intent.hasExtra(name)) return null;
Bundle extras = intent.getExtras();
Expand All @@ -381,7 +380,6 @@ public static IBinder safeGetBinderExtra(Intent intent, String name) {
* @param name Key.
* @param binder Binder object.
*/
@VisibleForTesting
public static void safePutBinderExtra(Intent intent, String name, IBinder binder) {
if (intent == null) return;
Bundle bundle = new Bundle();
Expand Down
4 changes: 0 additions & 4 deletions base/android/java/src/org/chromium/base/ThreadUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import android.os.Looper;
import android.os.Process;

import androidx.annotation.VisibleForTesting;

import org.chromium.base.annotations.CalledByNative;

import java.util.concurrent.Callable;
Expand Down Expand Up @@ -174,7 +172,6 @@ public static void runOnUiThreadBlocking(final Runnable r) {
* @return The result of the callable
*/
@Deprecated
@VisibleForTesting
public static <T> T runOnUiThreadBlockingNoException(Callable<T> c) {
try {
return runOnUiThreadBlocking(c);
Expand Down Expand Up @@ -310,7 +307,6 @@ public static void postOnUiThread(Runnable task) {
* @param task The Runnable to run
* @param delayMillis The delay in milliseconds until the Runnable will be run
*/
@VisibleForTesting
@Deprecated
public static void postOnUiThreadDelayed(Runnable task, long delayMillis) {
getUiThreadHandler().postDelayed(task, delayMillis);
Expand Down
Loading

0 comments on commit 6367b88

Please sign in to comment.