55import android .app .Activity ;
66import android .content .Context ;
77import android .view .MotionEvent ;
8+ import android .view .ViewGroup ;
9+ import android .widget .FrameLayout ;
810
911import androidx .annotation .NonNull ;
1012
1113import com .reactnativenavigation .options .Options ;
12- import com .reactnativenavigation .react .ReactView ;
1314import com .reactnativenavigation .viewcontrollers .child .ChildController ;
1415import com .reactnativenavigation .viewcontrollers .child .ChildControllersRegistry ;
1516import com .reactnativenavigation .viewcontrollers .component .ComponentPresenterBase ;
@@ -24,7 +25,8 @@ public SimpleViewController(Activity activity, ChildControllersRegistry childReg
2425 this (activity , childRegistry , id , new Presenter (activity , new Options ()), options );
2526 }
2627
27- public SimpleViewController (Activity activity , ChildControllersRegistry childRegistry , String id , Presenter presenter , Options options ) {
28+ public SimpleViewController (Activity activity , ChildControllersRegistry childRegistry , String id ,
29+ Presenter presenter , Options options ) {
2830 super (activity , childRegistry , id , presenter , options );
2931 }
3032
@@ -40,7 +42,8 @@ public void sendOnNavigationButtonPressed(String buttonId) {
4042
4143 @ Override
4244 public void destroy () {
43- if (!isDestroyed ()) performOnParentController (parent -> parent .onChildDestroyed (this ));
45+ if (!isDestroyed ())
46+ performOnParentController (parent -> parent .onChildDestroyed (this ));
4447 super .destroy ();
4548 }
4649
@@ -58,18 +61,24 @@ public int getTopInset() {
5861
5962 @ Override
6063 public void applyBottomInset () {
61- if (view != null ) presenter .applyBottomInset (view , getBottomInset ());
64+ if (view != null )
65+ presenter .applyBottomInset (view , getBottomInset ());
6266 }
6367
6468 @ Override
6569 public String getCurrentComponentName () {
6670 return null ;
6771 }
6872
69- public static class SimpleView extends ReactView implements ReactComponent {
73+ /**
74+ * A simple mock view that implements ReactComponent without actually using
75+ * React Native.
76+ * This avoids triggering React surface rendering in instrumented tests.
77+ */
78+ public static class SimpleView extends FrameLayout implements ReactComponent {
7079
7180 public SimpleView (@ NonNull Context context ) {
72- super (context , "compId" , "compName" );
81+ super (context );
7382 }
7483
7584 @ Override
@@ -79,22 +88,22 @@ public boolean isRendered() {
7988
8089 @ Override
8190 public boolean isReady () {
82- return false ;
91+ return true ;
8392 }
8493
8594 @ Override
86- public ReactView asView () {
95+ public ViewGroup asView () {
8796 return this ;
8897 }
8998
9099 @ Override
91100 public void destroy () {
92-
101+ // No-op for mock
93102 }
94103
95104 @ Override
96105 public void sendOnNavigationButtonPressed (String buttonId ) {
97-
106+ // No-op for mock
98107 }
99108
100109 @ Override
@@ -104,7 +113,7 @@ public ScrollEventListener getScrollEventListener() {
104113
105114 @ Override
106115 public void dispatchTouchEventToJs (MotionEvent event ) {
107-
116+ // No-op for mock
108117 }
109118 }
110119}
0 commit comments