@@ -16,7 +16,6 @@ let ReactFeatureFlags;
16
16
let createReactClass ;
17
17
let createReactNativeComponentClass ;
18
18
let UIManager ;
19
- let FabricUIManager ;
20
19
let StrictMode ;
21
20
let NativeMethodsMixin ;
22
21
@@ -31,13 +30,13 @@ describe('ReactFabric', () => {
31
30
beforeEach ( ( ) => {
32
31
jest . resetModules ( ) ;
33
32
33
+ require ( 'react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager' ) ;
34
+
34
35
React = require ( 'react' ) ;
35
36
StrictMode = React . StrictMode ;
36
37
ReactFeatureFlags = require ( 'shared/ReactFeatureFlags' ) ;
37
38
ReactFeatureFlags . warnAboutDeprecatedSetNativeProps = true ;
38
39
ReactFabric = require ( 'react-native-renderer/fabric' ) ;
39
- FabricUIManager = require ( 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' )
40
- . FabricUIManager ;
41
40
UIManager = require ( 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' )
42
41
. UIManager ;
43
42
createReactClass = require ( 'create-react-class/factory' ) (
@@ -50,11 +49,6 @@ describe('ReactFabric', () => {
50
49
NativeMethodsMixin =
51
50
ReactFabric . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
52
51
. NativeMethodsMixin ;
53
-
54
- global . nativeFabricUIManager = {
55
- measure : FabricUIManager . measure ,
56
- measureInWindow : FabricUIManager . measureInWindow ,
57
- } ;
58
52
} ) ;
59
53
60
54
it ( 'should be able to create and render a native component' , ( ) => {
@@ -64,9 +58,9 @@ describe('ReactFabric', () => {
64
58
} ) ) ;
65
59
66
60
ReactFabric . render ( < View foo = "test" /> , 1 ) ;
67
- expect ( FabricUIManager . createNode ) . toBeCalled ( ) ;
68
- expect ( FabricUIManager . appendChild ) . not . toBeCalled ( ) ;
69
- expect ( FabricUIManager . completeRoot ) . toBeCalled ( ) ;
61
+ expect ( nativeFabricUIManager . createNode ) . toBeCalled ( ) ;
62
+ expect ( nativeFabricUIManager . appendChild ) . not . toBeCalled ( ) ;
63
+ expect ( nativeFabricUIManager . completeRoot ) . toBeCalled ( ) ;
70
64
} ) ;
71
65
72
66
it ( 'should be able to create and update a native component' , ( ) => {
@@ -77,20 +71,20 @@ describe('ReactFabric', () => {
77
71
78
72
const firstNode = { } ;
79
73
80
- FabricUIManager . createNode . mockReturnValue ( firstNode ) ;
74
+ nativeFabricUIManager . createNode . mockReturnValue ( firstNode ) ;
81
75
82
76
ReactFabric . render ( < View foo = "foo" /> , 11 ) ;
83
77
84
- expect ( FabricUIManager . createNode ) . toHaveBeenCalledTimes ( 1 ) ;
78
+ expect ( nativeFabricUIManager . createNode ) . toHaveBeenCalledTimes ( 1 ) ;
85
79
86
80
ReactFabric . render ( < View foo = "bar" /> , 11 ) ;
87
81
88
- expect ( FabricUIManager . createNode ) . toHaveBeenCalledTimes ( 1 ) ;
89
- expect ( FabricUIManager . cloneNodeWithNewProps ) . toHaveBeenCalledTimes ( 1 ) ;
90
- expect ( FabricUIManager . cloneNodeWithNewProps . mock . calls [ 0 ] [ 0 ] ) . toBe (
82
+ expect ( nativeFabricUIManager . createNode ) . toHaveBeenCalledTimes ( 1 ) ;
83
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps ) . toHaveBeenCalledTimes ( 1 ) ;
84
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps . mock . calls [ 0 ] [ 0 ] ) . toBe (
91
85
firstNode ,
92
86
) ;
93
- expect ( FabricUIManager . cloneNodeWithNewProps . mock . calls [ 0 ] [ 1 ] ) . toEqual ( {
87
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps . mock . calls [ 0 ] [ 1 ] ) . toEqual ( {
94
88
foo : 'bar' ,
95
89
} ) ;
96
90
} ) ;
@@ -102,39 +96,39 @@ describe('ReactFabric', () => {
102
96
} ) ) ;
103
97
104
98
ReactFabric . render ( < Text foo = "a" > 1</ Text > , 11 ) ;
105
- expect ( FabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
106
- expect ( FabricUIManager . cloneNodeWithNewChildren ) . not . toBeCalled ( ) ;
107
- expect ( FabricUIManager . cloneNodeWithNewProps ) . not . toBeCalled ( ) ;
108
- expect ( FabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
99
+ expect ( nativeFabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
100
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildren ) . not . toBeCalled ( ) ;
101
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps ) . not . toBeCalled ( ) ;
102
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
109
103
110
104
// If no properties have changed, we shouldn't call cloneNode.
111
105
ReactFabric . render ( < Text foo = "a" > 1</ Text > , 11 ) ;
112
- expect ( FabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
113
- expect ( FabricUIManager . cloneNodeWithNewChildren ) . not . toBeCalled ( ) ;
114
- expect ( FabricUIManager . cloneNodeWithNewProps ) . not . toBeCalled ( ) ;
115
- expect ( FabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
106
+ expect ( nativeFabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
107
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildren ) . not . toBeCalled ( ) ;
108
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps ) . not . toBeCalled ( ) ;
109
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
116
110
117
111
// Only call cloneNode for the changed property (and not for text).
118
112
ReactFabric . render ( < Text foo = "b" > 1</ Text > , 11 ) ;
119
- expect ( FabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
120
- expect ( FabricUIManager . cloneNodeWithNewChildren ) . not . toBeCalled ( ) ;
121
- expect ( FabricUIManager . cloneNodeWithNewProps ) . toHaveBeenCalledTimes ( 1 ) ;
122
- expect ( FabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
113
+ expect ( nativeFabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
114
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildren ) . not . toBeCalled ( ) ;
115
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps ) . toHaveBeenCalledTimes ( 1 ) ;
116
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
123
117
124
118
// Only call cloneNode for the changed text (and no other properties).
125
119
ReactFabric . render ( < Text foo = "b" > 2</ Text > , 11 ) ;
126
- expect ( FabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
127
- expect ( FabricUIManager . cloneNodeWithNewChildren ) . toHaveBeenCalledTimes ( 1 ) ;
128
- expect ( FabricUIManager . cloneNodeWithNewProps ) . toHaveBeenCalledTimes ( 1 ) ;
129
- expect ( FabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
120
+ expect ( nativeFabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
121
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildren ) . toHaveBeenCalledTimes ( 1 ) ;
122
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps ) . toHaveBeenCalledTimes ( 1 ) ;
123
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
130
124
131
125
// Call cloneNode for both changed text and properties.
132
126
ReactFabric . render ( < Text foo = "c" > 3</ Text > , 11 ) ;
133
- expect ( FabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
134
- expect ( FabricUIManager . cloneNodeWithNewChildren ) . toHaveBeenCalledTimes ( 1 ) ;
135
- expect ( FabricUIManager . cloneNodeWithNewProps ) . toHaveBeenCalledTimes ( 1 ) ;
127
+ expect ( nativeFabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
128
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildren ) . toHaveBeenCalledTimes ( 1 ) ;
129
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps ) . toHaveBeenCalledTimes ( 1 ) ;
136
130
expect (
137
- FabricUIManager . cloneNodeWithNewChildrenAndProps ,
131
+ nativeFabricUIManager . cloneNodeWithNewChildrenAndProps ,
138
132
) . toHaveBeenCalledTimes ( 1 ) ;
139
133
} ) ;
140
134
@@ -150,21 +144,21 @@ describe('ReactFabric', () => {
150
144
</ Text > ,
151
145
11 ,
152
146
) ;
153
- expect ( FabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
154
- expect ( FabricUIManager . cloneNodeWithNewChildren ) . not . toBeCalled ( ) ;
155
- expect ( FabricUIManager . cloneNodeWithNewProps ) . not . toBeCalled ( ) ;
156
- expect ( FabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
147
+ expect ( nativeFabricUIManager . cloneNode ) . not . toBeCalled ( ) ;
148
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildren ) . not . toBeCalled ( ) ;
149
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps ) . not . toBeCalled ( ) ;
150
+ expect ( nativeFabricUIManager . cloneNodeWithNewChildrenAndProps ) . not . toBeCalled ( ) ;
157
151
158
152
ReactFabric . render (
159
153
< Text foo = "a" bar = "b" >
160
154
1
161
155
</ Text > ,
162
156
11 ,
163
157
) ;
164
- expect ( FabricUIManager . cloneNodeWithNewProps . mock . calls [ 0 ] [ 1 ] ) . toEqual ( {
158
+ expect ( nativeFabricUIManager . cloneNodeWithNewProps . mock . calls [ 0 ] [ 1 ] ) . toEqual ( {
165
159
bar : 'b' ,
166
160
} ) ;
167
- expect ( FabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
161
+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
168
162
169
163
ReactFabric . render (
170
164
< Text foo = "b" bar = "b" >
@@ -173,11 +167,11 @@ describe('ReactFabric', () => {
173
167
11 ,
174
168
) ;
175
169
expect (
176
- FabricUIManager . cloneNodeWithNewChildrenAndProps . mock . calls [ 0 ] [ 1 ] ,
170
+ nativeFabricUIManager . cloneNodeWithNewChildrenAndProps . mock . calls [ 0 ] [ 1 ] ,
177
171
) . toEqual ( {
178
172
foo : 'b' ,
179
173
} ) ;
180
- expect ( FabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
174
+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
181
175
} ) ;
182
176
183
177
it ( 'should not call UIManager.updateView from ref.setNativeProps' , ( ) => {
@@ -329,7 +323,7 @@ describe('ReactFabric', () => {
329
323
} ) ;
330
324
331
325
[ View , Subclass , CreateClass ] . forEach ( Component => {
332
- FabricUIManager . measure . mockClear ( ) ;
326
+ nativeFabricUIManager . measure . mockClear ( ) ;
333
327
334
328
let viewRef ;
335
329
ReactFabric . render (
@@ -341,10 +335,10 @@ describe('ReactFabric', () => {
341
335
11 ,
342
336
) ;
343
337
344
- expect ( FabricUIManager . measure ) . not . toBeCalled ( ) ;
338
+ expect ( nativeFabricUIManager . measure ) . not . toBeCalled ( ) ;
345
339
const successCallback = jest . fn ( ) ;
346
340
viewRef . measure ( successCallback ) ;
347
- expect ( FabricUIManager . measure ) . toHaveBeenCalledTimes ( 1 ) ;
341
+ expect ( nativeFabricUIManager . measure ) . toHaveBeenCalledTimes ( 1 ) ;
348
342
expect ( successCallback ) . toHaveBeenCalledTimes ( 1 ) ;
349
343
expect ( successCallback ) . toHaveBeenCalledWith ( 10 , 10 , 100 , 100 , 0 , 0 ) ;
350
344
} ) ;
@@ -370,7 +364,7 @@ describe('ReactFabric', () => {
370
364
} ) ;
371
365
372
366
[ View , Subclass , CreateClass ] . forEach ( Component => {
373
- FabricUIManager . measureInWindow . mockClear ( ) ;
367
+ nativeFabricUIManager . measureInWindow . mockClear ( ) ;
374
368
375
369
let viewRef ;
376
370
ReactFabric . render (
@@ -382,10 +376,10 @@ describe('ReactFabric', () => {
382
376
11 ,
383
377
) ;
384
378
385
- expect ( FabricUIManager . measureInWindow ) . not . toBeCalled ( ) ;
379
+ expect ( nativeFabricUIManager . measureInWindow ) . not . toBeCalled ( ) ;
386
380
const successCallback = jest . fn ( ) ;
387
381
viewRef . measureInWindow ( successCallback ) ;
388
- expect ( FabricUIManager . measureInWindow ) . toHaveBeenCalledTimes ( 1 ) ;
382
+ expect ( nativeFabricUIManager . measureInWindow ) . toHaveBeenCalledTimes ( 1 ) ;
389
383
expect ( successCallback ) . toHaveBeenCalledTimes ( 1 ) ;
390
384
expect ( successCallback ) . toHaveBeenCalledWith ( 10 , 10 , 100 , 100 ) ;
391
385
} ) ;
@@ -398,7 +392,7 @@ describe('ReactFabric', () => {
398
392
} ) ) ;
399
393
400
394
[ View ] . forEach ( Component => {
401
- FabricUIManager . measureLayout . mockClear ( ) ;
395
+ nativeFabricUIManager . measureLayout . mockClear ( ) ;
402
396
403
397
let viewRef ;
404
398
let otherRef ;
@@ -419,11 +413,11 @@ describe('ReactFabric', () => {
419
413
11 ,
420
414
) ;
421
415
422
- expect ( FabricUIManager . measureLayout ) . not . toBeCalled ( ) ;
416
+ expect ( nativeFabricUIManager . measureLayout ) . not . toBeCalled ( ) ;
423
417
const successCallback = jest . fn ( ) ;
424
418
const failureCallback = jest . fn ( ) ;
425
419
viewRef . measureLayout ( otherRef , successCallback , failureCallback ) ;
426
- expect ( FabricUIManager . measureLayout ) . toHaveBeenCalledTimes ( 1 ) ;
420
+ expect ( nativeFabricUIManager . measureLayout ) . toHaveBeenCalledTimes ( 1 ) ;
427
421
expect ( successCallback ) . toHaveBeenCalledTimes ( 1 ) ;
428
422
expect ( successCallback ) . toHaveBeenCalledWith ( 1 , 1 , 100 , 100 ) ;
429
423
} ) ;
@@ -449,7 +443,7 @@ describe('ReactFabric', () => {
449
443
} ) ;
450
444
451
445
[ Subclass , CreateClass ] . forEach ( Component => {
452
- FabricUIManager . measureLayout . mockReset ( ) ;
446
+ nativeFabricUIManager . measureLayout . mockReset ( ) ;
453
447
454
448
let viewRef ;
455
449
let otherRef ;
@@ -486,7 +480,7 @@ describe('ReactFabric', () => {
486
480
} ,
487
481
) ;
488
482
489
- expect ( FabricUIManager . measureLayout ) . not . toBeCalled ( ) ;
483
+ expect ( nativeFabricUIManager . measureLayout ) . not . toBeCalled ( ) ;
490
484
expect ( UIManager . measureLayout ) . not . toBeCalled ( ) ;
491
485
} ) ;
492
486
} ) ;
@@ -532,10 +526,10 @@ describe('ReactFabric', () => {
532
526
const after = 'mxhpgwfralkeoivcstzy' ;
533
527
534
528
ReactFabric . render ( < Component chars = { before } /> , 11 ) ;
535
- expect ( FabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
529
+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
536
530
537
531
ReactFabric . render ( < Component chars = { after } /> , 11 ) ;
538
- expect ( FabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
532
+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
539
533
} ) ;
540
534
541
535
it ( 'recreates host parents even if only children changed' , ( ) => {
@@ -567,14 +561,14 @@ describe('ReactFabric', () => {
567
561
</ View > ,
568
562
11 ,
569
563
) ;
570
- expect ( FabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
564
+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
571
565
572
566
// Call setState() so that we skip over the top-level host node.
573
567
// It should still get recreated despite a bailout.
574
568
ref . current . setState ( {
575
569
chars : after ,
576
570
} ) ;
577
- expect ( FabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
571
+ expect ( nativeFabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
578
572
} ) ;
579
573
580
574
it ( 'calls setState with no arguments' , ( ) => {
@@ -599,12 +593,12 @@ describe('ReactFabric', () => {
599
593
} ) ) ;
600
594
601
595
const snapshots = [ ] ;
602
- FabricUIManager . completeRoot . mockImplementation ( function (
596
+ nativeFabricUIManager . completeRoot . mockImplementation ( function (
603
597
rootTag ,
604
598
newChildSet ,
605
599
) {
606
600
snapshots . push (
607
- FabricUIManager . __dumpChildSetForJestTestsOnly ( newChildSet ) ,
601
+ nativeFabricUIManager . __dumpChildSetForJestTestsOnly ( newChildSet ) ,
608
602
) ;
609
603
} ) ;
610
604
@@ -706,11 +700,11 @@ describe('ReactFabric', () => {
706
700
707
701
ReactFabric . render ( < View onTouchStart = { touchStart } /> , 11 ) ;
708
702
709
- expect ( FabricUIManager . createNode . mock . calls . length ) . toBe ( 1 ) ;
710
- expect ( FabricUIManager . registerEventHandler . mock . calls . length ) . toBe ( 1 ) ;
703
+ expect ( nativeFabricUIManager . createNode . mock . calls . length ) . toBe ( 1 ) ;
704
+ expect ( nativeFabricUIManager . registerEventHandler . mock . calls . length ) . toBe ( 1 ) ;
711
705
712
- let [ , , , , instanceHandle ] = FabricUIManager . createNode . mock . calls [ 0 ] ;
713
- let [ dispatchEvent ] = FabricUIManager . registerEventHandler . mock . calls [ 0 ] ;
706
+ let [ , , , , instanceHandle ] = nativeFabricUIManager . createNode . mock . calls [ 0 ] ;
707
+ let [ dispatchEvent ] = nativeFabricUIManager . registerEventHandler . mock . calls [ 0 ] ;
714
708
715
709
let touchEvent = {
716
710
touches : [ ] ,
0 commit comments