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