androidx.annotation.VisibleForTesting Java Examples
The following examples show how to use
androidx.annotation.VisibleForTesting.
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: FirebaseDynamicLinksImpl.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
@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."); } }
Example #2
Source File: ChartData.java From science-journal with Apache License 2.0 | 6 votes |
@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; }
Example #3
Source File: Section.java From litho with Apache License 2.0 | 6 votes |
@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; }
Example #4
Source File: HomeContainerPresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@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); }); }
Example #5
Source File: HomeContainerPresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@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); }); }
Example #6
Source File: HomeContainerPresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@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); }); }
Example #7
Source File: ChartController.java From science-journal with Apache License 2.0 | 6 votes |
@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(); }
Example #8
Source File: FitbitGatt.java From bitgatt with Mozilla Public License 2.0 | 6 votes |
@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()); } }
Example #9
Source File: HomePresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@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); }); }
Example #10
Source File: HomeContainerPresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@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); }); }
Example #11
Source File: SimpleMetaDataManager.java From science-journal with Apache License 2.0 | 6 votes |
@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()}); } }
Example #12
Source File: TimestampPickerController.java From science-journal with Apache License 2.0 | 6 votes |
@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); }
Example #13
Source File: AndroidTestOrchestrator.java From android-test with Apache License 2.0 | 6 votes |
@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; }
Example #14
Source File: HomeContainerPresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@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); }); }
Example #15
Source File: SearchResultPresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@VisibleForTesting public void listenToSearchQueries() { view.getLifecycleEvent() .filter(event -> event == View.LifecycleEvent.RESUME) .flatMap(__ -> view.searchSetup()) .first() .flatMap(__ -> view.queryChanged()) .doOnNext(event -> view.queryEvent(event)) .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY)) .subscribe(__ -> { }, e -> crashReport.log(e)); }
Example #16
Source File: SearchResultPresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@VisibleForTesting public void handleToolbarClick() { view.getLifecycleEvent() .filter(event -> event == View.LifecycleEvent.CREATE) .flatMap(__ -> view.toolbarClick()) .doOnNext(__ -> { if (!view.shouldFocusInSearchBar()) { analytics.searchStart(SearchSource.SEARCH_TOOLBAR, true); } }) .doOnNext(__ -> view.focusInSearchBar()) .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY)) .subscribe(__ -> { }, err -> crashReport.log(err)); }
Example #17
Source File: BrickDataManager.java From brickkit-android with Apache License 2.0 | 5 votes |
/** * 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 #18
Source File: BleSensorSpec.java From science-journal with Apache License 2.0 | 5 votes |
@VisibleForTesting public void loadFromConfig(byte[] data) { try { config = new BleSensorConfigPojo(BleSensorConfig.parseFrom(data)); } catch (InvalidProtocolBufferException e) { Log.e(TAG, "Could not deserialize config", e); throw new IllegalStateException(e); } }
Example #19
Source File: SimpleMetaDataManager.java From science-journal with Apache License 2.0 | 5 votes |
@VisibleForTesting public void databaseAddMyDevice(InputDeviceSpec deviceSpec) { String deviceId = addOrGetExternalSensor(deviceSpec, InputDeviceSpec.PROVIDER_MAP); ContentValues values = new ContentValues(); values.put(MyDevicesColumns.DEVICE_ID, deviceId); synchronized (lock) { final SQLiteDatabase db = dbHelper.getWritableDatabase(); db.insert(Tables.MY_DEVICES, null, values); } }
Example #20
Source File: LithoView.java From litho with Apache License 2.0 | 5 votes |
@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 #21
Source File: GattConnection.java From bitgatt with Mozilla Public License 2.0 | 5 votes |
@VisibleForTesting(otherwise = VisibleForTesting.NONE) public void simulateDisconnect() { if (this.mockMode) { setState(GattState.DISCONNECTED); for (ConnectionEventListener asyncConnListener : getConnectionEventListeners()) { asyncConnListener.onClientConnectionStateChanged(new TransactionResult.Builder() .resultStatus(TransactionResult.TransactionResultStatus.FAILURE) .gattState(getGattState()) .responseStatus(GattStatus.GATT_UNKNOWN.ordinal()).build(), this); } } else { throw new IllegalStateException(String.format(Locale.ENGLISH, "[%s] You can't simulate a disconnection if you are not in mock mode", getDevice())); } }
Example #22
Source File: BrowserAuthenticationApi.java From line-sdk-android with Apache License 2.0 | 5 votes |
@VisibleForTesting @NonNull Uri createLoginUrl( @NonNull LineAuthenticationConfig config, @NonNull PKCECode pkceCode, @NonNull LineAuthenticationParams params, @NonNull String oAuthState, @Nullable String openIdNonce, @NonNull String redirectUri) { final String baseReturnUri = "/oauth2/v2.1/authorize/consent"; final Map<String, String> returnQueryParams = buildParams( "response_type", "code", "client_id", config.getChannelId(), "state", oAuthState, "code_challenge", pkceCode.getChallenge(), "code_challenge_method", CodeChallengeMethod.S256.getValue(), "redirect_uri", redirectUri, "sdk_ver", BuildConfig.VERSION_NAME, "scope", Scope.join(params.getScopes()) ); if (!TextUtils.isEmpty(openIdNonce)) { returnQueryParams.put("nonce", openIdNonce); } if (params.getBotPrompt() != null) { returnQueryParams.put("bot_prompt", params.getBotPrompt().name().toLowerCase()); } final String returnUri = appendQueryParams(baseReturnUri, returnQueryParams) .toString(); final Map<String, String> loginQueryParams = buildParams( "returnUri", returnUri, "loginChannelId", config.getChannelId() ); if (params.getUILocale() != null) { loginQueryParams.put("ui_locales", params.getUILocale().toString()); } return appendQueryParams(config.getWebLoginPageUrl(), loginQueryParams); }
Example #23
Source File: AccessibilityUtils.java From science-journal with Apache License 2.0 | 5 votes |
@VisibleForTesting public static void resizeRect(int a11ySize, Rect rect) { int heightToShift = (int) Math.ceil((a11ySize - rect.height()) / 2.0); int widthToShift = (int) Math.ceil((a11ySize - rect.width()) / 2.0); if (heightToShift > 0) { rect.top -= heightToShift; rect.bottom += heightToShift; } if (widthToShift > 0) { rect.left -= widthToShift; rect.right += widthToShift; } }
Example #24
Source File: ExperimentCache.java From science-journal with Apache License 2.0 | 5 votes |
/** Writes the given experiment to a file. */ @VisibleForTesting void writeExperimentFile(Experiment experimentToWrite) { boolean writingActiveExperiment = (activeExperiment == experimentToWrite); // If we are writing the active experiment, hold the activeExperimentLock until after we've set // activeExperimentNeedsWrite to false. Otherwise, if startWriteTimer is called on another // thread after we've got the proto from the experimentToWrite and before we set // activeExperimentNeedsWrite to false, it will see that activeExperimentNeedsWrite is true and // incorrectly decide that it doesn't need to start the timer. synchronized (writingActiveExperiment ? activeExperimentLock : new Object()) { GoosciExperiment.Experiment proto = experimentToWrite.getExperimentProto(); if ((proto.getVersion() > VERSION) || (proto.getVersion() == VERSION && proto.getMinorVersion() > MINOR_VERSION)) { // If the major version is too new, or the minor version is too new, we can't save this. // TODO: Or should this throw onWriteFailed? failureListener.onNewerVersionDetected(experimentToWrite.getExperimentOverview()); return; } File experimentFile = getExperimentFile(experimentToWrite.getExperimentOverview()); boolean success; synchronized (appAccount.getLockForExperimentProtoFile()) { success = experimentProtoFileHelper.writeToFile( experimentFile, experimentToWrite.getExperimentProto(), getUsageTracker()); } if (success) { if (writingActiveExperiment) { activeExperimentNeedsWrite = false; } } else { failureListener.onWriteFailed(experimentToWrite); } } }
Example #25
Source File: AccountsUtils.java From science-journal with Apache License 2.0 | 5 votes |
/** * Returns the account key associated with the given database file name or null if the database * file name does not belong to an account. */ @VisibleForTesting static String getAccountKeyFromDatabaseFileName(String databaseFileName) { String prefixWithDelimiter = DB_NAME_PREFIX + DB_NAME_DELIMITER; if (databaseFileName.startsWith(prefixWithDelimiter)) { int beginningOfAccountKey = prefixWithDelimiter.length(); int endOfAccountKey = databaseFileName.indexOf(DB_NAME_DELIMITER, beginningOfAccountKey); return databaseFileName.substring(beginningOfAccountKey, endOfAccountKey); } return null; }
Example #26
Source File: EditorialPresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@VisibleForTesting public void handleClickOnAppCard() { view.getLifecycleEvent() .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE)) .flatMap(__ -> setUpViewModelOnViewReady()) .flatMap(view::appCardClicked) .doOnNext(editorialEvent -> { editorialNavigator.navigateToAppView(editorialEvent.getId(), editorialEvent.getPackageName()); }) .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY)) .subscribe(__ -> { }, crashReporter::log); }
Example #27
Source File: SearchEngineParser.java From firefox-echo-show with Mozilla Public License 2.0 | 5 votes |
@VisibleForTesting static SearchEngine load(String identifier, InputStream stream) throws IOException, XmlPullParserException { final SearchEngine searchEngine = new SearchEngine(identifier); XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser(); parser.setInput(new InputStreamReader(stream, StandardCharsets.UTF_8)); parser.next(); readSearchPlugin(parser, searchEngine); return searchEngine; }
Example #28
Source File: TokenResponse.java From AppAuth-Android with Apache License 2.0 | 5 votes |
/** * 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; }
Example #29
Source File: ExperimentCache.java From science-journal with Apache License 2.0 | 5 votes |
@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)); }
Example #30
Source File: EditorialListPresenter.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@VisibleForTesting void handleOnDismissPopup() { view.getLifecycleEvent() .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE)) .flatMap(created -> view.onPopupDismiss()) .doOnNext(item -> view.setScrollEnabled(true)) .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY)) .subscribe(lifecycleEvent -> { }, crashReporter::log); }