Commit a5f8ead4 authored by aurimas's avatar aurimas Committed by Commit bot

[Android] Add missing @VisibleForTesting annotations.

Proguard strips these methods if they are not annotated because they
are only used in tests.

TBR=brettw
BUG=163393

Review URL: https://codereview.chromium.org/528963003

Cr-Commit-Position: refs/heads/master@{#293009}
parent 3d9a2469
...@@ -1407,6 +1407,7 @@ if (is_android) { ...@@ -1407,6 +1407,7 @@ if (is_android) {
"android/java/src/org/chromium/base/ActivityState.java", "android/java/src/org/chromium/base/ActivityState.java",
"android/java/src/org/chromium/base/ApplicationStatus.java", "android/java/src/org/chromium/base/ApplicationStatus.java",
"android/java/src/org/chromium/base/ApiCompatibilityUtils.java", "android/java/src/org/chromium/base/ApiCompatibilityUtils.java",
"android/java/src/org/chromium/base/VisibleForTesting.java",
] ]
# A new version of NativeLibraries.java (with the actual correct values) # A new version of NativeLibraries.java (with the actual correct values)
......
...@@ -222,6 +222,7 @@ public class ApplicationStatus { ...@@ -222,6 +222,7 @@ public class ApplicationStatus {
/** /**
* Testing method to update the state of the specified activity. * Testing method to update the state of the specified activity.
*/ */
@VisibleForTesting
public static void onStateChangeForTesting(Activity activity, int newState) { public static void onStateChangeForTesting(Activity activity, int newState) {
onStateChange(activity, newState); onStateChange(activity, newState);
} }
......
...@@ -126,6 +126,7 @@ public abstract class CommandLine { ...@@ -126,6 +126,7 @@ public abstract class CommandLine {
* Resets both the java proxy and the native command lines. This allows the entire * Resets both the java proxy and the native command lines. This allows the entire
* command line initialization to be re-run including the call to onJniLoaded. * command line initialization to be re-run including the call to onJniLoaded.
*/ */
@VisibleForTesting
public static void reset() { public static void reset() {
setInstance(null); setInstance(null);
} }
......
...@@ -82,6 +82,7 @@ public class PerfTraceEvent { ...@@ -82,6 +82,7 @@ public class PerfTraceEvent {
* *
* @param strings Event names we will record. * @param strings Event names we will record.
*/ */
@VisibleForTesting
public static synchronized void setFilter(List<String> strings) { public static synchronized void setFilter(List<String> strings) {
sFilter = new LinkedList<String>(strings); sFilter = new LinkedList<String>(strings);
} }
...@@ -90,6 +91,7 @@ public class PerfTraceEvent { ...@@ -90,6 +91,7 @@ public class PerfTraceEvent {
* Enable or disable perf tracing. * Enable or disable perf tracing.
* Disabling of perf tracing will dump trace data to the system log. * Disabling of perf tracing will dump trace data to the system log.
*/ */
@VisibleForTesting
public static synchronized void setEnabled(boolean enabled) { public static synchronized void setEnabled(boolean enabled) {
if (sEnabled == enabled) { if (sEnabled == enabled) {
return; return;
...@@ -118,6 +120,7 @@ public class PerfTraceEvent { ...@@ -118,6 +120,7 @@ public class PerfTraceEvent {
* *
* @param enabled Whether to enable memory tracking for all perf events. * @param enabled Whether to enable memory tracking for all perf events.
*/ */
@VisibleForTesting
public static synchronized void setMemoryTrackingEnabled(boolean enabled) { public static synchronized void setMemoryTrackingEnabled(boolean enabled) {
sTrackMemory = enabled; sTrackMemory = enabled;
} }
...@@ -134,6 +137,7 @@ public class PerfTraceEvent { ...@@ -134,6 +137,7 @@ public class PerfTraceEvent {
* *
* @param enabled Whether to enable timing tracking for all perf events. * @param enabled Whether to enable timing tracking for all perf events.
*/ */
@VisibleForTesting
public static synchronized void setTimingTrackingEnabled(boolean enabled) { public static synchronized void setTimingTrackingEnabled(boolean enabled) {
sTrackTiming = enabled; sTrackTiming = enabled;
} }
...@@ -143,6 +147,7 @@ public class PerfTraceEvent { ...@@ -143,6 +147,7 @@ public class PerfTraceEvent {
* It is safe to call trace methods without checking if PerfTraceEvent * It is safe to call trace methods without checking if PerfTraceEvent
* is enabled. * is enabled.
*/ */
@VisibleForTesting
public static synchronized boolean enabled() { public static synchronized boolean enabled() {
return sEnabled; return sEnabled;
} }
...@@ -164,6 +169,7 @@ public class PerfTraceEvent { ...@@ -164,6 +169,7 @@ public class PerfTraceEvent {
* Record an "begin" perf trace event. * Record an "begin" perf trace event.
* Begin trace events should have a matching end event. * Begin trace events should have a matching end event.
*/ */
@VisibleForTesting
public static synchronized void begin(String name) { public static synchronized void begin(String name) {
final long eventId = name.hashCode(); final long eventId = name.hashCode();
TraceEvent.startAsync(name, eventId); TraceEvent.startAsync(name, eventId);
...@@ -185,6 +191,7 @@ public class PerfTraceEvent { ...@@ -185,6 +191,7 @@ public class PerfTraceEvent {
* time delta between begin and end is usually interesting to * time delta between begin and end is usually interesting to
* graph code. * graph code.
*/ */
@VisibleForTesting
public static synchronized void end(String name) { public static synchronized void end(String name) {
final long eventId = name.hashCode(); final long eventId = name.hashCode();
TraceEvent.finishAsync(name, eventId); TraceEvent.finishAsync(name, eventId);
...@@ -205,6 +212,7 @@ public class PerfTraceEvent { ...@@ -205,6 +212,7 @@ public class PerfTraceEvent {
* Record an "begin" memory trace event. * Record an "begin" memory trace event.
* Begin trace events should have a matching end event. * Begin trace events should have a matching end event.
*/ */
@VisibleForTesting
public static synchronized void begin(String name, MemoryInfo memoryInfo) { public static synchronized void begin(String name, MemoryInfo memoryInfo) {
final long eventId = name.hashCode(); final long eventId = name.hashCode();
TraceEvent.startAsync(name, eventId); TraceEvent.startAsync(name, eventId);
...@@ -225,6 +233,7 @@ public class PerfTraceEvent { ...@@ -225,6 +233,7 @@ public class PerfTraceEvent {
* memory usage delta between begin and end is usually interesting to * memory usage delta between begin and end is usually interesting to
* graph code. * graph code.
*/ */
@VisibleForTesting
public static synchronized void end(String name, MemoryInfo memoryInfo) { public static synchronized void end(String name, MemoryInfo memoryInfo) {
final long eventId = name.hashCode(); final long eventId = name.hashCode();
TraceEvent.finishAsync(name, eventId); TraceEvent.finishAsync(name, eventId);
...@@ -333,6 +342,7 @@ public class PerfTraceEvent { ...@@ -333,6 +342,7 @@ public class PerfTraceEvent {
* @param file Which file to append the performance data to. If {@code null}, the performance * @param file Which file to append the performance data to. If {@code null}, the performance
* data will be sent to STDOUT. * data will be sent to STDOUT.
*/ */
@VisibleForTesting
public static synchronized void setOutputFile(File file) { public static synchronized void setOutputFile(File file) {
sOutputFile = file; sOutputFile = file;
} }
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.base;
/**
* Annotation used to mark code that has wider visibility or present for testing code.
*/
public @interface VisibleForTesting {
}
...@@ -14,6 +14,7 @@ import android.view.View; ...@@ -14,6 +14,7 @@ import android.view.View;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.base.ObserverList; import org.chromium.base.ObserverList;
import org.chromium.base.TraceEvent; import org.chromium.base.TraceEvent;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.banners.AppBannerManager; import org.chromium.chrome.browser.banners.AppBannerManager;
import org.chromium.chrome.browser.contextmenu.ChromeContextMenuItemDelegate; import org.chromium.chrome.browser.contextmenu.ChromeContextMenuItemDelegate;
import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator;
...@@ -305,6 +306,7 @@ public class Tab implements NavigationClient { ...@@ -305,6 +306,7 @@ public class Tab implements NavigationClient {
* @param context An instance of a {@link Context}. * @param context An instance of a {@link Context}.
* @param window An instance of a {@link WindowAndroid}. * @param window An instance of a {@link WindowAndroid}.
*/ */
@VisibleForTesting
public Tab(boolean incognito, Context context, WindowAndroid window) { public Tab(boolean incognito, Context context, WindowAndroid window) {
this(INVALID_TAB_ID, incognito, context, window); this(INVALID_TAB_ID, incognito, context, window);
} }
......
...@@ -7,9 +7,8 @@ package org.chromium.chrome.browser.infobar; ...@@ -7,9 +7,8 @@ package org.chromium.chrome.browser.infobar;
import android.content.Context; import android.content.Context;
import android.view.View; import android.view.View;
import com.google.common.annotations.VisibleForTesting;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R; import org.chromium.chrome.R;
/** /**
...@@ -199,6 +198,7 @@ public abstract class InfoBar implements InfoBarView { ...@@ -199,6 +198,7 @@ public abstract class InfoBar implements InfoBarView {
/** /**
* @return The content view for the info bar. * @return The content view for the info bar.
*/ */
@VisibleForTesting
public ContentWrapperView getContentWrapper() { public ContentWrapperView getContentWrapper() {
return getContentWrapper(true); return getContentWrapper(true);
} }
......
...@@ -16,9 +16,8 @@ import android.widget.FrameLayout; ...@@ -16,9 +16,8 @@ import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
import com.google.common.annotations.VisibleForTesting;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.UiUtils; import org.chromium.ui.UiUtils;
...@@ -151,6 +150,7 @@ public class InfoBarContainer extends ScrollView { ...@@ -151,6 +150,7 @@ public class InfoBarContainer extends ScrollView {
return mLinearLayout; return mLinearLayout;
} }
@VisibleForTesting
public void setAnimationListener(InfoBarAnimationListener listener) { public void setAnimationListener(InfoBarAnimationListener listener) {
mAnimationListener = listener; mAnimationListener = listener;
} }
......
...@@ -7,11 +7,11 @@ package org.chromium.chrome.browser.sync; ...@@ -7,11 +7,11 @@ package org.chromium.chrome.browser.sync;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator; import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator;
import org.chromium.sync.internal_api.pub.SyncDecryptionPassphraseType; import org.chromium.sync.internal_api.pub.SyncDecryptionPassphraseType;
import org.chromium.sync.internal_api.pub.base.ModelType; import org.chromium.sync.internal_api.pub.base.ModelType;
...@@ -508,6 +508,7 @@ public class ProfileSyncService { ...@@ -508,6 +508,7 @@ public class ProfileSyncService {
* @return The difference measured in microseconds, between last sync cycle completion time * @return The difference measured in microseconds, between last sync cycle completion time
* and 1 January 1970 00:00:00 UTC. * and 1 January 1970 00:00:00 UTC.
*/ */
@VisibleForTesting
public long getLastSyncedTimeForTest() { public long getLastSyncedTimeForTest() {
return nativeGetLastSyncedTimeForTest(mNativeProfileSyncServiceAndroid); return nativeGetLastSyncedTimeForTest(mNativeProfileSyncServiceAndroid);
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.tabmodel; package org.chromium.chrome.browser.tabmodel;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.Tab; import org.chromium.chrome.browser.Tab;
import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
import org.chromium.content.browser.LoadUrlParams; import org.chromium.content.browser.LoadUrlParams;
...@@ -51,6 +52,7 @@ public interface TabModelSelector { ...@@ -51,6 +52,7 @@ public interface TabModelSelector {
/** /**
* @return the model at {@code index} or null if no model exist for that index. * @return the model at {@code index} or null if no model exist for that index.
*/ */
@VisibleForTesting
TabModel getModelAt(int index); TabModel getModelAt(int index);
/** /**
......
...@@ -47,8 +47,6 @@ import android.view.inputmethod.InputConnection; ...@@ -47,8 +47,6 @@ import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import com.google.common.annotations.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
...@@ -56,6 +54,7 @@ import org.chromium.base.JNINamespace; ...@@ -56,6 +54,7 @@ import org.chromium.base.JNINamespace;
import org.chromium.base.ObserverList; import org.chromium.base.ObserverList;
import org.chromium.base.ObserverList.RewindableIterator; import org.chromium.base.ObserverList.RewindableIterator;
import org.chromium.base.TraceEvent; import org.chromium.base.TraceEvent;
import org.chromium.base.VisibleForTesting;
import org.chromium.content.R; import org.chromium.content.R;
import org.chromium.content.browser.ScreenOrientationListener.ScreenOrientationObserver; import org.chromium.content.browser.ScreenOrientationListener.ScreenOrientationObserver;
import org.chromium.content.browser.accessibility.AccessibilityInjector; import org.chromium.content.browser.accessibility.AccessibilityInjector;
...@@ -947,7 +946,9 @@ public class ContentViewCore ...@@ -947,7 +946,9 @@ public class ContentViewCore
public int getPhysicalBackingHeightPix() { return mPhysicalBackingHeightPix; } public int getPhysicalBackingHeightPix() { return mPhysicalBackingHeightPix; }
/* TODO(aelias): Remove these when downstream callers disappear. */ /* TODO(aelias): Remove these when downstream callers disappear. */
@VisibleForTesting
public int getViewportSizeOffsetWidthPix() { return 0; } public int getViewportSizeOffsetWidthPix() { return 0; }
@VisibleForTesting
public int getViewportSizeOffsetHeightPix() { return getTopControlsLayoutHeightPix(); } public int getViewportSizeOffsetHeightPix() { return getTopControlsLayoutHeightPix(); }
/** /**
...@@ -1000,6 +1001,7 @@ public class ContentViewCore ...@@ -1000,6 +1001,7 @@ public class ContentViewCore
* of bounds. * of bounds.
* @param offset The offset into the navigation history. * @param offset The offset into the navigation history.
*/ */
@VisibleForTesting
public void goToOffset(int offset) { public void goToOffset(int offset) {
if (mWebContents != null) mWebContents.getNavigationController().goToOffset(offset); if (mWebContents != null) mWebContents.getNavigationController().goToOffset(offset);
} }
...@@ -1421,6 +1423,7 @@ public class ContentViewCore ...@@ -1421,6 +1423,7 @@ public class ContentViewCore
* @return The ID of the renderer process that backs this tab or * @return The ID of the renderer process that backs this tab or
* {@link #INVALID_RENDER_PROCESS_PID} if there is none. * {@link #INVALID_RENDER_PROCESS_PID} if there is none.
*/ */
@VisibleForTesting
public int getCurrentRenderProcessId() { public int getCurrentRenderProcessId() {
return nativeGetCurrentRenderProcessId(mNativeContentViewCore); return nativeGetCurrentRenderProcessId(mNativeContentViewCore);
} }
...@@ -2385,14 +2388,17 @@ public class ContentViewCore ...@@ -2385,14 +2388,17 @@ public class ContentViewCore
private PopupTouchHandleDrawable createPopupTouchHandleDrawable() { private PopupTouchHandleDrawable createPopupTouchHandleDrawable() {
if (mTouchHandleDelegate == null) { if (mTouchHandleDelegate == null) {
mTouchHandleDelegate = new PopupTouchHandleDrawableDelegate() { mTouchHandleDelegate = new PopupTouchHandleDrawableDelegate() {
@Override
public View getParent() { public View getParent() {
return getContainerView(); return getContainerView();
} }
@Override
public PositionObserver getParentPositionObserver() { public PositionObserver getParentPositionObserver() {
return mPositionObserver; return mPositionObserver;
} }
@Override
public boolean onTouchHandleEvent(MotionEvent event) { public boolean onTouchHandleEvent(MotionEvent event) {
final boolean isTouchHandleEvent = true; final boolean isTouchHandleEvent = true;
return onTouchEventImpl(event, isTouchHandleEvent); return onTouchEventImpl(event, isTouchHandleEvent);
...@@ -2432,6 +2438,7 @@ public class ContentViewCore ...@@ -2432,6 +2438,7 @@ public class ContentViewCore
if (mPastePopupMenu == null) { if (mPastePopupMenu == null) {
mPastePopupMenu = new PastePopupMenu(getContainerView(), mPastePopupMenu = new PastePopupMenu(getContainerView(),
new PastePopupMenuDelegate() { new PastePopupMenuDelegate() {
@Override
public void paste() { public void paste() {
mImeAdapter.paste(); mImeAdapter.paste();
hideTextHandles(); hideTextHandles();
...@@ -2675,6 +2682,7 @@ public class ContentViewCore ...@@ -2675,6 +2682,7 @@ public class ContentViewCore
* Return the current scale of the ContentView. * Return the current scale of the ContentView.
* @return The current page scale factor. * @return The current page scale factor.
*/ */
@VisibleForTesting
public float getScale() { public float getScale() {
return mRenderCoordinates.getPageScaleFactor(); return mRenderCoordinates.getPageScaleFactor();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment