-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
convert ReactPropAnnotationSetterTest to Kotlin #39706
convert ReactPropAnnotationSetterTest to Kotlin #39706
Conversation
Hi @huzhanbo1996! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Base commit: 6635474 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending this over @huzhanbo1996
There are a couple of changes that we need to apply before we can merge this
|
||
@Suppress("UNUSED_PARAMETER") | ||
private inner class ViewManagerUnderTest | ||
constructor(val mViewManagerUpdatesReceiver: ViewManagerUpdatesReceiver) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor(val mViewManagerUpdatesReceiver: ViewManagerUpdatesReceiver) : | |
constructor(val viewManagerUpdatesReceiver: ViewManagerUpdatesReceiver) : |
...ive/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterTest.kt
Show resolved
Hide resolved
@Suppress("UNUSED_PARAMETER") | ||
private inner class ViewManagerUnderTest | ||
constructor(val mViewManagerUpdatesReceiver: ViewManagerUpdatesReceiver) : | ||
ViewManager<View?, ReactShadowNode<*>?>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ViewManager<View?, ReactShadowNode<*>?>() { | |
ViewManager<View, ReactShadowNode<*>>() { |
override fun getName(): String { | ||
return "RedpandasLivestreamVideoView" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override fun getName(): String { | |
return "RedpandasLivestreamVideoView" | |
} | |
override fun getName() = "RedpandasLivestreamVideoView" |
override fun createShadowNodeInstance(): ReactShadowNode<*>? { | ||
Assertions.fail<Any>("This method should not be executed as a part of this test") | ||
return null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override fun createShadowNodeInstance(): ReactShadowNode<*>? { | |
Assertions.fail<Any>("This method should not be executed as a part of this test") | |
return null | |
} | |
override fun createShadowNodeInstance(): ReactShadowNode<*>? = | |
error("This method should not be executed as a part of this test") |
private var mViewManager: ViewManagerUnderTest? = null | ||
private var mUpdatesReceiverMock: ViewManagerUpdatesReceiver? = null | ||
private var mTargetView: View? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private var mViewManager: ViewManagerUnderTest? = null | |
private var mUpdatesReceiverMock: ViewManagerUpdatesReceiver? = null | |
private var mTargetView: View? = null | |
private lateinit var viewManager: ViewManagerUnderTest | |
private lateinit var updatesReceiverMock: ViewManagerUpdatesReceiver | |
private lateinit var targetView: View |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update all the !!
in this test file because of this change
fun buildStyles(vararg keysAndValues: Any?): ReactStylesDiffMap { | ||
return ReactStylesDiffMap(JavaOnlyMap.of(*keysAndValues)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun buildStyles(vararg keysAndValues: Any?): ReactStylesDiffMap { | |
return ReactStylesDiffMap(JavaOnlyMap.of(*keysAndValues)) | |
} | |
fun buildStyles(vararg keysAndValues: Any?) = | |
ReactStylesDiffMap(JavaOnlyMap.of(*keysAndValues)) |
override fun getShadowNodeClass(): Class<out ReactShadowNode<*>> { | ||
return ReactShadowNode::class.java | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this and all the other getters to return an expression
override fun createViewInstance(reactContext: ThemedReactContext): View { | ||
Assertions.fail<Any>("This method should not be executed as a part of this test") | ||
return View(RuntimeEnvironment.getApplication()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override fun createViewInstance(reactContext: ThemedReactContext): View { | |
Assertions.fail<Any>("This method should not be executed as a part of this test") | |
return View(RuntimeEnvironment.getApplication()) | |
} | |
override fun createViewInstance(reactContext: ThemedReactContext): View = | |
error("This method should not be executed as a part of this test") |
Please apply the same change to all the similar methods that we don't expect to call inside the tests
0051639
to
842fa4c
Compare
Thanks for the suggestions, please take a look again at the changes and the reply @cortinico |
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cortinico merged this pull request in ea88338. |
Summary:
fix and convert
ReactPropAnnotationSetterTest
to Kotlin for #38825Changelog:
[ANDROID] [CHANGED] - Rewrite ReactPropAnnotationSetterTest to Kotlin,
Test Plan:
yarn && ./gradlew :packages:react-native:ReactAndroid:test
@cortinico @mdvacca