-
Notifications
You must be signed in to change notification settings - Fork 953
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: The field changed from mStates to states breaking our reflection based code. Ideally I would like to just check if type == KStateContainer and access the field normally but the rest of the infrastructure expect to work on a java field. Added tests to catch this sort of thing in the future. had to shift buck files around a bit to get it to work Reviewed By: antonk52 Differential Revision: D46974357 fbshipit-source-id: 87a6f5883b33e4d1a7359df5987fc7ead7c19033
- Loading branch information
1 parent
62cb33b
commit 20d7b57
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
.../test/java/com/facebook/flipper/plugins/uidebugger/litho/KStateContainerExtractionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import com.facebook.flipper.plugins.uidebugger.litho.descriptors.props.ComponentDataExtractor | ||
import com.facebook.flipper.plugins.uidebugger.model.InspectableArray | ||
import com.facebook.flipper.plugins.uidebugger.model.InspectableObject | ||
import com.facebook.flipper.plugins.uidebugger.model.InspectableValue | ||
import com.facebook.litho.KStateContainer | ||
import junit.framework.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class KStateContainerExtractionTest { | ||
@Test | ||
@Throws(Exception::class) | ||
fun testCanExtractKState() { | ||
|
||
// this test ensures that our reflection based extraction doesn't break if the KState class | ||
// structure changes | ||
val stateContainer = KStateContainer.withNewState(null, "foo") | ||
|
||
val result = ComponentDataExtractor.getState(stateContainer, "Comp1") | ||
|
||
assertEquals( | ||
result, | ||
InspectableObject(mapOf(1 to InspectableArray(listOf(InspectableValue.Text("foo")))))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters