Search in sources :

Example 41 with VisibleForTesting

use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.

the class MinidumpUploadService method createFindAndUploadAllCrashesIntent.

/**
     * Creates an intent that when started will find all minidumps, and try to upload them.
     *
     * @param context the context to use for the intent.
     * @return an Intent to use to start the service.
     */
@VisibleForTesting
static Intent createFindAndUploadAllCrashesIntent(Context context) {
    Intent intent = new Intent(context, MinidumpUploadService.class);
    intent.setAction(ACTION_FIND_ALL);
    return intent;
}
Also used : Intent(android.content.Intent) VisibleForTesting(org.chromium.base.VisibleForTesting)

Example 42 with VisibleForTesting

use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.

the class RequestThrottler method purgeAllEntriesForTesting.

@VisibleForTesting
static void purgeAllEntriesForTesting(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(PREFERENCES_NAME, 0);
    sharedPreferences.edit().clear().apply();
    if (sUidToThrottler != null)
        sUidToThrottler.clear();
}
Also used : SharedPreferences(android.content.SharedPreferences) VisibleForTesting(org.chromium.base.VisibleForTesting)

Example 43 with VisibleForTesting

use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.

the class LogcatExtractionCallable method elideUrl.

/**
     * Elides any URLs in the specified {@link String} with
     * {@link #URL_ELISION}.
     *
     * @param original String potentially containing URLs.
     * @return String with elided URLs.
     */
@VisibleForTesting
protected static String elideUrl(String original) {
    StringBuilder buffer = new StringBuilder(original);
    Matcher matcher = WEB_URL.matcher(buffer);
    int start = 0;
    while (matcher.find(start)) {
        start = matcher.start();
        int end = matcher.end();
        String url = buffer.substring(start, end);
        if (!likelyToBeChromeNamespace(url) && !likelyToBeSystemNamespace(url)) {
            buffer.replace(start, end, URL_ELISION);
            end = start + URL_ELISION.length();
            matcher = WEB_URL.matcher(buffer);
        }
        start = end;
    }
    return buffer.toString();
}
Also used : Matcher(java.util.regex.Matcher) VisibleForTesting(org.chromium.base.VisibleForTesting)

Example 44 with VisibleForTesting

use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.

the class DownloadNotificationService method pauseAllDownloads.

/**
     * Called to pause all the download notifications.
     */
@VisibleForTesting
void pauseAllDownloads() {
    for (int i = mDownloadSharedPreferenceEntries.size() - 1; i >= 0; --i) {
        DownloadSharedPreferenceEntry entry = mDownloadSharedPreferenceEntries.get(i);
        notifyDownloadPaused(entry.downloadGuid, !entry.isOffTheRecord, true);
    }
}
Also used : Paint(android.graphics.Paint) VisibleForTesting(org.chromium.base.VisibleForTesting)

Example 45 with VisibleForTesting

use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.

the class ExternalNavigationDelegateImpl method getSpecializedHandlersWithFilter.

@VisibleForTesting
static ArrayList<String> getSpecializedHandlersWithFilter(List<ResolveInfo> infos, String filterPackageName) {
    ArrayList<String> result = new ArrayList<>();
    if (infos == null) {
        return result;
    }
    int count = 0;
    for (ResolveInfo info : infos) {
        IntentFilter filter = info.filter;
        if (filter == null) {
            // Error on the side of classifying ResolveInfo as generic.
            continue;
        }
        if (filter.countDataAuthorities() == 0 && filter.countDataPaths() == 0) {
            // Don't count generic handlers.
            continue;
        }
        if (!TextUtils.isEmpty(filterPackageName) && (info.activityInfo == null || !info.activityInfo.packageName.equals(filterPackageName))) {
            continue;
        }
        result.add(info.activityInfo != null ? info.activityInfo.packageName : "");
    }
    return result;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) IntentFilter(android.content.IntentFilter) ArrayList(java.util.ArrayList) VisibleForTesting(org.chromium.base.VisibleForTesting)

Aggregations

VisibleForTesting (org.chromium.base.VisibleForTesting)52 Intent (android.content.Intent)6 IOException (java.io.IOException)6 SharedPreferences (android.content.SharedPreferences)5 JSONObject (org.json.JSONObject)4 PendingIntent (android.app.PendingIntent)3 SpannableString (android.text.SpannableString)3 BufferedReader (java.io.BufferedReader)3 Matcher (java.util.regex.Matcher)3 CalledByNative (org.chromium.base.annotations.CalledByNative)3 AccountManagerHelper (org.chromium.components.signin.AccountManagerHelper)3 SpanInfo (org.chromium.ui.text.SpanApplier.SpanInfo)3 SuppressLint (android.annotation.SuppressLint)2 IntentFilter (android.content.IntentFilter)2 Paint (android.graphics.Paint)2 File (java.io.File)2 FileReader (java.io.FileReader)2 HttpURLConnection (java.net.HttpURLConnection)2 ArrayList (java.util.ArrayList)2 Formatter (java.util.Formatter)2