本文整理匯總了Java中android.support.annotation.VisibleForTesting類的典型用法代碼示例。如果您正苦於以下問題:Java VisibleForTesting類的具體用法?Java VisibleForTesting怎麽用?Java VisibleForTesting使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VisibleForTesting類屬於android.support.annotation包,在下文中一共展示了VisibleForTesting類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSingletonSetterMethod
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
private MethodSpec getSingletonSetterMethod(ClassName className, FieldSpec singletonField) {
ParameterSpec parameter = ParameterSpec
.builder(className, "wrapper")
.build();
AnnotationSpec visibleForTesting = AnnotationSpec
.builder(VisibleForTesting.class)
.addMember("otherwise", "VisibleForTesting.NONE")
.build();
return MethodSpec
.methodBuilder("setInstance")
.addAnnotation(visibleForTesting)
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.addParameter(parameter)
.addStatement("$N = $N", singletonField, parameter)
.build();
}
示例2: run
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
MessagingController(Context context, NotificationController notificationController,
Contacts contacts, TransportProvider transportProvider) {
this.context = context;
this.notificationController = notificationController;
this.contacts = contacts;
this.transportProvider = transportProvider;
controllerThread = new Thread(new Runnable() {
@Override
public void run() {
runInBackground();
}
});
controllerThread.setName("MessagingController");
controllerThread.start();
addListener(memorizingMessagingListener);
}
示例3: getAllFields
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
/**
* Returns all fields from the given class, including its superclass fields. If cached fields are available, they will be used; instead, a new list will
* be saved to the cache.
*
* @param classInstance Which class to look into
* @return A list of declared class' fields. Do not modify this instance
*/
@NonNull
@VisibleForTesting
static List<Field> getAllFields(@NonNull final Class<?> classInstance) {
Class<?> parsedClass = classInstance;
final String name = parsedClass.getName();
List<Field> allFields = FIELD_CACHE.get(name);
if (allFields == null || allFields.isEmpty()) {
allFields = new LinkedList<>();
while (parsedClass != null && parsedClass != Object.class) {
allFields.addAll(Arrays.asList(parsedClass.getDeclaredFields()));
parsedClass = parsedClass.getSuperclass();
}
FIELD_CACHE.put(name, allFields);
}
return allFields;
}
示例4: updateAttachmentThumbnail
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
protected void updateAttachmentThumbnail(MasterSecret masterSecret, AttachmentId attachmentId, InputStream in, float aspectRatio)
throws MmsException
{
Log.w(TAG, "updating part thumbnail for #" + attachmentId);
Pair<File, Long> thumbnailFile = setAttachmentData(masterSecret, in);
SQLiteDatabase database = databaseHelper.getWritableDatabase();
ContentValues values = new ContentValues(2);
values.put(THUMBNAIL, thumbnailFile.first.getAbsolutePath());
values.put(THUMBNAIL_ASPECT_RATIO, aspectRatio);
database.update(TABLE_NAME, values, PART_ID_WHERE, attachmentId.toStrings());
Cursor cursor = database.query(TABLE_NAME, new String[] {MMS_ID}, PART_ID_WHERE, attachmentId.toStrings(), null, null, null);
try {
if (cursor != null && cursor.moveToFirst()) {
notifyConversationListeners(DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(cursor.getLong(cursor.getColumnIndexOrThrow(MMS_ID))));
}
} finally {
if (cursor != null) cursor.close();
}
}
示例5: checkConnection
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
void checkConnection(Connection target) {
switch (canConnectWithReason(target)) {
case CAN_CONNECT:
break;
case REASON_SELF_CONNECTION:
throw new IllegalArgumentException("Cannot connect a block to itself.");
case REASON_WRONG_TYPE:
throw new IllegalArgumentException("Cannot connect these types.");
case REASON_MUST_DISCONNECT:
throw new IllegalStateException(
"Must disconnect from current block before connecting to a new one.");
case REASON_TARGET_NULL:
throw new IllegalArgumentException("Cannot connect to a null connection/block");
case REASON_CHECKS_FAILED:
throw new IllegalArgumentException("Cannot connect, checks do not match.");
default:
throw new IllegalArgumentException(
"Unknown connection failure, this should never happen!");
}
}
示例6: setupCaptureRequestForPreview
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
/**
* does setup the repeating capture request for taking images for the preview
*/
@VisibleForTesting
void setupCaptureRequestForPreview(@NonNull CameraCaptureSession previewSession, @NonNull CameraDevice camera,
@NonNull List<Surface> surfaces) {
try {
CaptureRequest.Builder previewRequestBuilder = camera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
for (Surface surface : surfaces) {
previewRequestBuilder.addTarget(surface);
}
previewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
previewSession.setRepeatingRequest(previewRequestBuilder.build(), null, null);
} catch (CameraAccessException | IllegalStateException e) {
throw new CameraException(e);
}
}
示例7: configureTextureView
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
/**
* configures the ProportionalTextureView to respect the aspect ratio of the image and using an appropriate buffer size
*/
@VisibleForTesting
void configureTextureView(@NonNull ProportionalTextureView textureView, @ConfigurationOrientation int deviceOrientation,
@SurfaceRotation int relativeDisplayRotation, @NonNull Size previewSize) {
switch (deviceOrientation) {
case Configuration.ORIENTATION_PORTRAIT:
// swap values because preview sizes are always landscape
textureView.setAspectRatio(previewSize.getHeight(), previewSize.getWidth(), relativeDisplayRotation);
break;
case Configuration.ORIENTATION_LANDSCAPE:
textureView.setAspectRatio(previewSize.getWidth(), previewSize.getHeight(), relativeDisplayRotation);
break;
}
// working more memory efficient
SurfaceTexture surface = textureView.getSurfaceTexture();
if (surface != null) {
surface.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
} else {
throw new CameraException("surface texture not attached to view");
}
}
示例8: getContextFactory
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
/**
* @return The Context factory which has to be used on android.
*/
@VisibleForTesting
public AndroidContextFactory getContextFactory() {
AndroidContextFactory factory;
if (!ContextFactory.hasExplicitGlobal()) {
factory = new AndroidContextFactory(cacheDirectory);
ContextFactory.getGlobalSetter().setContextFactoryGlobal(factory);
} else if (!(ContextFactory.getGlobal() instanceof AndroidContextFactory)) {
throw new IllegalStateException("Cannot initialize factory for Android Rhino: There is already another factory");
} else {
factory = (AndroidContextFactory) ContextFactory.getGlobal();
}
return factory;
}
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:17,代碼來源:RhinoAndroidHelper.java
示例9: super
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOperations, AutocryptOpenPgpApiInteractor autocryptOpenPgpApiInteractor) {
super(context, messageIdGenerator, boundaryGenerator);
this.autocryptOperations = autocryptOperations;
this.autocryptOpenPgpApiInteractor = autocryptOpenPgpApiInteractor;
}
示例10: addTransitionToStaggeredTransition
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
final void addTransitionToStaggeredTransition(Transition basePartialTransition,
TransitionSet staggeredTransition,
int viewId, int indexInTransition) {
Transition partialTransition =
applyStaggeredTransitionParams(basePartialTransition, viewId, indexInTransition);
staggeredTransition.addTransition(partialTransition);
}
示例11: findSelected
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
@NonNull
Page findSelected(List<Page> visible) {
final String selectedPageId = selectedPageStorage.getSelectedPage();
for (Page page : visible) {
if (ObjectUtil.equals(selectedPageId, page.getId())) {
return page;
}
}
return visible.get(0);
}
示例12: ofArgb
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
static ViewPagerAnimator<Integer> ofArgb(ViewPager viewPager,
Provider<Integer> provider,
Property<Integer> property,
TypeEvaluator<Integer> evaluator,
Interpolator interpolator) {
return new ViewPagerAnimator<>(viewPager, provider, property, evaluator, interpolator);
}
示例13: readValue
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
static long readValue(byte[] buff) {
long res = 0;
for (int i = 0; i < buff.length; i++) {
res |= ((long) (buff[i] & 0xFF)) << ((buff.length - i - 1) * 8);
}
return res;
}
示例14: isPartPgpInlineEncryptedOrSigned
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
static boolean isPartPgpInlineEncryptedOrSigned(Part part) {
if (!part.isMimeType(TEXT_PLAIN) && !part.isMimeType(APPLICATION_PGP)) {
return false;
}
String text = MessageExtractor.getTextFromPart(part, TEXT_LENGTH_FOR_INLINE_CHECK);
if (TextUtils.isEmpty(text)) {
return false;
}
text = text.trim();
return text.startsWith(PGP_INLINE_START_MARKER) || text.startsWith(PGP_INLINE_SIGNED_START_MARKER);
}
示例15: buildUserAgentString
import android.support.annotation.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting static String buildUserAgentString(final Context context, final AmazonWebSettings settings, final String appName) {
final StringBuilder uaBuilder = new StringBuilder();
uaBuilder.append("Mozilla/5.0");
// WebView by default includes "; wv" as part of the platform string, but we're a full browser
// so we shouldn't include that.
// Most webview based browsers (and chrome), include the device name AND build ID, e.g.
// "Pixel XL Build/NOF26V", that seems unnecessary (and not great from a privacy perspective),
// so we skip that too.
uaBuilder.append(" (Linux; Android ").append(Build.VERSION.RELEASE).append(") ");
final String existingWebViewUA = settings.getUserAgentString();
final String appVersion;
try {
appVersion = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
// This should be impossible - we should always be able to get information about ourselves:
throw new IllegalStateException("Unable find package details for Focus", e);
}
final String focusToken = appName + "/" + appVersion;
uaBuilder.append(getUABrowserString(existingWebViewUA, focusToken));
return uaBuilder.toString();
}