mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Convert com.facebook.testutils.shadows to Kotlin (#47487)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47487 Changelog: [Android][Deprecated] Deprecated shadows for ReadableNative[Map|Array].[Readable|Writable] Reviewed By: rshest Differential Revision: D65597417 fbshipit-source-id: 61f649c32fb91a13af075aa65869093f31d218e3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eb5fbdf134
commit
d424bb9d7c
+2
-1
@@ -18,6 +18,7 @@ import com.facebook.testutils.shadows.ShadowArguments
|
||||
import com.facebook.testutils.shadows.ShadowNativeArray
|
||||
import com.facebook.testutils.shadows.ShadowNativeLoader
|
||||
import com.facebook.testutils.shadows.ShadowSoLoader
|
||||
import com.facebook.testutils.shadows.ShadowWritableNativeArray
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -41,7 +42,7 @@ import org.robolectric.annotation.Config
|
||||
ShadowSoLoader::class,
|
||||
ShadowNativeLoader::class,
|
||||
ShadowArguments::class,
|
||||
ShadowNativeArray.Writable::class])
|
||||
ShadowWritableNativeArray::class])
|
||||
class BridgelessReactContextTest {
|
||||
private lateinit var context: Context
|
||||
private lateinit var reactHost: ReactHostImpl
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class ShadowArguments {
|
||||
@Implementation
|
||||
fun fromJavaArgs(args: Array<Any?>): WritableNativeArray =
|
||||
WritableNativeArray().apply {
|
||||
(Shadow.extract(this) as ShadowNativeArray).contents = args.toList()
|
||||
(Shadow.extract(this) as ShadowNativeArray).backingArray = JavaOnlyArray.of(*args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-4
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.facebook.testutils.shadows
|
||||
|
||||
import com.facebook.react.bridge.JavaOnlyArray
|
||||
import com.facebook.react.bridge.NativeArray
|
||||
import com.facebook.react.bridge.ReadableNativeArray
|
||||
import com.facebook.react.bridge.WritableNativeArray
|
||||
@@ -16,14 +17,24 @@ import org.robolectric.shadow.api.Shadow
|
||||
// Mockito can't mock native methods, so shadow the entire class instead
|
||||
@Implements(NativeArray::class)
|
||||
public open class ShadowNativeArray {
|
||||
public var contents: List<Any?> = mutableListOf()
|
||||
var backingArray: JavaOnlyArray = JavaOnlyArray()
|
||||
|
||||
@Implements(ReadableNativeArray::class) public class Readable : ShadowNativeArray() {}
|
||||
@Deprecated(
|
||||
"Use ShadowReadableNativeArray",
|
||||
ReplaceWith(
|
||||
"ShadowReadableNativeArray", "com.facebook.testutils.shadows.ShadowReadableNativeArray"))
|
||||
@Implements(ReadableNativeArray::class)
|
||||
public class Readable : ShadowNativeArray() {}
|
||||
|
||||
@Implements(WritableNativeArray::class) public class Writable : ShadowNativeArray() {}
|
||||
@Deprecated(
|
||||
"Use ShadowWritableNativeArray",
|
||||
ReplaceWith(
|
||||
"ShadowWritableNativeArray", "com.facebook.testutils.shadows.ShadowWritableNativeArray"))
|
||||
@Implements(WritableNativeArray::class)
|
||||
public class Writable : ShadowNativeArray() {}
|
||||
|
||||
public companion object {
|
||||
public fun getContents(array: NativeArray): List<Any?> =
|
||||
(Shadow.extract(array) as ShadowNativeArray).contents
|
||||
(Shadow.extract(array) as ShadowNativeArray).backingArray.toArrayList()
|
||||
}
|
||||
}
|
||||
|
||||
+18
-7
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.facebook.testutils.shadows
|
||||
|
||||
import com.facebook.react.bridge.JavaOnlyMap
|
||||
import com.facebook.react.bridge.NativeMap
|
||||
import com.facebook.react.bridge.ReadableNativeMap
|
||||
import com.facebook.react.bridge.WritableNativeMap
|
||||
@@ -15,15 +16,25 @@ import org.robolectric.shadow.api.Shadow
|
||||
|
||||
// Mockito can't mock native methods, so shadow the entire class instead
|
||||
@Implements(NativeMap::class)
|
||||
public open class ShadowNativeMap {
|
||||
public var contents: Map<String, Any?> = HashMap()
|
||||
open class ShadowNativeMap {
|
||||
var backingMap: JavaOnlyMap = JavaOnlyMap()
|
||||
|
||||
@Implements(ReadableNativeMap::class) public class Readable : ShadowNativeMap() {}
|
||||
@Deprecated(
|
||||
"Use ShadowReadableNativeMap",
|
||||
ReplaceWith(
|
||||
"ShadowReadableNativeMap", "com.facebook.testutils.shadows.ShadowReadableNativeMap"))
|
||||
@Implements(ReadableNativeMap::class)
|
||||
public class Readable : ShadowNativeMap() {}
|
||||
|
||||
@Implements(WritableNativeMap::class) public class Writable : ShadowNativeMap() {}
|
||||
@Deprecated(
|
||||
"Use ShadowWritableNativeMap",
|
||||
ReplaceWith(
|
||||
"ShadowWritableNativeMap", "com.facebook.testutils.shadows.ShadowWritableNativeMap"))
|
||||
@Implements(WritableNativeMap::class)
|
||||
public class Writable : ShadowNativeMap() {}
|
||||
|
||||
public companion object {
|
||||
public fun getContents(map: NativeMap): Map<String, Any?> =
|
||||
(Shadow.extract(map) as ShadowNativeMap).contents
|
||||
companion object {
|
||||
fun getContents(map: NativeMap): Map<String, Any?> =
|
||||
(Shadow.extract(map) as ShadowNativeMap).backingMap.toHashMap()
|
||||
}
|
||||
}
|
||||
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* 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.testutils.shadows;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.JavaOnlyArray;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableNativeArray;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
import java.util.ArrayList;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@Implements(ReadableNativeArray.class)
|
||||
public class ShadowReadableNativeArray extends ShadowNativeArray implements ReadableArray {
|
||||
|
||||
protected JavaOnlyArray backingArray;
|
||||
|
||||
@Implementation
|
||||
protected void __constructor__() {
|
||||
this.backingArray = new JavaOnlyArray();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public int size() {
|
||||
return this.backingArray.size();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean isNull(int index) {
|
||||
return this.backingArray.isNull(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean getBoolean(int index) {
|
||||
return this.backingArray.getBoolean(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public double getDouble(int index) {
|
||||
return this.backingArray.getDouble(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public int getInt(int index) {
|
||||
return this.backingArray.getInt(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public long getLong(int index) {
|
||||
return this.backingArray.getLong(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull String getString(int index) {
|
||||
return this.backingArray.getString(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull ReadableArray getArray(int index) {
|
||||
return this.backingArray.getArray(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull ReadableMap getMap(int index) {
|
||||
return this.backingArray.getMap(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull Dynamic getDynamic(int index) {
|
||||
return this.backingArray.getDynamic(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull ReadableType getType(int index) {
|
||||
return this.backingArray.getType(index);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull ArrayList<Object> toArrayList() {
|
||||
return this.backingArray.toArrayList();
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.testutils.shadows
|
||||
|
||||
import com.facebook.react.bridge.Dynamic
|
||||
import com.facebook.react.bridge.ReadableArray
|
||||
import com.facebook.react.bridge.ReadableMap
|
||||
import com.facebook.react.bridge.ReadableNativeArray
|
||||
import com.facebook.react.bridge.ReadableType
|
||||
import java.util.ArrayList
|
||||
import org.robolectric.annotation.Implementation
|
||||
import org.robolectric.annotation.Implements
|
||||
|
||||
@Implements(ReadableNativeArray::class)
|
||||
open class ShadowReadableNativeArray : ShadowNativeArray(), ReadableArray {
|
||||
|
||||
@Implementation override fun size(): Int = backingArray.size()
|
||||
|
||||
@Implementation override fun isNull(index: Int): Boolean = backingArray.isNull(index)
|
||||
|
||||
@Implementation override fun getBoolean(index: Int): Boolean = backingArray.getBoolean(index)
|
||||
|
||||
@Implementation override fun getDouble(index: Int): Double = backingArray.getDouble(index)
|
||||
|
||||
@Implementation override fun getInt(index: Int): Int = backingArray.getInt(index)
|
||||
|
||||
@Implementation override fun getLong(index: Int): Long = backingArray.getLong(index)
|
||||
|
||||
@Implementation override fun getString(index: Int): String? = backingArray.getString(index)
|
||||
|
||||
@Implementation override fun getArray(index: Int): ReadableArray? = backingArray.getArray(index)
|
||||
|
||||
@Implementation override fun getMap(index: Int): ReadableMap? = backingArray.getMap(index)
|
||||
|
||||
@Implementation override fun getDynamic(index: Int): Dynamic = backingArray.getDynamic(index)
|
||||
|
||||
@Implementation override fun getType(index: Int): ReadableType = backingArray.getType(index)
|
||||
|
||||
@Implementation override fun toArrayList(): ArrayList<Any?> = backingArray.toArrayList()
|
||||
}
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* 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.testutils.shadows;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.JavaOnlyMap;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@Implements(ReadableNativeMap.class)
|
||||
public class ShadowReadableNativeMap extends ShadowNativeMap implements ReadableMap {
|
||||
|
||||
protected JavaOnlyMap backingMap;
|
||||
|
||||
@Implementation
|
||||
protected void __constructor__() {
|
||||
this.backingMap = new JavaOnlyMap();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean hasKey(@NonNull String name) {
|
||||
return backingMap.hasKey(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean isNull(@NonNull String name) {
|
||||
return backingMap.isNull(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean getBoolean(@NonNull String name) {
|
||||
return backingMap.getBoolean(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public double getDouble(@NonNull String name) {
|
||||
return backingMap.getDouble(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public int getInt(@NonNull String name) {
|
||||
return backingMap.getInt(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public long getLong(@NonNull String name) {
|
||||
return backingMap.getLong(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @Nullable String getString(@NonNull String name) {
|
||||
return backingMap.getString(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @Nullable ReadableArray getArray(@NonNull String name) {
|
||||
return backingMap.getArray(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @Nullable ReadableMap getMap(@NonNull String name) {
|
||||
return backingMap.getMap(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull Dynamic getDynamic(@NonNull String name) {
|
||||
return backingMap.getDynamic(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull ReadableType getType(@NonNull String name) {
|
||||
return backingMap.getType(name);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull Iterator<Map.Entry<String, Object>> getEntryIterator() {
|
||||
return backingMap.getEntryIterator();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull ReadableMapKeySetIterator keySetIterator() {
|
||||
return backingMap.keySetIterator();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public @NonNull HashMap<String, Object> toHashMap() {
|
||||
return backingMap.toHashMap();
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.testutils.shadows
|
||||
|
||||
import com.facebook.react.bridge.Dynamic
|
||||
import com.facebook.react.bridge.ReadableArray
|
||||
import com.facebook.react.bridge.ReadableMap
|
||||
import com.facebook.react.bridge.ReadableMapKeySetIterator
|
||||
import com.facebook.react.bridge.ReadableNativeMap
|
||||
import com.facebook.react.bridge.ReadableType
|
||||
import java.util.HashMap
|
||||
import org.robolectric.annotation.Implementation
|
||||
import org.robolectric.annotation.Implements
|
||||
|
||||
@Implements(ReadableNativeMap::class)
|
||||
open class ShadowReadableNativeMap : ShadowNativeMap(), ReadableMap {
|
||||
|
||||
@Implementation override fun hasKey(name: String): Boolean = backingMap.hasKey(name)
|
||||
|
||||
@Implementation override fun isNull(name: String): Boolean = backingMap.isNull(name)
|
||||
|
||||
@Implementation override fun getBoolean(name: String): Boolean = backingMap.getBoolean(name)
|
||||
|
||||
@Implementation override fun getDouble(name: String): Double = backingMap.getDouble(name)
|
||||
|
||||
@Implementation override fun getInt(name: String): Int = backingMap.getInt(name)
|
||||
|
||||
@Implementation override fun getLong(name: String): Long = backingMap.getLong(name)
|
||||
|
||||
@Implementation override fun getString(name: String): String? = backingMap.getString(name)
|
||||
|
||||
@Implementation override fun getArray(name: String): ReadableArray? = backingMap.getArray(name)
|
||||
|
||||
@Implementation override fun getMap(name: String): ReadableMap? = backingMap.getMap(name)
|
||||
|
||||
@Implementation override fun getDynamic(name: String): Dynamic = backingMap.getDynamic(name)
|
||||
|
||||
@Implementation override fun getType(name: String): ReadableType = backingMap.getType(name)
|
||||
|
||||
@get:Implementation
|
||||
override val entryIterator: Iterator<Map.Entry<String, Any?>>
|
||||
get() = backingMap.entryIterator
|
||||
|
||||
@Implementation
|
||||
override fun keySetIterator(): ReadableMapKeySetIterator = backingMap.keySetIterator()
|
||||
|
||||
@Implementation override fun toHashMap(): HashMap<String, Any?> = backingMap.toHashMap()
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* 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.testutils.shadows;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableNativeArray;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@Implements(WritableNativeArray.class)
|
||||
public class ShadowWritableNativeArray extends ShadowReadableNativeArray implements WritableArray {
|
||||
|
||||
@Implementation
|
||||
protected void __constructor__() {
|
||||
super.__constructor__();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void pushNull() {
|
||||
super.backingArray.pushNull();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void pushBoolean(boolean value) {
|
||||
super.backingArray.pushBoolean(value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void pushDouble(double value) {
|
||||
super.backingArray.pushDouble(value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void pushInt(int value) {
|
||||
super.backingArray.pushInt(value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void pushLong(long value) {
|
||||
super.backingArray.pushLong(value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void pushString(@Nullable String value) {
|
||||
super.backingArray.pushString(value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void pushArray(@Nullable ReadableArray array) {
|
||||
super.backingArray.pushArray(array);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void pushMap(@Nullable ReadableMap map) {
|
||||
super.backingArray.pushMap(map);
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.testutils.shadows
|
||||
|
||||
import com.facebook.react.bridge.ReadableArray
|
||||
import com.facebook.react.bridge.ReadableMap
|
||||
import com.facebook.react.bridge.WritableArray
|
||||
import com.facebook.react.bridge.WritableNativeArray
|
||||
import org.robolectric.annotation.Implementation
|
||||
import org.robolectric.annotation.Implements
|
||||
|
||||
@Implements(WritableNativeArray::class)
|
||||
class ShadowWritableNativeArray : ShadowReadableNativeArray(), WritableArray {
|
||||
|
||||
@Implementation override fun pushNull(): Unit = backingArray.pushNull()
|
||||
|
||||
@Implementation override fun pushBoolean(value: Boolean): Unit = backingArray.pushBoolean(value)
|
||||
|
||||
@Implementation override fun pushDouble(value: Double): Unit = backingArray.pushDouble(value)
|
||||
|
||||
@Implementation override fun pushInt(value: Int): Unit = backingArray.pushInt(value)
|
||||
|
||||
@Implementation override fun pushLong(value: Long): Unit = backingArray.pushLong(value)
|
||||
|
||||
@Implementation override fun pushString(value: String?): Unit = backingArray.pushString(value)
|
||||
|
||||
@Implementation
|
||||
override fun pushArray(array: ReadableArray?): Unit = backingArray.pushArray(array)
|
||||
|
||||
@Implementation override fun pushMap(map: ReadableMap?): Unit = backingArray.pushMap(map)
|
||||
}
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* 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.testutils.shadows;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.bridge.WritableNativeMap;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@Implements(WritableNativeMap.class)
|
||||
public class ShadowWritableNativeMap extends ShadowReadableNativeMap implements WritableMap {
|
||||
|
||||
@Implementation
|
||||
protected void __constructor__() {
|
||||
super.__constructor__();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void putNull(@NonNull String key) {
|
||||
super.backingMap.putNull(key);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void putBoolean(@NonNull String key, boolean value) {
|
||||
super.backingMap.putBoolean(key, value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void putDouble(@NonNull String key, double value) {
|
||||
super.backingMap.putDouble(key, value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void putInt(@NonNull String key, int value) {
|
||||
super.backingMap.putInt(key, value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void putLong(@NonNull String key, long value) {
|
||||
super.backingMap.putLong(key, value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void putString(@NonNull String key, @Nullable String value) {
|
||||
super.backingMap.putString(key, value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void putArray(@NonNull String key, @Nullable ReadableArray value) {
|
||||
super.backingMap.putArray(key, value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void putMap(@NonNull String key, @Nullable ReadableMap value) {
|
||||
super.backingMap.putMap(key, value);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void merge(@NonNull ReadableMap source) {
|
||||
super.backingMap.merge(source);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public WritableMap copy() {
|
||||
return super.backingMap.copy();
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.testutils.shadows
|
||||
|
||||
import com.facebook.react.bridge.ReadableArray
|
||||
import com.facebook.react.bridge.ReadableMap
|
||||
import com.facebook.react.bridge.WritableMap
|
||||
import com.facebook.react.bridge.WritableNativeMap
|
||||
import org.robolectric.annotation.Implementation
|
||||
import org.robolectric.annotation.Implements
|
||||
|
||||
@Implements(WritableNativeMap::class)
|
||||
class ShadowWritableNativeMap : ShadowReadableNativeMap(), WritableMap {
|
||||
|
||||
@Implementation override fun putNull(key: String): Unit = backingMap.putNull(key)
|
||||
|
||||
@Implementation
|
||||
override fun putBoolean(key: String, value: Boolean): Unit = backingMap.putBoolean(key, value)
|
||||
|
||||
@Implementation
|
||||
override fun putDouble(key: String, value: Double): Unit = backingMap.putDouble(key, value)
|
||||
|
||||
@Implementation override fun putInt(key: String, value: Int): Unit = backingMap.putInt(key, value)
|
||||
|
||||
@Implementation
|
||||
override fun putLong(key: String, value: Long): Unit = backingMap.putLong(key, value)
|
||||
|
||||
@Implementation
|
||||
override fun putString(key: String, value: String?): Unit = backingMap.putString(key, value)
|
||||
|
||||
@Implementation
|
||||
override fun putArray(key: String, value: ReadableArray?): Unit = backingMap.putArray(key, value)
|
||||
|
||||
@Implementation
|
||||
override fun putMap(key: String, value: ReadableMap?): Unit = backingMap.putMap(key, value)
|
||||
|
||||
@Implementation override fun merge(source: ReadableMap): Unit = backingMap.merge(source)
|
||||
|
||||
@Implementation override fun copy(): WritableMap = backingMap.copy()
|
||||
}
|
||||
Reference in New Issue
Block a user