Skip to content

Commit

Permalink
Fix test failure caused by flags switch from int to long
Browse files Browse the repository at this point in the history
Summary: D51734814 switched Litho's NodeInfo flags from an Int to a Long, since they exceeded 32 flags, but this test was still expecting them to be ints.

Differential Revision: D51968513

fbshipit-source-id: fa01ea25ef0c7139685b57483111a927cb6cbe97
  • Loading branch information
Brett Lavalla authored and facebook-github-bot committed Dec 8, 2023
1 parent f34db76 commit d21b7af
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions litho-it/src/test/java/com/facebook/litho/NodeInfoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,20 @@ class NodeInfoTest {
}

private fun isFlagSet(nodeInfo: NodeInfo?, flagName: String): Boolean {
val flagPosition = Whitebox.getInternalState<Int>(NodeInfo::class.java, flagName)
val flags = Whitebox.getInternalState<Int>(nodeInfo, "mPrivateFlags")
return flags and flagPosition != 0
val flagPosition = Whitebox.getInternalState<Long>(NodeInfo::class.java, flagName)
val flags = Whitebox.getInternalState<Long>(nodeInfo, "mPrivateFlags")
return flags and flagPosition != 0L
}

private fun clearFlag(nodeInfo: NodeInfo?, flagName: String) {
val flagPosition = Whitebox.getInternalState<Int>(NodeInfo::class.java, flagName)
var flags = Whitebox.getInternalState<Int>(nodeInfo, "mPrivateFlags")
val flagPosition = Whitebox.getInternalState<Long>(NodeInfo::class.java, flagName)
var flags = Whitebox.getInternalState<Long>(nodeInfo, "mPrivateFlags")
flags = flags and flagPosition.inv()
Whitebox.setInternalState(nodeInfo, "mPrivateFlags", flags)
}

private fun assertEmptyFlags(nodeInfo: NodeInfo?) {
assertThat(Whitebox.getInternalState<Any>(nodeInfo, "mPrivateFlags") as Int == 0).isTrue
assertThat(Whitebox.getInternalState<Any>(nodeInfo, "mPrivateFlags") as Long == 0L).isTrue
}
}
}

0 comments on commit d21b7af

Please sign in to comment.