类androidx.annotation.VisibleForTesting源码实例Demo

下面列出了怎么用androidx.annotation.VisibleForTesting的API类实例代码及写法,或者点击链接到github查看源代码。

@VisibleForTesting public void handlePromotionsClick() {
  view.getLifecycleEvent()
      .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE))
      .flatMap(created -> view.toolbarPromotionsClick()
          .observeOn(viewScheduler)
          .doOnNext(account -> {
            homeAnalytics.sendPromotionsIconClickEvent();
            homeNavigator.navigateToPromotions();
          })
          .retry())
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(__ -> {
      }, throwable -> {
        throw new OnErrorNotImplementedException(throwable);
      });
}
 
@VisibleForTesting public void handleLoggedInAcceptTermsAndConditions() {
  view.getLifecycleEvent()
      .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE))
      .flatMap(__ -> accountManager.accountStatus()
          .first())
      .filter(Account::isLoggedIn)
      .filter(
          account -> !(account.acceptedPrivacyPolicy() && account.acceptedTermsAndConditions()))
      .observeOn(viewScheduler)
      .doOnNext(__ -> view.showTermsAndConditionsDialog())
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(__ -> {
      }, throwable -> {
        throw new OnErrorNotImplementedException(throwable);
      });
}
 
@VisibleForTesting public void handleClickOnPromotionsDialogContinue() {
  view.getLifecycleEvent()
      .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE))
      .flatMap(__ -> view.promotionsHomeDialogClicked())
      .filter(action -> action.equals("navigate"))
      .doOnNext(__ -> {
        homeAnalytics.sendPromotionsDialogNavigateEvent();
        view.dismissPromotionsDialog();
        homeNavigator.navigateToPromotions();
      })
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(__ -> {
      }, throwable -> {
        throw new OnErrorNotImplementedException(throwable);
      });
}
 
源代码4 项目: science-journal   文件: ChartData.java
@VisibleForTesting
boolean tryAddingLabel(Label label) {
  long timestamp = label.getTimeStamp();
  if (data.isEmpty() || timestamp < getXMin() || timestamp > getXMax()) {
    return false;
  }
  int indexPrev = exactBinarySearch(timestamp, 0);
  DataPoint start = data.get(indexPrev);
  if (timestamp == start.getX()) {
    labels.add(start);
    return true;
  } else if (indexPrev < data.size() - 2) {
    DataPoint end = data.get(indexPrev + 1);
    double weight = (timestamp - start.getX()) / (1.0 * end.getX() - start.getX());
    labels.add(new DataPoint(timestamp, start.getY() * weight + end.getY() * (1 - weight)));
    return true;
  }
  return false;
}
 
源代码5 项目: litho   文件: Section.java
@VisibleForTesting
public String generateUniqueGlobalKeyForChild(Section section, String childKey) {
  final KeyHandler keyHandler = mScopedContext.getKeyHandler();

  /** If the key is already unique, return it. */
  if (!keyHandler.hasKey(childKey)) {
    return childKey;
  }

  final String childType = section.getSimpleName();

  if (mChildCounters == null) {
    mChildCounters = new HashMap<>();
  }

  /**
   * If the key is a duplicate, we start appending an index based on the child component's type
   * that would uniquely identify it.
   */
  final int childIndex =
      mChildCounters.containsKey(childType) ? mChildCounters.get(childType) : 0;
  mChildCounters.put(childType, childIndex + 1);

  return childKey + childIndex;
}
 
源代码6 项目: science-journal   文件: ChartController.java
@VisibleForTesting
public ChartController(
    ChartOptions.ChartPlacementType chartPlacementType,
    ScalarDisplayOptions scalarDisplayOptions,
    int chartDataThrowawayThreshold,
    long dataLoadBuffer,
    Clock uptimeClock,
    FailureListener dataFailureListener) {
  this.uptimeClock = uptimeClock;
  chartData =
      new ChartData(chartDataThrowawayThreshold, ChartData.DEFAULT_THROWAWAY_TIME_THRESHOLD);
  chartOptions = new ChartOptions(chartPlacementType);
  chartOptions.setScalarDisplayOptions(scalarDisplayOptions);
  this.dataFailureListener = dataFailureListener;
  defaultGraphRange = ExternalAxisController.DEFAULT_GRAPH_RANGE_IN_MILLIS;
  this.dataLoadBuffer = dataLoadBuffer;
  currentTimeClock = new CurrentTimeClock();
}
 
源代码7 项目: bitgatt   文件: FitbitGatt.java
@VisibleForTesting
void connectToScannedDevice(FitbitBluetoothDevice fitDevice, boolean shouldMock, GattTransactionCallback callback) {
    GattConnection conn = connectionMap.get(fitDevice);
    if (conn == null) {
        if (appContext == null) {
            Timber.w("[%s] Bitgatt client must not be started, please start bitgatt client", fitDevice);
            return;
        }
        conn = new GattConnection(fitDevice, appContext.getMainLooper());
        connectionMap.put(fitDevice, conn);
        notifyListenersOfConnectionAdded(conn);
    }
    conn.setMockMode(shouldMock);
    if (!conn.isConnected()) {
        GattConnectTransaction tx = new GattConnectTransaction(conn, GattState.CONNECTED);
        conn.runTx(tx, callback);
    } else {
        TransactionResult.Builder builder = new TransactionResult.Builder();
        builder.resultStatus(TransactionResult.TransactionResultStatus.SUCCESS)
            .gattState(conn.getGattState());
        callback.onTransactionComplete(builder.build());
    }
}
 
源代码8 项目: aptoide-client-v8   文件: HomePresenter.java
@VisibleForTesting public void handleKnowMoreClick() {
  view.getLifecycleEvent()
      .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE))
      .flatMap(created -> view.infoBundleKnowMoreClicked())
      .observeOn(viewScheduler)
      .doOnNext(homeEvent -> {
        homeAnalytics.sendActionItemTapOnCardInteractEvent(homeEvent.getBundle()
            .getTag(), homeEvent.getBundlePosition());
        homeNavigator.navigateToAppCoinsInformationView();
      })
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(lifecycleEvent -> {
      }, throwable -> {
        throw new OnErrorNotImplementedException(throwable);
      });
}
 
@VisibleForTesting public void loadMainHomeContent() {
  view.getLifecycleEvent()
      .filter(event -> event.equals(View.LifecycleEvent.CREATE))
      .flatMap(__ -> view.isChipChecked())
      .doOnNext(checked -> {
        switch (checked) {
          case GAMES:
            homeContainerNavigator.loadGamesHomeContent();
            break;
          case APPS:
            homeContainerNavigator.loadAppsHomeContent();
            break;
          default:
            homeContainerNavigator.loadMainHomeContent();
            break;
        }
      })
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(__ -> {
      }, err -> {
        throw new OnErrorNotImplementedException(err);
      });
}
 
源代码10 项目: science-journal   文件: SimpleMetaDataManager.java
@VisibleForTesting
@Deprecated
void updateProject(Project project) {
  synchronized (lock) {
    final SQLiteDatabase db = dbHelper.getWritableDatabase();
    final ContentValues values = new ContentValues();
    values.put(ProjectColumns.TITLE, project.getTitle());
    values.put(ProjectColumns.DESCRIPTION, project.getDescription());
    values.put(ProjectColumns.COVER_PHOTO, project.getCoverPhoto());
    values.put(ProjectColumns.ARCHIVED, project.isArchived());
    values.put(ProjectColumns.LAST_USED_TIME, project.getLastUsedTime());
    db.update(
        Tables.PROJECTS,
        values,
        ProjectColumns.PROJECT_ID + "=?",
        new String[] {project.getProjectId()});
  }
}
 
@VisibleForTesting
public TimestampPickerController(
    Locale locale,
    boolean isStartCrop,
    String negativePrefix,
    String hourMinuteDivider,
    String minuteSecondDivider,
    OnTimestampErrorListener errorListener) {
  this.locale = locale;
  this.isStartCrop = isStartCrop;
  this.errorListener = errorListener;
  this.negativePrefix = negativePrefix;
  // Builds the formatter, which will be used to read and write timestamp strings.
  periodFormatter =
      new PeriodFormatterBuilder()
          .rejectSignedValues(true) // Applies to all fields
          .printZeroAlways() // Applies to all fields
          .appendHours()
          .appendLiteral(hourMinuteDivider)
          .minimumPrintedDigits(2) // Applies to minutes and seconds
          .appendMinutes()
          .appendLiteral(minuteSecondDivider)
          .appendSecondsWithMillis()
          .toFormatter()
          .withLocale(this.locale);
}
 
源代码12 项目: android-test   文件: AndroidTestOrchestrator.java
@VisibleForTesting
static String addTestCoverageSupport(Bundle args, String filename) {
  // Only do the aggregate coverage mode if coverage was requested AND we're running in isolation
  // mode.
  // If not running in isolation, the AJUR coverage mechanism of dumping coverage data to a
  // single file is sufficient since all test run in the same invocation.
  if (shouldRunCoverage(args) && runsInIsolatedMode(args)) {
    checkState(
        args.getString(AJUR_COVERAGE_FILE) == null,
        "Can't use a custom coverage file name [-e %s %s] when running through "
            + "orchestrator in isolated mode, since the generated coverage files will "
            + "overwrite each other. Please consider using [%s] instead.",
        AJUR_COVERAGE_FILE,
        args.getString(AJUR_COVERAGE_FILE),
        COVERAGE_FILE_PATH);

    String path = args.getString(COVERAGE_FILE_PATH);
    return path + filename + ".ec";
  }
  return null;
}
 
源代码13 项目: aptoide-client-v8   文件: HomeContainerPresenter.java
@VisibleForTesting public void loadUserImage() {
  view.getLifecycleEvent()
      .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE))
      .flatMap(created -> accountManager.accountStatus())
      .flatMap(account -> getUserAvatar(account))
      .observeOn(viewScheduler)
      .doOnNext(userAvatarUrl -> {
        if (userAvatarUrl != null) {
          view.setUserImage(userAvatarUrl);
        } else {
          view.setDefaultUserImage();
        }
        view.showAvatar();
      })
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(__ -> {
      }, throwable -> {
        throw new OnErrorNotImplementedException(throwable);
      });
}
 
@VisibleForTesting
public FirebaseDynamicLinksImpl(
    GoogleApi<NoOptions> googleApi, @Nullable AnalyticsConnector analytics) {
  this.googleApi = googleApi;
  this.analytics = analytics;

  if (analytics == null) {
    // b/34217790: Try to get an instance of Analytics. This initializes Google Analytics
    // if it is set up for the app, which sets up the association for the app and package name,
    // allowing GmsCore to log FDL events on behalf of the app.

    // AppMeasurement was not found. This probably means that the app did not include
    // the FirebaseAnalytics dependency.
    Log.w(
        TAG,
        "FDL logging failed. Add a dependency for Firebase Analytics"
            + " to your app to enable logging of Dynamic Link events.");
  }
}
 
@VisibleForTesting
void resetKeymap() {
  TalkBackKeyboardShortcutPreferenceFragment fragment =
      (TalkBackKeyboardShortcutPreferenceFragment)
          getFragmentManager().findFragmentById(android.R.id.content);
  fragment.resetKeymap();
}
 
源代码16 项目: aptoide-client-v8   文件: MyAccountPresenter.java
@VisibleForTesting public void handleProfileEditClick() {
  view.getLifecycleEvent()
      .filter(event -> event.equals(View.LifecycleEvent.CREATE))
      .flatMap(viewCreated -> view.editUserProfileClick()
          .flatMap(click -> accountManager.accountStatus()
              .first())
          .doOnNext(account -> myAccountNavigator.navigateToEditProfileView()))
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(account -> {
      }, throwable -> crashReport.log(throwable));
}
 
源代码17 项目: aptoide-client-v8   文件: EditorialListPresenter.java
@VisibleForTesting public void handleReactionButtonClick() {
  view.getLifecycleEvent()
      .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE))
      .flatMap(created -> view.reactionsButtonClicked())
      .observeOn(viewScheduler)
      .flatMap(this::handleSinglePressReactionButton)
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(lifecycleEvent -> {
      }, crashReporter::log);
}
 
源代码18 项目: xipl   文件: EpgSyncJobService.java
@VisibleForTesting
public static Intent createSyncStartedIntent(String inputId) {
    Intent intent = new Intent(ACTION_SYNC_STATUS_CHANGED);
    intent.putExtra(BUNDLE_KEY_INPUT_ID, inputId);
    intent.putExtra(SYNC_STATUS, SYNC_STARTED);
    return intent;
}
 
源代码19 项目: ETSMobile-Android2   文件: MoodleViewModel.java
/**
 * Filter courses by removing the courses with no assignment
 *
 * @param assignmentCourses
 * @return filtered courses
 */
@VisibleForTesting
List<MoodleAssignmentCourse> filterAssignmentCourses(List<MoodleAssignmentCourse> assignmentCourses) {
    List<MoodleAssignmentCourse> filteredCourses = new ArrayList<>();

    for (MoodleAssignmentCourse course : assignmentCourses) {

        int nbAssignments = course.getAssignments().size();

        if (nbAssignments != 0) {
            /*
             Si les devoirs antérieurs ne doivent pas être affichés, ceux-ci ne doivent pas être
             pris en compte.
             */
            if (!isDisplayPastAssignments()) {
                for (MoodleAssignment assignment : course.getAssignments()) {
                    Date dueDate = assignment.getDueDateObj();
                    Date currentDate = new Date();
                    if (dueDate.before(currentDate))
                        nbAssignments--;
                }
            }

            // Ajout du cours si celui-ci contient des devoirs
            if (nbAssignments != 0)
                filteredCourses.add(course);
        }
    }

    return filteredCourses;
}
 
源代码20 项目: talkback   文件: ParseTreeResourceNode.java
/**
 * 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());
}
 
源代码21 项目: aptoide-client-v8   文件: HomeContainerPresenter.java
@VisibleForTesting public void handleTermsAndConditionsLogOutClicked() {
  view.getLifecycleEvent()
      .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE))
      .flatMap(__ -> view.gdprDialogClicked())
      .filter(action -> action.equals("logout"))
      .flatMapCompletable(__ -> accountManager.logout())
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(__ -> {
      }, throwable -> {
        throw new OnErrorNotImplementedException(throwable);
      });
}
 
源代码22 项目: science-journal   文件: SimpleMetaDataManager.java
@VisibleForTesting
List<ExperimentOverviewPojo> getDatabaseExperimentOverviews(boolean includeArchived) {
  List<ExperimentOverviewPojo> experiments = new ArrayList<>();
  synchronized (lock) {
    final SQLiteDatabase db = dbHelper.getReadableDatabase();

    String selection = "";
    if (!includeArchived) {
      selection = ExperimentColumns.ARCHIVED + "=0";
    }
    Cursor cursor = null;
    try {
      cursor =
          db.query(
              Tables.EXPERIMENTS,
              ExperimentColumns.GET_COLUMNS,
              selection,
              null,
              null,
              null,
              ExperimentColumns.LAST_USED_TIME + " DESC, " + BaseColumns._ID + " DESC");
      while (cursor.moveToNext()) {
        experiments.add(createExperimentOverviewFromCursor(cursor));
      }
    } finally {
      if (cursor != null) {
        cursor.close();
      }
    }
  }
  return experiments;
}
 
源代码23 项目: Leanplum-Android-SDK   文件: Leanplum.java
@VisibleForTesting
public static Map<String, String> parseFilenameToURLs(JSONObject response) {
  JSONObject filesObject = response.optJSONObject(
          Constants.Keys.FILES);
  if (filesObject != null) {
    return JsonConverter.mapFromJson(filesObject);
  }
  return null;
}
 
源代码24 项目: aptoide-client-v8   文件: EditorialListPresenter.java
@VisibleForTesting public void onCreateLoadViewModel() {
  view.getLifecycleEvent()
      .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE))
      .doOnNext(created -> view.showLoading())
      .flatMap(__ -> loadEditorialAndReactions(false, false))
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(__ -> {
      }, crashReporter::log);
}
 
源代码25 项目: litho   文件: TestItem.java
@DoNotStrip
@VisibleForTesting
public String getTextContent() {
  final List<CharSequence> textItems = getTextItems();
  final StringBuilder sb = new StringBuilder();
  for (int i = 0, size = textItems.size(); i < size; i++) {
    sb.append(textItems.get(i));
  }

  return sb.toString();
}
 
源代码26 项目: edx-app-android   文件: UserProfileFragment.java
@NonNull
@VisibleForTesting
public static Bundle createArguments(@NonNull String username) {
    final Bundle bundle = new Bundle();
    bundle.putString(UserProfileActivity.EXTRA_USERNAME, username);
    return bundle;
}
 
源代码27 项目: LiTr   文件: TransformationJob.java
@VisibleForTesting
void initStatsCollector() {
    // TODO modify TrackTransformationInfo to report muxing/demuxing and different media sources/targets
    for (TrackTransform trackTransform : trackTransforms) {
        statsCollector.addSourceTrack(trackTransform.getMediaSource().getTrackFormat(trackTransform.getSourceTrack()));
    }
}
 
源代码28 项目: aptoide-client-v8   文件: EditorialPresenter.java
@VisibleForTesting public void handleLongPressReactionButton() {
  view.getLifecycleEvent()
      .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE))
      .flatMap(created -> view.reactionsButtonLongPressed())
      .flatMap(click -> editorialManager.loadEditorialViewModel()
          .toObservable())
      .doOnNext(editorialViewModel -> {
        editorialAnalytics.sendReactionButtonClickEvent();
        view.showReactionsPopup(editorialViewModel.getCardId(), editorialViewModel.getGroupId());
      })
      .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY))
      .subscribe(lifecycleEvent -> {
      }, crashReporter::log);
}
 
源代码29 项目: science-journal   文件: ExperimentCache.java
@VisibleForTesting
ExperimentCache(
    Context context,
    AppAccount appAccount,
    FailureListener failureListener,
    boolean enableAutoWrite) {
  this(
      context,
      appAccount,
      failureListener,
      enableAutoWrite,
      AppSingleton.getInstance(context).getExperimentLibraryManager(appAccount),
      AppSingleton.getInstance(context).getLocalSyncManager(appAccount));
}
 
源代码30 项目: AppAuth-Android   文件: TokenResponse.java
/**
 * Sets the relative expiration time of the access token, in seconds, using the provided
 * clock as the source of the current time.
 */
@NonNull
@VisibleForTesting
Builder setAccessTokenExpiresIn(@Nullable Long expiresIn, @NonNull Clock clock) {
    if (expiresIn == null) {
        mAccessTokenExpirationTime = null;
    } else {
        mAccessTokenExpirationTime = clock.getCurrentTimeMillis()
                + TimeUnit.SECONDS.toMillis(expiresIn);
    }
    return this;
}