-
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.
introduce shadows helper library for robolectric (#36733)
Summary: Pull Request resolved: #36733 Changelog: [Android][Added] - Added testing shadow helpers for robolectric in this change, i'm creating a centralized place for test writers to add their shadows in robolectric. as we start deprecating powermock, we can expect that common infra classes will be needed to be stubbed out, so we can leverage this library in order to do so. Reviewed By: javache Differential Revision: D44565806 fbshipit-source-id: 2e322861e8e2f49ede21e4a000495d5f06b911d3
- Loading branch information
1 parent
47149d2
commit 4890d50
Showing
4 changed files
with
46 additions
and
15 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
18 changes: 18 additions & 0 deletions
18
packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/shadows/BUCK
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,18 @@ | ||
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_target", "rn_android_library") | ||
|
||
oncall("react_native") | ||
|
||
rn_android_library( | ||
name = "shadows", | ||
srcs = glob(["**/*.java"]), | ||
autoglob = False, | ||
language = "JAVA", | ||
visibility = [ | ||
"PUBLIC", | ||
], | ||
deps = [ | ||
react_native_target("java/com/facebook/react/bridge:bridge"), | ||
react_native_dep("third-party/java/robolectric:robolectric"), | ||
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"), | ||
], | ||
) |
24 changes: 24 additions & 0 deletions
24
...eact-native/ReactAndroid/src/test/java/com/facebook/testutils/shadows/ShadowSoLoader.java
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,24 @@ | ||
/* | ||
* 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 android.content.Context; | ||
import com.facebook.soloader.SoLoader; | ||
import org.robolectric.annotation.Implementation; | ||
import org.robolectric.annotation.Implements; | ||
|
||
@Implements(SoLoader.class) | ||
public class ShadowSoLoader { | ||
@Implementation | ||
public static void init(Context context, int flags) {} | ||
|
||
@Implementation | ||
public static boolean loadLibrary(String shortName) { | ||
return true; | ||
} | ||
} |