Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shadow_context_wrapper #2

Open
wants to merge 49 commits into
base: remove_shadow_context_wrapper
Choose a base branch
from

Conversation

jongerrish
Copy link
Owner

No description provided.

jongerrish and others added 30 commits March 9, 2016 09:37
…text_wrapper

Remove ShadowResources.{getResourceLoader(),getQualifiers(),getResName()} prefer to go direct to ShadowAssetManager for this. 

Part of work to remove excess shadowing of resources.
…ionClass() so that we can use the Android Framework Instrumentation class to create and bind the application for us rather than doing it ourselves via reflection in ParallelUniverse.

Switch usages of ShadowApplication.getResources() to Application.getResources()
…ead callers should access it through ShadowAssetManager
…text_get_resource_loader

Stop exposing ResourceLoader through ShadowContext + subclasses.
…obolectric into fix-set-runtimeapplicationASAP
…cationASAP

Set RuntimeEnvironment.application sooner
… exceptions would have been silently dropped
…_initialiser_exceptions

Display exceptions thrown during initialisation of static value.
…depenencies

Remove redundant dependencies.
Extended ShadowBitmap to write and be created from Parcel.
Jonathan Gerrish and others added 19 commits March 10, 2016 16:14
…of exposing the ResourceLoader and qualifiers.
Make ShadowAssetManager.resolveStyle() non-static
…ation

getResourceLoader fix & new createAttributeSet API
Remove getAssets(), getResources(), getText(), getString(int) and getString(int, Object..) from ShadowContext and subclasses.

We should use framework code instead. It is suspected that the excessive shadowing here is causing:-

robolectric#2315
…in_shadow_context_wrapper

ShadowContextWrapper cleanup
Remove ShadowContext.getShadowApplication() - use ShadowApplication.getInstance() instead.
Remove isStringI18n() which has no effect
Prefer Framework's getMainLooper() rather than storing our own.
…o-ShadowAssetManager

Migrate createAttributeSet to static RoboAttributeSet#create
…egate class and shadowing here was probably done for convenience (all components are ContextWrappers) but in reality should be done on the base context, the delegate.

The liberal use of shadowing here prevents certain tricks that AppCompat uses, e.g: emulating SVG on pre-21 devices by subclassing ShadowContextWrapper to provide their own custom Resources.

This change removes the shadowing from ContextWrapper as well as some shadowing from ShadowService, ShadowActivity and ShadowApplication and pushes it to ContextImpl, the base context which is a central location.

Some shadowing is still redirected to ShadowApplication since this hosts much of the environment recording logic, e.g: started activities and servcies. In a future PR we should move this to a new class, e.g: RuntimeEnvironment.getInstance().peekNextStartedActivity() and deprecate / remove those methods.

Move code from ShadowContextWrapper to ShadowContextImpl.
Move methods from ShadowActivity,ShadowApplication to ShadowContextImpl
Framework code expects all compontents to have a base context, so prefer Robolectric.{build,setup}{Activity,Service}
Base context (ContextImpl) should always exist so no need to fall back on RuntimeEnvironment.application.
Pass activity thread rather than null to Activity.attach().
Remove ComponentController.withBaseContext() should not be necessary since base context should be setup by the environment.
Remove CoreShadowAdapter.setPackageName() since its redundant since @config(packageName = "...").
Prefer Application.getPackageManager() over ShadowApplication.getPackageManager().
Sacrificed ShadowApplication.assertNoBroadcastListenersRegistered() since the calls come from the base context (ContextImpl) its not possible to know the originating outer Context.
Remove ShadowPreferenceManager + Test.
Remove ShadowContext.getShadowApplication() - use ShadowApplication.getInstance() instead.
Remove isStringI18n() which has no effect
Prefer Framework's getMainLooper() rather than storing our own.
…egate class and shadowing here was probably done for convenience (all components are ContextWrappers) but in reality should be done on the base context, the delegate.

The liberal use of shadowing here prevents certain tricks that AppCompat uses, e.g: emulating SVG on pre-21 devices by subclassing ShadowContextWrapper to provide their own custom Resources.

This change removes the shadowing from ContextWrapper as well as some shadowing from ShadowService, ShadowActivity and ShadowApplication and pushes it to ContextImpl, the base context which is a central location.

Some shadowing is still redirected to ShadowApplication since this hosts much of the environment recording logic, e.g: started activities and servcies. In a future PR we should move this to a new class, e.g: RuntimeEnvironment.getInstance().peekNextStartedActivity() and deprecate / remove those methods.

Move code from ShadowContextWrapper to ShadowContextImpl.
Move methods from ShadowActivity,ShadowApplication to ShadowContextImpl
Framework code expects all compontents to have a base context, so prefer Robolectric.{build,setup}{Activity,Service}
Base context (ContextImpl) should always exist so no need to fall back on RuntimeEnvironment.application.
Pass activity thread rather than null to Activity.attach().
Remove ComponentController.withBaseContext() should not be necessary since base context should be setup by the environment.
Remove CoreShadowAdapter.setPackageName() since its redundant since @config(packageName = "...").
Prefer Application.getPackageManager() over ShadowApplication.getPackageManager().
Sacrificed ShadowApplication.assertNoBroadcastListenersRegistered() since the calls come from the base context (ContextImpl) its not possible to know the originating outer Context.
Remove ShadowPreferenceManager + Test.
…egate class and shadowing here was probably done for convenience (all components are ContextWrappers) but in reality should be done on the base context, the delegate.

The liberal use of shadowing here prevents certain tricks that AppCompat uses, e.g: emulating SVG on pre-21 devices by subclassing ShadowContextWrapper to provide their own custom Resources.

This change removes the shadowing from ContextWrapper as well as some shadowing from ShadowService, ShadowActivity and ShadowApplication and pushes it to ContextImpl, the base context which is a central location.

Some shadowing is still redirected to ShadowApplication since this hosts much of the environment recording logic, e.g: started activities and servcies. In a future PR we should move this to a new class, e.g: RuntimeEnvironment.getInstance().peekNextStartedActivity() and deprecate / remove those methods.

Move code from ShadowContextWrapper to ShadowContextImpl.
Move methods from ShadowActivity,ShadowApplication to ShadowContextImpl
Framework code expects all compontents to have a base context, so prefer Robolectric.{build,setup}{Activity,Service}
Base context (ContextImpl) should always exist so no need to fall back on RuntimeEnvironment.application.
Pass activity thread rather than null to Activity.attach().
Remove ComponentController.withBaseContext() should not be necessary since base context should be setup by the environment.
Remove CoreShadowAdapter.setPackageName() since its redundant since @config(packageName = "...").
Prefer Application.getPackageManager() over ShadowApplication.getPackageManager().
Sacrificed ShadowApplication.assertNoBroadcastListenersRegistered() since the calls come from the base context (ContextImpl) its not possible to know the originating outer Context.
Remove ShadowPreferenceManager + Test.

Better creation API for RoboAttributeSet

Major RoboAttributeSet changes
…dow_context_wrapper

# Conflicts:
#	robolectric-shadows/shadows-core/src/main/java/org/robolectric/shadows/ShadowContext.java
#	robolectric/src/test/java/org/robolectric/shadows/ShadowServiceTest.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants