-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update bridge to handle long values (#43158)
Summary: This adds support for 64 bit integer (long) values to the Android bridge. Per the wide gamut color [RFC](react-native-community/discussions-and-proposals#738) Android encodes wide gamut colors as long values so we need to update the bridge to support 64 bit integers as well since these classes will soon receive those values from native. ## Changelog: [ANDROID] [ADDED] - Update bridge to handle long values Pull Request resolved: #43158 Test Plan: I added tests where I could for long types and truncation. I would like to add tests for ReadableNativeArray and ReadableNativeMap but I'm not sure how to go about mocking HybridData. Reviewed By: cipolleschi Differential Revision: D54276496 Pulled By: NickGerleman fbshipit-source-id: 1e71b5283f662748beef1bdb34d9c86099baecb0
- Loading branch information
1 parent
73664f5
commit 0dc5c5f
Showing
13 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
55 changes: 55 additions & 0 deletions
55
...ages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/JavaOnlyMapTest.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,55 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package com.facebook.react.bridge | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
|
||
/** Tests for [JavaOnlyMap] */ | ||
class JavaOnlyMapTest { | ||
@Test | ||
fun testGetType() { | ||
val values = | ||
JavaOnlyMap.of( | ||
"int", | ||
1, | ||
"float", | ||
2f, | ||
"double", | ||
3.0, | ||
"long", | ||
4L, | ||
"string", | ||
"5", | ||
"boolean", | ||
false, | ||
"array", | ||
JavaOnlyArray.of(), | ||
"map", | ||
JavaOnlyMap.of(), | ||
"null", | ||
null) | ||
|
||
assertThat(values.getType("int")).isEqualTo(ReadableType.Number) | ||
assertThat(values.getType("float")).isEqualTo(ReadableType.Number) | ||
assertThat(values.getType("double")).isEqualTo(ReadableType.Number) | ||
assertThat(values.getType("long")).isEqualTo(ReadableType.Number) | ||
assertThat(values.getType("string")).isEqualTo(ReadableType.String) | ||
assertThat(values.getType("boolean")).isEqualTo(ReadableType.Boolean) | ||
assertThat(values.getType("array")).isEqualTo(ReadableType.Array) | ||
assertThat(values.getType("map")).isEqualTo(ReadableType.Map) | ||
assertThat(values.getType("null")).isEqualTo(ReadableType.Null) | ||
} | ||
|
||
@Test | ||
fun testLongValueNotTruncated() { | ||
val values = JavaOnlyMap.of("long", 1125899906842623L) | ||
|
||
assertThat(values.getLong("long")).isEqualTo(1125899906842623L) | ||
} | ||
} |