本文整理汇总了Java中android.test.RenamingDelegatingContext类的典型用法代码示例。如果您正苦于以下问题:Java RenamingDelegatingContext类的具体用法?Java RenamingDelegatingContext怎么用?Java RenamingDelegatingContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RenamingDelegatingContext类属于android.test包,在下文中一共展示了RenamingDelegatingContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
MockContentResolver mockContentResolver = new MockContentResolver();
RenamingDelegatingContext targetContext = new RenamingDelegatingContext(
getContext(), getContext(), "test.");
MockContext context = new MockContext(mockContentResolver, targetContext);
MyTracksProvider provider = new MyTracksProvider();
provider.attachInfo(context, null);
mockContentResolver.addProvider(MyTracksProviderUtils.AUTHORITY, provider);
setContext(context);
providerUtils = MyTracksProviderUtils.Factory.get(context);
engine = new SearchEngine(providerUtils);
}
示例2: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
MockContentResolver mockContentResolver = new MockContentResolver();
RenamingDelegatingContext targetContext = new RenamingDelegatingContext(
getContext(), getContext(), "test.");
context = new MockContext(mockContentResolver, targetContext);
MyTracksProvider provider = new MyTracksProvider();
provider.attachInfo(context, null);
mockContentResolver.addProvider(MyTracksProviderUtils.AUTHORITY, provider);
setContext(context);
providerUtils = MyTracksProviderUtils.Factory.get(context);
providerUtils.deleteAllTracks(context);
}
示例3: TestMyModule
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
public TestMyModule(@NonNull Context context) {
super(context);
mContext = context;
mRenamingDelegatingContext = new RenamingDelegatingContext(mContext, "test_");
mMockWebServer = new MockWebServer();
mMockWebServer.setDispatcher(new AssetsDispatcher());
mSharedPreferences = mContext.getSharedPreferences("test_" + Constants.PREF_NAME, Context.MODE_PRIVATE);
mMySQLiteOpenHelper = new MySQLiteOpenHelper(mRenamingDelegatingContext, Constants.DB_NAME, null, Constants.DB_VERSION);
Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create();
mRetrofit = new Retrofit.Builder()
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.baseUrl(mMockWebServer.url("/").toString()).build();
mGitHubService = mRetrofit.create(GitHubService.class);
}
示例4: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
Context context = InstrumentationRegistry.getTargetContext();
RenamingDelegatingContext renamingDelegatingContext = new RenamingDelegatingContext(context, "test_");
setContext(renamingDelegatingContext);
db = DatabaseHelper.getInstance(renamingDelegatingContext);
routine1 = new Routine();
routine1.setName("routine1");
exercise1 = new Exercise();
exercise1.setName("exercise1");
exercise1.trackNewMeasurementCategory(MeasurementCategory.REPS);
exercise1.trackNewMeasurementCategory(MeasurementCategory.TIME);
routine1.addExercise(exercise1);
rSession1 = routine1.createNewRoutineSession();
eSession1 = rSession1.getExerciseSession(0);
}
示例5: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
FactoryUtils.initWithTestFactories();
mTargetContext = new RenamingDelegatingContext(getInstrumentation().getTargetContext(), "test_");
TestUtils.clearApplicationState(mTargetContext);
// Init contexts
XMLRPCFactoryTest.sContext = getInstrumentation().getContext();
RestClientFactoryTest.sContext = getInstrumentation().getContext();
AppLog.v(AppLog.T.TESTS, "Contexts set");
// Set mode to Customizable
XMLRPCFactoryTest.sMode = XMLRPCFactoryTest.Mode.CUSTOMIZABLE_XML;
RestClientFactoryTest.sMode = RestClientFactoryTest.Mode.CUSTOMIZABLE;
AppLog.v(AppLog.T.TESTS, "Modes set to customizable");
// Set default variant
RestClientFactoryTest.setPrefixAllInstances("default");
XMLRPCFactoryTest.setPrefixAllInstances("default");
}
示例6: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
String namespace = BuildConfig.FLAVOR.equals("zbetagroup") ? "org.wordpress.android.beta"
: "org.wordpress.android";
testContext = getContext().createPackageContext(namespace, Context.CONTEXT_IGNORE_SECURITY);
targetContext = new RenamingDelegatingContext(getContext(), "test_");
// Init contexts
XMLRPCFactoryTest.sContext = getContext();
RestClientFactoryTest.sContext = getContext();
AppLog.v(AppLog.T.TESTS, "Contexts set");
// Set mode to Customizable
XMLRPCFactoryTest.sMode = XMLRPCFactoryTest.Mode.CUSTOMIZABLE_XML;
RestClientFactoryTest.sMode = RestClientFactoryTest.Mode.CUSTOMIZABLE;
AppLog.v(AppLog.T.TESTS, "Modes set to customizable");
}
示例7: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Override
protected void setUp() {
// Clean application state
mTargetContext = new RenamingDelegatingContext(getInstrumentation().getTargetContext(), "test_");
TestUtils.clearApplicationState(mTargetContext);
// Init contexts
XMLRPCFactoryTest.sContext = getInstrumentation().getContext();
RestClientFactoryTest.sContext = getInstrumentation().getContext();
AppLog.v(T.TESTS, "Contexts set");
// Set mode to Customizable
XMLRPCFactoryTest.sMode = XMLRPCFactoryTest.Mode.CUSTOMIZABLE_JSON;
RestClientFactoryTest.sMode = RestClientFactoryTest.Mode.CUSTOMIZABLE;
AppLog.v(T.TESTS, "Modes set to customizable");
}
示例8: createTables
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
private SQLiteDatabase createTables(final boolean delete, final UniversalSearchContract.Table... tables) {
SQLiteDatabase db = null;
final String filenamePrefix = "test.";
RenamingDelegatingContext targetContextWrapper = new
RenamingDelegatingContext(
new MockContext2(), // The context that most methods are
//delegated to
getContext(), // The context that file methods are delegated to
filenamePrefix);
final Context context = new IsolatedContext(super.getContext().getContentResolver(), targetContextWrapper);
try {
db = context.openOrCreateDatabase(DATABASE, 1, null);
for (final UniversalSearchContract.Table table : tables) {
table.onCreate(db);
log("Table " + table + " onCreate successful");
}
return db;
} finally {
if (null != db && delete) {
db.close();
context.deleteDatabase(DATABASE);
}
}
}
示例9: setUpContentProvider
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
private void setUpContentProvider(ContentProvider targetProvider) throws Exception {
mResolver = new ChangeRecordingMockContentResolver();
final String filenamePrefix = this.getClass().getSimpleName() + ".";
RenamingDelegatingContext targetContextWrapper =
new RenamingDelegatingContext(
new ContentProviderMockContext(),
(Context)getActivity(),
filenamePrefix);
mProviderContext = new IsolatedContext(mResolver, targetContextWrapper);
targetProvider.attachInfo(mProviderContext, null);
mProvider = new DelegatingTestContentProvider(targetProvider);
mProvider.attachInfo(mProviderContext, null);
mResolver.addProvider(mProviderAuthority, mProvider);
}
示例10: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
ErrorLoggingSingleton log = ErrorLoggingSingleton.getInstance();
log.setContext(new RenamingDelegatingContext(getContext(), "test."));
uut = new PublicMessageDecryption(
ComputeMacFactory.getInstance(),
PublicMessageCipherFactory.getPublicMessageCipherInstance(
cipherAlgorithm, Ciphermode.ENCRYPT,
ivLengthCipher),
ivLengthMAC,
macOffset,
ivOffset,
textOffset,
PLAINSIZE
);
}
示例11: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Before
public void setUp() throws Exception {
this.context = new RenamingDelegatingContext(getContext(), UUID.randomUUID().toString());
StrictMode.setVmPolicy(STRICT_VM_POLICY);
Assume.assumeTrue(!System.getProperty("os.name").toLowerCase().startsWith("mac os x") || !System.getProperty("java.version").startsWith("1.7.0"));
this.store = (SQLStore) DataManager
.config("store", SQLStoreConfiguration.class)
.withContext(context)
.store(Data.class);
this.nestedStore = (SQLStore) DataManager
.config("trivialNestedClass", SQLStoreConfiguration.class)
.withContext(context)
.store(TrivialNestedClass.class);
this.nestedWithCollectionStore = (SQLStore) DataManager
.config("trivialNestedClassWithCollection", SQLStoreConfiguration.class)
.withContext(context)
.store(TrivialNestedClassWithCollection.class);
}
示例12: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
context = new RenamingDelegatingContext(getContext(), "test_");
db = new KanjotoDatabaseHelper(context);
eds = new EmotionsDataSource(context);
nds = new NotesDataSource(context);
nsds = new NotesetsDataSource(context);
Emotion emotion = new Emotion();
emotion.setId(1);
emotion.setName("happy");
eds.createEmotion(emotion);
emotion = new Emotion();
emotion.setId(2);
emotion.setName("sad");
eds.createEmotion(emotion);
// create noteset
Noteset noteset = new Noteset();
noteset.setApprenticeId(1);
noteset.setEmotion(1);
noteset.setEnabled(1);
nsds.createNoteset(noteset);
}
示例13: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
this.context = new RenamingDelegatingContext(getContext(), "test_");
DatabaseManager.initializeInstance(new DBHandlerClient(context));
db = DatabaseManager.getInstance().openDatabase();
testNews1 = new DataAccessNews(1, "t", "s", "text", "http://example.com/", "http://example.com/icon.png", "19.03.2015");
testNews2 = new DataAccessNews(2, "tt", "ss", "text2", "http://example.edu/", "http://example.edu/icon.png", "20.03.2015");
testEvent1 = new DataAccessEvent("e1", "s1", "<html><body>hello!</body></html>", "http://example.com/", Calendar.getInstance());
testEvent1.setId(1);
testEvent2 = new DataAccessEvent("e2", "s2", "<html><body>hello2!</body></html>", "http://example.de/", Calendar.getInstance());
testEvent2.setId(2);
tagsSet1 = new ArrayList<DataAccessTag>() {{
add(DataAccessTag.ENGINEER);
add(DataAccessTag.PROFESSOR);
}};
tagsSet2 = new ArrayList<DataAccessTag>() {{
add(DataAccessTag.ADMINISTRATION);
add(DataAccessTag.SCIENTIST);
add(DataAccessTag.DOCTORAND);
}};
testJob1 = new DataAccessJob(tagsSet1, "Wizard", "Task: kill all dragons in Karlsruhe", "http://example.com/");
testJob1.setId(1);
testJob2 = new DataAccessJob(tagsSet2, "Title2", "Description", "http://example.de/");
testJob2.setId(2);
}
示例14: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@UsesMocks({ MyTracksProviderUtils.class, DataSource.class, TrackDataListener.class })
@Override
protected void setUp() throws Exception {
super.setUp();
context = new MockContext(new MockContentResolver(), new RenamingDelegatingContext(
getContext(), getContext(), "test."));
sharedPreferences = context.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
myTracksProviderUtils = AndroidMock.createMock(MyTracksProviderUtils.class);
dataSource = AndroidMock.createMock(DataSource.class, context);
trackDataManager = new TrackDataManager();
trackDataHub = new TrackDataHub(
context, trackDataManager, myTracksProviderUtils, TARGET_POINTS) {
@Override
protected DataSource newDataSource() {
return dataSource;
}
@Override
protected void runInHanderThread(Runnable runnable) {
// Run everything in the same thread
runnable.run();
}
};
trackDataListener1 = AndroidMock.createStrictMock(
"trackDataListener1", TrackDataListener.class);
trackDataListener2 = AndroidMock.createStrictMock(
"trackDataListener2", TrackDataListener.class);
PreferencesUtils.setLong(context, R.string.recording_track_id_key, TRACK_ID);
}
示例15: setUp
import android.test.RenamingDelegatingContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
MockContentResolver mockContentResolver = new MockContentResolver();
RenamingDelegatingContext targetContext = new RenamingDelegatingContext(
getContext(), getContext(), "test.");
Context context = new MockContext(mockContentResolver, targetContext);
MyTracksProvider myTracksProvider = new MyTracksProvider();
myTracksProvider.attachInfo(context, null);
mockContentResolver.addProvider(MyTracksProviderUtils.AUTHORITY, myTracksProvider);
setContext(context);
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
oldProviderUtilsFactory = TestingProviderUtilsFactory.installWithInstance(
myTracksProviderUtils);
mocksControl = EasyMock.createStrictControl();
trackWriter = mocksControl.createMock(TrackWriter.class);
Track track = new Track();
track.setName(TRACK_NAME);
track.setId(TRACK_ID);
tracks = new Track[] {track};
outputStream = new ByteArrayOutputStream();
TrackExporterListener trackExporterListener = new TrackExporterListener() {
@Override
public void onProgressUpdate(int number, int max) {
// Safe to ignore
}
};
fileTrackExporter = new FileTrackExporter(
myTracksProviderUtils, tracks, trackWriter, trackExporterListener);
}