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

Documentation for creating our own isInAndroidSdk = false Shadows #177

Open
utzcoz opened this issue Nov 24, 2023 · 0 comments
Open

Documentation for creating our own isInAndroidSdk = false Shadows #177

utzcoz opened this issue Nov 24, 2023 · 0 comments

Comments

@utzcoz
Copy link
Member

utzcoz commented Nov 24, 2023

Discussed in robolectric/robolectric#8140

Originally posted by cmathew April 14, 2023
Crossposting from the Google Group.

I'm looking to create my own shadow for a low-level Android class. My current implementation extends the one included in Robolectric 4.9.2, and adds some additional functionality:

@Implements(value = ViewRootImpl::class)
class MyShadowViewRootImpl : ShadowViewRootImpl() {
  @Implementation
  fun getWindowInsets(forceConstruct: Boolean): WindowInsets {
    // return some reasonable insets
  }
}

To allow my project to reference ViewRootImpl, I found that I could include the android-all library. However, I'm not sure whether this is the correct next step to take. Also, having this on my classpath seems to be stomping on some framework classes in ways that result in runtime exceptions. For example, my Android Log calls now result in linking errors.

I would like to learn more about:
1.) How do I create low-level Shadows? What is android-all, and what roles does it play?
2.) Besides android-all, I noticed other interesting-sounding libraries surrounding Robolectric e.g. shadows-framework, shadowapi, sandbox, and android-all-instrumented. What are these libraries, and how should developers use them?

Thanks for any help!

@utzcoz utzcoz transferred this issue from robolectric/robolectric Nov 24, 2023
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

No branches or pull requests

1 participant