Java Code Examples for androidx.annotation.VisibleForTesting#PRIVATE

The following examples show how to use androidx.annotation.VisibleForTesting#PRIVATE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrickDataManager.java    From brickkit-android with Apache License 2.0 5 votes vote down vote up
/**
 * Deterimines if either the passed in param "paddingPosition" or the default value,
 * {@link #DEFAULT_BRICK_POSITION}, should be returned.
 *
 * @param paddingPosition used to compare with {@link #NO_PADDING_POSITION}
 * @return either the "paddingPosition" value or {@link #DEFAULT_BRICK_POSITION}
 */
@SuppressWarnings("WeakerAccess")
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
int getPaddingPositionOrDefault(int paddingPosition) {
    return NO_PADDING_POSITION == paddingPosition
            ? DEFAULT_BRICK_POSITION
            : paddingPosition;
}
 
Example 2
Source File: Pipeline.java    From talkback with Apache License 2.0 5 votes vote down vote up
/** Cancels all delayed feedback for group, at or below level. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected void cancelDelay(
    @InterruptGroup int group, @InterruptLevel int level, String senderName) {
  for (@InterruptLevel int l = 0; l <= level; l++) {
    feedbackDelayer.removeMessages(toMessageId(group, l));
    dumpInterruptLog(toMessageId(group, l), senderName);
  }
}
 
Example 3
Source File: Pipeline.java    From talkback with Apache License 2.0 5 votes vote down vote up
/** Delays feedback execution. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected void startDelay(EventId eventId, Feedback.Part feedback) {
  int messageId = toMessageId(feedback.interruptGroup(), feedback.interruptLevel());
  final Message message =
      feedbackDelayer.obtainMessage(messageId, new EventIdAnd<Feedback.Part>(feedback, eventId));
  feedbackDelayer.sendMessageDelayed(message, feedback.delayMs());
  messageIdToSenderName.put(messageId, feedback.senderName());
}
 
Example 4
Source File: AutoScrollActor.java    From talkback with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public int createScrollInstanceId() {
  int scrollInstanceId = nextScrollInstanceId;
  nextScrollInstanceId++;
  if (nextScrollInstanceId < 0) {
    nextScrollInstanceId = 0;
  }
  return scrollInstanceId;
}
 
Example 5
Source File: ParseTreeResourceNode.java    From talkback with Apache License 2.0 5 votes vote down vote up
/**
 * Creates CharSequence from template string by its parameters. The template string will be
 * transformed to contain "^1"-style placeholder values dynamically to match the format of
 * {@link TextUtils#expandTemplate(CharSequence, CharSequence...)} and formatted by other
 * none-string type parameters.
 *
 * @param templateString template string that may contains parameters with strings.
 * @param parameters object arrays that are supposed but not necessary to be string. If it is
 *     string, the corresponding placeholder value will be changed to "^1"-style. If not string
 *     type, the placeholder is kept and adjust the index.
 * @return CharSequence that composed by template string with "^1"-style placeholder values.
 */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected static CharSequence toExpandableTemplate(String templateString, Object[] parameters) {
  String expandTemplateString = templateString;
  List<Object> otherTypeList = new ArrayList<>();

  int spanTypeIndex = 1;
  int otherTypeIndex = 1;
  for (int i = 1; i <= parameters.length; i++) {
    Object param = parameters[i - 1];
    if (param instanceof CharSequence) {
      // replaces string type "%1$s" or "%s" to "^1" and so on.
      if (expandTemplateString.contains("%" + i + "$s")) {
        expandTemplateString =
            expandTemplateString.replace(("%" + i + "$s"), ("^" + spanTypeIndex));
      } else if (expandTemplateString.contains("%s")) {
        expandTemplateString = expandTemplateString.replaceFirst("%s", ("^" + spanTypeIndex));
      }
      spanTypeIndex++;
    } else {
      // keeps and assigns correct index to other type parameters
      expandTemplateString = expandTemplateString.replace(("%" + i), ("%" + otherTypeIndex));
      otherTypeList.add(param);
      otherTypeIndex++;
    }
  }
  return String.format(expandTemplateString, otherTypeList.toArray());
}
 
Example 6
Source File: BrickDataManager.java    From brickkit-android with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to tell manager to update the items returned from getRecyclerViewItems().
 */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void dataHasChanged() {
    dataHasChanged = true;
    for (BrickBehavior behavior : behaviors) {
        behavior.onDataSetChanged();
    }
}
 
Example 7
Source File: BrickDataManager.java    From brickkit-android with Apache License 2.0 5 votes vote down vote up
/**
 * Safely notifies of a range insertion.
 *
 * @param item         which was just inserted.
 * @param visibleCount the item count for the range
 */
@SuppressWarnings("WeakerAccess")
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void safeNotifyItemRangeInserted(@Nullable BaseBrick item, int visibleCount) {
    int adapterIndex = adapterIndex(item);
    if (adapterIndex != NO_INDEX) {
        brickRecyclerAdapter.safeNotifyItemRangeInserted(adapterIndex, visibleCount);
    }
}
 
Example 8
Source File: BrickDataManager.java    From brickkit-android with Apache License 2.0 5 votes vote down vote up
/**
 * Safely notifies of a single item insertion.
 *
 * @param item which was just inserted.
 */
@SuppressWarnings("WeakerAccess")
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void safeNotifyItemInserted(@Nullable BaseBrick item) {
    int adapterIndex = adapterIndex(item);
    if (adapterIndex != NO_INDEX) {
        brickRecyclerAdapter.safeNotifyItemInserted(adapterIndex);
    }
}
 
Example 9
Source File: GattServerCallback.java    From bitgatt with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Will return an error to the remote client with the error code (24)GATT_ERROR with the provided offset
 * and a zero data array
 *
 * @param conn      The gatt server connection
 * @param device    The bluetooth device
 * @param requestId The request id
 * @param offset    The offset
 */

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void returnErrorToRemoteClient(GattServerConnection conn, BluetoothDevice device, int requestId, int offset) {
    handler.post(() -> {
        try {
            conn.getServer().sendResponse(device, requestId, GattStatus.GATT_ERROR.getCode(), offset, new byte[0]);
        } catch (NullPointerException e) {
            Timber.w(e, "[%s] Looks like BluetoothGattServer#sendResponse(...) can run into the unboxing bug also.  No response sent, peripheral may disconnect.", getDeviceMacFromDevice(device));
        }
    });
}
 
Example 10
Source File: SectionTree.java    From litho with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public static synchronized Looper getDefaultChangeSetThreadLooper() {
  if (sDefaultChangeSetThreadLooper == null) {
    HandlerThread defaultThread =
        new HandlerThread(
            DEFAULT_CHANGESET_THREAD_NAME,
            ComponentsConfiguration.DEFAULT_CHANGE_SET_THREAD_PRIORITY);
    defaultThread.start();
    sDefaultChangeSetThreadLooper = defaultThread.getLooper();
  }

  return sDefaultChangeSetThreadLooper;
}
 
Example 11
Source File: Change.java    From litho with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public Change(
    @Type int ct,
    int index,
    int toIndex,
    int count,
    @Nullable RenderInfo renderInfo,
    @Nullable List<RenderInfo> renderInfos,
    @Nullable List<?> prevData,
    @Nullable List<?> nextData) {
  mType = ct;
  mIndex = index;
  mToIndex = toIndex;
  mCount = count;
  mRenderInfo = renderInfo == null ? ComponentRenderInfo.createEmpty() : renderInfo;

  if (renderInfos == null) {
    mRenderInfos = EMPTY;
  } else {
    int size = renderInfos.size();
    mRenderInfos = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
      final RenderInfo renderInfoTemp = renderInfos.get(i);
      mRenderInfos.add(
          renderInfoTemp == null ? ComponentRenderInfo.createEmpty() : renderInfoTemp);
    }
  }

  if (prevData != null) {
    mPrevData = Collections.unmodifiableList(prevData);
  }
  if (nextData != null) {
    mNextData = Collections.unmodifiableList(nextData);
  }
}
 
Example 12
Source File: StickyHeaderControllerImpl.java    From litho with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
int findStickyHeaderPosition(int currentFirstVisiblePosition) {
  for (int i = currentFirstVisiblePosition; i >= 0; i--) {
    if (mHasStickyHeader.isSticky(i)) {
      return i;
    }
  }
  return RecyclerView.NO_POSITION;
}
 
Example 13
Source File: LithoView.java    From litho with Apache License 2.0 5 votes vote down vote up
@DoNotStrip
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
Deque<TestItem> findTestItems(String testKey) {
  if (mUseExtensions && mLithoHostListenerCoordinator != null) {
    if (mLithoHostListenerCoordinator.getEndToEndTestingExtension() == null) {
      throw new IllegalStateException(
          "Trying to access TestItems while "
              + "ComponentsConfiguration.isEndToEndTestRun is false.");
    }

    return mLithoHostListenerCoordinator.getEndToEndTestingExtension().findTestItems(testKey);
  } else {
    return mMountState.findTestItems(testKey);
  }
}
 
Example 14
Source File: EndToEndTestingExtension.java    From litho with Apache License 2.0 5 votes vote down vote up
/** @see LithoViewTestHelper#findTestItems(LithoView, String) */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
Deque<TestItem> findTestItems(String testKey) {
  if (mTestItemMap == null) {
    throw new UnsupportedOperationException(
        "Trying to access TestItems while "
            + "ComponentsConfiguration.isEndToEndTestRun is false.");
  }

  final Deque<TestItem> items = mTestItemMap.get(testKey);
  return items == null ? new LinkedList<TestItem>() : items;
}
 
Example 15
Source File: MountState.java    From litho with Apache License 2.0 5 votes vote down vote up
/** @see LithoViewTestHelper#findTestItems(LithoView, String) */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
Deque<TestItem> findTestItems(String testKey) {
  if (mTestItemMap == null) {
    throw new UnsupportedOperationException(
        "Trying to access TestItems while "
            + "ComponentsConfiguration.isEndToEndTestRun is false.");
  }

  final Deque<TestItem> items = mTestItemMap.get(testKey);
  return items == null ? new LinkedList<TestItem>() : items;
}
 
Example 16
Source File: Pipeline.java    From talkback with Apache License 2.0 4 votes vote down vote up
/** Checks whether a delay exists for a given group and level. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected boolean delayExists(@InterruptGroup int group, @InterruptLevel int level) {
  return feedbackDelayer.hasMessages(toMessageId(group, level));
}
 
Example 17
Source File: Pipeline.java    From talkback with Apache License 2.0 4 votes vote down vote up
/** Allows tests to advance the handler time. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected Looper getDelayLooper() {
  return feedbackDelayer.getLooper();
}
 
Example 18
Source File: LithoView.java    From litho with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public void onAttachedToWindowForTest() {
  onAttachedToWindow();
}
 
Example 19
Source File: Pipeline.java    From talkback with Apache License 2.0 4 votes vote down vote up
/** Returns a unique result combining group and level. */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected static int toMessageId(@InterruptGroup int group, @InterruptLevel int level) {
  return (group * GROUP_DIGIT) + level;
}
 
Example 20
Source File: Component.java    From litho with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
InternalNode getLayoutCreatedInWillRenderForTesting() {
  return mLayoutCreatedInWillRender;
}