1 // Copyright 2023 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package org.chromium.net; 6 7 import android.content.Context; 8 import android.content.ContextWrapper; 9 10 /** 11 * An interface for providing a replacement for an Android {@link Context}. Useful for 12 * faking/mocking Context calls in tests. 13 * 14 * @see CronetTestRule.CronetTestFramework#interceptContext 15 */ 16 public interface ContextInterceptor { 17 /** 18 * Provides a {@link Context} that the current context should be replaced with. 19 * 20 * @param context the original Context to be replaced 21 * @return the new Context. Typically this would forward most calls to the original context, for 22 * example using {@link ContextWrapper}. 23 */ interceptContext(Context context)24 public Context interceptContext(Context context); 25 } 26